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.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.SetUtil;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.UnmodifiableList;
038    import com.liferay.portal.kernel.util.Validator;
039    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
040    import com.liferay.portal.model.CacheModel;
041    import com.liferay.portal.model.ModelListener;
042    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
043    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044    
045    import com.liferay.portlet.journal.NoSuchArticleException;
046    import com.liferay.portlet.journal.model.JournalArticle;
047    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
048    import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
049    
050    import java.io.Serializable;
051    
052    import java.util.ArrayList;
053    import java.util.Collections;
054    import java.util.List;
055    import java.util.Set;
056    
057    /**
058     * The persistence implementation for the journal article service.
059     *
060     * <p>
061     * Caching information and settings can be found in <code>portal.properties</code>
062     * </p>
063     *
064     * @author Brian Wing Shun Chan
065     * @see JournalArticlePersistence
066     * @see JournalArticleUtil
067     * @generated
068     */
069    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
070            implements JournalArticlePersistence {
071            /*
072             * NOTE FOR DEVELOPERS:
073             *
074             * 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.
075             */
076            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
077            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078                    ".List1";
079            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080                    ".List2";
081            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
082                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
083                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
084                            "findAll", new String[0]);
085            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
086                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
087                            JournalArticleImpl.class,
088                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
089            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
090                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
092            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
093                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
094                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
095                            "findByUuid",
096                            new String[] {
097                                    String.class.getName(),
098                                    
099                            Integer.class.getName(), Integer.class.getName(),
100                                    OrderByComparator.class.getName()
101                            });
102            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
103                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
104                            JournalArticleImpl.class,
105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
106                            new String[] { String.class.getName() },
107                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
108                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
109                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
110            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
111                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
112                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
113                            new String[] { String.class.getName() });
114    
115            /**
116             * Returns all the journal articles where uuid = &#63;.
117             *
118             * @param uuid the uuid
119             * @return the matching journal articles
120             * @throws SystemException if a system exception occurred
121             */
122            public List<JournalArticle> findByUuid(String uuid)
123                    throws SystemException {
124                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
125            }
126    
127            /**
128             * Returns a range of all the journal articles where uuid = &#63;.
129             *
130             * <p>
131             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
132             * </p>
133             *
134             * @param uuid the uuid
135             * @param start the lower bound of the range of journal articles
136             * @param end the upper bound of the range of journal articles (not inclusive)
137             * @return the range of matching journal articles
138             * @throws SystemException if a system exception occurred
139             */
140            public List<JournalArticle> findByUuid(String uuid, int start, int end)
141                    throws SystemException {
142                    return findByUuid(uuid, start, end, null);
143            }
144    
145            /**
146             * Returns an ordered range of all the journal articles where uuid = &#63;.
147             *
148             * <p>
149             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
150             * </p>
151             *
152             * @param uuid the uuid
153             * @param start the lower bound of the range of journal articles
154             * @param end the upper bound of the range of journal articles (not inclusive)
155             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
156             * @return the ordered range of matching journal articles
157             * @throws SystemException if a system exception occurred
158             */
159            public List<JournalArticle> findByUuid(String uuid, int start, int end,
160                    OrderByComparator orderByComparator) throws SystemException {
161                    boolean pagination = true;
162                    FinderPath finderPath = null;
163                    Object[] finderArgs = null;
164    
165                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
166                                    (orderByComparator == null)) {
167                            pagination = false;
168                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
169                            finderArgs = new Object[] { uuid };
170                    }
171                    else {
172                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
173                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
174                    }
175    
176                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
177                                    finderArgs, this);
178    
179                    if ((list != null) && !list.isEmpty()) {
180                            for (JournalArticle journalArticle : list) {
181                                    if (!Validator.equals(uuid, journalArticle.getUuid())) {
182                                            list = null;
183    
184                                            break;
185                                    }
186                            }
187                    }
188    
189                    if (list == null) {
190                            StringBundler query = null;
191    
192                            if (orderByComparator != null) {
193                                    query = new StringBundler(3 +
194                                                    (orderByComparator.getOrderByFields().length * 3));
195                            }
196                            else {
197                                    query = new StringBundler(3);
198                            }
199    
200                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
201    
202                            boolean bindUuid = false;
203    
204                            if (uuid == null) {
205                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
206                            }
207                            else if (uuid.equals(StringPool.BLANK)) {
208                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
209                            }
210                            else {
211                                    bindUuid = true;
212    
213                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
214                            }
215    
216                            if (orderByComparator != null) {
217                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
218                                            orderByComparator);
219                            }
220                            else
221                             if (pagination) {
222                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
223                            }
224    
225                            String sql = query.toString();
226    
227                            Session session = null;
228    
229                            try {
230                                    session = openSession();
231    
232                                    Query q = session.createQuery(sql);
233    
234                                    QueryPos qPos = QueryPos.getInstance(q);
235    
236                                    if (bindUuid) {
237                                            qPos.add(uuid);
238                                    }
239    
240                                    if (!pagination) {
241                                            list = (List<JournalArticle>)QueryUtil.list(q,
242                                                            getDialect(), start, end, false);
243    
244                                            Collections.sort(list);
245    
246                                            list = new UnmodifiableList<JournalArticle>(list);
247                                    }
248                                    else {
249                                            list = (List<JournalArticle>)QueryUtil.list(q,
250                                                            getDialect(), start, end);
251                                    }
252    
253                                    cacheResult(list);
254    
255                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
256                            }
257                            catch (Exception e) {
258                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
259    
260                                    throw processException(e);
261                            }
262                            finally {
263                                    closeSession(session);
264                            }
265                    }
266    
267                    return list;
268            }
269    
270            /**
271             * Returns the first journal article in the ordered set where uuid = &#63;.
272             *
273             * @param uuid the uuid
274             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
275             * @return the first matching journal article
276             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
277             * @throws SystemException if a system exception occurred
278             */
279            public JournalArticle findByUuid_First(String uuid,
280                    OrderByComparator orderByComparator)
281                    throws NoSuchArticleException, SystemException {
282                    JournalArticle journalArticle = fetchByUuid_First(uuid,
283                                    orderByComparator);
284    
285                    if (journalArticle != null) {
286                            return journalArticle;
287                    }
288    
289                    StringBundler msg = new StringBundler(4);
290    
291                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
292    
293                    msg.append("uuid=");
294                    msg.append(uuid);
295    
296                    msg.append(StringPool.CLOSE_CURLY_BRACE);
297    
298                    throw new NoSuchArticleException(msg.toString());
299            }
300    
301            /**
302             * Returns the first journal article in the ordered set where uuid = &#63;.
303             *
304             * @param uuid the uuid
305             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
306             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
307             * @throws SystemException if a system exception occurred
308             */
309            public JournalArticle fetchByUuid_First(String uuid,
310                    OrderByComparator orderByComparator) throws SystemException {
311                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
312    
313                    if (!list.isEmpty()) {
314                            return list.get(0);
315                    }
316    
317                    return null;
318            }
319    
320            /**
321             * Returns the last journal article in the ordered set where uuid = &#63;.
322             *
323             * @param uuid the uuid
324             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
325             * @return the last matching journal article
326             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
327             * @throws SystemException if a system exception occurred
328             */
329            public JournalArticle findByUuid_Last(String uuid,
330                    OrderByComparator orderByComparator)
331                    throws NoSuchArticleException, SystemException {
332                    JournalArticle journalArticle = fetchByUuid_Last(uuid, orderByComparator);
333    
334                    if (journalArticle != null) {
335                            return journalArticle;
336                    }
337    
338                    StringBundler msg = new StringBundler(4);
339    
340                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
341    
342                    msg.append("uuid=");
343                    msg.append(uuid);
344    
345                    msg.append(StringPool.CLOSE_CURLY_BRACE);
346    
347                    throw new NoSuchArticleException(msg.toString());
348            }
349    
350            /**
351             * Returns the last journal article in the ordered set where uuid = &#63;.
352             *
353             * @param uuid the uuid
354             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
355             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
356             * @throws SystemException if a system exception occurred
357             */
358            public JournalArticle fetchByUuid_Last(String uuid,
359                    OrderByComparator orderByComparator) throws SystemException {
360                    int count = countByUuid(uuid);
361    
362                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
363                                    orderByComparator);
364    
365                    if (!list.isEmpty()) {
366                            return list.get(0);
367                    }
368    
369                    return null;
370            }
371    
372            /**
373             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
374             *
375             * @param id the primary key of the current journal article
376             * @param uuid the uuid
377             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
378             * @return the previous, current, and next journal article
379             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
380             * @throws SystemException if a system exception occurred
381             */
382            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
383                    OrderByComparator orderByComparator)
384                    throws NoSuchArticleException, SystemException {
385                    JournalArticle journalArticle = findByPrimaryKey(id);
386    
387                    Session session = null;
388    
389                    try {
390                            session = openSession();
391    
392                            JournalArticle[] array = new JournalArticleImpl[3];
393    
394                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
395                                            orderByComparator, true);
396    
397                            array[1] = journalArticle;
398    
399                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
400                                            orderByComparator, false);
401    
402                            return array;
403                    }
404                    catch (Exception e) {
405                            throw processException(e);
406                    }
407                    finally {
408                            closeSession(session);
409                    }
410            }
411    
412            protected JournalArticle getByUuid_PrevAndNext(Session session,
413                    JournalArticle journalArticle, String uuid,
414                    OrderByComparator orderByComparator, boolean previous) {
415                    StringBundler query = null;
416    
417                    if (orderByComparator != null) {
418                            query = new StringBundler(6 +
419                                            (orderByComparator.getOrderByFields().length * 6));
420                    }
421                    else {
422                            query = new StringBundler(3);
423                    }
424    
425                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
426    
427                    boolean bindUuid = false;
428    
429                    if (uuid == null) {
430                            query.append(_FINDER_COLUMN_UUID_UUID_1);
431                    }
432                    else if (uuid.equals(StringPool.BLANK)) {
433                            query.append(_FINDER_COLUMN_UUID_UUID_3);
434                    }
435                    else {
436                            bindUuid = true;
437    
438                            query.append(_FINDER_COLUMN_UUID_UUID_2);
439                    }
440    
441                    if (orderByComparator != null) {
442                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
443    
444                            if (orderByConditionFields.length > 0) {
445                                    query.append(WHERE_AND);
446                            }
447    
448                            for (int i = 0; i < orderByConditionFields.length; i++) {
449                                    query.append(_ORDER_BY_ENTITY_ALIAS);
450                                    query.append(orderByConditionFields[i]);
451    
452                                    if ((i + 1) < orderByConditionFields.length) {
453                                            if (orderByComparator.isAscending() ^ previous) {
454                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
455                                            }
456                                            else {
457                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
458                                            }
459                                    }
460                                    else {
461                                            if (orderByComparator.isAscending() ^ previous) {
462                                                    query.append(WHERE_GREATER_THAN);
463                                            }
464                                            else {
465                                                    query.append(WHERE_LESSER_THAN);
466                                            }
467                                    }
468                            }
469    
470                            query.append(ORDER_BY_CLAUSE);
471    
472                            String[] orderByFields = orderByComparator.getOrderByFields();
473    
474                            for (int i = 0; i < orderByFields.length; i++) {
475                                    query.append(_ORDER_BY_ENTITY_ALIAS);
476                                    query.append(orderByFields[i]);
477    
478                                    if ((i + 1) < orderByFields.length) {
479                                            if (orderByComparator.isAscending() ^ previous) {
480                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
481                                            }
482                                            else {
483                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
484                                            }
485                                    }
486                                    else {
487                                            if (orderByComparator.isAscending() ^ previous) {
488                                                    query.append(ORDER_BY_ASC);
489                                            }
490                                            else {
491                                                    query.append(ORDER_BY_DESC);
492                                            }
493                                    }
494                            }
495                    }
496                    else {
497                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
498                    }
499    
500                    String sql = query.toString();
501    
502                    Query q = session.createQuery(sql);
503    
504                    q.setFirstResult(0);
505                    q.setMaxResults(2);
506    
507                    QueryPos qPos = QueryPos.getInstance(q);
508    
509                    if (bindUuid) {
510                            qPos.add(uuid);
511                    }
512    
513                    if (orderByComparator != null) {
514                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
515    
516                            for (Object value : values) {
517                                    qPos.add(value);
518                            }
519                    }
520    
521                    List<JournalArticle> list = q.list();
522    
523                    if (list.size() == 2) {
524                            return list.get(1);
525                    }
526                    else {
527                            return null;
528                    }
529            }
530    
531            /**
532             * Removes all the journal articles where uuid = &#63; from the database.
533             *
534             * @param uuid the uuid
535             * @throws SystemException if a system exception occurred
536             */
537            public void removeByUuid(String uuid) throws SystemException {
538                    for (JournalArticle journalArticle : findByUuid(uuid,
539                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
540                            remove(journalArticle);
541                    }
542            }
543    
544            /**
545             * Returns the number of journal articles where uuid = &#63;.
546             *
547             * @param uuid the uuid
548             * @return the number of matching journal articles
549             * @throws SystemException if a system exception occurred
550             */
551            public int countByUuid(String uuid) throws SystemException {
552                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
553    
554                    Object[] finderArgs = new Object[] { uuid };
555    
556                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
557                                    this);
558    
559                    if (count == null) {
560                            StringBundler query = new StringBundler(2);
561    
562                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
563    
564                            boolean bindUuid = false;
565    
566                            if (uuid == null) {
567                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
568                            }
569                            else if (uuid.equals(StringPool.BLANK)) {
570                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
571                            }
572                            else {
573                                    bindUuid = true;
574    
575                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
576                            }
577    
578                            String sql = query.toString();
579    
580                            Session session = null;
581    
582                            try {
583                                    session = openSession();
584    
585                                    Query q = session.createQuery(sql);
586    
587                                    QueryPos qPos = QueryPos.getInstance(q);
588    
589                                    if (bindUuid) {
590                                            qPos.add(uuid);
591                                    }
592    
593                                    count = (Long)q.uniqueResult();
594    
595                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
596                            }
597                            catch (Exception e) {
598                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
599    
600                                    throw processException(e);
601                            }
602                            finally {
603                                    closeSession(session);
604                            }
605                    }
606    
607                    return count.intValue();
608            }
609    
610            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
611            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
612            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '')";
613            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
614                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
615                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
616                            "fetchByUUID_G",
617                            new String[] { String.class.getName(), Long.class.getName() },
618                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
619                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
620            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
621                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
622                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
623                            new String[] { String.class.getName(), Long.class.getName() });
624    
625            /**
626             * 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.
627             *
628             * @param uuid the uuid
629             * @param groupId the group ID
630             * @return the matching journal article
631             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
632             * @throws SystemException if a system exception occurred
633             */
634            public JournalArticle findByUUID_G(String uuid, long groupId)
635                    throws NoSuchArticleException, SystemException {
636                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
637    
638                    if (journalArticle == null) {
639                            StringBundler msg = new StringBundler(6);
640    
641                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
642    
643                            msg.append("uuid=");
644                            msg.append(uuid);
645    
646                            msg.append(", groupId=");
647                            msg.append(groupId);
648    
649                            msg.append(StringPool.CLOSE_CURLY_BRACE);
650    
651                            if (_log.isWarnEnabled()) {
652                                    _log.warn(msg.toString());
653                            }
654    
655                            throw new NoSuchArticleException(msg.toString());
656                    }
657    
658                    return journalArticle;
659            }
660    
661            /**
662             * 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.
663             *
664             * @param uuid the uuid
665             * @param groupId the group ID
666             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
667             * @throws SystemException if a system exception occurred
668             */
669            public JournalArticle fetchByUUID_G(String uuid, long groupId)
670                    throws SystemException {
671                    return fetchByUUID_G(uuid, groupId, true);
672            }
673    
674            /**
675             * 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.
676             *
677             * @param uuid the uuid
678             * @param groupId the group ID
679             * @param retrieveFromCache whether to use the finder cache
680             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
681             * @throws SystemException if a system exception occurred
682             */
683            public JournalArticle fetchByUUID_G(String uuid, long groupId,
684                    boolean retrieveFromCache) throws SystemException {
685                    Object[] finderArgs = new Object[] { uuid, groupId };
686    
687                    Object result = null;
688    
689                    if (retrieveFromCache) {
690                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
691                                            finderArgs, this);
692                    }
693    
694                    if (result instanceof JournalArticle) {
695                            JournalArticle journalArticle = (JournalArticle)result;
696    
697                            if (!Validator.equals(uuid, journalArticle.getUuid()) ||
698                                            (groupId != journalArticle.getGroupId())) {
699                                    result = null;
700                            }
701                    }
702    
703                    if (result == null) {
704                            StringBundler query = new StringBundler(4);
705    
706                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
707    
708                            boolean bindUuid = false;
709    
710                            if (uuid == null) {
711                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
712                            }
713                            else if (uuid.equals(StringPool.BLANK)) {
714                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
715                            }
716                            else {
717                                    bindUuid = true;
718    
719                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
720                            }
721    
722                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
723    
724                            String sql = query.toString();
725    
726                            Session session = null;
727    
728                            try {
729                                    session = openSession();
730    
731                                    Query q = session.createQuery(sql);
732    
733                                    QueryPos qPos = QueryPos.getInstance(q);
734    
735                                    if (bindUuid) {
736                                            qPos.add(uuid);
737                                    }
738    
739                                    qPos.add(groupId);
740    
741                                    List<JournalArticle> list = q.list();
742    
743                                    if (list.isEmpty()) {
744                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
745                                                    finderArgs, list);
746                                    }
747                                    else {
748                                            JournalArticle journalArticle = list.get(0);
749    
750                                            result = journalArticle;
751    
752                                            cacheResult(journalArticle);
753    
754                                            if ((journalArticle.getUuid() == null) ||
755                                                            !journalArticle.getUuid().equals(uuid) ||
756                                                            (journalArticle.getGroupId() != groupId)) {
757                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
758                                                            finderArgs, journalArticle);
759                                            }
760                                    }
761                            }
762                            catch (Exception e) {
763                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
764                                            finderArgs);
765    
766                                    throw processException(e);
767                            }
768                            finally {
769                                    closeSession(session);
770                            }
771                    }
772    
773                    if (result instanceof List<?>) {
774                            return null;
775                    }
776                    else {
777                            return (JournalArticle)result;
778                    }
779            }
780    
781            /**
782             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
783             *
784             * @param uuid the uuid
785             * @param groupId the group ID
786             * @return the journal article that was removed
787             * @throws SystemException if a system exception occurred
788             */
789            public JournalArticle removeByUUID_G(String uuid, long groupId)
790                    throws NoSuchArticleException, SystemException {
791                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
792    
793                    return remove(journalArticle);
794            }
795    
796            /**
797             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
798             *
799             * @param uuid the uuid
800             * @param groupId the group ID
801             * @return the number of matching journal articles
802             * @throws SystemException if a system exception occurred
803             */
804            public int countByUUID_G(String uuid, long groupId)
805                    throws SystemException {
806                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
807    
808                    Object[] finderArgs = new Object[] { uuid, groupId };
809    
810                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
811                                    this);
812    
813                    if (count == null) {
814                            StringBundler query = new StringBundler(3);
815    
816                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
817    
818                            boolean bindUuid = false;
819    
820                            if (uuid == null) {
821                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
822                            }
823                            else if (uuid.equals(StringPool.BLANK)) {
824                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
825                            }
826                            else {
827                                    bindUuid = true;
828    
829                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
830                            }
831    
832                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
833    
834                            String sql = query.toString();
835    
836                            Session session = null;
837    
838                            try {
839                                    session = openSession();
840    
841                                    Query q = session.createQuery(sql);
842    
843                                    QueryPos qPos = QueryPos.getInstance(q);
844    
845                                    if (bindUuid) {
846                                            qPos.add(uuid);
847                                    }
848    
849                                    qPos.add(groupId);
850    
851                                    count = (Long)q.uniqueResult();
852    
853                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
854                            }
855                            catch (Exception e) {
856                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
857    
858                                    throw processException(e);
859                            }
860                            finally {
861                                    closeSession(session);
862                            }
863                    }
864    
865                    return count.intValue();
866            }
867    
868            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
869            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
870            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
871            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
872            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
873                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
874                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
875                            "findByUuid_C",
876                            new String[] {
877                                    String.class.getName(), Long.class.getName(),
878                                    
879                            Integer.class.getName(), Integer.class.getName(),
880                                    OrderByComparator.class.getName()
881                            });
882            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
883                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
884                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
885                            JournalArticleImpl.class,
886                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
887                            new String[] { String.class.getName(), Long.class.getName() },
888                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
889                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
890                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
891                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
892            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
893                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
894                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
895                            new String[] { String.class.getName(), Long.class.getName() });
896    
897            /**
898             * Returns all the journal articles where uuid = &#63; and companyId = &#63;.
899             *
900             * @param uuid the uuid
901             * @param companyId the company ID
902             * @return the matching journal articles
903             * @throws SystemException if a system exception occurred
904             */
905            public List<JournalArticle> findByUuid_C(String uuid, long companyId)
906                    throws SystemException {
907                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
908                            QueryUtil.ALL_POS, null);
909            }
910    
911            /**
912             * Returns a range of all the journal articles where uuid = &#63; and companyId = &#63;.
913             *
914             * <p>
915             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
916             * </p>
917             *
918             * @param uuid the uuid
919             * @param companyId the company ID
920             * @param start the lower bound of the range of journal articles
921             * @param end the upper bound of the range of journal articles (not inclusive)
922             * @return the range of matching journal articles
923             * @throws SystemException if a system exception occurred
924             */
925            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
926                    int start, int end) throws SystemException {
927                    return findByUuid_C(uuid, companyId, start, end, null);
928            }
929    
930            /**
931             * Returns an ordered range of all the journal articles where uuid = &#63; and companyId = &#63;.
932             *
933             * <p>
934             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
935             * </p>
936             *
937             * @param uuid the uuid
938             * @param companyId the company ID
939             * @param start the lower bound of the range of journal articles
940             * @param end the upper bound of the range of journal articles (not inclusive)
941             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
942             * @return the ordered range of matching journal articles
943             * @throws SystemException if a system exception occurred
944             */
945            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
946                    int start, int end, OrderByComparator orderByComparator)
947                    throws SystemException {
948                    boolean pagination = true;
949                    FinderPath finderPath = null;
950                    Object[] finderArgs = null;
951    
952                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
953                                    (orderByComparator == null)) {
954                            pagination = false;
955                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
956                            finderArgs = new Object[] { uuid, companyId };
957                    }
958                    else {
959                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
960                            finderArgs = new Object[] {
961                                            uuid, companyId,
962                                            
963                                            start, end, orderByComparator
964                                    };
965                    }
966    
967                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
968                                    finderArgs, this);
969    
970                    if ((list != null) && !list.isEmpty()) {
971                            for (JournalArticle journalArticle : list) {
972                                    if (!Validator.equals(uuid, journalArticle.getUuid()) ||
973                                                    (companyId != journalArticle.getCompanyId())) {
974                                            list = null;
975    
976                                            break;
977                                    }
978                            }
979                    }
980    
981                    if (list == null) {
982                            StringBundler query = null;
983    
984                            if (orderByComparator != null) {
985                                    query = new StringBundler(4 +
986                                                    (orderByComparator.getOrderByFields().length * 3));
987                            }
988                            else {
989                                    query = new StringBundler(4);
990                            }
991    
992                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
993    
994                            boolean bindUuid = false;
995    
996                            if (uuid == null) {
997                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
998                            }
999                            else if (uuid.equals(StringPool.BLANK)) {
1000                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1001                            }
1002                            else {
1003                                    bindUuid = true;
1004    
1005                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1006                            }
1007    
1008                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1009    
1010                            if (orderByComparator != null) {
1011                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1012                                            orderByComparator);
1013                            }
1014                            else
1015                             if (pagination) {
1016                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1017                            }
1018    
1019                            String sql = query.toString();
1020    
1021                            Session session = null;
1022    
1023                            try {
1024                                    session = openSession();
1025    
1026                                    Query q = session.createQuery(sql);
1027    
1028                                    QueryPos qPos = QueryPos.getInstance(q);
1029    
1030                                    if (bindUuid) {
1031                                            qPos.add(uuid);
1032                                    }
1033    
1034                                    qPos.add(companyId);
1035    
1036                                    if (!pagination) {
1037                                            list = (List<JournalArticle>)QueryUtil.list(q,
1038                                                            getDialect(), start, end, false);
1039    
1040                                            Collections.sort(list);
1041    
1042                                            list = new UnmodifiableList<JournalArticle>(list);
1043                                    }
1044                                    else {
1045                                            list = (List<JournalArticle>)QueryUtil.list(q,
1046                                                            getDialect(), start, end);
1047                                    }
1048    
1049                                    cacheResult(list);
1050    
1051                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1052                            }
1053                            catch (Exception e) {
1054                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1055    
1056                                    throw processException(e);
1057                            }
1058                            finally {
1059                                    closeSession(session);
1060                            }
1061                    }
1062    
1063                    return list;
1064            }
1065    
1066            /**
1067             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1068             *
1069             * @param uuid the uuid
1070             * @param companyId the company ID
1071             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1072             * @return the first matching journal article
1073             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1074             * @throws SystemException if a system exception occurred
1075             */
1076            public JournalArticle findByUuid_C_First(String uuid, long companyId,
1077                    OrderByComparator orderByComparator)
1078                    throws NoSuchArticleException, SystemException {
1079                    JournalArticle journalArticle = fetchByUuid_C_First(uuid, companyId,
1080                                    orderByComparator);
1081    
1082                    if (journalArticle != null) {
1083                            return journalArticle;
1084                    }
1085    
1086                    StringBundler msg = new StringBundler(6);
1087    
1088                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1089    
1090                    msg.append("uuid=");
1091                    msg.append(uuid);
1092    
1093                    msg.append(", companyId=");
1094                    msg.append(companyId);
1095    
1096                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1097    
1098                    throw new NoSuchArticleException(msg.toString());
1099            }
1100    
1101            /**
1102             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1103             *
1104             * @param uuid the uuid
1105             * @param companyId the company ID
1106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1107             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1108             * @throws SystemException if a system exception occurred
1109             */
1110            public JournalArticle fetchByUuid_C_First(String uuid, long companyId,
1111                    OrderByComparator orderByComparator) throws SystemException {
1112                    List<JournalArticle> list = findByUuid_C(uuid, companyId, 0, 1,
1113                                    orderByComparator);
1114    
1115                    if (!list.isEmpty()) {
1116                            return list.get(0);
1117                    }
1118    
1119                    return null;
1120            }
1121    
1122            /**
1123             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1124             *
1125             * @param uuid the uuid
1126             * @param companyId the company ID
1127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1128             * @return the last matching journal article
1129             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1130             * @throws SystemException if a system exception occurred
1131             */
1132            public JournalArticle findByUuid_C_Last(String uuid, long companyId,
1133                    OrderByComparator orderByComparator)
1134                    throws NoSuchArticleException, SystemException {
1135                    JournalArticle journalArticle = fetchByUuid_C_Last(uuid, companyId,
1136                                    orderByComparator);
1137    
1138                    if (journalArticle != null) {
1139                            return journalArticle;
1140                    }
1141    
1142                    StringBundler msg = new StringBundler(6);
1143    
1144                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1145    
1146                    msg.append("uuid=");
1147                    msg.append(uuid);
1148    
1149                    msg.append(", companyId=");
1150                    msg.append(companyId);
1151    
1152                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1153    
1154                    throw new NoSuchArticleException(msg.toString());
1155            }
1156    
1157            /**
1158             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1159             *
1160             * @param uuid the uuid
1161             * @param companyId the company ID
1162             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1163             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1164             * @throws SystemException if a system exception occurred
1165             */
1166            public JournalArticle fetchByUuid_C_Last(String uuid, long companyId,
1167                    OrderByComparator orderByComparator) throws SystemException {
1168                    int count = countByUuid_C(uuid, companyId);
1169    
1170                    List<JournalArticle> list = findByUuid_C(uuid, companyId, count - 1,
1171                                    count, orderByComparator);
1172    
1173                    if (!list.isEmpty()) {
1174                            return list.get(0);
1175                    }
1176    
1177                    return null;
1178            }
1179    
1180            /**
1181             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1182             *
1183             * @param id the primary key of the current journal article
1184             * @param uuid the uuid
1185             * @param companyId the company ID
1186             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1187             * @return the previous, current, and next journal article
1188             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1189             * @throws SystemException if a system exception occurred
1190             */
1191            public JournalArticle[] findByUuid_C_PrevAndNext(long id, String uuid,
1192                    long companyId, OrderByComparator orderByComparator)
1193                    throws NoSuchArticleException, SystemException {
1194                    JournalArticle journalArticle = findByPrimaryKey(id);
1195    
1196                    Session session = null;
1197    
1198                    try {
1199                            session = openSession();
1200    
1201                            JournalArticle[] array = new JournalArticleImpl[3];
1202    
1203                            array[0] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1204                                            companyId, orderByComparator, true);
1205    
1206                            array[1] = journalArticle;
1207    
1208                            array[2] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1209                                            companyId, orderByComparator, false);
1210    
1211                            return array;
1212                    }
1213                    catch (Exception e) {
1214                            throw processException(e);
1215                    }
1216                    finally {
1217                            closeSession(session);
1218                    }
1219            }
1220    
1221            protected JournalArticle getByUuid_C_PrevAndNext(Session session,
1222                    JournalArticle journalArticle, String uuid, long companyId,
1223                    OrderByComparator orderByComparator, boolean previous) {
1224                    StringBundler query = null;
1225    
1226                    if (orderByComparator != null) {
1227                            query = new StringBundler(6 +
1228                                            (orderByComparator.getOrderByFields().length * 6));
1229                    }
1230                    else {
1231                            query = new StringBundler(3);
1232                    }
1233    
1234                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1235    
1236                    boolean bindUuid = false;
1237    
1238                    if (uuid == null) {
1239                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1240                    }
1241                    else if (uuid.equals(StringPool.BLANK)) {
1242                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1243                    }
1244                    else {
1245                            bindUuid = true;
1246    
1247                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1248                    }
1249    
1250                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1251    
1252                    if (orderByComparator != null) {
1253                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1254    
1255                            if (orderByConditionFields.length > 0) {
1256                                    query.append(WHERE_AND);
1257                            }
1258    
1259                            for (int i = 0; i < orderByConditionFields.length; i++) {
1260                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1261                                    query.append(orderByConditionFields[i]);
1262    
1263                                    if ((i + 1) < orderByConditionFields.length) {
1264                                            if (orderByComparator.isAscending() ^ previous) {
1265                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1266                                            }
1267                                            else {
1268                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1269                                            }
1270                                    }
1271                                    else {
1272                                            if (orderByComparator.isAscending() ^ previous) {
1273                                                    query.append(WHERE_GREATER_THAN);
1274                                            }
1275                                            else {
1276                                                    query.append(WHERE_LESSER_THAN);
1277                                            }
1278                                    }
1279                            }
1280    
1281                            query.append(ORDER_BY_CLAUSE);
1282    
1283                            String[] orderByFields = orderByComparator.getOrderByFields();
1284    
1285                            for (int i = 0; i < orderByFields.length; i++) {
1286                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1287                                    query.append(orderByFields[i]);
1288    
1289                                    if ((i + 1) < orderByFields.length) {
1290                                            if (orderByComparator.isAscending() ^ previous) {
1291                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1292                                            }
1293                                            else {
1294                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1295                                            }
1296                                    }
1297                                    else {
1298                                            if (orderByComparator.isAscending() ^ previous) {
1299                                                    query.append(ORDER_BY_ASC);
1300                                            }
1301                                            else {
1302                                                    query.append(ORDER_BY_DESC);
1303                                            }
1304                                    }
1305                            }
1306                    }
1307                    else {
1308                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1309                    }
1310    
1311                    String sql = query.toString();
1312    
1313                    Query q = session.createQuery(sql);
1314    
1315                    q.setFirstResult(0);
1316                    q.setMaxResults(2);
1317    
1318                    QueryPos qPos = QueryPos.getInstance(q);
1319    
1320                    if (bindUuid) {
1321                            qPos.add(uuid);
1322                    }
1323    
1324                    qPos.add(companyId);
1325    
1326                    if (orderByComparator != null) {
1327                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1328    
1329                            for (Object value : values) {
1330                                    qPos.add(value);
1331                            }
1332                    }
1333    
1334                    List<JournalArticle> list = q.list();
1335    
1336                    if (list.size() == 2) {
1337                            return list.get(1);
1338                    }
1339                    else {
1340                            return null;
1341                    }
1342            }
1343    
1344            /**
1345             * Removes all the journal articles where uuid = &#63; and companyId = &#63; from the database.
1346             *
1347             * @param uuid the uuid
1348             * @param companyId the company ID
1349             * @throws SystemException if a system exception occurred
1350             */
1351            public void removeByUuid_C(String uuid, long companyId)
1352                    throws SystemException {
1353                    for (JournalArticle journalArticle : findByUuid_C(uuid, companyId,
1354                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1355                            remove(journalArticle);
1356                    }
1357            }
1358    
1359            /**
1360             * Returns the number of journal articles where uuid = &#63; and companyId = &#63;.
1361             *
1362             * @param uuid the uuid
1363             * @param companyId the company ID
1364             * @return the number of matching journal articles
1365             * @throws SystemException if a system exception occurred
1366             */
1367            public int countByUuid_C(String uuid, long companyId)
1368                    throws SystemException {
1369                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1370    
1371                    Object[] finderArgs = new Object[] { uuid, companyId };
1372    
1373                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1374                                    this);
1375    
1376                    if (count == null) {
1377                            StringBundler query = new StringBundler(3);
1378    
1379                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1380    
1381                            boolean bindUuid = false;
1382    
1383                            if (uuid == null) {
1384                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1385                            }
1386                            else if (uuid.equals(StringPool.BLANK)) {
1387                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1388                            }
1389                            else {
1390                                    bindUuid = true;
1391    
1392                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1393                            }
1394    
1395                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1396    
1397                            String sql = query.toString();
1398    
1399                            Session session = null;
1400    
1401                            try {
1402                                    session = openSession();
1403    
1404                                    Query q = session.createQuery(sql);
1405    
1406                                    QueryPos qPos = QueryPos.getInstance(q);
1407    
1408                                    if (bindUuid) {
1409                                            qPos.add(uuid);
1410                                    }
1411    
1412                                    qPos.add(companyId);
1413    
1414                                    count = (Long)q.uniqueResult();
1415    
1416                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1417                            }
1418                            catch (Exception e) {
1419                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1420    
1421                                    throw processException(e);
1422                            }
1423                            finally {
1424                                    closeSession(session);
1425                            }
1426                    }
1427    
1428                    return count.intValue();
1429            }
1430    
1431            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalArticle.uuid IS NULL AND ";
1432            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalArticle.uuid = ? AND ";
1433            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
1434            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalArticle.companyId = ?";
1435            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1436                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1437                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1438                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1439                            "findByResourcePrimKey",
1440                            new String[] {
1441                                    Long.class.getName(),
1442                                    
1443                            Integer.class.getName(), Integer.class.getName(),
1444                                    OrderByComparator.class.getName()
1445                            });
1446            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1447                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1448                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1449                            JournalArticleImpl.class,
1450                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
1451                            new String[] { Long.class.getName() },
1452                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
1453                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1454                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1455            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1456                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1457                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1458                            "countByResourcePrimKey", new String[] { Long.class.getName() });
1459    
1460            /**
1461             * Returns all the journal articles where resourcePrimKey = &#63;.
1462             *
1463             * @param resourcePrimKey the resource prim key
1464             * @return the matching journal articles
1465             * @throws SystemException if a system exception occurred
1466             */
1467            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
1468                    throws SystemException {
1469                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
1470                            QueryUtil.ALL_POS, null);
1471            }
1472    
1473            /**
1474             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
1475             *
1476             * <p>
1477             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1478             * </p>
1479             *
1480             * @param resourcePrimKey the resource prim key
1481             * @param start the lower bound of the range of journal articles
1482             * @param end the upper bound of the range of journal articles (not inclusive)
1483             * @return the range of matching journal articles
1484             * @throws SystemException if a system exception occurred
1485             */
1486            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1487                    int start, int end) throws SystemException {
1488                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
1489            }
1490    
1491            /**
1492             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
1493             *
1494             * <p>
1495             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1496             * </p>
1497             *
1498             * @param resourcePrimKey the resource prim key
1499             * @param start the lower bound of the range of journal articles
1500             * @param end the upper bound of the range of journal articles (not inclusive)
1501             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1502             * @return the ordered range of matching journal articles
1503             * @throws SystemException if a system exception occurred
1504             */
1505            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1506                    int start, int end, OrderByComparator orderByComparator)
1507                    throws SystemException {
1508                    boolean pagination = true;
1509                    FinderPath finderPath = null;
1510                    Object[] finderArgs = null;
1511    
1512                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1513                                    (orderByComparator == null)) {
1514                            pagination = false;
1515                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1516                            finderArgs = new Object[] { resourcePrimKey };
1517                    }
1518                    else {
1519                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1520                            finderArgs = new Object[] {
1521                                            resourcePrimKey,
1522                                            
1523                                            start, end, orderByComparator
1524                                    };
1525                    }
1526    
1527                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1528                                    finderArgs, this);
1529    
1530                    if ((list != null) && !list.isEmpty()) {
1531                            for (JournalArticle journalArticle : list) {
1532                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey())) {
1533                                            list = null;
1534    
1535                                            break;
1536                                    }
1537                            }
1538                    }
1539    
1540                    if (list == null) {
1541                            StringBundler query = null;
1542    
1543                            if (orderByComparator != null) {
1544                                    query = new StringBundler(3 +
1545                                                    (orderByComparator.getOrderByFields().length * 3));
1546                            }
1547                            else {
1548                                    query = new StringBundler(3);
1549                            }
1550    
1551                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1552    
1553                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1554    
1555                            if (orderByComparator != null) {
1556                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1557                                            orderByComparator);
1558                            }
1559                            else
1560                             if (pagination) {
1561                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1562                            }
1563    
1564                            String sql = query.toString();
1565    
1566                            Session session = null;
1567    
1568                            try {
1569                                    session = openSession();
1570    
1571                                    Query q = session.createQuery(sql);
1572    
1573                                    QueryPos qPos = QueryPos.getInstance(q);
1574    
1575                                    qPos.add(resourcePrimKey);
1576    
1577                                    if (!pagination) {
1578                                            list = (List<JournalArticle>)QueryUtil.list(q,
1579                                                            getDialect(), start, end, false);
1580    
1581                                            Collections.sort(list);
1582    
1583                                            list = new UnmodifiableList<JournalArticle>(list);
1584                                    }
1585                                    else {
1586                                            list = (List<JournalArticle>)QueryUtil.list(q,
1587                                                            getDialect(), start, end);
1588                                    }
1589    
1590                                    cacheResult(list);
1591    
1592                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1593                            }
1594                            catch (Exception e) {
1595                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1596    
1597                                    throw processException(e);
1598                            }
1599                            finally {
1600                                    closeSession(session);
1601                            }
1602                    }
1603    
1604                    return list;
1605            }
1606    
1607            /**
1608             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1609             *
1610             * @param resourcePrimKey the resource prim key
1611             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1612             * @return the first matching journal article
1613             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1614             * @throws SystemException if a system exception occurred
1615             */
1616            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
1617                    OrderByComparator orderByComparator)
1618                    throws NoSuchArticleException, SystemException {
1619                    JournalArticle journalArticle = fetchByResourcePrimKey_First(resourcePrimKey,
1620                                    orderByComparator);
1621    
1622                    if (journalArticle != null) {
1623                            return journalArticle;
1624                    }
1625    
1626                    StringBundler msg = new StringBundler(4);
1627    
1628                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1629    
1630                    msg.append("resourcePrimKey=");
1631                    msg.append(resourcePrimKey);
1632    
1633                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1634    
1635                    throw new NoSuchArticleException(msg.toString());
1636            }
1637    
1638            /**
1639             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1640             *
1641             * @param resourcePrimKey the resource prim key
1642             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1643             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1644             * @throws SystemException if a system exception occurred
1645             */
1646            public JournalArticle fetchByResourcePrimKey_First(long resourcePrimKey,
1647                    OrderByComparator orderByComparator) throws SystemException {
1648                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
1649                                    1, orderByComparator);
1650    
1651                    if (!list.isEmpty()) {
1652                            return list.get(0);
1653                    }
1654    
1655                    return null;
1656            }
1657    
1658            /**
1659             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1660             *
1661             * @param resourcePrimKey the resource prim key
1662             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1663             * @return the last matching journal article
1664             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1665             * @throws SystemException if a system exception occurred
1666             */
1667            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
1668                    OrderByComparator orderByComparator)
1669                    throws NoSuchArticleException, SystemException {
1670                    JournalArticle journalArticle = fetchByResourcePrimKey_Last(resourcePrimKey,
1671                                    orderByComparator);
1672    
1673                    if (journalArticle != null) {
1674                            return journalArticle;
1675                    }
1676    
1677                    StringBundler msg = new StringBundler(4);
1678    
1679                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1680    
1681                    msg.append("resourcePrimKey=");
1682                    msg.append(resourcePrimKey);
1683    
1684                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1685    
1686                    throw new NoSuchArticleException(msg.toString());
1687            }
1688    
1689            /**
1690             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1691             *
1692             * @param resourcePrimKey the resource prim key
1693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1694             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1695             * @throws SystemException if a system exception occurred
1696             */
1697            public JournalArticle fetchByResourcePrimKey_Last(long resourcePrimKey,
1698                    OrderByComparator orderByComparator) throws SystemException {
1699                    int count = countByResourcePrimKey(resourcePrimKey);
1700    
1701                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
1702                                    count - 1, count, orderByComparator);
1703    
1704                    if (!list.isEmpty()) {
1705                            return list.get(0);
1706                    }
1707    
1708                    return null;
1709            }
1710    
1711            /**
1712             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
1713             *
1714             * @param id the primary key of the current journal article
1715             * @param resourcePrimKey the resource prim key
1716             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1717             * @return the previous, current, and next journal article
1718             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1719             * @throws SystemException if a system exception occurred
1720             */
1721            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
1722                    long resourcePrimKey, OrderByComparator orderByComparator)
1723                    throws NoSuchArticleException, SystemException {
1724                    JournalArticle journalArticle = findByPrimaryKey(id);
1725    
1726                    Session session = null;
1727    
1728                    try {
1729                            session = openSession();
1730    
1731                            JournalArticle[] array = new JournalArticleImpl[3];
1732    
1733                            array[0] = getByResourcePrimKey_PrevAndNext(session,
1734                                            journalArticle, resourcePrimKey, orderByComparator, true);
1735    
1736                            array[1] = journalArticle;
1737    
1738                            array[2] = getByResourcePrimKey_PrevAndNext(session,
1739                                            journalArticle, resourcePrimKey, orderByComparator, false);
1740    
1741                            return array;
1742                    }
1743                    catch (Exception e) {
1744                            throw processException(e);
1745                    }
1746                    finally {
1747                            closeSession(session);
1748                    }
1749            }
1750    
1751            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
1752                    JournalArticle journalArticle, long resourcePrimKey,
1753                    OrderByComparator orderByComparator, boolean previous) {
1754                    StringBundler query = null;
1755    
1756                    if (orderByComparator != null) {
1757                            query = new StringBundler(6 +
1758                                            (orderByComparator.getOrderByFields().length * 6));
1759                    }
1760                    else {
1761                            query = new StringBundler(3);
1762                    }
1763    
1764                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1765    
1766                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1767    
1768                    if (orderByComparator != null) {
1769                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1770    
1771                            if (orderByConditionFields.length > 0) {
1772                                    query.append(WHERE_AND);
1773                            }
1774    
1775                            for (int i = 0; i < orderByConditionFields.length; i++) {
1776                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1777                                    query.append(orderByConditionFields[i]);
1778    
1779                                    if ((i + 1) < orderByConditionFields.length) {
1780                                            if (orderByComparator.isAscending() ^ previous) {
1781                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1782                                            }
1783                                            else {
1784                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1785                                            }
1786                                    }
1787                                    else {
1788                                            if (orderByComparator.isAscending() ^ previous) {
1789                                                    query.append(WHERE_GREATER_THAN);
1790                                            }
1791                                            else {
1792                                                    query.append(WHERE_LESSER_THAN);
1793                                            }
1794                                    }
1795                            }
1796    
1797                            query.append(ORDER_BY_CLAUSE);
1798    
1799                            String[] orderByFields = orderByComparator.getOrderByFields();
1800    
1801                            for (int i = 0; i < orderByFields.length; i++) {
1802                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1803                                    query.append(orderByFields[i]);
1804    
1805                                    if ((i + 1) < orderByFields.length) {
1806                                            if (orderByComparator.isAscending() ^ previous) {
1807                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1808                                            }
1809                                            else {
1810                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1811                                            }
1812                                    }
1813                                    else {
1814                                            if (orderByComparator.isAscending() ^ previous) {
1815                                                    query.append(ORDER_BY_ASC);
1816                                            }
1817                                            else {
1818                                                    query.append(ORDER_BY_DESC);
1819                                            }
1820                                    }
1821                            }
1822                    }
1823                    else {
1824                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1825                    }
1826    
1827                    String sql = query.toString();
1828    
1829                    Query q = session.createQuery(sql);
1830    
1831                    q.setFirstResult(0);
1832                    q.setMaxResults(2);
1833    
1834                    QueryPos qPos = QueryPos.getInstance(q);
1835    
1836                    qPos.add(resourcePrimKey);
1837    
1838                    if (orderByComparator != null) {
1839                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1840    
1841                            for (Object value : values) {
1842                                    qPos.add(value);
1843                            }
1844                    }
1845    
1846                    List<JournalArticle> list = q.list();
1847    
1848                    if (list.size() == 2) {
1849                            return list.get(1);
1850                    }
1851                    else {
1852                            return null;
1853                    }
1854            }
1855    
1856            /**
1857             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
1858             *
1859             * @param resourcePrimKey the resource prim key
1860             * @throws SystemException if a system exception occurred
1861             */
1862            public void removeByResourcePrimKey(long resourcePrimKey)
1863                    throws SystemException {
1864                    for (JournalArticle journalArticle : findByResourcePrimKey(
1865                                    resourcePrimKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1866                            remove(journalArticle);
1867                    }
1868            }
1869    
1870            /**
1871             * Returns the number of journal articles where resourcePrimKey = &#63;.
1872             *
1873             * @param resourcePrimKey the resource prim key
1874             * @return the number of matching journal articles
1875             * @throws SystemException if a system exception occurred
1876             */
1877            public int countByResourcePrimKey(long resourcePrimKey)
1878                    throws SystemException {
1879                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY;
1880    
1881                    Object[] finderArgs = new Object[] { resourcePrimKey };
1882    
1883                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1884                                    this);
1885    
1886                    if (count == null) {
1887                            StringBundler query = new StringBundler(2);
1888    
1889                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1890    
1891                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1892    
1893                            String sql = query.toString();
1894    
1895                            Session session = null;
1896    
1897                            try {
1898                                    session = openSession();
1899    
1900                                    Query q = session.createQuery(sql);
1901    
1902                                    QueryPos qPos = QueryPos.getInstance(q);
1903    
1904                                    qPos.add(resourcePrimKey);
1905    
1906                                    count = (Long)q.uniqueResult();
1907    
1908                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1909                            }
1910                            catch (Exception e) {
1911                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1912    
1913                                    throw processException(e);
1914                            }
1915                            finally {
1916                                    closeSession(session);
1917                            }
1918                    }
1919    
1920                    return count.intValue();
1921            }
1922    
1923            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
1924                    "journalArticle.resourcePrimKey = ?";
1925            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1926                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1927                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1928                            "findByGroupId",
1929                            new String[] {
1930                                    Long.class.getName(),
1931                                    
1932                            Integer.class.getName(), Integer.class.getName(),
1933                                    OrderByComparator.class.getName()
1934                            });
1935            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1936                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1937                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1938                            JournalArticleImpl.class,
1939                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1940                            new String[] { Long.class.getName() },
1941                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
1942                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1943                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1944            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1945                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1946                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1947                            new String[] { Long.class.getName() });
1948    
1949            /**
1950             * Returns all the journal articles where groupId = &#63;.
1951             *
1952             * @param groupId the group ID
1953             * @return the matching journal articles
1954             * @throws SystemException if a system exception occurred
1955             */
1956            public List<JournalArticle> findByGroupId(long groupId)
1957                    throws SystemException {
1958                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1959            }
1960    
1961            /**
1962             * Returns a range of all the journal articles where groupId = &#63;.
1963             *
1964             * <p>
1965             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1966             * </p>
1967             *
1968             * @param groupId the group ID
1969             * @param start the lower bound of the range of journal articles
1970             * @param end the upper bound of the range of journal articles (not inclusive)
1971             * @return the range of matching journal articles
1972             * @throws SystemException if a system exception occurred
1973             */
1974            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
1975                    throws SystemException {
1976                    return findByGroupId(groupId, start, end, null);
1977            }
1978    
1979            /**
1980             * Returns an ordered range of all the journal articles where groupId = &#63;.
1981             *
1982             * <p>
1983             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1984             * </p>
1985             *
1986             * @param groupId the group ID
1987             * @param start the lower bound of the range of journal articles
1988             * @param end the upper bound of the range of journal articles (not inclusive)
1989             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1990             * @return the ordered range of matching journal articles
1991             * @throws SystemException if a system exception occurred
1992             */
1993            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
1994                    OrderByComparator orderByComparator) throws SystemException {
1995                    boolean pagination = true;
1996                    FinderPath finderPath = null;
1997                    Object[] finderArgs = null;
1998    
1999                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2000                                    (orderByComparator == null)) {
2001                            pagination = false;
2002                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2003                            finderArgs = new Object[] { groupId };
2004                    }
2005                    else {
2006                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2007                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2008                    }
2009    
2010                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2011                                    finderArgs, this);
2012    
2013                    if ((list != null) && !list.isEmpty()) {
2014                            for (JournalArticle journalArticle : list) {
2015                                    if ((groupId != journalArticle.getGroupId())) {
2016                                            list = null;
2017    
2018                                            break;
2019                                    }
2020                            }
2021                    }
2022    
2023                    if (list == null) {
2024                            StringBundler query = null;
2025    
2026                            if (orderByComparator != null) {
2027                                    query = new StringBundler(3 +
2028                                                    (orderByComparator.getOrderByFields().length * 3));
2029                            }
2030                            else {
2031                                    query = new StringBundler(3);
2032                            }
2033    
2034                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2035    
2036                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2037    
2038                            if (orderByComparator != null) {
2039                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2040                                            orderByComparator);
2041                            }
2042                            else
2043                             if (pagination) {
2044                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2045                            }
2046    
2047                            String sql = query.toString();
2048    
2049                            Session session = null;
2050    
2051                            try {
2052                                    session = openSession();
2053    
2054                                    Query q = session.createQuery(sql);
2055    
2056                                    QueryPos qPos = QueryPos.getInstance(q);
2057    
2058                                    qPos.add(groupId);
2059    
2060                                    if (!pagination) {
2061                                            list = (List<JournalArticle>)QueryUtil.list(q,
2062                                                            getDialect(), start, end, false);
2063    
2064                                            Collections.sort(list);
2065    
2066                                            list = new UnmodifiableList<JournalArticle>(list);
2067                                    }
2068                                    else {
2069                                            list = (List<JournalArticle>)QueryUtil.list(q,
2070                                                            getDialect(), start, end);
2071                                    }
2072    
2073                                    cacheResult(list);
2074    
2075                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2076                            }
2077                            catch (Exception e) {
2078                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2079    
2080                                    throw processException(e);
2081                            }
2082                            finally {
2083                                    closeSession(session);
2084                            }
2085                    }
2086    
2087                    return list;
2088            }
2089    
2090            /**
2091             * Returns the first journal article in the ordered set where groupId = &#63;.
2092             *
2093             * @param groupId the group ID
2094             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2095             * @return the first matching journal article
2096             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2097             * @throws SystemException if a system exception occurred
2098             */
2099            public JournalArticle findByGroupId_First(long groupId,
2100                    OrderByComparator orderByComparator)
2101                    throws NoSuchArticleException, SystemException {
2102                    JournalArticle journalArticle = fetchByGroupId_First(groupId,
2103                                    orderByComparator);
2104    
2105                    if (journalArticle != null) {
2106                            return journalArticle;
2107                    }
2108    
2109                    StringBundler msg = new StringBundler(4);
2110    
2111                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2112    
2113                    msg.append("groupId=");
2114                    msg.append(groupId);
2115    
2116                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2117    
2118                    throw new NoSuchArticleException(msg.toString());
2119            }
2120    
2121            /**
2122             * Returns the first journal article in the ordered set where groupId = &#63;.
2123             *
2124             * @param groupId the group ID
2125             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2126             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2127             * @throws SystemException if a system exception occurred
2128             */
2129            public JournalArticle fetchByGroupId_First(long groupId,
2130                    OrderByComparator orderByComparator) throws SystemException {
2131                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2132                                    orderByComparator);
2133    
2134                    if (!list.isEmpty()) {
2135                            return list.get(0);
2136                    }
2137    
2138                    return null;
2139            }
2140    
2141            /**
2142             * Returns the last journal article in the ordered set where groupId = &#63;.
2143             *
2144             * @param groupId the group ID
2145             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2146             * @return the last matching journal article
2147             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2148             * @throws SystemException if a system exception occurred
2149             */
2150            public JournalArticle findByGroupId_Last(long groupId,
2151                    OrderByComparator orderByComparator)
2152                    throws NoSuchArticleException, SystemException {
2153                    JournalArticle journalArticle = fetchByGroupId_Last(groupId,
2154                                    orderByComparator);
2155    
2156                    if (journalArticle != null) {
2157                            return journalArticle;
2158                    }
2159    
2160                    StringBundler msg = new StringBundler(4);
2161    
2162                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2163    
2164                    msg.append("groupId=");
2165                    msg.append(groupId);
2166    
2167                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2168    
2169                    throw new NoSuchArticleException(msg.toString());
2170            }
2171    
2172            /**
2173             * Returns the last journal article in the ordered set where groupId = &#63;.
2174             *
2175             * @param groupId the group ID
2176             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2177             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2178             * @throws SystemException if a system exception occurred
2179             */
2180            public JournalArticle fetchByGroupId_Last(long groupId,
2181                    OrderByComparator orderByComparator) throws SystemException {
2182                    int count = countByGroupId(groupId);
2183    
2184                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2185                                    orderByComparator);
2186    
2187                    if (!list.isEmpty()) {
2188                            return list.get(0);
2189                    }
2190    
2191                    return null;
2192            }
2193    
2194            /**
2195             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2196             *
2197             * @param id the primary key of the current journal article
2198             * @param groupId the group ID
2199             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2200             * @return the previous, current, and next journal article
2201             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2202             * @throws SystemException if a system exception occurred
2203             */
2204            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2205                    OrderByComparator orderByComparator)
2206                    throws NoSuchArticleException, SystemException {
2207                    JournalArticle journalArticle = findByPrimaryKey(id);
2208    
2209                    Session session = null;
2210    
2211                    try {
2212                            session = openSession();
2213    
2214                            JournalArticle[] array = new JournalArticleImpl[3];
2215    
2216                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2217                                            groupId, orderByComparator, true);
2218    
2219                            array[1] = journalArticle;
2220    
2221                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2222                                            groupId, orderByComparator, false);
2223    
2224                            return array;
2225                    }
2226                    catch (Exception e) {
2227                            throw processException(e);
2228                    }
2229                    finally {
2230                            closeSession(session);
2231                    }
2232            }
2233    
2234            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2235                    JournalArticle journalArticle, long groupId,
2236                    OrderByComparator orderByComparator, boolean previous) {
2237                    StringBundler query = null;
2238    
2239                    if (orderByComparator != null) {
2240                            query = new StringBundler(6 +
2241                                            (orderByComparator.getOrderByFields().length * 6));
2242                    }
2243                    else {
2244                            query = new StringBundler(3);
2245                    }
2246    
2247                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2248    
2249                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2250    
2251                    if (orderByComparator != null) {
2252                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2253    
2254                            if (orderByConditionFields.length > 0) {
2255                                    query.append(WHERE_AND);
2256                            }
2257    
2258                            for (int i = 0; i < orderByConditionFields.length; i++) {
2259                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2260                                    query.append(orderByConditionFields[i]);
2261    
2262                                    if ((i + 1) < orderByConditionFields.length) {
2263                                            if (orderByComparator.isAscending() ^ previous) {
2264                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2265                                            }
2266                                            else {
2267                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2268                                            }
2269                                    }
2270                                    else {
2271                                            if (orderByComparator.isAscending() ^ previous) {
2272                                                    query.append(WHERE_GREATER_THAN);
2273                                            }
2274                                            else {
2275                                                    query.append(WHERE_LESSER_THAN);
2276                                            }
2277                                    }
2278                            }
2279    
2280                            query.append(ORDER_BY_CLAUSE);
2281    
2282                            String[] orderByFields = orderByComparator.getOrderByFields();
2283    
2284                            for (int i = 0; i < orderByFields.length; i++) {
2285                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2286                                    query.append(orderByFields[i]);
2287    
2288                                    if ((i + 1) < orderByFields.length) {
2289                                            if (orderByComparator.isAscending() ^ previous) {
2290                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2291                                            }
2292                                            else {
2293                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2294                                            }
2295                                    }
2296                                    else {
2297                                            if (orderByComparator.isAscending() ^ previous) {
2298                                                    query.append(ORDER_BY_ASC);
2299                                            }
2300                                            else {
2301                                                    query.append(ORDER_BY_DESC);
2302                                            }
2303                                    }
2304                            }
2305                    }
2306                    else {
2307                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2308                    }
2309    
2310                    String sql = query.toString();
2311    
2312                    Query q = session.createQuery(sql);
2313    
2314                    q.setFirstResult(0);
2315                    q.setMaxResults(2);
2316    
2317                    QueryPos qPos = QueryPos.getInstance(q);
2318    
2319                    qPos.add(groupId);
2320    
2321                    if (orderByComparator != null) {
2322                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2323    
2324                            for (Object value : values) {
2325                                    qPos.add(value);
2326                            }
2327                    }
2328    
2329                    List<JournalArticle> list = q.list();
2330    
2331                    if (list.size() == 2) {
2332                            return list.get(1);
2333                    }
2334                    else {
2335                            return null;
2336                    }
2337            }
2338    
2339            /**
2340             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2341             *
2342             * @param groupId the group ID
2343             * @return the matching journal articles that the user has permission to view
2344             * @throws SystemException if a system exception occurred
2345             */
2346            public List<JournalArticle> filterFindByGroupId(long groupId)
2347                    throws SystemException {
2348                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2349                            QueryUtil.ALL_POS, null);
2350            }
2351    
2352            /**
2353             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
2354             *
2355             * <p>
2356             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2357             * </p>
2358             *
2359             * @param groupId the group ID
2360             * @param start the lower bound of the range of journal articles
2361             * @param end the upper bound of the range of journal articles (not inclusive)
2362             * @return the range of matching journal articles that the user has permission to view
2363             * @throws SystemException if a system exception occurred
2364             */
2365            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2366                    int end) throws SystemException {
2367                    return filterFindByGroupId(groupId, start, end, null);
2368            }
2369    
2370            /**
2371             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
2372             *
2373             * <p>
2374             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2375             * </p>
2376             *
2377             * @param groupId the group ID
2378             * @param start the lower bound of the range of journal articles
2379             * @param end the upper bound of the range of journal articles (not inclusive)
2380             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2381             * @return the ordered range of matching journal articles that the user has permission to view
2382             * @throws SystemException if a system exception occurred
2383             */
2384            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2385                    int end, OrderByComparator orderByComparator) throws SystemException {
2386                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2387                            return findByGroupId(groupId, start, end, orderByComparator);
2388                    }
2389    
2390                    StringBundler query = null;
2391    
2392                    if (orderByComparator != null) {
2393                            query = new StringBundler(3 +
2394                                            (orderByComparator.getOrderByFields().length * 3));
2395                    }
2396                    else {
2397                            query = new StringBundler(3);
2398                    }
2399    
2400                    if (getDB().isSupportsInlineDistinct()) {
2401                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2402                    }
2403                    else {
2404                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2405                    }
2406    
2407                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2408    
2409                    if (!getDB().isSupportsInlineDistinct()) {
2410                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2411                    }
2412    
2413                    if (orderByComparator != null) {
2414                            if (getDB().isSupportsInlineDistinct()) {
2415                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2416                                            orderByComparator, true);
2417                            }
2418                            else {
2419                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2420                                            orderByComparator, true);
2421                            }
2422                    }
2423                    else {
2424                            if (getDB().isSupportsInlineDistinct()) {
2425                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2426                            }
2427                            else {
2428                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2429                            }
2430                    }
2431    
2432                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2433                                    JournalArticle.class.getName(),
2434                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2435    
2436                    Session session = null;
2437    
2438                    try {
2439                            session = openSession();
2440    
2441                            SQLQuery q = session.createSQLQuery(sql);
2442    
2443                            if (getDB().isSupportsInlineDistinct()) {
2444                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2445                            }
2446                            else {
2447                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2448                            }
2449    
2450                            QueryPos qPos = QueryPos.getInstance(q);
2451    
2452                            qPos.add(groupId);
2453    
2454                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
2455                                    end);
2456                    }
2457                    catch (Exception e) {
2458                            throw processException(e);
2459                    }
2460                    finally {
2461                            closeSession(session);
2462                    }
2463            }
2464    
2465            /**
2466             * 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;.
2467             *
2468             * @param id the primary key of the current journal article
2469             * @param groupId the group ID
2470             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2471             * @return the previous, current, and next journal article
2472             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2473             * @throws SystemException if a system exception occurred
2474             */
2475            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
2476                    long groupId, OrderByComparator orderByComparator)
2477                    throws NoSuchArticleException, SystemException {
2478                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2479                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
2480                    }
2481    
2482                    JournalArticle journalArticle = findByPrimaryKey(id);
2483    
2484                    Session session = null;
2485    
2486                    try {
2487                            session = openSession();
2488    
2489                            JournalArticle[] array = new JournalArticleImpl[3];
2490    
2491                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2492                                            groupId, orderByComparator, true);
2493    
2494                            array[1] = journalArticle;
2495    
2496                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2497                                            groupId, orderByComparator, false);
2498    
2499                            return array;
2500                    }
2501                    catch (Exception e) {
2502                            throw processException(e);
2503                    }
2504                    finally {
2505                            closeSession(session);
2506                    }
2507            }
2508    
2509            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
2510                    JournalArticle journalArticle, long groupId,
2511                    OrderByComparator orderByComparator, boolean previous) {
2512                    StringBundler query = null;
2513    
2514                    if (orderByComparator != null) {
2515                            query = new StringBundler(6 +
2516                                            (orderByComparator.getOrderByFields().length * 6));
2517                    }
2518                    else {
2519                            query = new StringBundler(3);
2520                    }
2521    
2522                    if (getDB().isSupportsInlineDistinct()) {
2523                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2524                    }
2525                    else {
2526                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2527                    }
2528    
2529                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2530    
2531                    if (!getDB().isSupportsInlineDistinct()) {
2532                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2533                    }
2534    
2535                    if (orderByComparator != null) {
2536                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2537    
2538                            if (orderByConditionFields.length > 0) {
2539                                    query.append(WHERE_AND);
2540                            }
2541    
2542                            for (int i = 0; i < orderByConditionFields.length; i++) {
2543                                    if (getDB().isSupportsInlineDistinct()) {
2544                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2545                                    }
2546                                    else {
2547                                            query.append(_ORDER_BY_ENTITY_TABLE);
2548                                    }
2549    
2550                                    query.append(orderByConditionFields[i]);
2551    
2552                                    if ((i + 1) < orderByConditionFields.length) {
2553                                            if (orderByComparator.isAscending() ^ previous) {
2554                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2555                                            }
2556                                            else {
2557                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2558                                            }
2559                                    }
2560                                    else {
2561                                            if (orderByComparator.isAscending() ^ previous) {
2562                                                    query.append(WHERE_GREATER_THAN);
2563                                            }
2564                                            else {
2565                                                    query.append(WHERE_LESSER_THAN);
2566                                            }
2567                                    }
2568                            }
2569    
2570                            query.append(ORDER_BY_CLAUSE);
2571    
2572                            String[] orderByFields = orderByComparator.getOrderByFields();
2573    
2574                            for (int i = 0; i < orderByFields.length; i++) {
2575                                    if (getDB().isSupportsInlineDistinct()) {
2576                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2577                                    }
2578                                    else {
2579                                            query.append(_ORDER_BY_ENTITY_TABLE);
2580                                    }
2581    
2582                                    query.append(orderByFields[i]);
2583    
2584                                    if ((i + 1) < orderByFields.length) {
2585                                            if (orderByComparator.isAscending() ^ previous) {
2586                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2587                                            }
2588                                            else {
2589                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2590                                            }
2591                                    }
2592                                    else {
2593                                            if (orderByComparator.isAscending() ^ previous) {
2594                                                    query.append(ORDER_BY_ASC);
2595                                            }
2596                                            else {
2597                                                    query.append(ORDER_BY_DESC);
2598                                            }
2599                                    }
2600                            }
2601                    }
2602                    else {
2603                            if (getDB().isSupportsInlineDistinct()) {
2604                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2605                            }
2606                            else {
2607                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2608                            }
2609                    }
2610    
2611                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2612                                    JournalArticle.class.getName(),
2613                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2614    
2615                    SQLQuery q = session.createSQLQuery(sql);
2616    
2617                    q.setFirstResult(0);
2618                    q.setMaxResults(2);
2619    
2620                    if (getDB().isSupportsInlineDistinct()) {
2621                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2622                    }
2623                    else {
2624                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2625                    }
2626    
2627                    QueryPos qPos = QueryPos.getInstance(q);
2628    
2629                    qPos.add(groupId);
2630    
2631                    if (orderByComparator != null) {
2632                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2633    
2634                            for (Object value : values) {
2635                                    qPos.add(value);
2636                            }
2637                    }
2638    
2639                    List<JournalArticle> list = q.list();
2640    
2641                    if (list.size() == 2) {
2642                            return list.get(1);
2643                    }
2644                    else {
2645                            return null;
2646                    }
2647            }
2648    
2649            /**
2650             * Removes all the journal articles where groupId = &#63; from the database.
2651             *
2652             * @param groupId the group ID
2653             * @throws SystemException if a system exception occurred
2654             */
2655            public void removeByGroupId(long groupId) throws SystemException {
2656                    for (JournalArticle journalArticle : findByGroupId(groupId,
2657                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2658                            remove(journalArticle);
2659                    }
2660            }
2661    
2662            /**
2663             * Returns the number of journal articles where groupId = &#63;.
2664             *
2665             * @param groupId the group ID
2666             * @return the number of matching journal articles
2667             * @throws SystemException if a system exception occurred
2668             */
2669            public int countByGroupId(long groupId) throws SystemException {
2670                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2671    
2672                    Object[] finderArgs = new Object[] { groupId };
2673    
2674                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2675                                    this);
2676    
2677                    if (count == null) {
2678                            StringBundler query = new StringBundler(2);
2679    
2680                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
2681    
2682                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2683    
2684                            String sql = query.toString();
2685    
2686                            Session session = null;
2687    
2688                            try {
2689                                    session = openSession();
2690    
2691                                    Query q = session.createQuery(sql);
2692    
2693                                    QueryPos qPos = QueryPos.getInstance(q);
2694    
2695                                    qPos.add(groupId);
2696    
2697                                    count = (Long)q.uniqueResult();
2698    
2699                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2700                            }
2701                            catch (Exception e) {
2702                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2703    
2704                                    throw processException(e);
2705                            }
2706                            finally {
2707                                    closeSession(session);
2708                            }
2709                    }
2710    
2711                    return count.intValue();
2712            }
2713    
2714            /**
2715             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
2716             *
2717             * @param groupId the group ID
2718             * @return the number of matching journal articles that the user has permission to view
2719             * @throws SystemException if a system exception occurred
2720             */
2721            public int filterCountByGroupId(long groupId) throws SystemException {
2722                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2723                            return countByGroupId(groupId);
2724                    }
2725    
2726                    StringBundler query = new StringBundler(2);
2727    
2728                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
2729    
2730                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2731    
2732                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2733                                    JournalArticle.class.getName(),
2734                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2735    
2736                    Session session = null;
2737    
2738                    try {
2739                            session = openSession();
2740    
2741                            SQLQuery q = session.createSQLQuery(sql);
2742    
2743                            q.addScalar(COUNT_COLUMN_NAME,
2744                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2745    
2746                            QueryPos qPos = QueryPos.getInstance(q);
2747    
2748                            qPos.add(groupId);
2749    
2750                            Long count = (Long)q.uniqueResult();
2751    
2752                            return count.intValue();
2753                    }
2754                    catch (Exception e) {
2755                            throw processException(e);
2756                    }
2757                    finally {
2758                            closeSession(session);
2759                    }
2760            }
2761    
2762            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
2763            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2764                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2765                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2766                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2767                            "findByCompanyId",
2768                            new String[] {
2769                                    Long.class.getName(),
2770                                    
2771                            Integer.class.getName(), Integer.class.getName(),
2772                                    OrderByComparator.class.getName()
2773                            });
2774            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2775                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2776                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2777                            JournalArticleImpl.class,
2778                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2779                            new String[] { Long.class.getName() },
2780                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
2781                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
2782                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
2783            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2784                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
2785                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2786                            new String[] { Long.class.getName() });
2787    
2788            /**
2789             * Returns all the journal articles where companyId = &#63;.
2790             *
2791             * @param companyId the company ID
2792             * @return the matching journal articles
2793             * @throws SystemException if a system exception occurred
2794             */
2795            public List<JournalArticle> findByCompanyId(long companyId)
2796                    throws SystemException {
2797                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2798                            null);
2799            }
2800    
2801            /**
2802             * Returns a range of all the journal articles where companyId = &#63;.
2803             *
2804             * <p>
2805             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2806             * </p>
2807             *
2808             * @param companyId the company ID
2809             * @param start the lower bound of the range of journal articles
2810             * @param end the upper bound of the range of journal articles (not inclusive)
2811             * @return the range of matching journal articles
2812             * @throws SystemException if a system exception occurred
2813             */
2814            public List<JournalArticle> findByCompanyId(long companyId, int start,
2815                    int end) throws SystemException {
2816                    return findByCompanyId(companyId, start, end, null);
2817            }
2818    
2819            /**
2820             * Returns an ordered range of all the journal articles where companyId = &#63;.
2821             *
2822             * <p>
2823             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2824             * </p>
2825             *
2826             * @param companyId the company ID
2827             * @param start the lower bound of the range of journal articles
2828             * @param end the upper bound of the range of journal articles (not inclusive)
2829             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2830             * @return the ordered range of matching journal articles
2831             * @throws SystemException if a system exception occurred
2832             */
2833            public List<JournalArticle> findByCompanyId(long companyId, int start,
2834                    int end, OrderByComparator orderByComparator) throws SystemException {
2835                    boolean pagination = true;
2836                    FinderPath finderPath = null;
2837                    Object[] finderArgs = null;
2838    
2839                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2840                                    (orderByComparator == null)) {
2841                            pagination = false;
2842                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2843                            finderArgs = new Object[] { companyId };
2844                    }
2845                    else {
2846                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2847                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2848                    }
2849    
2850                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2851                                    finderArgs, this);
2852    
2853                    if ((list != null) && !list.isEmpty()) {
2854                            for (JournalArticle journalArticle : list) {
2855                                    if ((companyId != journalArticle.getCompanyId())) {
2856                                            list = null;
2857    
2858                                            break;
2859                                    }
2860                            }
2861                    }
2862    
2863                    if (list == null) {
2864                            StringBundler query = null;
2865    
2866                            if (orderByComparator != null) {
2867                                    query = new StringBundler(3 +
2868                                                    (orderByComparator.getOrderByFields().length * 3));
2869                            }
2870                            else {
2871                                    query = new StringBundler(3);
2872                            }
2873    
2874                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2875    
2876                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2877    
2878                            if (orderByComparator != null) {
2879                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2880                                            orderByComparator);
2881                            }
2882                            else
2883                             if (pagination) {
2884                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2885                            }
2886    
2887                            String sql = query.toString();
2888    
2889                            Session session = null;
2890    
2891                            try {
2892                                    session = openSession();
2893    
2894                                    Query q = session.createQuery(sql);
2895    
2896                                    QueryPos qPos = QueryPos.getInstance(q);
2897    
2898                                    qPos.add(companyId);
2899    
2900                                    if (!pagination) {
2901                                            list = (List<JournalArticle>)QueryUtil.list(q,
2902                                                            getDialect(), start, end, false);
2903    
2904                                            Collections.sort(list);
2905    
2906                                            list = new UnmodifiableList<JournalArticle>(list);
2907                                    }
2908                                    else {
2909                                            list = (List<JournalArticle>)QueryUtil.list(q,
2910                                                            getDialect(), start, end);
2911                                    }
2912    
2913                                    cacheResult(list);
2914    
2915                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2916                            }
2917                            catch (Exception e) {
2918                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2919    
2920                                    throw processException(e);
2921                            }
2922                            finally {
2923                                    closeSession(session);
2924                            }
2925                    }
2926    
2927                    return list;
2928            }
2929    
2930            /**
2931             * Returns the first journal article in the ordered set where companyId = &#63;.
2932             *
2933             * @param companyId the company ID
2934             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2935             * @return the first matching journal article
2936             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2937             * @throws SystemException if a system exception occurred
2938             */
2939            public JournalArticle findByCompanyId_First(long companyId,
2940                    OrderByComparator orderByComparator)
2941                    throws NoSuchArticleException, SystemException {
2942                    JournalArticle journalArticle = fetchByCompanyId_First(companyId,
2943                                    orderByComparator);
2944    
2945                    if (journalArticle != null) {
2946                            return journalArticle;
2947                    }
2948    
2949                    StringBundler msg = new StringBundler(4);
2950    
2951                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2952    
2953                    msg.append("companyId=");
2954                    msg.append(companyId);
2955    
2956                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2957    
2958                    throw new NoSuchArticleException(msg.toString());
2959            }
2960    
2961            /**
2962             * Returns the first journal article in the ordered set where companyId = &#63;.
2963             *
2964             * @param companyId the company ID
2965             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2966             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2967             * @throws SystemException if a system exception occurred
2968             */
2969            public JournalArticle fetchByCompanyId_First(long companyId,
2970                    OrderByComparator orderByComparator) throws SystemException {
2971                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
2972                                    orderByComparator);
2973    
2974                    if (!list.isEmpty()) {
2975                            return list.get(0);
2976                    }
2977    
2978                    return null;
2979            }
2980    
2981            /**
2982             * Returns the last journal article in the ordered set where companyId = &#63;.
2983             *
2984             * @param companyId the company ID
2985             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2986             * @return the last matching journal article
2987             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2988             * @throws SystemException if a system exception occurred
2989             */
2990            public JournalArticle findByCompanyId_Last(long companyId,
2991                    OrderByComparator orderByComparator)
2992                    throws NoSuchArticleException, SystemException {
2993                    JournalArticle journalArticle = fetchByCompanyId_Last(companyId,
2994                                    orderByComparator);
2995    
2996                    if (journalArticle != null) {
2997                            return journalArticle;
2998                    }
2999    
3000                    StringBundler msg = new StringBundler(4);
3001    
3002                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3003    
3004                    msg.append("companyId=");
3005                    msg.append(companyId);
3006    
3007                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3008    
3009                    throw new NoSuchArticleException(msg.toString());
3010            }
3011    
3012            /**
3013             * Returns the last journal article in the ordered set where companyId = &#63;.
3014             *
3015             * @param companyId the company ID
3016             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3017             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3018             * @throws SystemException if a system exception occurred
3019             */
3020            public JournalArticle fetchByCompanyId_Last(long companyId,
3021                    OrderByComparator orderByComparator) throws SystemException {
3022                    int count = countByCompanyId(companyId);
3023    
3024                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3025                                    count, orderByComparator);
3026    
3027                    if (!list.isEmpty()) {
3028                            return list.get(0);
3029                    }
3030    
3031                    return null;
3032            }
3033    
3034            /**
3035             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3036             *
3037             * @param id the primary key of the current journal article
3038             * @param companyId the company ID
3039             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3040             * @return the previous, current, and next journal article
3041             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3042             * @throws SystemException if a system exception occurred
3043             */
3044            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3045                    long companyId, OrderByComparator orderByComparator)
3046                    throws NoSuchArticleException, SystemException {
3047                    JournalArticle journalArticle = findByPrimaryKey(id);
3048    
3049                    Session session = null;
3050    
3051                    try {
3052                            session = openSession();
3053    
3054                            JournalArticle[] array = new JournalArticleImpl[3];
3055    
3056                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3057                                            companyId, orderByComparator, true);
3058    
3059                            array[1] = journalArticle;
3060    
3061                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3062                                            companyId, orderByComparator, false);
3063    
3064                            return array;
3065                    }
3066                    catch (Exception e) {
3067                            throw processException(e);
3068                    }
3069                    finally {
3070                            closeSession(session);
3071                    }
3072            }
3073    
3074            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3075                    JournalArticle journalArticle, long companyId,
3076                    OrderByComparator orderByComparator, boolean previous) {
3077                    StringBundler query = null;
3078    
3079                    if (orderByComparator != null) {
3080                            query = new StringBundler(6 +
3081                                            (orderByComparator.getOrderByFields().length * 6));
3082                    }
3083                    else {
3084                            query = new StringBundler(3);
3085                    }
3086    
3087                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3088    
3089                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3090    
3091                    if (orderByComparator != null) {
3092                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3093    
3094                            if (orderByConditionFields.length > 0) {
3095                                    query.append(WHERE_AND);
3096                            }
3097    
3098                            for (int i = 0; i < orderByConditionFields.length; i++) {
3099                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3100                                    query.append(orderByConditionFields[i]);
3101    
3102                                    if ((i + 1) < orderByConditionFields.length) {
3103                                            if (orderByComparator.isAscending() ^ previous) {
3104                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3105                                            }
3106                                            else {
3107                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3108                                            }
3109                                    }
3110                                    else {
3111                                            if (orderByComparator.isAscending() ^ previous) {
3112                                                    query.append(WHERE_GREATER_THAN);
3113                                            }
3114                                            else {
3115                                                    query.append(WHERE_LESSER_THAN);
3116                                            }
3117                                    }
3118                            }
3119    
3120                            query.append(ORDER_BY_CLAUSE);
3121    
3122                            String[] orderByFields = orderByComparator.getOrderByFields();
3123    
3124                            for (int i = 0; i < orderByFields.length; i++) {
3125                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3126                                    query.append(orderByFields[i]);
3127    
3128                                    if ((i + 1) < orderByFields.length) {
3129                                            if (orderByComparator.isAscending() ^ previous) {
3130                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3131                                            }
3132                                            else {
3133                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3134                                            }
3135                                    }
3136                                    else {
3137                                            if (orderByComparator.isAscending() ^ previous) {
3138                                                    query.append(ORDER_BY_ASC);
3139                                            }
3140                                            else {
3141                                                    query.append(ORDER_BY_DESC);
3142                                            }
3143                                    }
3144                            }
3145                    }
3146                    else {
3147                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3148                    }
3149    
3150                    String sql = query.toString();
3151    
3152                    Query q = session.createQuery(sql);
3153    
3154                    q.setFirstResult(0);
3155                    q.setMaxResults(2);
3156    
3157                    QueryPos qPos = QueryPos.getInstance(q);
3158    
3159                    qPos.add(companyId);
3160    
3161                    if (orderByComparator != null) {
3162                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3163    
3164                            for (Object value : values) {
3165                                    qPos.add(value);
3166                            }
3167                    }
3168    
3169                    List<JournalArticle> list = q.list();
3170    
3171                    if (list.size() == 2) {
3172                            return list.get(1);
3173                    }
3174                    else {
3175                            return null;
3176                    }
3177            }
3178    
3179            /**
3180             * Removes all the journal articles where companyId = &#63; from the database.
3181             *
3182             * @param companyId the company ID
3183             * @throws SystemException if a system exception occurred
3184             */
3185            public void removeByCompanyId(long companyId) throws SystemException {
3186                    for (JournalArticle journalArticle : findByCompanyId(companyId,
3187                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3188                            remove(journalArticle);
3189                    }
3190            }
3191    
3192            /**
3193             * Returns the number of journal articles where companyId = &#63;.
3194             *
3195             * @param companyId the company ID
3196             * @return the number of matching journal articles
3197             * @throws SystemException if a system exception occurred
3198             */
3199            public int countByCompanyId(long companyId) throws SystemException {
3200                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
3201    
3202                    Object[] finderArgs = new Object[] { companyId };
3203    
3204                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3205                                    this);
3206    
3207                    if (count == null) {
3208                            StringBundler query = new StringBundler(2);
3209    
3210                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3211    
3212                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3213    
3214                            String sql = query.toString();
3215    
3216                            Session session = null;
3217    
3218                            try {
3219                                    session = openSession();
3220    
3221                                    Query q = session.createQuery(sql);
3222    
3223                                    QueryPos qPos = QueryPos.getInstance(q);
3224    
3225                                    qPos.add(companyId);
3226    
3227                                    count = (Long)q.uniqueResult();
3228    
3229                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3230                            }
3231                            catch (Exception e) {
3232                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3233    
3234                                    throw processException(e);
3235                            }
3236                            finally {
3237                                    closeSession(session);
3238                            }
3239                    }
3240    
3241                    return count.intValue();
3242            }
3243    
3244            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
3245            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
3246                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3247                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3248                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3249                            "findByStructureId",
3250                            new String[] {
3251                                    String.class.getName(),
3252                                    
3253                            Integer.class.getName(), Integer.class.getName(),
3254                                    OrderByComparator.class.getName()
3255                            });
3256            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
3257                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3258                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3259                            JournalArticleImpl.class,
3260                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
3261                            new String[] { String.class.getName() },
3262                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
3263                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
3264                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
3265            public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3266                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3267                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
3268                            new String[] { String.class.getName() });
3269            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID =
3270                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3271                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3272                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByStructureId",
3273                            new String[] { String.class.getName() });
3274    
3275            /**
3276             * Returns all the journal articles where structureId = &#63;.
3277             *
3278             * @param structureId the structure ID
3279             * @return the matching journal articles
3280             * @throws SystemException if a system exception occurred
3281             */
3282            public List<JournalArticle> findByStructureId(String structureId)
3283                    throws SystemException {
3284                    return findByStructureId(structureId, QueryUtil.ALL_POS,
3285                            QueryUtil.ALL_POS, null);
3286            }
3287    
3288            /**
3289             * Returns a range of all the journal articles where structureId = &#63;.
3290             *
3291             * <p>
3292             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3293             * </p>
3294             *
3295             * @param structureId the structure ID
3296             * @param start the lower bound of the range of journal articles
3297             * @param end the upper bound of the range of journal articles (not inclusive)
3298             * @return the range of matching journal articles
3299             * @throws SystemException if a system exception occurred
3300             */
3301            public List<JournalArticle> findByStructureId(String structureId,
3302                    int start, int end) throws SystemException {
3303                    return findByStructureId(structureId, start, end, null);
3304            }
3305    
3306            /**
3307             * Returns an ordered range of all the journal articles where structureId = &#63;.
3308             *
3309             * <p>
3310             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3311             * </p>
3312             *
3313             * @param structureId the structure ID
3314             * @param start the lower bound of the range of journal articles
3315             * @param end the upper bound of the range of journal articles (not inclusive)
3316             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3317             * @return the ordered range of matching journal articles
3318             * @throws SystemException if a system exception occurred
3319             */
3320            public List<JournalArticle> findByStructureId(String structureId,
3321                    int start, int end, OrderByComparator orderByComparator)
3322                    throws SystemException {
3323                    boolean pagination = true;
3324                    FinderPath finderPath = null;
3325                    Object[] finderArgs = null;
3326    
3327                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3328                                    (orderByComparator == null)) {
3329                            pagination = false;
3330                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
3331                            finderArgs = new Object[] { structureId };
3332                    }
3333                    else {
3334                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
3335                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
3336                    }
3337    
3338                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3339                                    finderArgs, this);
3340    
3341                    if ((list != null) && !list.isEmpty()) {
3342                            for (JournalArticle journalArticle : list) {
3343                                    if (!Validator.equals(structureId,
3344                                                            journalArticle.getStructureId())) {
3345                                            list = null;
3346    
3347                                            break;
3348                                    }
3349                            }
3350                    }
3351    
3352                    if (list == null) {
3353                            StringBundler query = null;
3354    
3355                            if (orderByComparator != null) {
3356                                    query = new StringBundler(3 +
3357                                                    (orderByComparator.getOrderByFields().length * 3));
3358                            }
3359                            else {
3360                                    query = new StringBundler(3);
3361                            }
3362    
3363                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3364    
3365                            boolean bindStructureId = false;
3366    
3367                            if (structureId == null) {
3368                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3369                            }
3370                            else if (structureId.equals(StringPool.BLANK)) {
3371                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3372                            }
3373                            else {
3374                                    bindStructureId = true;
3375    
3376                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3377                            }
3378    
3379                            if (orderByComparator != null) {
3380                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3381                                            orderByComparator);
3382                            }
3383                            else
3384                             if (pagination) {
3385                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3386                            }
3387    
3388                            String sql = query.toString();
3389    
3390                            Session session = null;
3391    
3392                            try {
3393                                    session = openSession();
3394    
3395                                    Query q = session.createQuery(sql);
3396    
3397                                    QueryPos qPos = QueryPos.getInstance(q);
3398    
3399                                    if (bindStructureId) {
3400                                            qPos.add(structureId);
3401                                    }
3402    
3403                                    if (!pagination) {
3404                                            list = (List<JournalArticle>)QueryUtil.list(q,
3405                                                            getDialect(), start, end, false);
3406    
3407                                            Collections.sort(list);
3408    
3409                                            list = new UnmodifiableList<JournalArticle>(list);
3410                                    }
3411                                    else {
3412                                            list = (List<JournalArticle>)QueryUtil.list(q,
3413                                                            getDialect(), start, end);
3414                                    }
3415    
3416                                    cacheResult(list);
3417    
3418                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3419                            }
3420                            catch (Exception e) {
3421                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3422    
3423                                    throw processException(e);
3424                            }
3425                            finally {
3426                                    closeSession(session);
3427                            }
3428                    }
3429    
3430                    return list;
3431            }
3432    
3433            /**
3434             * Returns the first journal article in the ordered set where structureId = &#63;.
3435             *
3436             * @param structureId the structure ID
3437             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3438             * @return the first matching journal article
3439             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3440             * @throws SystemException if a system exception occurred
3441             */
3442            public JournalArticle findByStructureId_First(String structureId,
3443                    OrderByComparator orderByComparator)
3444                    throws NoSuchArticleException, SystemException {
3445                    JournalArticle journalArticle = fetchByStructureId_First(structureId,
3446                                    orderByComparator);
3447    
3448                    if (journalArticle != null) {
3449                            return journalArticle;
3450                    }
3451    
3452                    StringBundler msg = new StringBundler(4);
3453    
3454                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3455    
3456                    msg.append("structureId=");
3457                    msg.append(structureId);
3458    
3459                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3460    
3461                    throw new NoSuchArticleException(msg.toString());
3462            }
3463    
3464            /**
3465             * Returns the first journal article in the ordered set where structureId = &#63;.
3466             *
3467             * @param structureId the structure ID
3468             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3469             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3470             * @throws SystemException if a system exception occurred
3471             */
3472            public JournalArticle fetchByStructureId_First(String structureId,
3473                    OrderByComparator orderByComparator) throws SystemException {
3474                    List<JournalArticle> list = findByStructureId(structureId, 0, 1,
3475                                    orderByComparator);
3476    
3477                    if (!list.isEmpty()) {
3478                            return list.get(0);
3479                    }
3480    
3481                    return null;
3482            }
3483    
3484            /**
3485             * Returns the last journal article in the ordered set where structureId = &#63;.
3486             *
3487             * @param structureId the structure ID
3488             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3489             * @return the last matching journal article
3490             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3491             * @throws SystemException if a system exception occurred
3492             */
3493            public JournalArticle findByStructureId_Last(String structureId,
3494                    OrderByComparator orderByComparator)
3495                    throws NoSuchArticleException, SystemException {
3496                    JournalArticle journalArticle = fetchByStructureId_Last(structureId,
3497                                    orderByComparator);
3498    
3499                    if (journalArticle != null) {
3500                            return journalArticle;
3501                    }
3502    
3503                    StringBundler msg = new StringBundler(4);
3504    
3505                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3506    
3507                    msg.append("structureId=");
3508                    msg.append(structureId);
3509    
3510                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3511    
3512                    throw new NoSuchArticleException(msg.toString());
3513            }
3514    
3515            /**
3516             * Returns the last journal article in the ordered set where structureId = &#63;.
3517             *
3518             * @param structureId the structure ID
3519             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3520             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3521             * @throws SystemException if a system exception occurred
3522             */
3523            public JournalArticle fetchByStructureId_Last(String structureId,
3524                    OrderByComparator orderByComparator) throws SystemException {
3525                    int count = countByStructureId(structureId);
3526    
3527                    List<JournalArticle> list = findByStructureId(structureId, count - 1,
3528                                    count, orderByComparator);
3529    
3530                    if (!list.isEmpty()) {
3531                            return list.get(0);
3532                    }
3533    
3534                    return null;
3535            }
3536    
3537            /**
3538             * Returns the journal articles before and after the current journal article in the ordered set where structureId = &#63;.
3539             *
3540             * @param id the primary key of the current journal article
3541             * @param structureId the structure ID
3542             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3543             * @return the previous, current, and next journal article
3544             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3545             * @throws SystemException if a system exception occurred
3546             */
3547            public JournalArticle[] findByStructureId_PrevAndNext(long id,
3548                    String structureId, OrderByComparator orderByComparator)
3549                    throws NoSuchArticleException, SystemException {
3550                    JournalArticle journalArticle = findByPrimaryKey(id);
3551    
3552                    Session session = null;
3553    
3554                    try {
3555                            session = openSession();
3556    
3557                            JournalArticle[] array = new JournalArticleImpl[3];
3558    
3559                            array[0] = getByStructureId_PrevAndNext(session, journalArticle,
3560                                            structureId, orderByComparator, true);
3561    
3562                            array[1] = journalArticle;
3563    
3564                            array[2] = getByStructureId_PrevAndNext(session, journalArticle,
3565                                            structureId, orderByComparator, false);
3566    
3567                            return array;
3568                    }
3569                    catch (Exception e) {
3570                            throw processException(e);
3571                    }
3572                    finally {
3573                            closeSession(session);
3574                    }
3575            }
3576    
3577            protected JournalArticle getByStructureId_PrevAndNext(Session session,
3578                    JournalArticle journalArticle, String structureId,
3579                    OrderByComparator orderByComparator, boolean previous) {
3580                    StringBundler query = null;
3581    
3582                    if (orderByComparator != null) {
3583                            query = new StringBundler(6 +
3584                                            (orderByComparator.getOrderByFields().length * 6));
3585                    }
3586                    else {
3587                            query = new StringBundler(3);
3588                    }
3589    
3590                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3591    
3592                    boolean bindStructureId = false;
3593    
3594                    if (structureId == null) {
3595                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3596                    }
3597                    else if (structureId.equals(StringPool.BLANK)) {
3598                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3599                    }
3600                    else {
3601                            bindStructureId = true;
3602    
3603                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3604                    }
3605    
3606                    if (orderByComparator != null) {
3607                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3608    
3609                            if (orderByConditionFields.length > 0) {
3610                                    query.append(WHERE_AND);
3611                            }
3612    
3613                            for (int i = 0; i < orderByConditionFields.length; i++) {
3614                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3615                                    query.append(orderByConditionFields[i]);
3616    
3617                                    if ((i + 1) < orderByConditionFields.length) {
3618                                            if (orderByComparator.isAscending() ^ previous) {
3619                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3620                                            }
3621                                            else {
3622                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3623                                            }
3624                                    }
3625                                    else {
3626                                            if (orderByComparator.isAscending() ^ previous) {
3627                                                    query.append(WHERE_GREATER_THAN);
3628                                            }
3629                                            else {
3630                                                    query.append(WHERE_LESSER_THAN);
3631                                            }
3632                                    }
3633                            }
3634    
3635                            query.append(ORDER_BY_CLAUSE);
3636    
3637                            String[] orderByFields = orderByComparator.getOrderByFields();
3638    
3639                            for (int i = 0; i < orderByFields.length; i++) {
3640                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3641                                    query.append(orderByFields[i]);
3642    
3643                                    if ((i + 1) < orderByFields.length) {
3644                                            if (orderByComparator.isAscending() ^ previous) {
3645                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3646                                            }
3647                                            else {
3648                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3649                                            }
3650                                    }
3651                                    else {
3652                                            if (orderByComparator.isAscending() ^ previous) {
3653                                                    query.append(ORDER_BY_ASC);
3654                                            }
3655                                            else {
3656                                                    query.append(ORDER_BY_DESC);
3657                                            }
3658                                    }
3659                            }
3660                    }
3661                    else {
3662                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3663                    }
3664    
3665                    String sql = query.toString();
3666    
3667                    Query q = session.createQuery(sql);
3668    
3669                    q.setFirstResult(0);
3670                    q.setMaxResults(2);
3671    
3672                    QueryPos qPos = QueryPos.getInstance(q);
3673    
3674                    if (bindStructureId) {
3675                            qPos.add(structureId);
3676                    }
3677    
3678                    if (orderByComparator != null) {
3679                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3680    
3681                            for (Object value : values) {
3682                                    qPos.add(value);
3683                            }
3684                    }
3685    
3686                    List<JournalArticle> list = q.list();
3687    
3688                    if (list.size() == 2) {
3689                            return list.get(1);
3690                    }
3691                    else {
3692                            return null;
3693                    }
3694            }
3695    
3696            /**
3697             * Returns all the journal articles where structureId = any &#63;.
3698             *
3699             * <p>
3700             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3701             * </p>
3702             *
3703             * @param structureIds the structure IDs
3704             * @return the matching journal articles
3705             * @throws SystemException if a system exception occurred
3706             */
3707            public List<JournalArticle> findByStructureId(String[] structureIds)
3708                    throws SystemException {
3709                    return findByStructureId(structureIds, QueryUtil.ALL_POS,
3710                            QueryUtil.ALL_POS, null);
3711            }
3712    
3713            /**
3714             * Returns a range of all the journal articles where structureId = any &#63;.
3715             *
3716             * <p>
3717             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3718             * </p>
3719             *
3720             * @param structureIds the structure IDs
3721             * @param start the lower bound of the range of journal articles
3722             * @param end the upper bound of the range of journal articles (not inclusive)
3723             * @return the range of matching journal articles
3724             * @throws SystemException if a system exception occurred
3725             */
3726            public List<JournalArticle> findByStructureId(String[] structureIds,
3727                    int start, int end) throws SystemException {
3728                    return findByStructureId(structureIds, start, end, null);
3729            }
3730    
3731            /**
3732             * Returns an ordered range of all the journal articles where structureId = any &#63;.
3733             *
3734             * <p>
3735             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3736             * </p>
3737             *
3738             * @param structureIds the structure IDs
3739             * @param start the lower bound of the range of journal articles
3740             * @param end the upper bound of the range of journal articles (not inclusive)
3741             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3742             * @return the ordered range of matching journal articles
3743             * @throws SystemException if a system exception occurred
3744             */
3745            public List<JournalArticle> findByStructureId(String[] structureIds,
3746                    int start, int end, OrderByComparator orderByComparator)
3747                    throws SystemException {
3748                    if ((structureIds != null) && (structureIds.length == 1)) {
3749                            return findByStructureId(structureIds[0], start, end,
3750                                    orderByComparator);
3751                    }
3752    
3753                    boolean pagination = true;
3754                    Object[] finderArgs = null;
3755    
3756                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3757                                    (orderByComparator == null)) {
3758                            pagination = false;
3759                            finderArgs = new Object[] { StringUtil.merge(structureIds) };
3760                    }
3761                    else {
3762                            finderArgs = new Object[] {
3763                                            StringUtil.merge(structureIds),
3764                                            
3765                                            start, end, orderByComparator
3766                                    };
3767                    }
3768    
3769                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3770                                    finderArgs, this);
3771    
3772                    if ((list != null) && !list.isEmpty()) {
3773                            for (JournalArticle journalArticle : list) {
3774                                    if (!ArrayUtil.contains(structureIds,
3775                                                            journalArticle.getStructureId())) {
3776                                            list = null;
3777    
3778                                            break;
3779                                    }
3780                            }
3781                    }
3782    
3783                    if (list == null) {
3784                            StringBundler query = new StringBundler();
3785    
3786                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3787    
3788                            boolean conjunctionable = false;
3789    
3790                            if ((structureIds == null) || (structureIds.length > 0)) {
3791                                    if (conjunctionable) {
3792                                            query.append(WHERE_AND);
3793                                    }
3794    
3795                                    query.append(StringPool.OPEN_PARENTHESIS);
3796    
3797                                    for (int i = 0; i < structureIds.length; i++) {
3798                                            String structureId = structureIds[i];
3799    
3800                                            if (structureId == null) {
3801                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4);
3802                                            }
3803                                            else if (structureId.equals(StringPool.BLANK)) {
3804                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6);
3805                                            }
3806                                            else {
3807                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5);
3808                                            }
3809    
3810                                            if ((i + 1) < structureIds.length) {
3811                                                    query.append(WHERE_OR);
3812                                            }
3813                                    }
3814    
3815                                    query.append(StringPool.CLOSE_PARENTHESIS);
3816    
3817                                    conjunctionable = true;
3818                            }
3819    
3820                            if (orderByComparator != null) {
3821                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3822                                            orderByComparator);
3823                            }
3824                            else
3825                             if (pagination) {
3826                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3827                            }
3828    
3829                            String sql = query.toString();
3830    
3831                            Session session = null;
3832    
3833                            try {
3834                                    session = openSession();
3835    
3836                                    Query q = session.createQuery(sql);
3837    
3838                                    QueryPos qPos = QueryPos.getInstance(q);
3839    
3840                                    if (structureIds != null) {
3841                                            qPos.add(structureIds);
3842                                    }
3843    
3844                                    if (!pagination) {
3845                                            list = (List<JournalArticle>)QueryUtil.list(q,
3846                                                            getDialect(), start, end, false);
3847    
3848                                            Collections.sort(list);
3849    
3850                                            list = new UnmodifiableList<JournalArticle>(list);
3851                                    }
3852                                    else {
3853                                            list = (List<JournalArticle>)QueryUtil.list(q,
3854                                                            getDialect(), start, end);
3855                                    }
3856    
3857                                    cacheResult(list);
3858    
3859                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3860                                            finderArgs, list);
3861                            }
3862                            catch (Exception e) {
3863                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID,
3864                                            finderArgs);
3865    
3866                                    throw processException(e);
3867                            }
3868                            finally {
3869                                    closeSession(session);
3870                            }
3871                    }
3872    
3873                    return list;
3874            }
3875    
3876            /**
3877             * Removes all the journal articles where structureId = &#63; from the database.
3878             *
3879             * @param structureId the structure ID
3880             * @throws SystemException if a system exception occurred
3881             */
3882            public void removeByStructureId(String structureId)
3883                    throws SystemException {
3884                    for (JournalArticle journalArticle : findByStructureId(structureId,
3885                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3886                            remove(journalArticle);
3887                    }
3888            }
3889    
3890            /**
3891             * Returns the number of journal articles where structureId = &#63;.
3892             *
3893             * @param structureId the structure ID
3894             * @return the number of matching journal articles
3895             * @throws SystemException if a system exception occurred
3896             */
3897            public int countByStructureId(String structureId) throws SystemException {
3898                    FinderPath finderPath = FINDER_PATH_COUNT_BY_STRUCTUREID;
3899    
3900                    Object[] finderArgs = new Object[] { structureId };
3901    
3902                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3903                                    this);
3904    
3905                    if (count == null) {
3906                            StringBundler query = new StringBundler(2);
3907    
3908                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3909    
3910                            boolean bindStructureId = false;
3911    
3912                            if (structureId == null) {
3913                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3914                            }
3915                            else if (structureId.equals(StringPool.BLANK)) {
3916                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3917                            }
3918                            else {
3919                                    bindStructureId = true;
3920    
3921                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3922                            }
3923    
3924                            String sql = query.toString();
3925    
3926                            Session session = null;
3927    
3928                            try {
3929                                    session = openSession();
3930    
3931                                    Query q = session.createQuery(sql);
3932    
3933                                    QueryPos qPos = QueryPos.getInstance(q);
3934    
3935                                    if (bindStructureId) {
3936                                            qPos.add(structureId);
3937                                    }
3938    
3939                                    count = (Long)q.uniqueResult();
3940    
3941                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3942                            }
3943                            catch (Exception e) {
3944                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3945    
3946                                    throw processException(e);
3947                            }
3948                            finally {
3949                                    closeSession(session);
3950                            }
3951                    }
3952    
3953                    return count.intValue();
3954            }
3955    
3956            /**
3957             * Returns the number of journal articles where structureId = any &#63;.
3958             *
3959             * @param structureIds the structure IDs
3960             * @return the number of matching journal articles
3961             * @throws SystemException if a system exception occurred
3962             */
3963            public int countByStructureId(String[] structureIds)
3964                    throws SystemException {
3965                    Object[] finderArgs = new Object[] { StringUtil.merge(structureIds) };
3966    
3967                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
3968                                    finderArgs, this);
3969    
3970                    if (count == null) {
3971                            StringBundler query = new StringBundler();
3972    
3973                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3974    
3975                            boolean conjunctionable = false;
3976    
3977                            if ((structureIds == null) || (structureIds.length > 0)) {
3978                                    if (conjunctionable) {
3979                                            query.append(WHERE_AND);
3980                                    }
3981    
3982                                    query.append(StringPool.OPEN_PARENTHESIS);
3983    
3984                                    for (int i = 0; i < structureIds.length; i++) {
3985                                            String structureId = structureIds[i];
3986    
3987                                            if (structureId == null) {
3988                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4);
3989                                            }
3990                                            else if (structureId.equals(StringPool.BLANK)) {
3991                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6);
3992                                            }
3993                                            else {
3994                                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5);
3995                                            }
3996    
3997                                            if ((i + 1) < structureIds.length) {
3998                                                    query.append(WHERE_OR);
3999                                            }
4000                                    }
4001    
4002                                    query.append(StringPool.CLOSE_PARENTHESIS);
4003    
4004                                    conjunctionable = true;
4005                            }
4006    
4007                            String sql = query.toString();
4008    
4009                            Session session = null;
4010    
4011                            try {
4012                                    session = openSession();
4013    
4014                                    Query q = session.createQuery(sql);
4015    
4016                                    QueryPos qPos = QueryPos.getInstance(q);
4017    
4018                                    if (structureIds != null) {
4019                                            qPos.add(structureIds);
4020                                    }
4021    
4022                                    count = (Long)q.uniqueResult();
4023    
4024                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4025                                            finderArgs, count);
4026                            }
4027                            catch (Exception e) {
4028                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_STRUCTUREID,
4029                                            finderArgs);
4030    
4031                                    throw processException(e);
4032                            }
4033                            finally {
4034                                    closeSession(session);
4035                            }
4036                    }
4037    
4038                    return count.intValue();
4039            }
4040    
4041            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
4042            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalArticle.structureId = ?";
4043            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
4044            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_4 = "(" +
4045                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1) + ")";
4046            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_5 = "(" +
4047                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2) + ")";
4048            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_6 = "(" +
4049                    removeConjunction(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3) + ")";
4050            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID =
4051                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4052                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4053                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4054                            "findByTemplateId",
4055                            new String[] {
4056                                    String.class.getName(),
4057                                    
4058                            Integer.class.getName(), Integer.class.getName(),
4059                                    OrderByComparator.class.getName()
4060                            });
4061            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID =
4062                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4063                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4064                            JournalArticleImpl.class,
4065                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTemplateId",
4066                            new String[] { String.class.getName() },
4067                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
4068                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4069                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4070            public static final FinderPath FINDER_PATH_COUNT_BY_TEMPLATEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4071                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4072                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTemplateId",
4073                            new String[] { String.class.getName() });
4074    
4075            /**
4076             * Returns all the journal articles where templateId = &#63;.
4077             *
4078             * @param templateId the template ID
4079             * @return the matching journal articles
4080             * @throws SystemException if a system exception occurred
4081             */
4082            public List<JournalArticle> findByTemplateId(String templateId)
4083                    throws SystemException {
4084                    return findByTemplateId(templateId, QueryUtil.ALL_POS,
4085                            QueryUtil.ALL_POS, null);
4086            }
4087    
4088            /**
4089             * Returns a range of all the journal articles where templateId = &#63;.
4090             *
4091             * <p>
4092             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4093             * </p>
4094             *
4095             * @param templateId the template ID
4096             * @param start the lower bound of the range of journal articles
4097             * @param end the upper bound of the range of journal articles (not inclusive)
4098             * @return the range of matching journal articles
4099             * @throws SystemException if a system exception occurred
4100             */
4101            public List<JournalArticle> findByTemplateId(String templateId, int start,
4102                    int end) throws SystemException {
4103                    return findByTemplateId(templateId, start, end, null);
4104            }
4105    
4106            /**
4107             * Returns an ordered range of all the journal articles where templateId = &#63;.
4108             *
4109             * <p>
4110             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4111             * </p>
4112             *
4113             * @param templateId the template ID
4114             * @param start the lower bound of the range of journal articles
4115             * @param end the upper bound of the range of journal articles (not inclusive)
4116             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4117             * @return the ordered range of matching journal articles
4118             * @throws SystemException if a system exception occurred
4119             */
4120            public List<JournalArticle> findByTemplateId(String templateId, int start,
4121                    int end, OrderByComparator orderByComparator) throws SystemException {
4122                    boolean pagination = true;
4123                    FinderPath finderPath = null;
4124                    Object[] finderArgs = null;
4125    
4126                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4127                                    (orderByComparator == null)) {
4128                            pagination = false;
4129                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID;
4130                            finderArgs = new Object[] { templateId };
4131                    }
4132                    else {
4133                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID;
4134                            finderArgs = new Object[] { templateId, start, end, orderByComparator };
4135                    }
4136    
4137                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4138                                    finderArgs, this);
4139    
4140                    if ((list != null) && !list.isEmpty()) {
4141                            for (JournalArticle journalArticle : list) {
4142                                    if (!Validator.equals(templateId, journalArticle.getTemplateId())) {
4143                                            list = null;
4144    
4145                                            break;
4146                                    }
4147                            }
4148                    }
4149    
4150                    if (list == null) {
4151                            StringBundler query = null;
4152    
4153                            if (orderByComparator != null) {
4154                                    query = new StringBundler(3 +
4155                                                    (orderByComparator.getOrderByFields().length * 3));
4156                            }
4157                            else {
4158                                    query = new StringBundler(3);
4159                            }
4160    
4161                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4162    
4163                            boolean bindTemplateId = false;
4164    
4165                            if (templateId == null) {
4166                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4167                            }
4168                            else if (templateId.equals(StringPool.BLANK)) {
4169                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4170                            }
4171                            else {
4172                                    bindTemplateId = true;
4173    
4174                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4175                            }
4176    
4177                            if (orderByComparator != null) {
4178                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4179                                            orderByComparator);
4180                            }
4181                            else
4182                             if (pagination) {
4183                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4184                            }
4185    
4186                            String sql = query.toString();
4187    
4188                            Session session = null;
4189    
4190                            try {
4191                                    session = openSession();
4192    
4193                                    Query q = session.createQuery(sql);
4194    
4195                                    QueryPos qPos = QueryPos.getInstance(q);
4196    
4197                                    if (bindTemplateId) {
4198                                            qPos.add(templateId);
4199                                    }
4200    
4201                                    if (!pagination) {
4202                                            list = (List<JournalArticle>)QueryUtil.list(q,
4203                                                            getDialect(), start, end, false);
4204    
4205                                            Collections.sort(list);
4206    
4207                                            list = new UnmodifiableList<JournalArticle>(list);
4208                                    }
4209                                    else {
4210                                            list = (List<JournalArticle>)QueryUtil.list(q,
4211                                                            getDialect(), start, end);
4212                                    }
4213    
4214                                    cacheResult(list);
4215    
4216                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4217                            }
4218                            catch (Exception e) {
4219                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4220    
4221                                    throw processException(e);
4222                            }
4223                            finally {
4224                                    closeSession(session);
4225                            }
4226                    }
4227    
4228                    return list;
4229            }
4230    
4231            /**
4232             * Returns the first journal article in the ordered set where templateId = &#63;.
4233             *
4234             * @param templateId the template ID
4235             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4236             * @return the first matching journal article
4237             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4238             * @throws SystemException if a system exception occurred
4239             */
4240            public JournalArticle findByTemplateId_First(String templateId,
4241                    OrderByComparator orderByComparator)
4242                    throws NoSuchArticleException, SystemException {
4243                    JournalArticle journalArticle = fetchByTemplateId_First(templateId,
4244                                    orderByComparator);
4245    
4246                    if (journalArticle != null) {
4247                            return journalArticle;
4248                    }
4249    
4250                    StringBundler msg = new StringBundler(4);
4251    
4252                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4253    
4254                    msg.append("templateId=");
4255                    msg.append(templateId);
4256    
4257                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4258    
4259                    throw new NoSuchArticleException(msg.toString());
4260            }
4261    
4262            /**
4263             * Returns the first journal article in the ordered set where templateId = &#63;.
4264             *
4265             * @param templateId the template ID
4266             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4267             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4268             * @throws SystemException if a system exception occurred
4269             */
4270            public JournalArticle fetchByTemplateId_First(String templateId,
4271                    OrderByComparator orderByComparator) throws SystemException {
4272                    List<JournalArticle> list = findByTemplateId(templateId, 0, 1,
4273                                    orderByComparator);
4274    
4275                    if (!list.isEmpty()) {
4276                            return list.get(0);
4277                    }
4278    
4279                    return null;
4280            }
4281    
4282            /**
4283             * Returns the last journal article in the ordered set where templateId = &#63;.
4284             *
4285             * @param templateId the template ID
4286             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4287             * @return the last matching journal article
4288             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4289             * @throws SystemException if a system exception occurred
4290             */
4291            public JournalArticle findByTemplateId_Last(String templateId,
4292                    OrderByComparator orderByComparator)
4293                    throws NoSuchArticleException, SystemException {
4294                    JournalArticle journalArticle = fetchByTemplateId_Last(templateId,
4295                                    orderByComparator);
4296    
4297                    if (journalArticle != null) {
4298                            return journalArticle;
4299                    }
4300    
4301                    StringBundler msg = new StringBundler(4);
4302    
4303                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4304    
4305                    msg.append("templateId=");
4306                    msg.append(templateId);
4307    
4308                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4309    
4310                    throw new NoSuchArticleException(msg.toString());
4311            }
4312    
4313            /**
4314             * Returns the last journal article in the ordered set where templateId = &#63;.
4315             *
4316             * @param templateId the template ID
4317             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4318             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4319             * @throws SystemException if a system exception occurred
4320             */
4321            public JournalArticle fetchByTemplateId_Last(String templateId,
4322                    OrderByComparator orderByComparator) throws SystemException {
4323                    int count = countByTemplateId(templateId);
4324    
4325                    List<JournalArticle> list = findByTemplateId(templateId, count - 1,
4326                                    count, orderByComparator);
4327    
4328                    if (!list.isEmpty()) {
4329                            return list.get(0);
4330                    }
4331    
4332                    return null;
4333            }
4334    
4335            /**
4336             * Returns the journal articles before and after the current journal article in the ordered set where templateId = &#63;.
4337             *
4338             * @param id the primary key of the current journal article
4339             * @param templateId the template ID
4340             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4341             * @return the previous, current, and next journal article
4342             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4343             * @throws SystemException if a system exception occurred
4344             */
4345            public JournalArticle[] findByTemplateId_PrevAndNext(long id,
4346                    String templateId, OrderByComparator orderByComparator)
4347                    throws NoSuchArticleException, SystemException {
4348                    JournalArticle journalArticle = findByPrimaryKey(id);
4349    
4350                    Session session = null;
4351    
4352                    try {
4353                            session = openSession();
4354    
4355                            JournalArticle[] array = new JournalArticleImpl[3];
4356    
4357                            array[0] = getByTemplateId_PrevAndNext(session, journalArticle,
4358                                            templateId, orderByComparator, true);
4359    
4360                            array[1] = journalArticle;
4361    
4362                            array[2] = getByTemplateId_PrevAndNext(session, journalArticle,
4363                                            templateId, orderByComparator, false);
4364    
4365                            return array;
4366                    }
4367                    catch (Exception e) {
4368                            throw processException(e);
4369                    }
4370                    finally {
4371                            closeSession(session);
4372                    }
4373            }
4374    
4375            protected JournalArticle getByTemplateId_PrevAndNext(Session session,
4376                    JournalArticle journalArticle, String templateId,
4377                    OrderByComparator orderByComparator, boolean previous) {
4378                    StringBundler query = null;
4379    
4380                    if (orderByComparator != null) {
4381                            query = new StringBundler(6 +
4382                                            (orderByComparator.getOrderByFields().length * 6));
4383                    }
4384                    else {
4385                            query = new StringBundler(3);
4386                    }
4387    
4388                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4389    
4390                    boolean bindTemplateId = false;
4391    
4392                    if (templateId == null) {
4393                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4394                    }
4395                    else if (templateId.equals(StringPool.BLANK)) {
4396                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4397                    }
4398                    else {
4399                            bindTemplateId = true;
4400    
4401                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4402                    }
4403    
4404                    if (orderByComparator != null) {
4405                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4406    
4407                            if (orderByConditionFields.length > 0) {
4408                                    query.append(WHERE_AND);
4409                            }
4410    
4411                            for (int i = 0; i < orderByConditionFields.length; i++) {
4412                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4413                                    query.append(orderByConditionFields[i]);
4414    
4415                                    if ((i + 1) < orderByConditionFields.length) {
4416                                            if (orderByComparator.isAscending() ^ previous) {
4417                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4418                                            }
4419                                            else {
4420                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4421                                            }
4422                                    }
4423                                    else {
4424                                            if (orderByComparator.isAscending() ^ previous) {
4425                                                    query.append(WHERE_GREATER_THAN);
4426                                            }
4427                                            else {
4428                                                    query.append(WHERE_LESSER_THAN);
4429                                            }
4430                                    }
4431                            }
4432    
4433                            query.append(ORDER_BY_CLAUSE);
4434    
4435                            String[] orderByFields = orderByComparator.getOrderByFields();
4436    
4437                            for (int i = 0; i < orderByFields.length; i++) {
4438                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4439                                    query.append(orderByFields[i]);
4440    
4441                                    if ((i + 1) < orderByFields.length) {
4442                                            if (orderByComparator.isAscending() ^ previous) {
4443                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4444                                            }
4445                                            else {
4446                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4447                                            }
4448                                    }
4449                                    else {
4450                                            if (orderByComparator.isAscending() ^ previous) {
4451                                                    query.append(ORDER_BY_ASC);
4452                                            }
4453                                            else {
4454                                                    query.append(ORDER_BY_DESC);
4455                                            }
4456                                    }
4457                            }
4458                    }
4459                    else {
4460                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4461                    }
4462    
4463                    String sql = query.toString();
4464    
4465                    Query q = session.createQuery(sql);
4466    
4467                    q.setFirstResult(0);
4468                    q.setMaxResults(2);
4469    
4470                    QueryPos qPos = QueryPos.getInstance(q);
4471    
4472                    if (bindTemplateId) {
4473                            qPos.add(templateId);
4474                    }
4475    
4476                    if (orderByComparator != null) {
4477                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4478    
4479                            for (Object value : values) {
4480                                    qPos.add(value);
4481                            }
4482                    }
4483    
4484                    List<JournalArticle> list = q.list();
4485    
4486                    if (list.size() == 2) {
4487                            return list.get(1);
4488                    }
4489                    else {
4490                            return null;
4491                    }
4492            }
4493    
4494            /**
4495             * Removes all the journal articles where templateId = &#63; from the database.
4496             *
4497             * @param templateId the template ID
4498             * @throws SystemException if a system exception occurred
4499             */
4500            public void removeByTemplateId(String templateId) throws SystemException {
4501                    for (JournalArticle journalArticle : findByTemplateId(templateId,
4502                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4503                            remove(journalArticle);
4504                    }
4505            }
4506    
4507            /**
4508             * Returns the number of journal articles where templateId = &#63;.
4509             *
4510             * @param templateId the template ID
4511             * @return the number of matching journal articles
4512             * @throws SystemException if a system exception occurred
4513             */
4514            public int countByTemplateId(String templateId) throws SystemException {
4515                    FinderPath finderPath = FINDER_PATH_COUNT_BY_TEMPLATEID;
4516    
4517                    Object[] finderArgs = new Object[] { templateId };
4518    
4519                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4520                                    this);
4521    
4522                    if (count == null) {
4523                            StringBundler query = new StringBundler(2);
4524    
4525                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4526    
4527                            boolean bindTemplateId = false;
4528    
4529                            if (templateId == null) {
4530                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4531                            }
4532                            else if (templateId.equals(StringPool.BLANK)) {
4533                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4534                            }
4535                            else {
4536                                    bindTemplateId = true;
4537    
4538                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4539                            }
4540    
4541                            String sql = query.toString();
4542    
4543                            Session session = null;
4544    
4545                            try {
4546                                    session = openSession();
4547    
4548                                    Query q = session.createQuery(sql);
4549    
4550                                    QueryPos qPos = QueryPos.getInstance(q);
4551    
4552                                    if (bindTemplateId) {
4553                                            qPos.add(templateId);
4554                                    }
4555    
4556                                    count = (Long)q.uniqueResult();
4557    
4558                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4559                            }
4560                            catch (Exception e) {
4561                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4562    
4563                                    throw processException(e);
4564                            }
4565                            finally {
4566                                    closeSession(session);
4567                            }
4568                    }
4569    
4570                    return count.intValue();
4571            }
4572    
4573            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
4574            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2 = "journalArticle.templateId = ?";
4575            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
4576            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
4577                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4578                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4579                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4580                            "findByLayoutUuid",
4581                            new String[] {
4582                                    String.class.getName(),
4583                                    
4584                            Integer.class.getName(), Integer.class.getName(),
4585                                    OrderByComparator.class.getName()
4586                            });
4587            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
4588                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4589                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4590                            JournalArticleImpl.class,
4591                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
4592                            new String[] { String.class.getName() },
4593                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
4594                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4595                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4596            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4597                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4598                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
4599                            new String[] { String.class.getName() });
4600    
4601            /**
4602             * Returns all the journal articles where layoutUuid = &#63;.
4603             *
4604             * @param layoutUuid the layout uuid
4605             * @return the matching journal articles
4606             * @throws SystemException if a system exception occurred
4607             */
4608            public List<JournalArticle> findByLayoutUuid(String layoutUuid)
4609                    throws SystemException {
4610                    return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
4611                            QueryUtil.ALL_POS, null);
4612            }
4613    
4614            /**
4615             * Returns a range of all the journal articles where layoutUuid = &#63;.
4616             *
4617             * <p>
4618             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4619             * </p>
4620             *
4621             * @param layoutUuid the layout uuid
4622             * @param start the lower bound of the range of journal articles
4623             * @param end the upper bound of the range of journal articles (not inclusive)
4624             * @return the range of matching journal articles
4625             * @throws SystemException if a system exception occurred
4626             */
4627            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4628                    int end) throws SystemException {
4629                    return findByLayoutUuid(layoutUuid, start, end, null);
4630            }
4631    
4632            /**
4633             * Returns an ordered range of all the journal articles where layoutUuid = &#63;.
4634             *
4635             * <p>
4636             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4637             * </p>
4638             *
4639             * @param layoutUuid the layout uuid
4640             * @param start the lower bound of the range of journal articles
4641             * @param end the upper bound of the range of journal articles (not inclusive)
4642             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4643             * @return the ordered range of matching journal articles
4644             * @throws SystemException if a system exception occurred
4645             */
4646            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4647                    int end, OrderByComparator orderByComparator) throws SystemException {
4648                    boolean pagination = true;
4649                    FinderPath finderPath = null;
4650                    Object[] finderArgs = null;
4651    
4652                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4653                                    (orderByComparator == null)) {
4654                            pagination = false;
4655                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
4656                            finderArgs = new Object[] { layoutUuid };
4657                    }
4658                    else {
4659                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
4660                            finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
4661                    }
4662    
4663                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4664                                    finderArgs, this);
4665    
4666                    if ((list != null) && !list.isEmpty()) {
4667                            for (JournalArticle journalArticle : list) {
4668                                    if (!Validator.equals(layoutUuid, journalArticle.getLayoutUuid())) {
4669                                            list = null;
4670    
4671                                            break;
4672                                    }
4673                            }
4674                    }
4675    
4676                    if (list == null) {
4677                            StringBundler query = null;
4678    
4679                            if (orderByComparator != null) {
4680                                    query = new StringBundler(3 +
4681                                                    (orderByComparator.getOrderByFields().length * 3));
4682                            }
4683                            else {
4684                                    query = new StringBundler(3);
4685                            }
4686    
4687                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4688    
4689                            boolean bindLayoutUuid = false;
4690    
4691                            if (layoutUuid == null) {
4692                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4693                            }
4694                            else if (layoutUuid.equals(StringPool.BLANK)) {
4695                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4696                            }
4697                            else {
4698                                    bindLayoutUuid = true;
4699    
4700                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4701                            }
4702    
4703                            if (orderByComparator != null) {
4704                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4705                                            orderByComparator);
4706                            }
4707                            else
4708                             if (pagination) {
4709                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4710                            }
4711    
4712                            String sql = query.toString();
4713    
4714                            Session session = null;
4715    
4716                            try {
4717                                    session = openSession();
4718    
4719                                    Query q = session.createQuery(sql);
4720    
4721                                    QueryPos qPos = QueryPos.getInstance(q);
4722    
4723                                    if (bindLayoutUuid) {
4724                                            qPos.add(layoutUuid);
4725                                    }
4726    
4727                                    if (!pagination) {
4728                                            list = (List<JournalArticle>)QueryUtil.list(q,
4729                                                            getDialect(), start, end, false);
4730    
4731                                            Collections.sort(list);
4732    
4733                                            list = new UnmodifiableList<JournalArticle>(list);
4734                                    }
4735                                    else {
4736                                            list = (List<JournalArticle>)QueryUtil.list(q,
4737                                                            getDialect(), start, end);
4738                                    }
4739    
4740                                    cacheResult(list);
4741    
4742                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4743                            }
4744                            catch (Exception e) {
4745                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4746    
4747                                    throw processException(e);
4748                            }
4749                            finally {
4750                                    closeSession(session);
4751                            }
4752                    }
4753    
4754                    return list;
4755            }
4756    
4757            /**
4758             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4759             *
4760             * @param layoutUuid the layout uuid
4761             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4762             * @return the first matching journal article
4763             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4764             * @throws SystemException if a system exception occurred
4765             */
4766            public JournalArticle findByLayoutUuid_First(String layoutUuid,
4767                    OrderByComparator orderByComparator)
4768                    throws NoSuchArticleException, SystemException {
4769                    JournalArticle journalArticle = fetchByLayoutUuid_First(layoutUuid,
4770                                    orderByComparator);
4771    
4772                    if (journalArticle != null) {
4773                            return journalArticle;
4774                    }
4775    
4776                    StringBundler msg = new StringBundler(4);
4777    
4778                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4779    
4780                    msg.append("layoutUuid=");
4781                    msg.append(layoutUuid);
4782    
4783                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4784    
4785                    throw new NoSuchArticleException(msg.toString());
4786            }
4787    
4788            /**
4789             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4790             *
4791             * @param layoutUuid the layout uuid
4792             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4793             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4794             * @throws SystemException if a system exception occurred
4795             */
4796            public JournalArticle fetchByLayoutUuid_First(String layoutUuid,
4797                    OrderByComparator orderByComparator) throws SystemException {
4798                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, 0, 1,
4799                                    orderByComparator);
4800    
4801                    if (!list.isEmpty()) {
4802                            return list.get(0);
4803                    }
4804    
4805                    return null;
4806            }
4807    
4808            /**
4809             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4810             *
4811             * @param layoutUuid the layout uuid
4812             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4813             * @return the last matching journal article
4814             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4815             * @throws SystemException if a system exception occurred
4816             */
4817            public JournalArticle findByLayoutUuid_Last(String layoutUuid,
4818                    OrderByComparator orderByComparator)
4819                    throws NoSuchArticleException, SystemException {
4820                    JournalArticle journalArticle = fetchByLayoutUuid_Last(layoutUuid,
4821                                    orderByComparator);
4822    
4823                    if (journalArticle != null) {
4824                            return journalArticle;
4825                    }
4826    
4827                    StringBundler msg = new StringBundler(4);
4828    
4829                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4830    
4831                    msg.append("layoutUuid=");
4832                    msg.append(layoutUuid);
4833    
4834                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4835    
4836                    throw new NoSuchArticleException(msg.toString());
4837            }
4838    
4839            /**
4840             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4841             *
4842             * @param layoutUuid the layout uuid
4843             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4844             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4845             * @throws SystemException if a system exception occurred
4846             */
4847            public JournalArticle fetchByLayoutUuid_Last(String layoutUuid,
4848                    OrderByComparator orderByComparator) throws SystemException {
4849                    int count = countByLayoutUuid(layoutUuid);
4850    
4851                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, count - 1,
4852                                    count, orderByComparator);
4853    
4854                    if (!list.isEmpty()) {
4855                            return list.get(0);
4856                    }
4857    
4858                    return null;
4859            }
4860    
4861            /**
4862             * Returns the journal articles before and after the current journal article in the ordered set where layoutUuid = &#63;.
4863             *
4864             * @param id the primary key of the current journal article
4865             * @param layoutUuid the layout uuid
4866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4867             * @return the previous, current, and next journal article
4868             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4869             * @throws SystemException if a system exception occurred
4870             */
4871            public JournalArticle[] findByLayoutUuid_PrevAndNext(long id,
4872                    String layoutUuid, OrderByComparator orderByComparator)
4873                    throws NoSuchArticleException, SystemException {
4874                    JournalArticle journalArticle = findByPrimaryKey(id);
4875    
4876                    Session session = null;
4877    
4878                    try {
4879                            session = openSession();
4880    
4881                            JournalArticle[] array = new JournalArticleImpl[3];
4882    
4883                            array[0] = getByLayoutUuid_PrevAndNext(session, journalArticle,
4884                                            layoutUuid, orderByComparator, true);
4885    
4886                            array[1] = journalArticle;
4887    
4888                            array[2] = getByLayoutUuid_PrevAndNext(session, journalArticle,
4889                                            layoutUuid, orderByComparator, false);
4890    
4891                            return array;
4892                    }
4893                    catch (Exception e) {
4894                            throw processException(e);
4895                    }
4896                    finally {
4897                            closeSession(session);
4898                    }
4899            }
4900    
4901            protected JournalArticle getByLayoutUuid_PrevAndNext(Session session,
4902                    JournalArticle journalArticle, String layoutUuid,
4903                    OrderByComparator orderByComparator, boolean previous) {
4904                    StringBundler query = null;
4905    
4906                    if (orderByComparator != null) {
4907                            query = new StringBundler(6 +
4908                                            (orderByComparator.getOrderByFields().length * 6));
4909                    }
4910                    else {
4911                            query = new StringBundler(3);
4912                    }
4913    
4914                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4915    
4916                    boolean bindLayoutUuid = false;
4917    
4918                    if (layoutUuid == null) {
4919                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4920                    }
4921                    else if (layoutUuid.equals(StringPool.BLANK)) {
4922                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4923                    }
4924                    else {
4925                            bindLayoutUuid = true;
4926    
4927                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4928                    }
4929    
4930                    if (orderByComparator != null) {
4931                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4932    
4933                            if (orderByConditionFields.length > 0) {
4934                                    query.append(WHERE_AND);
4935                            }
4936    
4937                            for (int i = 0; i < orderByConditionFields.length; i++) {
4938                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4939                                    query.append(orderByConditionFields[i]);
4940    
4941                                    if ((i + 1) < orderByConditionFields.length) {
4942                                            if (orderByComparator.isAscending() ^ previous) {
4943                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4944                                            }
4945                                            else {
4946                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4947                                            }
4948                                    }
4949                                    else {
4950                                            if (orderByComparator.isAscending() ^ previous) {
4951                                                    query.append(WHERE_GREATER_THAN);
4952                                            }
4953                                            else {
4954                                                    query.append(WHERE_LESSER_THAN);
4955                                            }
4956                                    }
4957                            }
4958    
4959                            query.append(ORDER_BY_CLAUSE);
4960    
4961                            String[] orderByFields = orderByComparator.getOrderByFields();
4962    
4963                            for (int i = 0; i < orderByFields.length; i++) {
4964                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4965                                    query.append(orderByFields[i]);
4966    
4967                                    if ((i + 1) < orderByFields.length) {
4968                                            if (orderByComparator.isAscending() ^ previous) {
4969                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4970                                            }
4971                                            else {
4972                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4973                                            }
4974                                    }
4975                                    else {
4976                                            if (orderByComparator.isAscending() ^ previous) {
4977                                                    query.append(ORDER_BY_ASC);
4978                                            }
4979                                            else {
4980                                                    query.append(ORDER_BY_DESC);
4981                                            }
4982                                    }
4983                            }
4984                    }
4985                    else {
4986                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4987                    }
4988    
4989                    String sql = query.toString();
4990    
4991                    Query q = session.createQuery(sql);
4992    
4993                    q.setFirstResult(0);
4994                    q.setMaxResults(2);
4995    
4996                    QueryPos qPos = QueryPos.getInstance(q);
4997    
4998                    if (bindLayoutUuid) {
4999                            qPos.add(layoutUuid);
5000                    }
5001    
5002                    if (orderByComparator != null) {
5003                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5004    
5005                            for (Object value : values) {
5006                                    qPos.add(value);
5007                            }
5008                    }
5009    
5010                    List<JournalArticle> list = q.list();
5011    
5012                    if (list.size() == 2) {
5013                            return list.get(1);
5014                    }
5015                    else {
5016                            return null;
5017                    }
5018            }
5019    
5020            /**
5021             * Removes all the journal articles where layoutUuid = &#63; from the database.
5022             *
5023             * @param layoutUuid the layout uuid
5024             * @throws SystemException if a system exception occurred
5025             */
5026            public void removeByLayoutUuid(String layoutUuid) throws SystemException {
5027                    for (JournalArticle journalArticle : findByLayoutUuid(layoutUuid,
5028                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5029                            remove(journalArticle);
5030                    }
5031            }
5032    
5033            /**
5034             * Returns the number of journal articles where layoutUuid = &#63;.
5035             *
5036             * @param layoutUuid the layout uuid
5037             * @return the number of matching journal articles
5038             * @throws SystemException if a system exception occurred
5039             */
5040            public int countByLayoutUuid(String layoutUuid) throws SystemException {
5041                    FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
5042    
5043                    Object[] finderArgs = new Object[] { layoutUuid };
5044    
5045                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5046                                    this);
5047    
5048                    if (count == null) {
5049                            StringBundler query = new StringBundler(2);
5050    
5051                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5052    
5053                            boolean bindLayoutUuid = false;
5054    
5055                            if (layoutUuid == null) {
5056                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5057                            }
5058                            else if (layoutUuid.equals(StringPool.BLANK)) {
5059                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5060                            }
5061                            else {
5062                                    bindLayoutUuid = true;
5063    
5064                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5065                            }
5066    
5067                            String sql = query.toString();
5068    
5069                            Session session = null;
5070    
5071                            try {
5072                                    session = openSession();
5073    
5074                                    Query q = session.createQuery(sql);
5075    
5076                                    QueryPos qPos = QueryPos.getInstance(q);
5077    
5078                                    if (bindLayoutUuid) {
5079                                            qPos.add(layoutUuid);
5080                                    }
5081    
5082                                    count = (Long)q.uniqueResult();
5083    
5084                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5085                            }
5086                            catch (Exception e) {
5087                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5088    
5089                                    throw processException(e);
5090                            }
5091                            finally {
5092                                    closeSession(session);
5093                            }
5094                    }
5095    
5096                    return count.intValue();
5097            }
5098    
5099            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
5100            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
5101            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
5102            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
5103                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5104                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5105                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5106                            "findBySmallImageId",
5107                            new String[] {
5108                                    Long.class.getName(),
5109                                    
5110                            Integer.class.getName(), Integer.class.getName(),
5111                                    OrderByComparator.class.getName()
5112                            });
5113            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
5114                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5115                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5116                            JournalArticleImpl.class,
5117                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
5118                            new String[] { Long.class.getName() },
5119                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK |
5120                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5121                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5122            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5123                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5124                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
5125                            new String[] { Long.class.getName() });
5126    
5127            /**
5128             * Returns all the journal articles where smallImageId = &#63;.
5129             *
5130             * @param smallImageId the small image ID
5131             * @return the matching journal articles
5132             * @throws SystemException if a system exception occurred
5133             */
5134            public List<JournalArticle> findBySmallImageId(long smallImageId)
5135                    throws SystemException {
5136                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
5137                            QueryUtil.ALL_POS, null);
5138            }
5139    
5140            /**
5141             * Returns a range of all the journal articles where smallImageId = &#63;.
5142             *
5143             * <p>
5144             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5145             * </p>
5146             *
5147             * @param smallImageId the small image ID
5148             * @param start the lower bound of the range of journal articles
5149             * @param end the upper bound of the range of journal articles (not inclusive)
5150             * @return the range of matching journal articles
5151             * @throws SystemException if a system exception occurred
5152             */
5153            public List<JournalArticle> findBySmallImageId(long smallImageId,
5154                    int start, int end) throws SystemException {
5155                    return findBySmallImageId(smallImageId, start, end, null);
5156            }
5157    
5158            /**
5159             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
5160             *
5161             * <p>
5162             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5163             * </p>
5164             *
5165             * @param smallImageId the small image ID
5166             * @param start the lower bound of the range of journal articles
5167             * @param end the upper bound of the range of journal articles (not inclusive)
5168             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5169             * @return the ordered range of matching journal articles
5170             * @throws SystemException if a system exception occurred
5171             */
5172            public List<JournalArticle> findBySmallImageId(long smallImageId,
5173                    int start, int end, OrderByComparator orderByComparator)
5174                    throws SystemException {
5175                    boolean pagination = true;
5176                    FinderPath finderPath = null;
5177                    Object[] finderArgs = null;
5178    
5179                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5180                                    (orderByComparator == null)) {
5181                            pagination = false;
5182                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
5183                            finderArgs = new Object[] { smallImageId };
5184                    }
5185                    else {
5186                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
5187                            finderArgs = new Object[] {
5188                                            smallImageId,
5189                                            
5190                                            start, end, orderByComparator
5191                                    };
5192                    }
5193    
5194                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5195                                    finderArgs, this);
5196    
5197                    if ((list != null) && !list.isEmpty()) {
5198                            for (JournalArticle journalArticle : list) {
5199                                    if ((smallImageId != journalArticle.getSmallImageId())) {
5200                                            list = null;
5201    
5202                                            break;
5203                                    }
5204                            }
5205                    }
5206    
5207                    if (list == null) {
5208                            StringBundler query = null;
5209    
5210                            if (orderByComparator != null) {
5211                                    query = new StringBundler(3 +
5212                                                    (orderByComparator.getOrderByFields().length * 3));
5213                            }
5214                            else {
5215                                    query = new StringBundler(3);
5216                            }
5217    
5218                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5219    
5220                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5221    
5222                            if (orderByComparator != null) {
5223                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5224                                            orderByComparator);
5225                            }
5226                            else
5227                             if (pagination) {
5228                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5229                            }
5230    
5231                            String sql = query.toString();
5232    
5233                            Session session = null;
5234    
5235                            try {
5236                                    session = openSession();
5237    
5238                                    Query q = session.createQuery(sql);
5239    
5240                                    QueryPos qPos = QueryPos.getInstance(q);
5241    
5242                                    qPos.add(smallImageId);
5243    
5244                                    if (!pagination) {
5245                                            list = (List<JournalArticle>)QueryUtil.list(q,
5246                                                            getDialect(), start, end, false);
5247    
5248                                            Collections.sort(list);
5249    
5250                                            list = new UnmodifiableList<JournalArticle>(list);
5251                                    }
5252                                    else {
5253                                            list = (List<JournalArticle>)QueryUtil.list(q,
5254                                                            getDialect(), start, end);
5255                                    }
5256    
5257                                    cacheResult(list);
5258    
5259                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5260                            }
5261                            catch (Exception e) {
5262                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5263    
5264                                    throw processException(e);
5265                            }
5266                            finally {
5267                                    closeSession(session);
5268                            }
5269                    }
5270    
5271                    return list;
5272            }
5273    
5274            /**
5275             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5276             *
5277             * @param smallImageId the small image ID
5278             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5279             * @return the first matching journal article
5280             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5281             * @throws SystemException if a system exception occurred
5282             */
5283            public JournalArticle findBySmallImageId_First(long smallImageId,
5284                    OrderByComparator orderByComparator)
5285                    throws NoSuchArticleException, SystemException {
5286                    JournalArticle journalArticle = fetchBySmallImageId_First(smallImageId,
5287                                    orderByComparator);
5288    
5289                    if (journalArticle != null) {
5290                            return journalArticle;
5291                    }
5292    
5293                    StringBundler msg = new StringBundler(4);
5294    
5295                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5296    
5297                    msg.append("smallImageId=");
5298                    msg.append(smallImageId);
5299    
5300                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5301    
5302                    throw new NoSuchArticleException(msg.toString());
5303            }
5304    
5305            /**
5306             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5307             *
5308             * @param smallImageId the small image ID
5309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5310             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5311             * @throws SystemException if a system exception occurred
5312             */
5313            public JournalArticle fetchBySmallImageId_First(long smallImageId,
5314                    OrderByComparator orderByComparator) throws SystemException {
5315                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
5316                                    orderByComparator);
5317    
5318                    if (!list.isEmpty()) {
5319                            return list.get(0);
5320                    }
5321    
5322                    return null;
5323            }
5324    
5325            /**
5326             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5327             *
5328             * @param smallImageId the small image ID
5329             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5330             * @return the last matching journal article
5331             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5332             * @throws SystemException if a system exception occurred
5333             */
5334            public JournalArticle findBySmallImageId_Last(long smallImageId,
5335                    OrderByComparator orderByComparator)
5336                    throws NoSuchArticleException, SystemException {
5337                    JournalArticle journalArticle = fetchBySmallImageId_Last(smallImageId,
5338                                    orderByComparator);
5339    
5340                    if (journalArticle != null) {
5341                            return journalArticle;
5342                    }
5343    
5344                    StringBundler msg = new StringBundler(4);
5345    
5346                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5347    
5348                    msg.append("smallImageId=");
5349                    msg.append(smallImageId);
5350    
5351                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5352    
5353                    throw new NoSuchArticleException(msg.toString());
5354            }
5355    
5356            /**
5357             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5358             *
5359             * @param smallImageId the small image ID
5360             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5361             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5362             * @throws SystemException if a system exception occurred
5363             */
5364            public JournalArticle fetchBySmallImageId_Last(long smallImageId,
5365                    OrderByComparator orderByComparator) throws SystemException {
5366                    int count = countBySmallImageId(smallImageId);
5367    
5368                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
5369                                    count, orderByComparator);
5370    
5371                    if (!list.isEmpty()) {
5372                            return list.get(0);
5373                    }
5374    
5375                    return null;
5376            }
5377    
5378            /**
5379             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
5380             *
5381             * @param id the primary key of the current journal article
5382             * @param smallImageId the small image ID
5383             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5384             * @return the previous, current, and next journal article
5385             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5386             * @throws SystemException if a system exception occurred
5387             */
5388            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
5389                    long smallImageId, OrderByComparator orderByComparator)
5390                    throws NoSuchArticleException, SystemException {
5391                    JournalArticle journalArticle = findByPrimaryKey(id);
5392    
5393                    Session session = null;
5394    
5395                    try {
5396                            session = openSession();
5397    
5398                            JournalArticle[] array = new JournalArticleImpl[3];
5399    
5400                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
5401                                            smallImageId, orderByComparator, true);
5402    
5403                            array[1] = journalArticle;
5404    
5405                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
5406                                            smallImageId, orderByComparator, false);
5407    
5408                            return array;
5409                    }
5410                    catch (Exception e) {
5411                            throw processException(e);
5412                    }
5413                    finally {
5414                            closeSession(session);
5415                    }
5416            }
5417    
5418            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
5419                    JournalArticle journalArticle, long smallImageId,
5420                    OrderByComparator orderByComparator, boolean previous) {
5421                    StringBundler query = null;
5422    
5423                    if (orderByComparator != null) {
5424                            query = new StringBundler(6 +
5425                                            (orderByComparator.getOrderByFields().length * 6));
5426                    }
5427                    else {
5428                            query = new StringBundler(3);
5429                    }
5430    
5431                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5432    
5433                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5434    
5435                    if (orderByComparator != null) {
5436                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5437    
5438                            if (orderByConditionFields.length > 0) {
5439                                    query.append(WHERE_AND);
5440                            }
5441    
5442                            for (int i = 0; i < orderByConditionFields.length; i++) {
5443                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5444                                    query.append(orderByConditionFields[i]);
5445    
5446                                    if ((i + 1) < orderByConditionFields.length) {
5447                                            if (orderByComparator.isAscending() ^ previous) {
5448                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5449                                            }
5450                                            else {
5451                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5452                                            }
5453                                    }
5454                                    else {
5455                                            if (orderByComparator.isAscending() ^ previous) {
5456                                                    query.append(WHERE_GREATER_THAN);
5457                                            }
5458                                            else {
5459                                                    query.append(WHERE_LESSER_THAN);
5460                                            }
5461                                    }
5462                            }
5463    
5464                            query.append(ORDER_BY_CLAUSE);
5465    
5466                            String[] orderByFields = orderByComparator.getOrderByFields();
5467    
5468                            for (int i = 0; i < orderByFields.length; i++) {
5469                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5470                                    query.append(orderByFields[i]);
5471    
5472                                    if ((i + 1) < orderByFields.length) {
5473                                            if (orderByComparator.isAscending() ^ previous) {
5474                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5475                                            }
5476                                            else {
5477                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5478                                            }
5479                                    }
5480                                    else {
5481                                            if (orderByComparator.isAscending() ^ previous) {
5482                                                    query.append(ORDER_BY_ASC);
5483                                            }
5484                                            else {
5485                                                    query.append(ORDER_BY_DESC);
5486                                            }
5487                                    }
5488                            }
5489                    }
5490                    else {
5491                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5492                    }
5493    
5494                    String sql = query.toString();
5495    
5496                    Query q = session.createQuery(sql);
5497    
5498                    q.setFirstResult(0);
5499                    q.setMaxResults(2);
5500    
5501                    QueryPos qPos = QueryPos.getInstance(q);
5502    
5503                    qPos.add(smallImageId);
5504    
5505                    if (orderByComparator != null) {
5506                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5507    
5508                            for (Object value : values) {
5509                                    qPos.add(value);
5510                            }
5511                    }
5512    
5513                    List<JournalArticle> list = q.list();
5514    
5515                    if (list.size() == 2) {
5516                            return list.get(1);
5517                    }
5518                    else {
5519                            return null;
5520                    }
5521            }
5522    
5523            /**
5524             * Removes all the journal articles where smallImageId = &#63; from the database.
5525             *
5526             * @param smallImageId the small image ID
5527             * @throws SystemException if a system exception occurred
5528             */
5529            public void removeBySmallImageId(long smallImageId)
5530                    throws SystemException {
5531                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId,
5532                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5533                            remove(journalArticle);
5534                    }
5535            }
5536    
5537            /**
5538             * Returns the number of journal articles where smallImageId = &#63;.
5539             *
5540             * @param smallImageId the small image ID
5541             * @return the number of matching journal articles
5542             * @throws SystemException if a system exception occurred
5543             */
5544            public int countBySmallImageId(long smallImageId) throws SystemException {
5545                    FinderPath finderPath = FINDER_PATH_COUNT_BY_SMALLIMAGEID;
5546    
5547                    Object[] finderArgs = new Object[] { smallImageId };
5548    
5549                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5550                                    this);
5551    
5552                    if (count == null) {
5553                            StringBundler query = new StringBundler(2);
5554    
5555                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5556    
5557                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5558    
5559                            String sql = query.toString();
5560    
5561                            Session session = null;
5562    
5563                            try {
5564                                    session = openSession();
5565    
5566                                    Query q = session.createQuery(sql);
5567    
5568                                    QueryPos qPos = QueryPos.getInstance(q);
5569    
5570                                    qPos.add(smallImageId);
5571    
5572                                    count = (Long)q.uniqueResult();
5573    
5574                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5575                            }
5576                            catch (Exception e) {
5577                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5578    
5579                                    throw processException(e);
5580                            }
5581                            finally {
5582                                    closeSession(session);
5583                            }
5584                    }
5585    
5586                    return count.intValue();
5587            }
5588    
5589            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
5590            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5591                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5592                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5593                            "findByR_ST",
5594                            new String[] {
5595                                    Long.class.getName(), Integer.class.getName(),
5596                                    
5597                            Integer.class.getName(), Integer.class.getName(),
5598                                    OrderByComparator.class.getName()
5599                            });
5600            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5601                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5602                            JournalArticleImpl.class,
5603                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
5604                            new String[] { Long.class.getName(), Integer.class.getName() },
5605                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5606                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
5607                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5608                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5609            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5610                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5611                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
5612                            new String[] { Long.class.getName(), Integer.class.getName() });
5613    
5614            /**
5615             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5616             *
5617             * @param resourcePrimKey the resource prim key
5618             * @param status the status
5619             * @return the matching journal articles
5620             * @throws SystemException if a system exception occurred
5621             */
5622            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
5623                    throws SystemException {
5624                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
5625                            QueryUtil.ALL_POS, null);
5626            }
5627    
5628            /**
5629             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5630             *
5631             * <p>
5632             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5633             * </p>
5634             *
5635             * @param resourcePrimKey the resource prim key
5636             * @param status the status
5637             * @param start the lower bound of the range of journal articles
5638             * @param end the upper bound of the range of journal articles (not inclusive)
5639             * @return the range of matching journal articles
5640             * @throws SystemException if a system exception occurred
5641             */
5642            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
5643                    int start, int end) throws SystemException {
5644                    return findByR_ST(resourcePrimKey, status, start, end, null);
5645            }
5646    
5647            /**
5648             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5649             *
5650             * <p>
5651             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5652             * </p>
5653             *
5654             * @param resourcePrimKey the resource prim key
5655             * @param status the status
5656             * @param start the lower bound of the range of journal articles
5657             * @param end the upper bound of the range of journal articles (not inclusive)
5658             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5659             * @return the ordered range of matching journal articles
5660             * @throws SystemException if a system exception occurred
5661             */
5662            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
5663                    int start, int end, OrderByComparator orderByComparator)
5664                    throws SystemException {
5665                    boolean pagination = true;
5666                    FinderPath finderPath = null;
5667                    Object[] finderArgs = null;
5668    
5669                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5670                                    (orderByComparator == null)) {
5671                            pagination = false;
5672                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
5673                            finderArgs = new Object[] { resourcePrimKey, status };
5674                    }
5675                    else {
5676                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
5677                            finderArgs = new Object[] {
5678                                            resourcePrimKey, status,
5679                                            
5680                                            start, end, orderByComparator
5681                                    };
5682                    }
5683    
5684                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5685                                    finderArgs, this);
5686    
5687                    if ((list != null) && !list.isEmpty()) {
5688                            for (JournalArticle journalArticle : list) {
5689                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
5690                                                    (status != journalArticle.getStatus())) {
5691                                            list = null;
5692    
5693                                            break;
5694                                    }
5695                            }
5696                    }
5697    
5698                    if (list == null) {
5699                            StringBundler query = null;
5700    
5701                            if (orderByComparator != null) {
5702                                    query = new StringBundler(4 +
5703                                                    (orderByComparator.getOrderByFields().length * 3));
5704                            }
5705                            else {
5706                                    query = new StringBundler(4);
5707                            }
5708    
5709                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5710    
5711                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
5712    
5713                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
5714    
5715                            if (orderByComparator != null) {
5716                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5717                                            orderByComparator);
5718                            }
5719                            else
5720                             if (pagination) {
5721                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5722                            }
5723    
5724                            String sql = query.toString();
5725    
5726                            Session session = null;
5727    
5728                            try {
5729                                    session = openSession();
5730    
5731                                    Query q = session.createQuery(sql);
5732    
5733                                    QueryPos qPos = QueryPos.getInstance(q);
5734    
5735                                    qPos.add(resourcePrimKey);
5736    
5737                                    qPos.add(status);
5738    
5739                                    if (!pagination) {
5740                                            list = (List<JournalArticle>)QueryUtil.list(q,
5741                                                            getDialect(), start, end, false);
5742    
5743                                            Collections.sort(list);
5744    
5745                                            list = new UnmodifiableList<JournalArticle>(list);
5746                                    }
5747                                    else {
5748                                            list = (List<JournalArticle>)QueryUtil.list(q,
5749                                                            getDialect(), start, end);
5750                                    }
5751    
5752                                    cacheResult(list);
5753    
5754                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5755                            }
5756                            catch (Exception e) {
5757                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5758    
5759                                    throw processException(e);
5760                            }
5761                            finally {
5762                                    closeSession(session);
5763                            }
5764                    }
5765    
5766                    return list;
5767            }
5768    
5769            /**
5770             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5771             *
5772             * @param resourcePrimKey the resource prim key
5773             * @param status the status
5774             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5775             * @return the first matching journal article
5776             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5777             * @throws SystemException if a system exception occurred
5778             */
5779            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
5780                    OrderByComparator orderByComparator)
5781                    throws NoSuchArticleException, SystemException {
5782                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
5783                                    status, orderByComparator);
5784    
5785                    if (journalArticle != null) {
5786                            return journalArticle;
5787                    }
5788    
5789                    StringBundler msg = new StringBundler(6);
5790    
5791                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5792    
5793                    msg.append("resourcePrimKey=");
5794                    msg.append(resourcePrimKey);
5795    
5796                    msg.append(", status=");
5797                    msg.append(status);
5798    
5799                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5800    
5801                    throw new NoSuchArticleException(msg.toString());
5802            }
5803    
5804            /**
5805             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5806             *
5807             * @param resourcePrimKey the resource prim key
5808             * @param status the status
5809             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5810             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5811             * @throws SystemException if a system exception occurred
5812             */
5813            public JournalArticle fetchByR_ST_First(long resourcePrimKey, int status,
5814                    OrderByComparator orderByComparator) throws SystemException {
5815                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
5816                                    orderByComparator);
5817    
5818                    if (!list.isEmpty()) {
5819                            return list.get(0);
5820                    }
5821    
5822                    return null;
5823            }
5824    
5825            /**
5826             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5827             *
5828             * @param resourcePrimKey the resource prim key
5829             * @param status the status
5830             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5831             * @return the last matching journal article
5832             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5833             * @throws SystemException if a system exception occurred
5834             */
5835            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
5836                    OrderByComparator orderByComparator)
5837                    throws NoSuchArticleException, SystemException {
5838                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
5839                                    status, orderByComparator);
5840    
5841                    if (journalArticle != null) {
5842                            return journalArticle;
5843                    }
5844    
5845                    StringBundler msg = new StringBundler(6);
5846    
5847                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5848    
5849                    msg.append("resourcePrimKey=");
5850                    msg.append(resourcePrimKey);
5851    
5852                    msg.append(", status=");
5853                    msg.append(status);
5854    
5855                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5856    
5857                    throw new NoSuchArticleException(msg.toString());
5858            }
5859    
5860            /**
5861             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5862             *
5863             * @param resourcePrimKey the resource prim key
5864             * @param status the status
5865             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5866             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5867             * @throws SystemException if a system exception occurred
5868             */
5869            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
5870                    OrderByComparator orderByComparator) throws SystemException {
5871                    int count = countByR_ST(resourcePrimKey, status);
5872    
5873                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
5874                                    count - 1, count, orderByComparator);
5875    
5876                    if (!list.isEmpty()) {
5877                            return list.get(0);
5878                    }
5879    
5880                    return null;
5881            }
5882    
5883            /**
5884             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5885             *
5886             * @param id the primary key of the current journal article
5887             * @param resourcePrimKey the resource prim key
5888             * @param status the status
5889             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5890             * @return the previous, current, and next journal article
5891             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5892             * @throws SystemException if a system exception occurred
5893             */
5894            public JournalArticle[] findByR_ST_PrevAndNext(long id,
5895                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
5896                    throws NoSuchArticleException, SystemException {
5897                    JournalArticle journalArticle = findByPrimaryKey(id);
5898    
5899                    Session session = null;
5900    
5901                    try {
5902                            session = openSession();
5903    
5904                            JournalArticle[] array = new JournalArticleImpl[3];
5905    
5906                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
5907                                            resourcePrimKey, status, orderByComparator, true);
5908    
5909                            array[1] = journalArticle;
5910    
5911                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
5912                                            resourcePrimKey, status, orderByComparator, false);
5913    
5914                            return array;
5915                    }
5916                    catch (Exception e) {
5917                            throw processException(e);
5918                    }
5919                    finally {
5920                            closeSession(session);
5921                    }
5922            }
5923    
5924            protected JournalArticle getByR_ST_PrevAndNext(Session session,
5925                    JournalArticle journalArticle, long resourcePrimKey, int status,
5926                    OrderByComparator orderByComparator, boolean previous) {
5927                    StringBundler query = null;
5928    
5929                    if (orderByComparator != null) {
5930                            query = new StringBundler(6 +
5931                                            (orderByComparator.getOrderByFields().length * 6));
5932                    }
5933                    else {
5934                            query = new StringBundler(3);
5935                    }
5936    
5937                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5938    
5939                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
5940    
5941                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
5942    
5943                    if (orderByComparator != null) {
5944                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5945    
5946                            if (orderByConditionFields.length > 0) {
5947                                    query.append(WHERE_AND);
5948                            }
5949    
5950                            for (int i = 0; i < orderByConditionFields.length; i++) {
5951                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5952                                    query.append(orderByConditionFields[i]);
5953    
5954                                    if ((i + 1) < orderByConditionFields.length) {
5955                                            if (orderByComparator.isAscending() ^ previous) {
5956                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5957                                            }
5958                                            else {
5959                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5960                                            }
5961                                    }
5962                                    else {
5963                                            if (orderByComparator.isAscending() ^ previous) {
5964                                                    query.append(WHERE_GREATER_THAN);
5965                                            }
5966                                            else {
5967                                                    query.append(WHERE_LESSER_THAN);
5968                                            }
5969                                    }
5970                            }
5971    
5972                            query.append(ORDER_BY_CLAUSE);
5973    
5974                            String[] orderByFields = orderByComparator.getOrderByFields();
5975    
5976                            for (int i = 0; i < orderByFields.length; i++) {
5977                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5978                                    query.append(orderByFields[i]);
5979    
5980                                    if ((i + 1) < orderByFields.length) {
5981                                            if (orderByComparator.isAscending() ^ previous) {
5982                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5983                                            }
5984                                            else {
5985                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5986                                            }
5987                                    }
5988                                    else {
5989                                            if (orderByComparator.isAscending() ^ previous) {
5990                                                    query.append(ORDER_BY_ASC);
5991                                            }
5992                                            else {
5993                                                    query.append(ORDER_BY_DESC);
5994                                            }
5995                                    }
5996                            }
5997                    }
5998                    else {
5999                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6000                    }
6001    
6002                    String sql = query.toString();
6003    
6004                    Query q = session.createQuery(sql);
6005    
6006                    q.setFirstResult(0);
6007                    q.setMaxResults(2);
6008    
6009                    QueryPos qPos = QueryPos.getInstance(q);
6010    
6011                    qPos.add(resourcePrimKey);
6012    
6013                    qPos.add(status);
6014    
6015                    if (orderByComparator != null) {
6016                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6017    
6018                            for (Object value : values) {
6019                                    qPos.add(value);
6020                            }
6021                    }
6022    
6023                    List<JournalArticle> list = q.list();
6024    
6025                    if (list.size() == 2) {
6026                            return list.get(1);
6027                    }
6028                    else {
6029                            return null;
6030                    }
6031            }
6032    
6033            /**
6034             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
6035             *
6036             * @param resourcePrimKey the resource prim key
6037             * @param status the status
6038             * @throws SystemException if a system exception occurred
6039             */
6040            public void removeByR_ST(long resourcePrimKey, int status)
6041                    throws SystemException {
6042                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey,
6043                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6044                            remove(journalArticle);
6045                    }
6046            }
6047    
6048            /**
6049             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
6050             *
6051             * @param resourcePrimKey the resource prim key
6052             * @param status the status
6053             * @return the number of matching journal articles
6054             * @throws SystemException if a system exception occurred
6055             */
6056            public int countByR_ST(long resourcePrimKey, int status)
6057                    throws SystemException {
6058                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_ST;
6059    
6060                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
6061    
6062                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6063                                    this);
6064    
6065                    if (count == null) {
6066                            StringBundler query = new StringBundler(3);
6067    
6068                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6069    
6070                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6071    
6072                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6073    
6074                            String sql = query.toString();
6075    
6076                            Session session = null;
6077    
6078                            try {
6079                                    session = openSession();
6080    
6081                                    Query q = session.createQuery(sql);
6082    
6083                                    QueryPos qPos = QueryPos.getInstance(q);
6084    
6085                                    qPos.add(resourcePrimKey);
6086    
6087                                    qPos.add(status);
6088    
6089                                    count = (Long)q.uniqueResult();
6090    
6091                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6092                            }
6093                            catch (Exception e) {
6094                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6095    
6096                                    throw processException(e);
6097                            }
6098                            finally {
6099                                    closeSession(session);
6100                            }
6101                    }
6102    
6103                    return count.intValue();
6104            }
6105    
6106            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
6107            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
6108            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6109                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6110                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6111                            "findByG_U",
6112                            new String[] {
6113                                    Long.class.getName(), Long.class.getName(),
6114                                    
6115                            Integer.class.getName(), Integer.class.getName(),
6116                                    OrderByComparator.class.getName()
6117                            });
6118            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6119                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6120                            JournalArticleImpl.class,
6121                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
6122                            new String[] { Long.class.getName(), Long.class.getName() },
6123                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
6124                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
6125                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6126                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6127            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6128                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6129                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
6130                            new String[] { Long.class.getName(), Long.class.getName() });
6131    
6132            /**
6133             * Returns all the journal articles where groupId = &#63; and userId = &#63;.
6134             *
6135             * @param groupId the group ID
6136             * @param userId the user ID
6137             * @return the matching journal articles
6138             * @throws SystemException if a system exception occurred
6139             */
6140            public List<JournalArticle> findByG_U(long groupId, long userId)
6141                    throws SystemException {
6142                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6143                            null);
6144            }
6145    
6146            /**
6147             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63;.
6148             *
6149             * <p>
6150             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6151             * </p>
6152             *
6153             * @param groupId the group ID
6154             * @param userId the user ID
6155             * @param start the lower bound of the range of journal articles
6156             * @param end the upper bound of the range of journal articles (not inclusive)
6157             * @return the range of matching journal articles
6158             * @throws SystemException if a system exception occurred
6159             */
6160            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6161                    int end) throws SystemException {
6162                    return findByG_U(groupId, userId, start, end, null);
6163            }
6164    
6165            /**
6166             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63;.
6167             *
6168             * <p>
6169             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6170             * </p>
6171             *
6172             * @param groupId the group ID
6173             * @param userId the user ID
6174             * @param start the lower bound of the range of journal articles
6175             * @param end the upper bound of the range of journal articles (not inclusive)
6176             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6177             * @return the ordered range of matching journal articles
6178             * @throws SystemException if a system exception occurred
6179             */
6180            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6181                    int end, OrderByComparator orderByComparator) throws SystemException {
6182                    boolean pagination = true;
6183                    FinderPath finderPath = null;
6184                    Object[] finderArgs = null;
6185    
6186                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6187                                    (orderByComparator == null)) {
6188                            pagination = false;
6189                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
6190                            finderArgs = new Object[] { groupId, userId };
6191                    }
6192                    else {
6193                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
6194                            finderArgs = new Object[] {
6195                                            groupId, userId,
6196                                            
6197                                            start, end, orderByComparator
6198                                    };
6199                    }
6200    
6201                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6202                                    finderArgs, this);
6203    
6204                    if ((list != null) && !list.isEmpty()) {
6205                            for (JournalArticle journalArticle : list) {
6206                                    if ((groupId != journalArticle.getGroupId()) ||
6207                                                    (userId != journalArticle.getUserId())) {
6208                                            list = null;
6209    
6210                                            break;
6211                                    }
6212                            }
6213                    }
6214    
6215                    if (list == null) {
6216                            StringBundler query = null;
6217    
6218                            if (orderByComparator != null) {
6219                                    query = new StringBundler(4 +
6220                                                    (orderByComparator.getOrderByFields().length * 3));
6221                            }
6222                            else {
6223                                    query = new StringBundler(4);
6224                            }
6225    
6226                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6227    
6228                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6229    
6230                            query.append(_FINDER_COLUMN_G_U_USERID_2);
6231    
6232                            if (orderByComparator != null) {
6233                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6234                                            orderByComparator);
6235                            }
6236                            else
6237                             if (pagination) {
6238                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6239                            }
6240    
6241                            String sql = query.toString();
6242    
6243                            Session session = null;
6244    
6245                            try {
6246                                    session = openSession();
6247    
6248                                    Query q = session.createQuery(sql);
6249    
6250                                    QueryPos qPos = QueryPos.getInstance(q);
6251    
6252                                    qPos.add(groupId);
6253    
6254                                    qPos.add(userId);
6255    
6256                                    if (!pagination) {
6257                                            list = (List<JournalArticle>)QueryUtil.list(q,
6258                                                            getDialect(), start, end, false);
6259    
6260                                            Collections.sort(list);
6261    
6262                                            list = new UnmodifiableList<JournalArticle>(list);
6263                                    }
6264                                    else {
6265                                            list = (List<JournalArticle>)QueryUtil.list(q,
6266                                                            getDialect(), start, end);
6267                                    }
6268    
6269                                    cacheResult(list);
6270    
6271                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6272                            }
6273                            catch (Exception e) {
6274                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6275    
6276                                    throw processException(e);
6277                            }
6278                            finally {
6279                                    closeSession(session);
6280                            }
6281                    }
6282    
6283                    return list;
6284            }
6285    
6286            /**
6287             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
6288             *
6289             * @param groupId the group ID
6290             * @param userId the user ID
6291             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6292             * @return the first matching journal article
6293             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6294             * @throws SystemException if a system exception occurred
6295             */
6296            public JournalArticle findByG_U_First(long groupId, long userId,
6297                    OrderByComparator orderByComparator)
6298                    throws NoSuchArticleException, SystemException {
6299                    JournalArticle journalArticle = fetchByG_U_First(groupId, userId,
6300                                    orderByComparator);
6301    
6302                    if (journalArticle != null) {
6303                            return journalArticle;
6304                    }
6305    
6306                    StringBundler msg = new StringBundler(6);
6307    
6308                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6309    
6310                    msg.append("groupId=");
6311                    msg.append(groupId);
6312    
6313                    msg.append(", userId=");
6314                    msg.append(userId);
6315    
6316                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6317    
6318                    throw new NoSuchArticleException(msg.toString());
6319            }
6320    
6321            /**
6322             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
6323             *
6324             * @param groupId the group ID
6325             * @param userId the user ID
6326             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6327             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6328             * @throws SystemException if a system exception occurred
6329             */
6330            public JournalArticle fetchByG_U_First(long groupId, long userId,
6331                    OrderByComparator orderByComparator) throws SystemException {
6332                    List<JournalArticle> list = findByG_U(groupId, userId, 0, 1,
6333                                    orderByComparator);
6334    
6335                    if (!list.isEmpty()) {
6336                            return list.get(0);
6337                    }
6338    
6339                    return null;
6340            }
6341    
6342            /**
6343             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
6344             *
6345             * @param groupId the group ID
6346             * @param userId the user ID
6347             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6348             * @return the last matching journal article
6349             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6350             * @throws SystemException if a system exception occurred
6351             */
6352            public JournalArticle findByG_U_Last(long groupId, long userId,
6353                    OrderByComparator orderByComparator)
6354                    throws NoSuchArticleException, SystemException {
6355                    JournalArticle journalArticle = fetchByG_U_Last(groupId, userId,
6356                                    orderByComparator);
6357    
6358                    if (journalArticle != null) {
6359                            return journalArticle;
6360                    }
6361    
6362                    StringBundler msg = new StringBundler(6);
6363    
6364                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6365    
6366                    msg.append("groupId=");
6367                    msg.append(groupId);
6368    
6369                    msg.append(", userId=");
6370                    msg.append(userId);
6371    
6372                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6373    
6374                    throw new NoSuchArticleException(msg.toString());
6375            }
6376    
6377            /**
6378             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
6379             *
6380             * @param groupId the group ID
6381             * @param userId the user ID
6382             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6383             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6384             * @throws SystemException if a system exception occurred
6385             */
6386            public JournalArticle fetchByG_U_Last(long groupId, long userId,
6387                    OrderByComparator orderByComparator) throws SystemException {
6388                    int count = countByG_U(groupId, userId);
6389    
6390                    List<JournalArticle> list = findByG_U(groupId, userId, count - 1,
6391                                    count, orderByComparator);
6392    
6393                    if (!list.isEmpty()) {
6394                            return list.get(0);
6395                    }
6396    
6397                    return null;
6398            }
6399    
6400            /**
6401             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63;.
6402             *
6403             * @param id the primary key of the current journal article
6404             * @param groupId the group ID
6405             * @param userId the user ID
6406             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6407             * @return the previous, current, and next journal article
6408             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6409             * @throws SystemException if a system exception occurred
6410             */
6411            public JournalArticle[] findByG_U_PrevAndNext(long id, long groupId,
6412                    long userId, OrderByComparator orderByComparator)
6413                    throws NoSuchArticleException, SystemException {
6414                    JournalArticle journalArticle = findByPrimaryKey(id);
6415    
6416                    Session session = null;
6417    
6418                    try {
6419                            session = openSession();
6420    
6421                            JournalArticle[] array = new JournalArticleImpl[3];
6422    
6423                            array[0] = getByG_U_PrevAndNext(session, journalArticle, groupId,
6424                                            userId, orderByComparator, true);
6425    
6426                            array[1] = journalArticle;
6427    
6428                            array[2] = getByG_U_PrevAndNext(session, journalArticle, groupId,
6429                                            userId, orderByComparator, false);
6430    
6431                            return array;
6432                    }
6433                    catch (Exception e) {
6434                            throw processException(e);
6435                    }
6436                    finally {
6437                            closeSession(session);
6438                    }
6439            }
6440    
6441            protected JournalArticle getByG_U_PrevAndNext(Session session,
6442                    JournalArticle journalArticle, long groupId, long userId,
6443                    OrderByComparator orderByComparator, boolean previous) {
6444                    StringBundler query = null;
6445    
6446                    if (orderByComparator != null) {
6447                            query = new StringBundler(6 +
6448                                            (orderByComparator.getOrderByFields().length * 6));
6449                    }
6450                    else {
6451                            query = new StringBundler(3);
6452                    }
6453    
6454                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6455    
6456                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6457    
6458                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6459    
6460                    if (orderByComparator != null) {
6461                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6462    
6463                            if (orderByConditionFields.length > 0) {
6464                                    query.append(WHERE_AND);
6465                            }
6466    
6467                            for (int i = 0; i < orderByConditionFields.length; i++) {
6468                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6469                                    query.append(orderByConditionFields[i]);
6470    
6471                                    if ((i + 1) < orderByConditionFields.length) {
6472                                            if (orderByComparator.isAscending() ^ previous) {
6473                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6474                                            }
6475                                            else {
6476                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6477                                            }
6478                                    }
6479                                    else {
6480                                            if (orderByComparator.isAscending() ^ previous) {
6481                                                    query.append(WHERE_GREATER_THAN);
6482                                            }
6483                                            else {
6484                                                    query.append(WHERE_LESSER_THAN);
6485                                            }
6486                                    }
6487                            }
6488    
6489                            query.append(ORDER_BY_CLAUSE);
6490    
6491                            String[] orderByFields = orderByComparator.getOrderByFields();
6492    
6493                            for (int i = 0; i < orderByFields.length; i++) {
6494                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6495                                    query.append(orderByFields[i]);
6496    
6497                                    if ((i + 1) < orderByFields.length) {
6498                                            if (orderByComparator.isAscending() ^ previous) {
6499                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6500                                            }
6501                                            else {
6502                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6503                                            }
6504                                    }
6505                                    else {
6506                                            if (orderByComparator.isAscending() ^ previous) {
6507                                                    query.append(ORDER_BY_ASC);
6508                                            }
6509                                            else {
6510                                                    query.append(ORDER_BY_DESC);
6511                                            }
6512                                    }
6513                            }
6514                    }
6515                    else {
6516                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6517                    }
6518    
6519                    String sql = query.toString();
6520    
6521                    Query q = session.createQuery(sql);
6522    
6523                    q.setFirstResult(0);
6524                    q.setMaxResults(2);
6525    
6526                    QueryPos qPos = QueryPos.getInstance(q);
6527    
6528                    qPos.add(groupId);
6529    
6530                    qPos.add(userId);
6531    
6532                    if (orderByComparator != null) {
6533                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6534    
6535                            for (Object value : values) {
6536                                    qPos.add(value);
6537                            }
6538                    }
6539    
6540                    List<JournalArticle> list = q.list();
6541    
6542                    if (list.size() == 2) {
6543                            return list.get(1);
6544                    }
6545                    else {
6546                            return null;
6547                    }
6548            }
6549    
6550            /**
6551             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6552             *
6553             * @param groupId the group ID
6554             * @param userId the user ID
6555             * @return the matching journal articles that the user has permission to view
6556             * @throws SystemException if a system exception occurred
6557             */
6558            public List<JournalArticle> filterFindByG_U(long groupId, long userId)
6559                    throws SystemException {
6560                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
6561                            QueryUtil.ALL_POS, null);
6562            }
6563    
6564            /**
6565             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6566             *
6567             * <p>
6568             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6569             * </p>
6570             *
6571             * @param groupId the group ID
6572             * @param userId the user ID
6573             * @param start the lower bound of the range of journal articles
6574             * @param end the upper bound of the range of journal articles (not inclusive)
6575             * @return the range of matching journal articles that the user has permission to view
6576             * @throws SystemException if a system exception occurred
6577             */
6578            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
6579                    int start, int end) throws SystemException {
6580                    return filterFindByG_U(groupId, userId, start, end, null);
6581            }
6582    
6583            /**
6584             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63;.
6585             *
6586             * <p>
6587             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6588             * </p>
6589             *
6590             * @param groupId the group ID
6591             * @param userId the user ID
6592             * @param start the lower bound of the range of journal articles
6593             * @param end the upper bound of the range of journal articles (not inclusive)
6594             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6595             * @return the ordered range of matching journal articles that the user has permission to view
6596             * @throws SystemException if a system exception occurred
6597             */
6598            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
6599                    int start, int end, OrderByComparator orderByComparator)
6600                    throws SystemException {
6601                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6602                            return findByG_U(groupId, userId, start, end, orderByComparator);
6603                    }
6604    
6605                    StringBundler query = null;
6606    
6607                    if (orderByComparator != null) {
6608                            query = new StringBundler(4 +
6609                                            (orderByComparator.getOrderByFields().length * 3));
6610                    }
6611                    else {
6612                            query = new StringBundler(4);
6613                    }
6614    
6615                    if (getDB().isSupportsInlineDistinct()) {
6616                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6617                    }
6618                    else {
6619                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6620                    }
6621    
6622                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6623    
6624                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6625    
6626                    if (!getDB().isSupportsInlineDistinct()) {
6627                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6628                    }
6629    
6630                    if (orderByComparator != null) {
6631                            if (getDB().isSupportsInlineDistinct()) {
6632                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6633                                            orderByComparator, true);
6634                            }
6635                            else {
6636                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6637                                            orderByComparator, true);
6638                            }
6639                    }
6640                    else {
6641                            if (getDB().isSupportsInlineDistinct()) {
6642                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6643                            }
6644                            else {
6645                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6646                            }
6647                    }
6648    
6649                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6650                                    JournalArticle.class.getName(),
6651                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6652    
6653                    Session session = null;
6654    
6655                    try {
6656                            session = openSession();
6657    
6658                            SQLQuery q = session.createSQLQuery(sql);
6659    
6660                            if (getDB().isSupportsInlineDistinct()) {
6661                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6662                            }
6663                            else {
6664                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6665                            }
6666    
6667                            QueryPos qPos = QueryPos.getInstance(q);
6668    
6669                            qPos.add(groupId);
6670    
6671                            qPos.add(userId);
6672    
6673                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6674                                    end);
6675                    }
6676                    catch (Exception e) {
6677                            throw processException(e);
6678                    }
6679                    finally {
6680                            closeSession(session);
6681                    }
6682            }
6683    
6684            /**
6685             * 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;.
6686             *
6687             * @param id the primary key of the current journal article
6688             * @param groupId the group ID
6689             * @param userId the user ID
6690             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6691             * @return the previous, current, and next journal article
6692             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6693             * @throws SystemException if a system exception occurred
6694             */
6695            public JournalArticle[] filterFindByG_U_PrevAndNext(long id, long groupId,
6696                    long userId, OrderByComparator orderByComparator)
6697                    throws NoSuchArticleException, SystemException {
6698                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6699                            return findByG_U_PrevAndNext(id, groupId, userId, orderByComparator);
6700                    }
6701    
6702                    JournalArticle journalArticle = findByPrimaryKey(id);
6703    
6704                    Session session = null;
6705    
6706                    try {
6707                            session = openSession();
6708    
6709                            JournalArticle[] array = new JournalArticleImpl[3];
6710    
6711                            array[0] = filterGetByG_U_PrevAndNext(session, journalArticle,
6712                                            groupId, userId, orderByComparator, true);
6713    
6714                            array[1] = journalArticle;
6715    
6716                            array[2] = filterGetByG_U_PrevAndNext(session, journalArticle,
6717                                            groupId, userId, orderByComparator, false);
6718    
6719                            return array;
6720                    }
6721                    catch (Exception e) {
6722                            throw processException(e);
6723                    }
6724                    finally {
6725                            closeSession(session);
6726                    }
6727            }
6728    
6729            protected JournalArticle filterGetByG_U_PrevAndNext(Session session,
6730                    JournalArticle journalArticle, long groupId, long userId,
6731                    OrderByComparator orderByComparator, boolean previous) {
6732                    StringBundler query = null;
6733    
6734                    if (orderByComparator != null) {
6735                            query = new StringBundler(6 +
6736                                            (orderByComparator.getOrderByFields().length * 6));
6737                    }
6738                    else {
6739                            query = new StringBundler(3);
6740                    }
6741    
6742                    if (getDB().isSupportsInlineDistinct()) {
6743                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6744                    }
6745                    else {
6746                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6747                    }
6748    
6749                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6750    
6751                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6752    
6753                    if (!getDB().isSupportsInlineDistinct()) {
6754                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6755                    }
6756    
6757                    if (orderByComparator != null) {
6758                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6759    
6760                            if (orderByConditionFields.length > 0) {
6761                                    query.append(WHERE_AND);
6762                            }
6763    
6764                            for (int i = 0; i < orderByConditionFields.length; i++) {
6765                                    if (getDB().isSupportsInlineDistinct()) {
6766                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6767                                    }
6768                                    else {
6769                                            query.append(_ORDER_BY_ENTITY_TABLE);
6770                                    }
6771    
6772                                    query.append(orderByConditionFields[i]);
6773    
6774                                    if ((i + 1) < orderByConditionFields.length) {
6775                                            if (orderByComparator.isAscending() ^ previous) {
6776                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6777                                            }
6778                                            else {
6779                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6780                                            }
6781                                    }
6782                                    else {
6783                                            if (orderByComparator.isAscending() ^ previous) {
6784                                                    query.append(WHERE_GREATER_THAN);
6785                                            }
6786                                            else {
6787                                                    query.append(WHERE_LESSER_THAN);
6788                                            }
6789                                    }
6790                            }
6791    
6792                            query.append(ORDER_BY_CLAUSE);
6793    
6794                            String[] orderByFields = orderByComparator.getOrderByFields();
6795    
6796                            for (int i = 0; i < orderByFields.length; i++) {
6797                                    if (getDB().isSupportsInlineDistinct()) {
6798                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6799                                    }
6800                                    else {
6801                                            query.append(_ORDER_BY_ENTITY_TABLE);
6802                                    }
6803    
6804                                    query.append(orderByFields[i]);
6805    
6806                                    if ((i + 1) < orderByFields.length) {
6807                                            if (orderByComparator.isAscending() ^ previous) {
6808                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6809                                            }
6810                                            else {
6811                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6812                                            }
6813                                    }
6814                                    else {
6815                                            if (orderByComparator.isAscending() ^ previous) {
6816                                                    query.append(ORDER_BY_ASC);
6817                                            }
6818                                            else {
6819                                                    query.append(ORDER_BY_DESC);
6820                                            }
6821                                    }
6822                            }
6823                    }
6824                    else {
6825                            if (getDB().isSupportsInlineDistinct()) {
6826                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6827                            }
6828                            else {
6829                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6830                            }
6831                    }
6832    
6833                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6834                                    JournalArticle.class.getName(),
6835                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6836    
6837                    SQLQuery q = session.createSQLQuery(sql);
6838    
6839                    q.setFirstResult(0);
6840                    q.setMaxResults(2);
6841    
6842                    if (getDB().isSupportsInlineDistinct()) {
6843                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6844                    }
6845                    else {
6846                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6847                    }
6848    
6849                    QueryPos qPos = QueryPos.getInstance(q);
6850    
6851                    qPos.add(groupId);
6852    
6853                    qPos.add(userId);
6854    
6855                    if (orderByComparator != null) {
6856                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6857    
6858                            for (Object value : values) {
6859                                    qPos.add(value);
6860                            }
6861                    }
6862    
6863                    List<JournalArticle> list = q.list();
6864    
6865                    if (list.size() == 2) {
6866                            return list.get(1);
6867                    }
6868                    else {
6869                            return null;
6870                    }
6871            }
6872    
6873            /**
6874             * Removes all the journal articles where groupId = &#63; and userId = &#63; from the database.
6875             *
6876             * @param groupId the group ID
6877             * @param userId the user ID
6878             * @throws SystemException if a system exception occurred
6879             */
6880            public void removeByG_U(long groupId, long userId)
6881                    throws SystemException {
6882                    for (JournalArticle journalArticle : findByG_U(groupId, userId,
6883                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6884                            remove(journalArticle);
6885                    }
6886            }
6887    
6888            /**
6889             * Returns the number of journal articles where groupId = &#63; and userId = &#63;.
6890             *
6891             * @param groupId the group ID
6892             * @param userId the user ID
6893             * @return the number of matching journal articles
6894             * @throws SystemException if a system exception occurred
6895             */
6896            public int countByG_U(long groupId, long userId) throws SystemException {
6897                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
6898    
6899                    Object[] finderArgs = new Object[] { groupId, userId };
6900    
6901                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6902                                    this);
6903    
6904                    if (count == null) {
6905                            StringBundler query = new StringBundler(3);
6906    
6907                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6908    
6909                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6910    
6911                            query.append(_FINDER_COLUMN_G_U_USERID_2);
6912    
6913                            String sql = query.toString();
6914    
6915                            Session session = null;
6916    
6917                            try {
6918                                    session = openSession();
6919    
6920                                    Query q = session.createQuery(sql);
6921    
6922                                    QueryPos qPos = QueryPos.getInstance(q);
6923    
6924                                    qPos.add(groupId);
6925    
6926                                    qPos.add(userId);
6927    
6928                                    count = (Long)q.uniqueResult();
6929    
6930                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6931                            }
6932                            catch (Exception e) {
6933                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6934    
6935                                    throw processException(e);
6936                            }
6937                            finally {
6938                                    closeSession(session);
6939                            }
6940                    }
6941    
6942                    return count.intValue();
6943            }
6944    
6945            /**
6946             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6947             *
6948             * @param groupId the group ID
6949             * @param userId the user ID
6950             * @return the number of matching journal articles that the user has permission to view
6951             * @throws SystemException if a system exception occurred
6952             */
6953            public int filterCountByG_U(long groupId, long userId)
6954                    throws SystemException {
6955                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6956                            return countByG_U(groupId, userId);
6957                    }
6958    
6959                    StringBundler query = new StringBundler(3);
6960    
6961                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
6962    
6963                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6964    
6965                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6966    
6967                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6968                                    JournalArticle.class.getName(),
6969                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6970    
6971                    Session session = null;
6972    
6973                    try {
6974                            session = openSession();
6975    
6976                            SQLQuery q = session.createSQLQuery(sql);
6977    
6978                            q.addScalar(COUNT_COLUMN_NAME,
6979                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6980    
6981                            QueryPos qPos = QueryPos.getInstance(q);
6982    
6983                            qPos.add(groupId);
6984    
6985                            qPos.add(userId);
6986    
6987                            Long count = (Long)q.uniqueResult();
6988    
6989                            return count.intValue();
6990                    }
6991                    catch (Exception e) {
6992                            throw processException(e);
6993                    }
6994                    finally {
6995                            closeSession(session);
6996                    }
6997            }
6998    
6999            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "journalArticle.groupId = ? AND ";
7000            private static final String _FINDER_COLUMN_G_U_USERID_2 = "journalArticle.userId = ?";
7001            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7002                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7003                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7004                            "findByG_F",
7005                            new String[] {
7006                                    Long.class.getName(), Long.class.getName(),
7007                                    
7008                            Integer.class.getName(), Integer.class.getName(),
7009                                    OrderByComparator.class.getName()
7010                            });
7011            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7012                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7013                            JournalArticleImpl.class,
7014                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
7015                            new String[] { Long.class.getName(), Long.class.getName() },
7016                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
7017                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
7018                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
7019                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
7020            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7021                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7022                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
7023                            new String[] { Long.class.getName(), Long.class.getName() });
7024            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7025                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7026                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
7027                            new String[] { Long.class.getName(), Long.class.getName() });
7028    
7029            /**
7030             * Returns all the journal articles where groupId = &#63; and folderId = &#63;.
7031             *
7032             * @param groupId the group ID
7033             * @param folderId the folder ID
7034             * @return the matching journal articles
7035             * @throws SystemException if a system exception occurred
7036             */
7037            public List<JournalArticle> findByG_F(long groupId, long folderId)
7038                    throws SystemException {
7039                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
7040                            QueryUtil.ALL_POS, null);
7041            }
7042    
7043            /**
7044             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63;.
7045             *
7046             * <p>
7047             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7048             * </p>
7049             *
7050             * @param groupId the group ID
7051             * @param folderId the folder ID
7052             * @param start the lower bound of the range of journal articles
7053             * @param end the upper bound of the range of journal articles (not inclusive)
7054             * @return the range of matching journal articles
7055             * @throws SystemException if a system exception occurred
7056             */
7057            public List<JournalArticle> findByG_F(long groupId, long folderId,
7058                    int start, int end) throws SystemException {
7059                    return findByG_F(groupId, folderId, start, end, null);
7060            }
7061    
7062            /**
7063             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63;.
7064             *
7065             * <p>
7066             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7067             * </p>
7068             *
7069             * @param groupId the group ID
7070             * @param folderId the folder ID
7071             * @param start the lower bound of the range of journal articles
7072             * @param end the upper bound of the range of journal articles (not inclusive)
7073             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7074             * @return the ordered range of matching journal articles
7075             * @throws SystemException if a system exception occurred
7076             */
7077            public List<JournalArticle> findByG_F(long groupId, long folderId,
7078                    int start, int end, OrderByComparator orderByComparator)
7079                    throws SystemException {
7080                    boolean pagination = true;
7081                    FinderPath finderPath = null;
7082                    Object[] finderArgs = null;
7083    
7084                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7085                                    (orderByComparator == null)) {
7086                            pagination = false;
7087                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
7088                            finderArgs = new Object[] { groupId, folderId };
7089                    }
7090                    else {
7091                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
7092                            finderArgs = new Object[] {
7093                                            groupId, folderId,
7094                                            
7095                                            start, end, orderByComparator
7096                                    };
7097                    }
7098    
7099                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7100                                    finderArgs, this);
7101    
7102                    if ((list != null) && !list.isEmpty()) {
7103                            for (JournalArticle journalArticle : list) {
7104                                    if ((groupId != journalArticle.getGroupId()) ||
7105                                                    (folderId != journalArticle.getFolderId())) {
7106                                            list = null;
7107    
7108                                            break;
7109                                    }
7110                            }
7111                    }
7112    
7113                    if (list == null) {
7114                            StringBundler query = null;
7115    
7116                            if (orderByComparator != null) {
7117                                    query = new StringBundler(4 +
7118                                                    (orderByComparator.getOrderByFields().length * 3));
7119                            }
7120                            else {
7121                                    query = new StringBundler(4);
7122                            }
7123    
7124                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7125    
7126                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7127    
7128                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7129    
7130                            if (orderByComparator != null) {
7131                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7132                                            orderByComparator);
7133                            }
7134                            else
7135                             if (pagination) {
7136                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7137                            }
7138    
7139                            String sql = query.toString();
7140    
7141                            Session session = null;
7142    
7143                            try {
7144                                    session = openSession();
7145    
7146                                    Query q = session.createQuery(sql);
7147    
7148                                    QueryPos qPos = QueryPos.getInstance(q);
7149    
7150                                    qPos.add(groupId);
7151    
7152                                    qPos.add(folderId);
7153    
7154                                    if (!pagination) {
7155                                            list = (List<JournalArticle>)QueryUtil.list(q,
7156                                                            getDialect(), start, end, false);
7157    
7158                                            Collections.sort(list);
7159    
7160                                            list = new UnmodifiableList<JournalArticle>(list);
7161                                    }
7162                                    else {
7163                                            list = (List<JournalArticle>)QueryUtil.list(q,
7164                                                            getDialect(), start, end);
7165                                    }
7166    
7167                                    cacheResult(list);
7168    
7169                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7170                            }
7171                            catch (Exception e) {
7172                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7173    
7174                                    throw processException(e);
7175                            }
7176                            finally {
7177                                    closeSession(session);
7178                            }
7179                    }
7180    
7181                    return list;
7182            }
7183    
7184            /**
7185             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7186             *
7187             * @param groupId the group ID
7188             * @param folderId the folder ID
7189             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7190             * @return the first matching journal article
7191             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7192             * @throws SystemException if a system exception occurred
7193             */
7194            public JournalArticle findByG_F_First(long groupId, long folderId,
7195                    OrderByComparator orderByComparator)
7196                    throws NoSuchArticleException, SystemException {
7197                    JournalArticle journalArticle = fetchByG_F_First(groupId, folderId,
7198                                    orderByComparator);
7199    
7200                    if (journalArticle != null) {
7201                            return journalArticle;
7202                    }
7203    
7204                    StringBundler msg = new StringBundler(6);
7205    
7206                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7207    
7208                    msg.append("groupId=");
7209                    msg.append(groupId);
7210    
7211                    msg.append(", folderId=");
7212                    msg.append(folderId);
7213    
7214                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7215    
7216                    throw new NoSuchArticleException(msg.toString());
7217            }
7218    
7219            /**
7220             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7221             *
7222             * @param groupId the group ID
7223             * @param folderId the folder ID
7224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7225             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7226             * @throws SystemException if a system exception occurred
7227             */
7228            public JournalArticle fetchByG_F_First(long groupId, long folderId,
7229                    OrderByComparator orderByComparator) throws SystemException {
7230                    List<JournalArticle> list = findByG_F(groupId, folderId, 0, 1,
7231                                    orderByComparator);
7232    
7233                    if (!list.isEmpty()) {
7234                            return list.get(0);
7235                    }
7236    
7237                    return null;
7238            }
7239    
7240            /**
7241             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7242             *
7243             * @param groupId the group ID
7244             * @param folderId the folder ID
7245             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7246             * @return the last matching journal article
7247             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7248             * @throws SystemException if a system exception occurred
7249             */
7250            public JournalArticle findByG_F_Last(long groupId, long folderId,
7251                    OrderByComparator orderByComparator)
7252                    throws NoSuchArticleException, SystemException {
7253                    JournalArticle journalArticle = fetchByG_F_Last(groupId, folderId,
7254                                    orderByComparator);
7255    
7256                    if (journalArticle != null) {
7257                            return journalArticle;
7258                    }
7259    
7260                    StringBundler msg = new StringBundler(6);
7261    
7262                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7263    
7264                    msg.append("groupId=");
7265                    msg.append(groupId);
7266    
7267                    msg.append(", folderId=");
7268                    msg.append(folderId);
7269    
7270                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7271    
7272                    throw new NoSuchArticleException(msg.toString());
7273            }
7274    
7275            /**
7276             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7277             *
7278             * @param groupId the group ID
7279             * @param folderId the folder ID
7280             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7281             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7282             * @throws SystemException if a system exception occurred
7283             */
7284            public JournalArticle fetchByG_F_Last(long groupId, long folderId,
7285                    OrderByComparator orderByComparator) throws SystemException {
7286                    int count = countByG_F(groupId, folderId);
7287    
7288                    List<JournalArticle> list = findByG_F(groupId, folderId, count - 1,
7289                                    count, orderByComparator);
7290    
7291                    if (!list.isEmpty()) {
7292                            return list.get(0);
7293                    }
7294    
7295                    return null;
7296            }
7297    
7298            /**
7299             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7300             *
7301             * @param id the primary key of the current journal article
7302             * @param groupId the group ID
7303             * @param folderId the folder ID
7304             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7305             * @return the previous, current, and next journal article
7306             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7307             * @throws SystemException if a system exception occurred
7308             */
7309            public JournalArticle[] findByG_F_PrevAndNext(long id, long groupId,
7310                    long folderId, OrderByComparator orderByComparator)
7311                    throws NoSuchArticleException, SystemException {
7312                    JournalArticle journalArticle = findByPrimaryKey(id);
7313    
7314                    Session session = null;
7315    
7316                    try {
7317                            session = openSession();
7318    
7319                            JournalArticle[] array = new JournalArticleImpl[3];
7320    
7321                            array[0] = getByG_F_PrevAndNext(session, journalArticle, groupId,
7322                                            folderId, orderByComparator, true);
7323    
7324                            array[1] = journalArticle;
7325    
7326                            array[2] = getByG_F_PrevAndNext(session, journalArticle, groupId,
7327                                            folderId, orderByComparator, false);
7328    
7329                            return array;
7330                    }
7331                    catch (Exception e) {
7332                            throw processException(e);
7333                    }
7334                    finally {
7335                            closeSession(session);
7336                    }
7337            }
7338    
7339            protected JournalArticle getByG_F_PrevAndNext(Session session,
7340                    JournalArticle journalArticle, long groupId, long folderId,
7341                    OrderByComparator orderByComparator, boolean previous) {
7342                    StringBundler query = null;
7343    
7344                    if (orderByComparator != null) {
7345                            query = new StringBundler(6 +
7346                                            (orderByComparator.getOrderByFields().length * 6));
7347                    }
7348                    else {
7349                            query = new StringBundler(3);
7350                    }
7351    
7352                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7353    
7354                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7355    
7356                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7357    
7358                    if (orderByComparator != null) {
7359                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7360    
7361                            if (orderByConditionFields.length > 0) {
7362                                    query.append(WHERE_AND);
7363                            }
7364    
7365                            for (int i = 0; i < orderByConditionFields.length; i++) {
7366                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7367                                    query.append(orderByConditionFields[i]);
7368    
7369                                    if ((i + 1) < orderByConditionFields.length) {
7370                                            if (orderByComparator.isAscending() ^ previous) {
7371                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7372                                            }
7373                                            else {
7374                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7375                                            }
7376                                    }
7377                                    else {
7378                                            if (orderByComparator.isAscending() ^ previous) {
7379                                                    query.append(WHERE_GREATER_THAN);
7380                                            }
7381                                            else {
7382                                                    query.append(WHERE_LESSER_THAN);
7383                                            }
7384                                    }
7385                            }
7386    
7387                            query.append(ORDER_BY_CLAUSE);
7388    
7389                            String[] orderByFields = orderByComparator.getOrderByFields();
7390    
7391                            for (int i = 0; i < orderByFields.length; i++) {
7392                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7393                                    query.append(orderByFields[i]);
7394    
7395                                    if ((i + 1) < orderByFields.length) {
7396                                            if (orderByComparator.isAscending() ^ previous) {
7397                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7398                                            }
7399                                            else {
7400                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7401                                            }
7402                                    }
7403                                    else {
7404                                            if (orderByComparator.isAscending() ^ previous) {
7405                                                    query.append(ORDER_BY_ASC);
7406                                            }
7407                                            else {
7408                                                    query.append(ORDER_BY_DESC);
7409                                            }
7410                                    }
7411                            }
7412                    }
7413                    else {
7414                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7415                    }
7416    
7417                    String sql = query.toString();
7418    
7419                    Query q = session.createQuery(sql);
7420    
7421                    q.setFirstResult(0);
7422                    q.setMaxResults(2);
7423    
7424                    QueryPos qPos = QueryPos.getInstance(q);
7425    
7426                    qPos.add(groupId);
7427    
7428                    qPos.add(folderId);
7429    
7430                    if (orderByComparator != null) {
7431                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7432    
7433                            for (Object value : values) {
7434                                    qPos.add(value);
7435                            }
7436                    }
7437    
7438                    List<JournalArticle> list = q.list();
7439    
7440                    if (list.size() == 2) {
7441                            return list.get(1);
7442                    }
7443                    else {
7444                            return null;
7445                    }
7446            }
7447    
7448            /**
7449             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7450             *
7451             * @param groupId the group ID
7452             * @param folderId the folder ID
7453             * @return the matching journal articles that the user has permission to view
7454             * @throws SystemException if a system exception occurred
7455             */
7456            public List<JournalArticle> filterFindByG_F(long groupId, long folderId)
7457                    throws SystemException {
7458                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
7459                            QueryUtil.ALL_POS, null);
7460            }
7461    
7462            /**
7463             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7464             *
7465             * <p>
7466             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7467             * </p>
7468             *
7469             * @param groupId the group ID
7470             * @param folderId the folder ID
7471             * @param start the lower bound of the range of journal articles
7472             * @param end the upper bound of the range of journal articles (not inclusive)
7473             * @return the range of matching journal articles that the user has permission to view
7474             * @throws SystemException if a system exception occurred
7475             */
7476            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
7477                    int start, int end) throws SystemException {
7478                    return filterFindByG_F(groupId, folderId, start, end, null);
7479            }
7480    
7481            /**
7482             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63;.
7483             *
7484             * <p>
7485             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7486             * </p>
7487             *
7488             * @param groupId the group ID
7489             * @param folderId the folder ID
7490             * @param start the lower bound of the range of journal articles
7491             * @param end the upper bound of the range of journal articles (not inclusive)
7492             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7493             * @return the ordered range of matching journal articles that the user has permission to view
7494             * @throws SystemException if a system exception occurred
7495             */
7496            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
7497                    int start, int end, OrderByComparator orderByComparator)
7498                    throws SystemException {
7499                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7500                            return findByG_F(groupId, folderId, start, end, orderByComparator);
7501                    }
7502    
7503                    StringBundler query = null;
7504    
7505                    if (orderByComparator != null) {
7506                            query = new StringBundler(4 +
7507                                            (orderByComparator.getOrderByFields().length * 3));
7508                    }
7509                    else {
7510                            query = new StringBundler(4);
7511                    }
7512    
7513                    if (getDB().isSupportsInlineDistinct()) {
7514                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7515                    }
7516                    else {
7517                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7518                    }
7519    
7520                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7521    
7522                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7523    
7524                    if (!getDB().isSupportsInlineDistinct()) {
7525                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7526                    }
7527    
7528                    if (orderByComparator != null) {
7529                            if (getDB().isSupportsInlineDistinct()) {
7530                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7531                                            orderByComparator, true);
7532                            }
7533                            else {
7534                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7535                                            orderByComparator, true);
7536                            }
7537                    }
7538                    else {
7539                            if (getDB().isSupportsInlineDistinct()) {
7540                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7541                            }
7542                            else {
7543                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7544                            }
7545                    }
7546    
7547                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7548                                    JournalArticle.class.getName(),
7549                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7550    
7551                    Session session = null;
7552    
7553                    try {
7554                            session = openSession();
7555    
7556                            SQLQuery q = session.createSQLQuery(sql);
7557    
7558                            if (getDB().isSupportsInlineDistinct()) {
7559                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7560                            }
7561                            else {
7562                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7563                            }
7564    
7565                            QueryPos qPos = QueryPos.getInstance(q);
7566    
7567                            qPos.add(groupId);
7568    
7569                            qPos.add(folderId);
7570    
7571                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7572                                    end);
7573                    }
7574                    catch (Exception e) {
7575                            throw processException(e);
7576                    }
7577                    finally {
7578                            closeSession(session);
7579                    }
7580            }
7581    
7582            /**
7583             * 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;.
7584             *
7585             * @param id the primary key of the current journal article
7586             * @param groupId the group ID
7587             * @param folderId the folder ID
7588             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7589             * @return the previous, current, and next journal article
7590             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7591             * @throws SystemException if a system exception occurred
7592             */
7593            public JournalArticle[] filterFindByG_F_PrevAndNext(long id, long groupId,
7594                    long folderId, OrderByComparator orderByComparator)
7595                    throws NoSuchArticleException, SystemException {
7596                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7597                            return findByG_F_PrevAndNext(id, groupId, folderId,
7598                                    orderByComparator);
7599                    }
7600    
7601                    JournalArticle journalArticle = findByPrimaryKey(id);
7602    
7603                    Session session = null;
7604    
7605                    try {
7606                            session = openSession();
7607    
7608                            JournalArticle[] array = new JournalArticleImpl[3];
7609    
7610                            array[0] = filterGetByG_F_PrevAndNext(session, journalArticle,
7611                                            groupId, folderId, orderByComparator, true);
7612    
7613                            array[1] = journalArticle;
7614    
7615                            array[2] = filterGetByG_F_PrevAndNext(session, journalArticle,
7616                                            groupId, folderId, orderByComparator, false);
7617    
7618                            return array;
7619                    }
7620                    catch (Exception e) {
7621                            throw processException(e);
7622                    }
7623                    finally {
7624                            closeSession(session);
7625                    }
7626            }
7627    
7628            protected JournalArticle filterGetByG_F_PrevAndNext(Session session,
7629                    JournalArticle journalArticle, long groupId, long folderId,
7630                    OrderByComparator orderByComparator, boolean previous) {
7631                    StringBundler query = null;
7632    
7633                    if (orderByComparator != null) {
7634                            query = new StringBundler(6 +
7635                                            (orderByComparator.getOrderByFields().length * 6));
7636                    }
7637                    else {
7638                            query = new StringBundler(3);
7639                    }
7640    
7641                    if (getDB().isSupportsInlineDistinct()) {
7642                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7643                    }
7644                    else {
7645                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7646                    }
7647    
7648                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7649    
7650                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7651    
7652                    if (!getDB().isSupportsInlineDistinct()) {
7653                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7654                    }
7655    
7656                    if (orderByComparator != null) {
7657                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7658    
7659                            if (orderByConditionFields.length > 0) {
7660                                    query.append(WHERE_AND);
7661                            }
7662    
7663                            for (int i = 0; i < orderByConditionFields.length; i++) {
7664                                    if (getDB().isSupportsInlineDistinct()) {
7665                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7666                                    }
7667                                    else {
7668                                            query.append(_ORDER_BY_ENTITY_TABLE);
7669                                    }
7670    
7671                                    query.append(orderByConditionFields[i]);
7672    
7673                                    if ((i + 1) < orderByConditionFields.length) {
7674                                            if (orderByComparator.isAscending() ^ previous) {
7675                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7676                                            }
7677                                            else {
7678                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7679                                            }
7680                                    }
7681                                    else {
7682                                            if (orderByComparator.isAscending() ^ previous) {
7683                                                    query.append(WHERE_GREATER_THAN);
7684                                            }
7685                                            else {
7686                                                    query.append(WHERE_LESSER_THAN);
7687                                            }
7688                                    }
7689                            }
7690    
7691                            query.append(ORDER_BY_CLAUSE);
7692    
7693                            String[] orderByFields = orderByComparator.getOrderByFields();
7694    
7695                            for (int i = 0; i < orderByFields.length; i++) {
7696                                    if (getDB().isSupportsInlineDistinct()) {
7697                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7698                                    }
7699                                    else {
7700                                            query.append(_ORDER_BY_ENTITY_TABLE);
7701                                    }
7702    
7703                                    query.append(orderByFields[i]);
7704    
7705                                    if ((i + 1) < orderByFields.length) {
7706                                            if (orderByComparator.isAscending() ^ previous) {
7707                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7708                                            }
7709                                            else {
7710                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7711                                            }
7712                                    }
7713                                    else {
7714                                            if (orderByComparator.isAscending() ^ previous) {
7715                                                    query.append(ORDER_BY_ASC);
7716                                            }
7717                                            else {
7718                                                    query.append(ORDER_BY_DESC);
7719                                            }
7720                                    }
7721                            }
7722                    }
7723                    else {
7724                            if (getDB().isSupportsInlineDistinct()) {
7725                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7726                            }
7727                            else {
7728                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7729                            }
7730                    }
7731    
7732                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7733                                    JournalArticle.class.getName(),
7734                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7735    
7736                    SQLQuery q = session.createSQLQuery(sql);
7737    
7738                    q.setFirstResult(0);
7739                    q.setMaxResults(2);
7740    
7741                    if (getDB().isSupportsInlineDistinct()) {
7742                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7743                    }
7744                    else {
7745                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7746                    }
7747    
7748                    QueryPos qPos = QueryPos.getInstance(q);
7749    
7750                    qPos.add(groupId);
7751    
7752                    qPos.add(folderId);
7753    
7754                    if (orderByComparator != null) {
7755                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7756    
7757                            for (Object value : values) {
7758                                    qPos.add(value);
7759                            }
7760                    }
7761    
7762                    List<JournalArticle> list = q.list();
7763    
7764                    if (list.size() == 2) {
7765                            return list.get(1);
7766                    }
7767                    else {
7768                            return null;
7769                    }
7770            }
7771    
7772            /**
7773             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7774             *
7775             * @param groupId the group ID
7776             * @param folderIds the folder IDs
7777             * @return the matching journal articles that the user has permission to view
7778             * @throws SystemException if a system exception occurred
7779             */
7780            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds)
7781                    throws SystemException {
7782                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
7783                            QueryUtil.ALL_POS, null);
7784            }
7785    
7786            /**
7787             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7788             *
7789             * <p>
7790             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7791             * </p>
7792             *
7793             * @param groupId the group ID
7794             * @param folderIds the folder IDs
7795             * @param start the lower bound of the range of journal articles
7796             * @param end the upper bound of the range of journal articles (not inclusive)
7797             * @return the range of matching journal articles that the user has permission to view
7798             * @throws SystemException if a system exception occurred
7799             */
7800            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
7801                    int start, int end) throws SystemException {
7802                    return filterFindByG_F(groupId, folderIds, start, end, null);
7803            }
7804    
7805            /**
7806             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7807             *
7808             * <p>
7809             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7810             * </p>
7811             *
7812             * @param groupId the group ID
7813             * @param folderIds the folder IDs
7814             * @param start the lower bound of the range of journal articles
7815             * @param end the upper bound of the range of journal articles (not inclusive)
7816             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7817             * @return the ordered range of matching journal articles that the user has permission to view
7818             * @throws SystemException if a system exception occurred
7819             */
7820            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
7821                    int start, int end, OrderByComparator orderByComparator)
7822                    throws SystemException {
7823                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7824                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
7825                    }
7826    
7827                    StringBundler query = new StringBundler();
7828    
7829                    if (getDB().isSupportsInlineDistinct()) {
7830                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7831                    }
7832                    else {
7833                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7834                    }
7835    
7836                    boolean conjunctionable = false;
7837    
7838                    if (conjunctionable) {
7839                            query.append(WHERE_AND);
7840                    }
7841    
7842                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7843    
7844                    conjunctionable = true;
7845    
7846                    if ((folderIds == null) || (folderIds.length > 0)) {
7847                            if (conjunctionable) {
7848                                    query.append(WHERE_AND);
7849                            }
7850    
7851                            query.append(StringPool.OPEN_PARENTHESIS);
7852    
7853                            for (int i = 0; i < folderIds.length; i++) {
7854                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7855    
7856                                    if ((i + 1) < folderIds.length) {
7857                                            query.append(WHERE_OR);
7858                                    }
7859                            }
7860    
7861                            query.append(StringPool.CLOSE_PARENTHESIS);
7862    
7863                            conjunctionable = true;
7864                    }
7865    
7866                    if (!getDB().isSupportsInlineDistinct()) {
7867                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7868                    }
7869    
7870                    if (orderByComparator != null) {
7871                            if (getDB().isSupportsInlineDistinct()) {
7872                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7873                                            orderByComparator, true);
7874                            }
7875                            else {
7876                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7877                                            orderByComparator, true);
7878                            }
7879                    }
7880                    else {
7881                            if (getDB().isSupportsInlineDistinct()) {
7882                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7883                            }
7884                            else {
7885                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7886                            }
7887                    }
7888    
7889                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7890                                    JournalArticle.class.getName(),
7891                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7892    
7893                    Session session = null;
7894    
7895                    try {
7896                            session = openSession();
7897    
7898                            SQLQuery q = session.createSQLQuery(sql);
7899    
7900                            if (getDB().isSupportsInlineDistinct()) {
7901                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7902                            }
7903                            else {
7904                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7905                            }
7906    
7907                            QueryPos qPos = QueryPos.getInstance(q);
7908    
7909                            qPos.add(groupId);
7910    
7911                            if (folderIds != null) {
7912                                    qPos.add(folderIds);
7913                            }
7914    
7915                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7916                                    end);
7917                    }
7918                    catch (Exception e) {
7919                            throw processException(e);
7920                    }
7921                    finally {
7922                            closeSession(session);
7923                    }
7924            }
7925    
7926            /**
7927             * Returns all the journal articles where groupId = &#63; and folderId = any &#63;.
7928             *
7929             * <p>
7930             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7931             * </p>
7932             *
7933             * @param groupId the group ID
7934             * @param folderIds the folder IDs
7935             * @return the matching journal articles
7936             * @throws SystemException if a system exception occurred
7937             */
7938            public List<JournalArticle> findByG_F(long groupId, long[] folderIds)
7939                    throws SystemException {
7940                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
7941                            QueryUtil.ALL_POS, null);
7942            }
7943    
7944            /**
7945             * Returns a range of all the journal articles where groupId = &#63; and folderId = any &#63;.
7946             *
7947             * <p>
7948             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7949             * </p>
7950             *
7951             * @param groupId the group ID
7952             * @param folderIds the folder IDs
7953             * @param start the lower bound of the range of journal articles
7954             * @param end the upper bound of the range of journal articles (not inclusive)
7955             * @return the range of matching journal articles
7956             * @throws SystemException if a system exception occurred
7957             */
7958            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
7959                    int start, int end) throws SystemException {
7960                    return findByG_F(groupId, folderIds, start, end, null);
7961            }
7962    
7963            /**
7964             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = any &#63;.
7965             *
7966             * <p>
7967             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7968             * </p>
7969             *
7970             * @param groupId the group ID
7971             * @param folderIds the folder IDs
7972             * @param start the lower bound of the range of journal articles
7973             * @param end the upper bound of the range of journal articles (not inclusive)
7974             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7975             * @return the ordered range of matching journal articles
7976             * @throws SystemException if a system exception occurred
7977             */
7978            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
7979                    int start, int end, OrderByComparator orderByComparator)
7980                    throws SystemException {
7981                    if ((folderIds != null) && (folderIds.length == 1)) {
7982                            return findByG_F(groupId, folderIds[0], start, end,
7983                                    orderByComparator);
7984                    }
7985    
7986                    boolean pagination = true;
7987                    Object[] finderArgs = null;
7988    
7989                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7990                                    (orderByComparator == null)) {
7991                            pagination = false;
7992                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
7993                    }
7994                    else {
7995                            finderArgs = new Object[] {
7996                                            groupId, StringUtil.merge(folderIds),
7997                                            
7998                                            start, end, orderByComparator
7999                                    };
8000                    }
8001    
8002                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8003                                    finderArgs, this);
8004    
8005                    if ((list != null) && !list.isEmpty()) {
8006                            for (JournalArticle journalArticle : list) {
8007                                    if ((groupId != journalArticle.getGroupId()) ||
8008                                                    !ArrayUtil.contains(folderIds,
8009                                                            journalArticle.getFolderId())) {
8010                                            list = null;
8011    
8012                                            break;
8013                                    }
8014                            }
8015                    }
8016    
8017                    if (list == null) {
8018                            StringBundler query = new StringBundler();
8019    
8020                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8021    
8022                            boolean conjunctionable = false;
8023    
8024                            if (conjunctionable) {
8025                                    query.append(WHERE_AND);
8026                            }
8027    
8028                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8029    
8030                            conjunctionable = true;
8031    
8032                            if ((folderIds == null) || (folderIds.length > 0)) {
8033                                    if (conjunctionable) {
8034                                            query.append(WHERE_AND);
8035                                    }
8036    
8037                                    query.append(StringPool.OPEN_PARENTHESIS);
8038    
8039                                    for (int i = 0; i < folderIds.length; i++) {
8040                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8041    
8042                                            if ((i + 1) < folderIds.length) {
8043                                                    query.append(WHERE_OR);
8044                                            }
8045                                    }
8046    
8047                                    query.append(StringPool.CLOSE_PARENTHESIS);
8048    
8049                                    conjunctionable = true;
8050                            }
8051    
8052                            if (orderByComparator != null) {
8053                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8054                                            orderByComparator);
8055                            }
8056                            else
8057                             if (pagination) {
8058                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8059                            }
8060    
8061                            String sql = query.toString();
8062    
8063                            Session session = null;
8064    
8065                            try {
8066                                    session = openSession();
8067    
8068                                    Query q = session.createQuery(sql);
8069    
8070                                    QueryPos qPos = QueryPos.getInstance(q);
8071    
8072                                    qPos.add(groupId);
8073    
8074                                    if (folderIds != null) {
8075                                            qPos.add(folderIds);
8076                                    }
8077    
8078                                    if (!pagination) {
8079                                            list = (List<JournalArticle>)QueryUtil.list(q,
8080                                                            getDialect(), start, end, false);
8081    
8082                                            Collections.sort(list);
8083    
8084                                            list = new UnmodifiableList<JournalArticle>(list);
8085                                    }
8086                                    else {
8087                                            list = (List<JournalArticle>)QueryUtil.list(q,
8088                                                            getDialect(), start, end);
8089                                    }
8090    
8091                                    cacheResult(list);
8092    
8093                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8094                                            finderArgs, list);
8095                            }
8096                            catch (Exception e) {
8097                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8098                                            finderArgs);
8099    
8100                                    throw processException(e);
8101                            }
8102                            finally {
8103                                    closeSession(session);
8104                            }
8105                    }
8106    
8107                    return list;
8108            }
8109    
8110            /**
8111             * Removes all the journal articles where groupId = &#63; and folderId = &#63; from the database.
8112             *
8113             * @param groupId the group ID
8114             * @param folderId the folder ID
8115             * @throws SystemException if a system exception occurred
8116             */
8117            public void removeByG_F(long groupId, long folderId)
8118                    throws SystemException {
8119                    for (JournalArticle journalArticle : findByG_F(groupId, folderId,
8120                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8121                            remove(journalArticle);
8122                    }
8123            }
8124    
8125            /**
8126             * Returns the number of journal articles where groupId = &#63; and folderId = &#63;.
8127             *
8128             * @param groupId the group ID
8129             * @param folderId the folder ID
8130             * @return the number of matching journal articles
8131             * @throws SystemException if a system exception occurred
8132             */
8133            public int countByG_F(long groupId, long folderId)
8134                    throws SystemException {
8135                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
8136    
8137                    Object[] finderArgs = new Object[] { groupId, folderId };
8138    
8139                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8140                                    this);
8141    
8142                    if (count == null) {
8143                            StringBundler query = new StringBundler(3);
8144    
8145                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8146    
8147                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8148    
8149                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8150    
8151                            String sql = query.toString();
8152    
8153                            Session session = null;
8154    
8155                            try {
8156                                    session = openSession();
8157    
8158                                    Query q = session.createQuery(sql);
8159    
8160                                    QueryPos qPos = QueryPos.getInstance(q);
8161    
8162                                    qPos.add(groupId);
8163    
8164                                    qPos.add(folderId);
8165    
8166                                    count = (Long)q.uniqueResult();
8167    
8168                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8169                            }
8170                            catch (Exception e) {
8171                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8172    
8173                                    throw processException(e);
8174                            }
8175                            finally {
8176                                    closeSession(session);
8177                            }
8178                    }
8179    
8180                    return count.intValue();
8181            }
8182    
8183            /**
8184             * Returns the number of journal articles where groupId = &#63; and folderId = any &#63;.
8185             *
8186             * @param groupId the group ID
8187             * @param folderIds the folder IDs
8188             * @return the number of matching journal articles
8189             * @throws SystemException if a system exception occurred
8190             */
8191            public int countByG_F(long groupId, long[] folderIds)
8192                    throws SystemException {
8193                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
8194    
8195                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
8196                                    finderArgs, this);
8197    
8198                    if (count == null) {
8199                            StringBundler query = new StringBundler();
8200    
8201                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8202    
8203                            boolean conjunctionable = false;
8204    
8205                            if (conjunctionable) {
8206                                    query.append(WHERE_AND);
8207                            }
8208    
8209                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8210    
8211                            conjunctionable = true;
8212    
8213                            if ((folderIds == null) || (folderIds.length > 0)) {
8214                                    if (conjunctionable) {
8215                                            query.append(WHERE_AND);
8216                                    }
8217    
8218                                    query.append(StringPool.OPEN_PARENTHESIS);
8219    
8220                                    for (int i = 0; i < folderIds.length; i++) {
8221                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8222    
8223                                            if ((i + 1) < folderIds.length) {
8224                                                    query.append(WHERE_OR);
8225                                            }
8226                                    }
8227    
8228                                    query.append(StringPool.CLOSE_PARENTHESIS);
8229    
8230                                    conjunctionable = true;
8231                            }
8232    
8233                            String sql = query.toString();
8234    
8235                            Session session = null;
8236    
8237                            try {
8238                                    session = openSession();
8239    
8240                                    Query q = session.createQuery(sql);
8241    
8242                                    QueryPos qPos = QueryPos.getInstance(q);
8243    
8244                                    qPos.add(groupId);
8245    
8246                                    if (folderIds != null) {
8247                                            qPos.add(folderIds);
8248                                    }
8249    
8250                                    count = (Long)q.uniqueResult();
8251    
8252                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
8253                                            finderArgs, count);
8254                            }
8255                            catch (Exception e) {
8256                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
8257                                            finderArgs);
8258    
8259                                    throw processException(e);
8260                            }
8261                            finally {
8262                                    closeSession(session);
8263                            }
8264                    }
8265    
8266                    return count.intValue();
8267            }
8268    
8269            /**
8270             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8271             *
8272             * @param groupId the group ID
8273             * @param folderId the folder ID
8274             * @return the number of matching journal articles that the user has permission to view
8275             * @throws SystemException if a system exception occurred
8276             */
8277            public int filterCountByG_F(long groupId, long folderId)
8278                    throws SystemException {
8279                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8280                            return countByG_F(groupId, folderId);
8281                    }
8282    
8283                    StringBundler query = new StringBundler(3);
8284    
8285                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8286    
8287                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8288    
8289                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8290    
8291                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8292                                    JournalArticle.class.getName(),
8293                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8294    
8295                    Session session = null;
8296    
8297                    try {
8298                            session = openSession();
8299    
8300                            SQLQuery q = session.createSQLQuery(sql);
8301    
8302                            q.addScalar(COUNT_COLUMN_NAME,
8303                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8304    
8305                            QueryPos qPos = QueryPos.getInstance(q);
8306    
8307                            qPos.add(groupId);
8308    
8309                            qPos.add(folderId);
8310    
8311                            Long count = (Long)q.uniqueResult();
8312    
8313                            return count.intValue();
8314                    }
8315                    catch (Exception e) {
8316                            throw processException(e);
8317                    }
8318                    finally {
8319                            closeSession(session);
8320                    }
8321            }
8322    
8323            /**
8324             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8325             *
8326             * @param groupId the group ID
8327             * @param folderIds the folder IDs
8328             * @return the number of matching journal articles that the user has permission to view
8329             * @throws SystemException if a system exception occurred
8330             */
8331            public int filterCountByG_F(long groupId, long[] folderIds)
8332                    throws SystemException {
8333                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8334                            return countByG_F(groupId, folderIds);
8335                    }
8336    
8337                    StringBundler query = new StringBundler();
8338    
8339                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8340    
8341                    boolean conjunctionable = false;
8342    
8343                    if (conjunctionable) {
8344                            query.append(WHERE_AND);
8345                    }
8346    
8347                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8348    
8349                    conjunctionable = true;
8350    
8351                    if ((folderIds == null) || (folderIds.length > 0)) {
8352                            if (conjunctionable) {
8353                                    query.append(WHERE_AND);
8354                            }
8355    
8356                            query.append(StringPool.OPEN_PARENTHESIS);
8357    
8358                            for (int i = 0; i < folderIds.length; i++) {
8359                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8360    
8361                                    if ((i + 1) < folderIds.length) {
8362                                            query.append(WHERE_OR);
8363                                    }
8364                            }
8365    
8366                            query.append(StringPool.CLOSE_PARENTHESIS);
8367    
8368                            conjunctionable = true;
8369                    }
8370    
8371                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8372                                    JournalArticle.class.getName(),
8373                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8374    
8375                    Session session = null;
8376    
8377                    try {
8378                            session = openSession();
8379    
8380                            SQLQuery q = session.createSQLQuery(sql);
8381    
8382                            q.addScalar(COUNT_COLUMN_NAME,
8383                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8384    
8385                            QueryPos qPos = QueryPos.getInstance(q);
8386    
8387                            qPos.add(groupId);
8388    
8389                            if (folderIds != null) {
8390                                    qPos.add(folderIds);
8391                            }
8392    
8393                            Long count = (Long)q.uniqueResult();
8394    
8395                            return count.intValue();
8396                    }
8397                    catch (Exception e) {
8398                            throw processException(e);
8399                    }
8400                    finally {
8401                            closeSession(session);
8402                    }
8403            }
8404    
8405            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalArticle.groupId = ? AND ";
8406            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
8407                    removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
8408            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "journalArticle.folderId = ?";
8409            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
8410                    removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
8411            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8412                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8413                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
8414                            "findByG_A",
8415                            new String[] {
8416                                    Long.class.getName(), String.class.getName(),
8417                                    
8418                            Integer.class.getName(), Integer.class.getName(),
8419                                    OrderByComparator.class.getName()
8420                            });
8421            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8422                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
8423                            JournalArticleImpl.class,
8424                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
8425                            new String[] { Long.class.getName(), String.class.getName() },
8426                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
8427                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
8428                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
8429            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
8430                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
8431                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
8432                            new String[] { Long.class.getName(), String.class.getName() });
8433    
8434            /**
8435             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
8436             *
8437             * @param groupId the group ID
8438             * @param articleId the article ID
8439             * @return the matching journal articles
8440             * @throws SystemException if a system exception occurred
8441             */
8442            public List<JournalArticle> findByG_A(long groupId, String articleId)
8443                    throws SystemException {
8444                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
8445                            QueryUtil.ALL_POS, null);
8446            }
8447    
8448            /**
8449             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
8450             *
8451             * <p>
8452             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8453             * </p>
8454             *
8455             * @param groupId the group ID
8456             * @param articleId the article ID
8457             * @param start the lower bound of the range of journal articles
8458             * @param end the upper bound of the range of journal articles (not inclusive)
8459             * @return the range of matching journal articles
8460             * @throws SystemException if a system exception occurred
8461             */
8462            public List<JournalArticle> findByG_A(long groupId, String articleId,
8463                    int start, int end) throws SystemException {
8464                    return findByG_A(groupId, articleId, start, end, null);
8465            }
8466    
8467            /**
8468             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
8469             *
8470             * <p>
8471             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8472             * </p>
8473             *
8474             * @param groupId the group ID
8475             * @param articleId the article ID
8476             * @param start the lower bound of the range of journal articles
8477             * @param end the upper bound of the range of journal articles (not inclusive)
8478             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8479             * @return the ordered range of matching journal articles
8480             * @throws SystemException if a system exception occurred
8481             */
8482            public List<JournalArticle> findByG_A(long groupId, String articleId,
8483                    int start, int end, OrderByComparator orderByComparator)
8484                    throws SystemException {
8485                    boolean pagination = true;
8486                    FinderPath finderPath = null;
8487                    Object[] finderArgs = null;
8488    
8489                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8490                                    (orderByComparator == null)) {
8491                            pagination = false;
8492                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
8493                            finderArgs = new Object[] { groupId, articleId };
8494                    }
8495                    else {
8496                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
8497                            finderArgs = new Object[] {
8498                                            groupId, articleId,
8499                                            
8500                                            start, end, orderByComparator
8501                                    };
8502                    }
8503    
8504                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8505                                    finderArgs, this);
8506    
8507                    if ((list != null) && !list.isEmpty()) {
8508                            for (JournalArticle journalArticle : list) {
8509                                    if ((groupId != journalArticle.getGroupId()) ||
8510                                                    !Validator.equals(articleId,
8511                                                            journalArticle.getArticleId())) {
8512                                            list = null;
8513    
8514                                            break;
8515                                    }
8516                            }
8517                    }
8518    
8519                    if (list == null) {
8520                            StringBundler query = null;
8521    
8522                            if (orderByComparator != null) {
8523                                    query = new StringBundler(4 +
8524                                                    (orderByComparator.getOrderByFields().length * 3));
8525                            }
8526                            else {
8527                                    query = new StringBundler(4);
8528                            }
8529    
8530                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8531    
8532                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8533    
8534                            boolean bindArticleId = false;
8535    
8536                            if (articleId == null) {
8537                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8538                            }
8539                            else if (articleId.equals(StringPool.BLANK)) {
8540                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8541                            }
8542                            else {
8543                                    bindArticleId = true;
8544    
8545                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8546                            }
8547    
8548                            if (orderByComparator != null) {
8549                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8550                                            orderByComparator);
8551                            }
8552                            else
8553                             if (pagination) {
8554                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8555                            }
8556    
8557                            String sql = query.toString();
8558    
8559                            Session session = null;
8560    
8561                            try {
8562                                    session = openSession();
8563    
8564                                    Query q = session.createQuery(sql);
8565    
8566                                    QueryPos qPos = QueryPos.getInstance(q);
8567    
8568                                    qPos.add(groupId);
8569    
8570                                    if (bindArticleId) {
8571                                            qPos.add(articleId);
8572                                    }
8573    
8574                                    if (!pagination) {
8575                                            list = (List<JournalArticle>)QueryUtil.list(q,
8576                                                            getDialect(), start, end, false);
8577    
8578                                            Collections.sort(list);
8579    
8580                                            list = new UnmodifiableList<JournalArticle>(list);
8581                                    }
8582                                    else {
8583                                            list = (List<JournalArticle>)QueryUtil.list(q,
8584                                                            getDialect(), start, end);
8585                                    }
8586    
8587                                    cacheResult(list);
8588    
8589                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8590                            }
8591                            catch (Exception e) {
8592                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8593    
8594                                    throw processException(e);
8595                            }
8596                            finally {
8597                                    closeSession(session);
8598                            }
8599                    }
8600    
8601                    return list;
8602            }
8603    
8604            /**
8605             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8606             *
8607             * @param groupId the group ID
8608             * @param articleId the article ID
8609             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8610             * @return the first matching journal article
8611             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8612             * @throws SystemException if a system exception occurred
8613             */
8614            public JournalArticle findByG_A_First(long groupId, String articleId,
8615                    OrderByComparator orderByComparator)
8616                    throws NoSuchArticleException, SystemException {
8617                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
8618                                    orderByComparator);
8619    
8620                    if (journalArticle != null) {
8621                            return journalArticle;
8622                    }
8623    
8624                    StringBundler msg = new StringBundler(6);
8625    
8626                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8627    
8628                    msg.append("groupId=");
8629                    msg.append(groupId);
8630    
8631                    msg.append(", articleId=");
8632                    msg.append(articleId);
8633    
8634                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8635    
8636                    throw new NoSuchArticleException(msg.toString());
8637            }
8638    
8639            /**
8640             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8641             *
8642             * @param groupId the group ID
8643             * @param articleId the article ID
8644             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8645             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
8646             * @throws SystemException if a system exception occurred
8647             */
8648            public JournalArticle fetchByG_A_First(long groupId, String articleId,
8649                    OrderByComparator orderByComparator) throws SystemException {
8650                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
8651                                    orderByComparator);
8652    
8653                    if (!list.isEmpty()) {
8654                            return list.get(0);
8655                    }
8656    
8657                    return null;
8658            }
8659    
8660            /**
8661             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8662             *
8663             * @param groupId the group ID
8664             * @param articleId the article ID
8665             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8666             * @return the last matching journal article
8667             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8668             * @throws SystemException if a system exception occurred
8669             */
8670            public JournalArticle findByG_A_Last(long groupId, String articleId,
8671                    OrderByComparator orderByComparator)
8672                    throws NoSuchArticleException, SystemException {
8673                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
8674                                    orderByComparator);
8675    
8676                    if (journalArticle != null) {
8677                            return journalArticle;
8678                    }
8679    
8680                    StringBundler msg = new StringBundler(6);
8681    
8682                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8683    
8684                    msg.append("groupId=");
8685                    msg.append(groupId);
8686    
8687                    msg.append(", articleId=");
8688                    msg.append(articleId);
8689    
8690                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8691    
8692                    throw new NoSuchArticleException(msg.toString());
8693            }
8694    
8695            /**
8696             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8697             *
8698             * @param groupId the group ID
8699             * @param articleId the article ID
8700             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8701             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
8702             * @throws SystemException if a system exception occurred
8703             */
8704            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
8705                    OrderByComparator orderByComparator) throws SystemException {
8706                    int count = countByG_A(groupId, articleId);
8707    
8708                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
8709                                    count, orderByComparator);
8710    
8711                    if (!list.isEmpty()) {
8712                            return list.get(0);
8713                    }
8714    
8715                    return null;
8716            }
8717    
8718            /**
8719             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8720             *
8721             * @param id the primary key of the current journal article
8722             * @param groupId the group ID
8723             * @param articleId the article ID
8724             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8725             * @return the previous, current, and next journal article
8726             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8727             * @throws SystemException if a system exception occurred
8728             */
8729            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
8730                    String articleId, OrderByComparator orderByComparator)
8731                    throws NoSuchArticleException, SystemException {
8732                    JournalArticle journalArticle = findByPrimaryKey(id);
8733    
8734                    Session session = null;
8735    
8736                    try {
8737                            session = openSession();
8738    
8739                            JournalArticle[] array = new JournalArticleImpl[3];
8740    
8741                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
8742                                            articleId, orderByComparator, true);
8743    
8744                            array[1] = journalArticle;
8745    
8746                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
8747                                            articleId, orderByComparator, false);
8748    
8749                            return array;
8750                    }
8751                    catch (Exception e) {
8752                            throw processException(e);
8753                    }
8754                    finally {
8755                            closeSession(session);
8756                    }
8757            }
8758    
8759            protected JournalArticle getByG_A_PrevAndNext(Session session,
8760                    JournalArticle journalArticle, long groupId, String articleId,
8761                    OrderByComparator orderByComparator, boolean previous) {
8762                    StringBundler query = null;
8763    
8764                    if (orderByComparator != null) {
8765                            query = new StringBundler(6 +
8766                                            (orderByComparator.getOrderByFields().length * 6));
8767                    }
8768                    else {
8769                            query = new StringBundler(3);
8770                    }
8771    
8772                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8773    
8774                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8775    
8776                    boolean bindArticleId = false;
8777    
8778                    if (articleId == null) {
8779                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8780                    }
8781                    else if (articleId.equals(StringPool.BLANK)) {
8782                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8783                    }
8784                    else {
8785                            bindArticleId = true;
8786    
8787                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8788                    }
8789    
8790                    if (orderByComparator != null) {
8791                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8792    
8793                            if (orderByConditionFields.length > 0) {
8794                                    query.append(WHERE_AND);
8795                            }
8796    
8797                            for (int i = 0; i < orderByConditionFields.length; i++) {
8798                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8799                                    query.append(orderByConditionFields[i]);
8800    
8801                                    if ((i + 1) < orderByConditionFields.length) {
8802                                            if (orderByComparator.isAscending() ^ previous) {
8803                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8804                                            }
8805                                            else {
8806                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8807                                            }
8808                                    }
8809                                    else {
8810                                            if (orderByComparator.isAscending() ^ previous) {
8811                                                    query.append(WHERE_GREATER_THAN);
8812                                            }
8813                                            else {
8814                                                    query.append(WHERE_LESSER_THAN);
8815                                            }
8816                                    }
8817                            }
8818    
8819                            query.append(ORDER_BY_CLAUSE);
8820    
8821                            String[] orderByFields = orderByComparator.getOrderByFields();
8822    
8823                            for (int i = 0; i < orderByFields.length; i++) {
8824                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8825                                    query.append(orderByFields[i]);
8826    
8827                                    if ((i + 1) < orderByFields.length) {
8828                                            if (orderByComparator.isAscending() ^ previous) {
8829                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8830                                            }
8831                                            else {
8832                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8833                                            }
8834                                    }
8835                                    else {
8836                                            if (orderByComparator.isAscending() ^ previous) {
8837                                                    query.append(ORDER_BY_ASC);
8838                                            }
8839                                            else {
8840                                                    query.append(ORDER_BY_DESC);
8841                                            }
8842                                    }
8843                            }
8844                    }
8845                    else {
8846                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8847                    }
8848    
8849                    String sql = query.toString();
8850    
8851                    Query q = session.createQuery(sql);
8852    
8853                    q.setFirstResult(0);
8854                    q.setMaxResults(2);
8855    
8856                    QueryPos qPos = QueryPos.getInstance(q);
8857    
8858                    qPos.add(groupId);
8859    
8860                    if (bindArticleId) {
8861                            qPos.add(articleId);
8862                    }
8863    
8864                    if (orderByComparator != null) {
8865                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8866    
8867                            for (Object value : values) {
8868                                    qPos.add(value);
8869                            }
8870                    }
8871    
8872                    List<JournalArticle> list = q.list();
8873    
8874                    if (list.size() == 2) {
8875                            return list.get(1);
8876                    }
8877                    else {
8878                            return null;
8879                    }
8880            }
8881    
8882            /**
8883             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
8884             *
8885             * @param groupId the group ID
8886             * @param articleId the article ID
8887             * @return the matching journal articles that the user has permission to view
8888             * @throws SystemException if a system exception occurred
8889             */
8890            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
8891                    throws SystemException {
8892                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
8893                            QueryUtil.ALL_POS, null);
8894            }
8895    
8896            /**
8897             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
8898             *
8899             * <p>
8900             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8901             * </p>
8902             *
8903             * @param groupId the group ID
8904             * @param articleId the article ID
8905             * @param start the lower bound of the range of journal articles
8906             * @param end the upper bound of the range of journal articles (not inclusive)
8907             * @return the range of matching journal articles that the user has permission to view
8908             * @throws SystemException if a system exception occurred
8909             */
8910            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
8911                    int start, int end) throws SystemException {
8912                    return filterFindByG_A(groupId, articleId, start, end, null);
8913            }
8914    
8915            /**
8916             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
8917             *
8918             * <p>
8919             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8920             * </p>
8921             *
8922             * @param groupId the group ID
8923             * @param articleId the article ID
8924             * @param start the lower bound of the range of journal articles
8925             * @param end the upper bound of the range of journal articles (not inclusive)
8926             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8927             * @return the ordered range of matching journal articles that the user has permission to view
8928             * @throws SystemException if a system exception occurred
8929             */
8930            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
8931                    int start, int end, OrderByComparator orderByComparator)
8932                    throws SystemException {
8933                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8934                            return findByG_A(groupId, articleId, start, end, orderByComparator);
8935                    }
8936    
8937                    StringBundler query = null;
8938    
8939                    if (orderByComparator != null) {
8940                            query = new StringBundler(4 +
8941                                            (orderByComparator.getOrderByFields().length * 3));
8942                    }
8943                    else {
8944                            query = new StringBundler(4);
8945                    }
8946    
8947                    if (getDB().isSupportsInlineDistinct()) {
8948                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8949                    }
8950                    else {
8951                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8952                    }
8953    
8954                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8955    
8956                    boolean bindArticleId = false;
8957    
8958                    if (articleId == null) {
8959                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8960                    }
8961                    else if (articleId.equals(StringPool.BLANK)) {
8962                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8963                    }
8964                    else {
8965                            bindArticleId = true;
8966    
8967                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8968                    }
8969    
8970                    if (!getDB().isSupportsInlineDistinct()) {
8971                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8972                    }
8973    
8974                    if (orderByComparator != null) {
8975                            if (getDB().isSupportsInlineDistinct()) {
8976                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8977                                            orderByComparator, true);
8978                            }
8979                            else {
8980                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8981                                            orderByComparator, true);
8982                            }
8983                    }
8984                    else {
8985                            if (getDB().isSupportsInlineDistinct()) {
8986                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8987                            }
8988                            else {
8989                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8990                            }
8991                    }
8992    
8993                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8994                                    JournalArticle.class.getName(),
8995                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8996    
8997                    Session session = null;
8998    
8999                    try {
9000                            session = openSession();
9001    
9002                            SQLQuery q = session.createSQLQuery(sql);
9003    
9004                            if (getDB().isSupportsInlineDistinct()) {
9005                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9006                            }
9007                            else {
9008                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9009                            }
9010    
9011                            QueryPos qPos = QueryPos.getInstance(q);
9012    
9013                            qPos.add(groupId);
9014    
9015                            if (bindArticleId) {
9016                                    qPos.add(articleId);
9017                            }
9018    
9019                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9020                                    end);
9021                    }
9022                    catch (Exception e) {
9023                            throw processException(e);
9024                    }
9025                    finally {
9026                            closeSession(session);
9027                    }
9028            }
9029    
9030            /**
9031             * 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;.
9032             *
9033             * @param id the primary key of the current journal article
9034             * @param groupId the group ID
9035             * @param articleId the article ID
9036             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9037             * @return the previous, current, and next journal article
9038             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9039             * @throws SystemException if a system exception occurred
9040             */
9041            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
9042                    String articleId, OrderByComparator orderByComparator)
9043                    throws NoSuchArticleException, SystemException {
9044                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9045                            return findByG_A_PrevAndNext(id, groupId, articleId,
9046                                    orderByComparator);
9047                    }
9048    
9049                    JournalArticle journalArticle = findByPrimaryKey(id);
9050    
9051                    Session session = null;
9052    
9053                    try {
9054                            session = openSession();
9055    
9056                            JournalArticle[] array = new JournalArticleImpl[3];
9057    
9058                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
9059                                            groupId, articleId, orderByComparator, true);
9060    
9061                            array[1] = journalArticle;
9062    
9063                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
9064                                            groupId, articleId, orderByComparator, false);
9065    
9066                            return array;
9067                    }
9068                    catch (Exception e) {
9069                            throw processException(e);
9070                    }
9071                    finally {
9072                            closeSession(session);
9073                    }
9074            }
9075    
9076            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
9077                    JournalArticle journalArticle, long groupId, String articleId,
9078                    OrderByComparator orderByComparator, boolean previous) {
9079                    StringBundler query = null;
9080    
9081                    if (orderByComparator != null) {
9082                            query = new StringBundler(6 +
9083                                            (orderByComparator.getOrderByFields().length * 6));
9084                    }
9085                    else {
9086                            query = new StringBundler(3);
9087                    }
9088    
9089                    if (getDB().isSupportsInlineDistinct()) {
9090                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9091                    }
9092                    else {
9093                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9094                    }
9095    
9096                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9097    
9098                    boolean bindArticleId = false;
9099    
9100                    if (articleId == null) {
9101                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9102                    }
9103                    else if (articleId.equals(StringPool.BLANK)) {
9104                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9105                    }
9106                    else {
9107                            bindArticleId = true;
9108    
9109                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9110                    }
9111    
9112                    if (!getDB().isSupportsInlineDistinct()) {
9113                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9114                    }
9115    
9116                    if (orderByComparator != null) {
9117                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9118    
9119                            if (orderByConditionFields.length > 0) {
9120                                    query.append(WHERE_AND);
9121                            }
9122    
9123                            for (int i = 0; i < orderByConditionFields.length; i++) {
9124                                    if (getDB().isSupportsInlineDistinct()) {
9125                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9126                                    }
9127                                    else {
9128                                            query.append(_ORDER_BY_ENTITY_TABLE);
9129                                    }
9130    
9131                                    query.append(orderByConditionFields[i]);
9132    
9133                                    if ((i + 1) < orderByConditionFields.length) {
9134                                            if (orderByComparator.isAscending() ^ previous) {
9135                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9136                                            }
9137                                            else {
9138                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9139                                            }
9140                                    }
9141                                    else {
9142                                            if (orderByComparator.isAscending() ^ previous) {
9143                                                    query.append(WHERE_GREATER_THAN);
9144                                            }
9145                                            else {
9146                                                    query.append(WHERE_LESSER_THAN);
9147                                            }
9148                                    }
9149                            }
9150    
9151                            query.append(ORDER_BY_CLAUSE);
9152    
9153                            String[] orderByFields = orderByComparator.getOrderByFields();
9154    
9155                            for (int i = 0; i < orderByFields.length; i++) {
9156                                    if (getDB().isSupportsInlineDistinct()) {
9157                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9158                                    }
9159                                    else {
9160                                            query.append(_ORDER_BY_ENTITY_TABLE);
9161                                    }
9162    
9163                                    query.append(orderByFields[i]);
9164    
9165                                    if ((i + 1) < orderByFields.length) {
9166                                            if (orderByComparator.isAscending() ^ previous) {
9167                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9168                                            }
9169                                            else {
9170                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9171                                            }
9172                                    }
9173                                    else {
9174                                            if (orderByComparator.isAscending() ^ previous) {
9175                                                    query.append(ORDER_BY_ASC);
9176                                            }
9177                                            else {
9178                                                    query.append(ORDER_BY_DESC);
9179                                            }
9180                                    }
9181                            }
9182                    }
9183                    else {
9184                            if (getDB().isSupportsInlineDistinct()) {
9185                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9186                            }
9187                            else {
9188                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9189                            }
9190                    }
9191    
9192                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9193                                    JournalArticle.class.getName(),
9194                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9195    
9196                    SQLQuery q = session.createSQLQuery(sql);
9197    
9198                    q.setFirstResult(0);
9199                    q.setMaxResults(2);
9200    
9201                    if (getDB().isSupportsInlineDistinct()) {
9202                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9203                    }
9204                    else {
9205                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9206                    }
9207    
9208                    QueryPos qPos = QueryPos.getInstance(q);
9209    
9210                    qPos.add(groupId);
9211    
9212                    if (bindArticleId) {
9213                            qPos.add(articleId);
9214                    }
9215    
9216                    if (orderByComparator != null) {
9217                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9218    
9219                            for (Object value : values) {
9220                                    qPos.add(value);
9221                            }
9222                    }
9223    
9224                    List<JournalArticle> list = q.list();
9225    
9226                    if (list.size() == 2) {
9227                            return list.get(1);
9228                    }
9229                    else {
9230                            return null;
9231                    }
9232            }
9233    
9234            /**
9235             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
9236             *
9237             * @param groupId the group ID
9238             * @param articleId the article ID
9239             * @throws SystemException if a system exception occurred
9240             */
9241            public void removeByG_A(long groupId, String articleId)
9242                    throws SystemException {
9243                    for (JournalArticle journalArticle : findByG_A(groupId, articleId,
9244                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9245                            remove(journalArticle);
9246                    }
9247            }
9248    
9249            /**
9250             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
9251             *
9252             * @param groupId the group ID
9253             * @param articleId the article ID
9254             * @return the number of matching journal articles
9255             * @throws SystemException if a system exception occurred
9256             */
9257            public int countByG_A(long groupId, String articleId)
9258                    throws SystemException {
9259                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
9260    
9261                    Object[] finderArgs = new Object[] { groupId, articleId };
9262    
9263                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9264                                    this);
9265    
9266                    if (count == null) {
9267                            StringBundler query = new StringBundler(3);
9268    
9269                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
9270    
9271                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9272    
9273                            boolean bindArticleId = false;
9274    
9275                            if (articleId == null) {
9276                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9277                            }
9278                            else if (articleId.equals(StringPool.BLANK)) {
9279                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9280                            }
9281                            else {
9282                                    bindArticleId = true;
9283    
9284                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9285                            }
9286    
9287                            String sql = query.toString();
9288    
9289                            Session session = null;
9290    
9291                            try {
9292                                    session = openSession();
9293    
9294                                    Query q = session.createQuery(sql);
9295    
9296                                    QueryPos qPos = QueryPos.getInstance(q);
9297    
9298                                    qPos.add(groupId);
9299    
9300                                    if (bindArticleId) {
9301                                            qPos.add(articleId);
9302                                    }
9303    
9304                                    count = (Long)q.uniqueResult();
9305    
9306                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9307                            }
9308                            catch (Exception e) {
9309                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9310    
9311                                    throw processException(e);
9312                            }
9313                            finally {
9314                                    closeSession(session);
9315                            }
9316                    }
9317    
9318                    return count.intValue();
9319            }
9320    
9321            /**
9322             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9323             *
9324             * @param groupId the group ID
9325             * @param articleId the article ID
9326             * @return the number of matching journal articles that the user has permission to view
9327             * @throws SystemException if a system exception occurred
9328             */
9329            public int filterCountByG_A(long groupId, String articleId)
9330                    throws SystemException {
9331                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9332                            return countByG_A(groupId, articleId);
9333                    }
9334    
9335                    StringBundler query = new StringBundler(3);
9336    
9337                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9338    
9339                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9340    
9341                    boolean bindArticleId = false;
9342    
9343                    if (articleId == null) {
9344                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9345                    }
9346                    else if (articleId.equals(StringPool.BLANK)) {
9347                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9348                    }
9349                    else {
9350                            bindArticleId = true;
9351    
9352                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9353                    }
9354    
9355                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9356                                    JournalArticle.class.getName(),
9357                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9358    
9359                    Session session = null;
9360    
9361                    try {
9362                            session = openSession();
9363    
9364                            SQLQuery q = session.createSQLQuery(sql);
9365    
9366                            q.addScalar(COUNT_COLUMN_NAME,
9367                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9368    
9369                            QueryPos qPos = QueryPos.getInstance(q);
9370    
9371                            qPos.add(groupId);
9372    
9373                            if (bindArticleId) {
9374                                    qPos.add(articleId);
9375                            }
9376    
9377                            Long count = (Long)q.uniqueResult();
9378    
9379                            return count.intValue();
9380                    }
9381                    catch (Exception e) {
9382                            throw processException(e);
9383                    }
9384                    finally {
9385                            closeSession(session);
9386                    }
9387            }
9388    
9389            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
9390            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
9391            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
9392            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '')";
9393            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9394                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9395                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9396                            "findByG_UT",
9397                            new String[] {
9398                                    Long.class.getName(), String.class.getName(),
9399                                    
9400                            Integer.class.getName(), Integer.class.getName(),
9401                                    OrderByComparator.class.getName()
9402                            });
9403            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9404                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9405                            JournalArticleImpl.class,
9406                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
9407                            new String[] { Long.class.getName(), String.class.getName() },
9408                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
9409                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
9410                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
9411                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
9412            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9413                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
9414                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
9415                            new String[] { Long.class.getName(), String.class.getName() });
9416    
9417            /**
9418             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
9419             *
9420             * @param groupId the group ID
9421             * @param urlTitle the url title
9422             * @return the matching journal articles
9423             * @throws SystemException if a system exception occurred
9424             */
9425            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
9426                    throws SystemException {
9427                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
9428                            QueryUtil.ALL_POS, null);
9429            }
9430    
9431            /**
9432             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
9433             *
9434             * <p>
9435             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9436             * </p>
9437             *
9438             * @param groupId the group ID
9439             * @param urlTitle the url title
9440             * @param start the lower bound of the range of journal articles
9441             * @param end the upper bound of the range of journal articles (not inclusive)
9442             * @return the range of matching journal articles
9443             * @throws SystemException if a system exception occurred
9444             */
9445            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
9446                    int start, int end) throws SystemException {
9447                    return findByG_UT(groupId, urlTitle, start, end, null);
9448            }
9449    
9450            /**
9451             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
9452             *
9453             * <p>
9454             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9455             * </p>
9456             *
9457             * @param groupId the group ID
9458             * @param urlTitle the url title
9459             * @param start the lower bound of the range of journal articles
9460             * @param end the upper bound of the range of journal articles (not inclusive)
9461             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9462             * @return the ordered range of matching journal articles
9463             * @throws SystemException if a system exception occurred
9464             */
9465            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
9466                    int start, int end, OrderByComparator orderByComparator)
9467                    throws SystemException {
9468                    boolean pagination = true;
9469                    FinderPath finderPath = null;
9470                    Object[] finderArgs = null;
9471    
9472                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9473                                    (orderByComparator == null)) {
9474                            pagination = false;
9475                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
9476                            finderArgs = new Object[] { groupId, urlTitle };
9477                    }
9478                    else {
9479                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
9480                            finderArgs = new Object[] {
9481                                            groupId, urlTitle,
9482                                            
9483                                            start, end, orderByComparator
9484                                    };
9485                    }
9486    
9487                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9488                                    finderArgs, this);
9489    
9490                    if ((list != null) && !list.isEmpty()) {
9491                            for (JournalArticle journalArticle : list) {
9492                                    if ((groupId != journalArticle.getGroupId()) ||
9493                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
9494                                            list = null;
9495    
9496                                            break;
9497                                    }
9498                            }
9499                    }
9500    
9501                    if (list == null) {
9502                            StringBundler query = null;
9503    
9504                            if (orderByComparator != null) {
9505                                    query = new StringBundler(4 +
9506                                                    (orderByComparator.getOrderByFields().length * 3));
9507                            }
9508                            else {
9509                                    query = new StringBundler(4);
9510                            }
9511    
9512                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9513    
9514                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9515    
9516                            boolean bindUrlTitle = false;
9517    
9518                            if (urlTitle == null) {
9519                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9520                            }
9521                            else if (urlTitle.equals(StringPool.BLANK)) {
9522                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9523                            }
9524                            else {
9525                                    bindUrlTitle = true;
9526    
9527                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9528                            }
9529    
9530                            if (orderByComparator != null) {
9531                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9532                                            orderByComparator);
9533                            }
9534                            else
9535                             if (pagination) {
9536                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9537                            }
9538    
9539                            String sql = query.toString();
9540    
9541                            Session session = null;
9542    
9543                            try {
9544                                    session = openSession();
9545    
9546                                    Query q = session.createQuery(sql);
9547    
9548                                    QueryPos qPos = QueryPos.getInstance(q);
9549    
9550                                    qPos.add(groupId);
9551    
9552                                    if (bindUrlTitle) {
9553                                            qPos.add(urlTitle);
9554                                    }
9555    
9556                                    if (!pagination) {
9557                                            list = (List<JournalArticle>)QueryUtil.list(q,
9558                                                            getDialect(), start, end, false);
9559    
9560                                            Collections.sort(list);
9561    
9562                                            list = new UnmodifiableList<JournalArticle>(list);
9563                                    }
9564                                    else {
9565                                            list = (List<JournalArticle>)QueryUtil.list(q,
9566                                                            getDialect(), start, end);
9567                                    }
9568    
9569                                    cacheResult(list);
9570    
9571                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9572                            }
9573                            catch (Exception e) {
9574                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9575    
9576                                    throw processException(e);
9577                            }
9578                            finally {
9579                                    closeSession(session);
9580                            }
9581                    }
9582    
9583                    return list;
9584            }
9585    
9586            /**
9587             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9588             *
9589             * @param groupId the group ID
9590             * @param urlTitle the url title
9591             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9592             * @return the first matching journal article
9593             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9594             * @throws SystemException if a system exception occurred
9595             */
9596            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
9597                    OrderByComparator orderByComparator)
9598                    throws NoSuchArticleException, SystemException {
9599                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
9600                                    orderByComparator);
9601    
9602                    if (journalArticle != null) {
9603                            return journalArticle;
9604                    }
9605    
9606                    StringBundler msg = new StringBundler(6);
9607    
9608                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9609    
9610                    msg.append("groupId=");
9611                    msg.append(groupId);
9612    
9613                    msg.append(", urlTitle=");
9614                    msg.append(urlTitle);
9615    
9616                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9617    
9618                    throw new NoSuchArticleException(msg.toString());
9619            }
9620    
9621            /**
9622             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9623             *
9624             * @param groupId the group ID
9625             * @param urlTitle the url title
9626             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9627             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9628             * @throws SystemException if a system exception occurred
9629             */
9630            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
9631                    OrderByComparator orderByComparator) throws SystemException {
9632                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
9633                                    orderByComparator);
9634    
9635                    if (!list.isEmpty()) {
9636                            return list.get(0);
9637                    }
9638    
9639                    return null;
9640            }
9641    
9642            /**
9643             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9644             *
9645             * @param groupId the group ID
9646             * @param urlTitle the url title
9647             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9648             * @return the last matching journal article
9649             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9650             * @throws SystemException if a system exception occurred
9651             */
9652            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
9653                    OrderByComparator orderByComparator)
9654                    throws NoSuchArticleException, SystemException {
9655                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
9656                                    orderByComparator);
9657    
9658                    if (journalArticle != null) {
9659                            return journalArticle;
9660                    }
9661    
9662                    StringBundler msg = new StringBundler(6);
9663    
9664                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9665    
9666                    msg.append("groupId=");
9667                    msg.append(groupId);
9668    
9669                    msg.append(", urlTitle=");
9670                    msg.append(urlTitle);
9671    
9672                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9673    
9674                    throw new NoSuchArticleException(msg.toString());
9675            }
9676    
9677            /**
9678             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9679             *
9680             * @param groupId the group ID
9681             * @param urlTitle the url title
9682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9683             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9684             * @throws SystemException if a system exception occurred
9685             */
9686            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
9687                    OrderByComparator orderByComparator) throws SystemException {
9688                    int count = countByG_UT(groupId, urlTitle);
9689    
9690                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
9691                                    count, orderByComparator);
9692    
9693                    if (!list.isEmpty()) {
9694                            return list.get(0);
9695                    }
9696    
9697                    return null;
9698            }
9699    
9700            /**
9701             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9702             *
9703             * @param id the primary key of the current journal article
9704             * @param groupId the group ID
9705             * @param urlTitle the url title
9706             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9707             * @return the previous, current, and next journal article
9708             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9709             * @throws SystemException if a system exception occurred
9710             */
9711            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
9712                    String urlTitle, OrderByComparator orderByComparator)
9713                    throws NoSuchArticleException, SystemException {
9714                    JournalArticle journalArticle = findByPrimaryKey(id);
9715    
9716                    Session session = null;
9717    
9718                    try {
9719                            session = openSession();
9720    
9721                            JournalArticle[] array = new JournalArticleImpl[3];
9722    
9723                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
9724                                            urlTitle, orderByComparator, true);
9725    
9726                            array[1] = journalArticle;
9727    
9728                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
9729                                            urlTitle, orderByComparator, false);
9730    
9731                            return array;
9732                    }
9733                    catch (Exception e) {
9734                            throw processException(e);
9735                    }
9736                    finally {
9737                            closeSession(session);
9738                    }
9739            }
9740    
9741            protected JournalArticle getByG_UT_PrevAndNext(Session session,
9742                    JournalArticle journalArticle, long groupId, String urlTitle,
9743                    OrderByComparator orderByComparator, boolean previous) {
9744                    StringBundler query = null;
9745    
9746                    if (orderByComparator != null) {
9747                            query = new StringBundler(6 +
9748                                            (orderByComparator.getOrderByFields().length * 6));
9749                    }
9750                    else {
9751                            query = new StringBundler(3);
9752                    }
9753    
9754                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9755    
9756                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9757    
9758                    boolean bindUrlTitle = false;
9759    
9760                    if (urlTitle == null) {
9761                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9762                    }
9763                    else if (urlTitle.equals(StringPool.BLANK)) {
9764                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9765                    }
9766                    else {
9767                            bindUrlTitle = true;
9768    
9769                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9770                    }
9771    
9772                    if (orderByComparator != null) {
9773                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9774    
9775                            if (orderByConditionFields.length > 0) {
9776                                    query.append(WHERE_AND);
9777                            }
9778    
9779                            for (int i = 0; i < orderByConditionFields.length; i++) {
9780                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9781                                    query.append(orderByConditionFields[i]);
9782    
9783                                    if ((i + 1) < orderByConditionFields.length) {
9784                                            if (orderByComparator.isAscending() ^ previous) {
9785                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9786                                            }
9787                                            else {
9788                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9789                                            }
9790                                    }
9791                                    else {
9792                                            if (orderByComparator.isAscending() ^ previous) {
9793                                                    query.append(WHERE_GREATER_THAN);
9794                                            }
9795                                            else {
9796                                                    query.append(WHERE_LESSER_THAN);
9797                                            }
9798                                    }
9799                            }
9800    
9801                            query.append(ORDER_BY_CLAUSE);
9802    
9803                            String[] orderByFields = orderByComparator.getOrderByFields();
9804    
9805                            for (int i = 0; i < orderByFields.length; i++) {
9806                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9807                                    query.append(orderByFields[i]);
9808    
9809                                    if ((i + 1) < orderByFields.length) {
9810                                            if (orderByComparator.isAscending() ^ previous) {
9811                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9812                                            }
9813                                            else {
9814                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9815                                            }
9816                                    }
9817                                    else {
9818                                            if (orderByComparator.isAscending() ^ previous) {
9819                                                    query.append(ORDER_BY_ASC);
9820                                            }
9821                                            else {
9822                                                    query.append(ORDER_BY_DESC);
9823                                            }
9824                                    }
9825                            }
9826                    }
9827                    else {
9828                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9829                    }
9830    
9831                    String sql = query.toString();
9832    
9833                    Query q = session.createQuery(sql);
9834    
9835                    q.setFirstResult(0);
9836                    q.setMaxResults(2);
9837    
9838                    QueryPos qPos = QueryPos.getInstance(q);
9839    
9840                    qPos.add(groupId);
9841    
9842                    if (bindUrlTitle) {
9843                            qPos.add(urlTitle);
9844                    }
9845    
9846                    if (orderByComparator != null) {
9847                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9848    
9849                            for (Object value : values) {
9850                                    qPos.add(value);
9851                            }
9852                    }
9853    
9854                    List<JournalArticle> list = q.list();
9855    
9856                    if (list.size() == 2) {
9857                            return list.get(1);
9858                    }
9859                    else {
9860                            return null;
9861                    }
9862            }
9863    
9864            /**
9865             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
9866             *
9867             * @param groupId the group ID
9868             * @param urlTitle the url title
9869             * @return the matching journal articles that the user has permission to view
9870             * @throws SystemException if a system exception occurred
9871             */
9872            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
9873                    throws SystemException {
9874                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
9875                            QueryUtil.ALL_POS, null);
9876            }
9877    
9878            /**
9879             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
9880             *
9881             * <p>
9882             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9883             * </p>
9884             *
9885             * @param groupId the group ID
9886             * @param urlTitle the url title
9887             * @param start the lower bound of the range of journal articles
9888             * @param end the upper bound of the range of journal articles (not inclusive)
9889             * @return the range of matching journal articles that the user has permission to view
9890             * @throws SystemException if a system exception occurred
9891             */
9892            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
9893                    int start, int end) throws SystemException {
9894                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
9895            }
9896    
9897            /**
9898             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
9899             *
9900             * <p>
9901             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9902             * </p>
9903             *
9904             * @param groupId the group ID
9905             * @param urlTitle the url title
9906             * @param start the lower bound of the range of journal articles
9907             * @param end the upper bound of the range of journal articles (not inclusive)
9908             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9909             * @return the ordered range of matching journal articles that the user has permission to view
9910             * @throws SystemException if a system exception occurred
9911             */
9912            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
9913                    int start, int end, OrderByComparator orderByComparator)
9914                    throws SystemException {
9915                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9916                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
9917                    }
9918    
9919                    StringBundler query = null;
9920    
9921                    if (orderByComparator != null) {
9922                            query = new StringBundler(4 +
9923                                            (orderByComparator.getOrderByFields().length * 3));
9924                    }
9925                    else {
9926                            query = new StringBundler(4);
9927                    }
9928    
9929                    if (getDB().isSupportsInlineDistinct()) {
9930                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9931                    }
9932                    else {
9933                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9934                    }
9935    
9936                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9937    
9938                    boolean bindUrlTitle = false;
9939    
9940                    if (urlTitle == null) {
9941                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9942                    }
9943                    else if (urlTitle.equals(StringPool.BLANK)) {
9944                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9945                    }
9946                    else {
9947                            bindUrlTitle = true;
9948    
9949                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9950                    }
9951    
9952                    if (!getDB().isSupportsInlineDistinct()) {
9953                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9954                    }
9955    
9956                    if (orderByComparator != null) {
9957                            if (getDB().isSupportsInlineDistinct()) {
9958                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9959                                            orderByComparator, true);
9960                            }
9961                            else {
9962                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9963                                            orderByComparator, true);
9964                            }
9965                    }
9966                    else {
9967                            if (getDB().isSupportsInlineDistinct()) {
9968                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9969                            }
9970                            else {
9971                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9972                            }
9973                    }
9974    
9975                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9976                                    JournalArticle.class.getName(),
9977                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9978    
9979                    Session session = null;
9980    
9981                    try {
9982                            session = openSession();
9983    
9984                            SQLQuery q = session.createSQLQuery(sql);
9985    
9986                            if (getDB().isSupportsInlineDistinct()) {
9987                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9988                            }
9989                            else {
9990                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9991                            }
9992    
9993                            QueryPos qPos = QueryPos.getInstance(q);
9994    
9995                            qPos.add(groupId);
9996    
9997                            if (bindUrlTitle) {
9998                                    qPos.add(urlTitle);
9999                            }
10000    
10001                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10002                                    end);
10003                    }
10004                    catch (Exception e) {
10005                            throw processException(e);
10006                    }
10007                    finally {
10008                            closeSession(session);
10009                    }
10010            }
10011    
10012            /**
10013             * 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;.
10014             *
10015             * @param id the primary key of the current journal article
10016             * @param groupId the group ID
10017             * @param urlTitle the url title
10018             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10019             * @return the previous, current, and next journal article
10020             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10021             * @throws SystemException if a system exception occurred
10022             */
10023            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
10024                    String urlTitle, OrderByComparator orderByComparator)
10025                    throws NoSuchArticleException, SystemException {
10026                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10027                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
10028                                    orderByComparator);
10029                    }
10030    
10031                    JournalArticle journalArticle = findByPrimaryKey(id);
10032    
10033                    Session session = null;
10034    
10035                    try {
10036                            session = openSession();
10037    
10038                            JournalArticle[] array = new JournalArticleImpl[3];
10039    
10040                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
10041                                            groupId, urlTitle, orderByComparator, true);
10042    
10043                            array[1] = journalArticle;
10044    
10045                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
10046                                            groupId, urlTitle, orderByComparator, false);
10047    
10048                            return array;
10049                    }
10050                    catch (Exception e) {
10051                            throw processException(e);
10052                    }
10053                    finally {
10054                            closeSession(session);
10055                    }
10056            }
10057    
10058            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
10059                    JournalArticle journalArticle, long groupId, String urlTitle,
10060                    OrderByComparator orderByComparator, boolean previous) {
10061                    StringBundler query = null;
10062    
10063                    if (orderByComparator != null) {
10064                            query = new StringBundler(6 +
10065                                            (orderByComparator.getOrderByFields().length * 6));
10066                    }
10067                    else {
10068                            query = new StringBundler(3);
10069                    }
10070    
10071                    if (getDB().isSupportsInlineDistinct()) {
10072                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10073                    }
10074                    else {
10075                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10076                    }
10077    
10078                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10079    
10080                    boolean bindUrlTitle = false;
10081    
10082                    if (urlTitle == null) {
10083                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10084                    }
10085                    else if (urlTitle.equals(StringPool.BLANK)) {
10086                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10087                    }
10088                    else {
10089                            bindUrlTitle = true;
10090    
10091                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10092                    }
10093    
10094                    if (!getDB().isSupportsInlineDistinct()) {
10095                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10096                    }
10097    
10098                    if (orderByComparator != null) {
10099                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10100    
10101                            if (orderByConditionFields.length > 0) {
10102                                    query.append(WHERE_AND);
10103                            }
10104    
10105                            for (int i = 0; i < orderByConditionFields.length; i++) {
10106                                    if (getDB().isSupportsInlineDistinct()) {
10107                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10108                                    }
10109                                    else {
10110                                            query.append(_ORDER_BY_ENTITY_TABLE);
10111                                    }
10112    
10113                                    query.append(orderByConditionFields[i]);
10114    
10115                                    if ((i + 1) < orderByConditionFields.length) {
10116                                            if (orderByComparator.isAscending() ^ previous) {
10117                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10118                                            }
10119                                            else {
10120                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10121                                            }
10122                                    }
10123                                    else {
10124                                            if (orderByComparator.isAscending() ^ previous) {
10125                                                    query.append(WHERE_GREATER_THAN);
10126                                            }
10127                                            else {
10128                                                    query.append(WHERE_LESSER_THAN);
10129                                            }
10130                                    }
10131                            }
10132    
10133                            query.append(ORDER_BY_CLAUSE);
10134    
10135                            String[] orderByFields = orderByComparator.getOrderByFields();
10136    
10137                            for (int i = 0; i < orderByFields.length; i++) {
10138                                    if (getDB().isSupportsInlineDistinct()) {
10139                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10140                                    }
10141                                    else {
10142                                            query.append(_ORDER_BY_ENTITY_TABLE);
10143                                    }
10144    
10145                                    query.append(orderByFields[i]);
10146    
10147                                    if ((i + 1) < orderByFields.length) {
10148                                            if (orderByComparator.isAscending() ^ previous) {
10149                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10150                                            }
10151                                            else {
10152                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10153                                            }
10154                                    }
10155                                    else {
10156                                            if (orderByComparator.isAscending() ^ previous) {
10157                                                    query.append(ORDER_BY_ASC);
10158                                            }
10159                                            else {
10160                                                    query.append(ORDER_BY_DESC);
10161                                            }
10162                                    }
10163                            }
10164                    }
10165                    else {
10166                            if (getDB().isSupportsInlineDistinct()) {
10167                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10168                            }
10169                            else {
10170                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10171                            }
10172                    }
10173    
10174                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10175                                    JournalArticle.class.getName(),
10176                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10177    
10178                    SQLQuery q = session.createSQLQuery(sql);
10179    
10180                    q.setFirstResult(0);
10181                    q.setMaxResults(2);
10182    
10183                    if (getDB().isSupportsInlineDistinct()) {
10184                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10185                    }
10186                    else {
10187                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10188                    }
10189    
10190                    QueryPos qPos = QueryPos.getInstance(q);
10191    
10192                    qPos.add(groupId);
10193    
10194                    if (bindUrlTitle) {
10195                            qPos.add(urlTitle);
10196                    }
10197    
10198                    if (orderByComparator != null) {
10199                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10200    
10201                            for (Object value : values) {
10202                                    qPos.add(value);
10203                            }
10204                    }
10205    
10206                    List<JournalArticle> list = q.list();
10207    
10208                    if (list.size() == 2) {
10209                            return list.get(1);
10210                    }
10211                    else {
10212                            return null;
10213                    }
10214            }
10215    
10216            /**
10217             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
10218             *
10219             * @param groupId the group ID
10220             * @param urlTitle the url title
10221             * @throws SystemException if a system exception occurred
10222             */
10223            public void removeByG_UT(long groupId, String urlTitle)
10224                    throws SystemException {
10225                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle,
10226                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10227                            remove(journalArticle);
10228                    }
10229            }
10230    
10231            /**
10232             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
10233             *
10234             * @param groupId the group ID
10235             * @param urlTitle the url title
10236             * @return the number of matching journal articles
10237             * @throws SystemException if a system exception occurred
10238             */
10239            public int countByG_UT(long groupId, String urlTitle)
10240                    throws SystemException {
10241                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
10242    
10243                    Object[] finderArgs = new Object[] { groupId, urlTitle };
10244    
10245                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10246                                    this);
10247    
10248                    if (count == null) {
10249                            StringBundler query = new StringBundler(3);
10250    
10251                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
10252    
10253                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10254    
10255                            boolean bindUrlTitle = false;
10256    
10257                            if (urlTitle == null) {
10258                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10259                            }
10260                            else if (urlTitle.equals(StringPool.BLANK)) {
10261                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10262                            }
10263                            else {
10264                                    bindUrlTitle = true;
10265    
10266                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10267                            }
10268    
10269                            String sql = query.toString();
10270    
10271                            Session session = null;
10272    
10273                            try {
10274                                    session = openSession();
10275    
10276                                    Query q = session.createQuery(sql);
10277    
10278                                    QueryPos qPos = QueryPos.getInstance(q);
10279    
10280                                    qPos.add(groupId);
10281    
10282                                    if (bindUrlTitle) {
10283                                            qPos.add(urlTitle);
10284                                    }
10285    
10286                                    count = (Long)q.uniqueResult();
10287    
10288                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10289                            }
10290                            catch (Exception e) {
10291                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10292    
10293                                    throw processException(e);
10294                            }
10295                            finally {
10296                                    closeSession(session);
10297                            }
10298                    }
10299    
10300                    return count.intValue();
10301            }
10302    
10303            /**
10304             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10305             *
10306             * @param groupId the group ID
10307             * @param urlTitle the url title
10308             * @return the number of matching journal articles that the user has permission to view
10309             * @throws SystemException if a system exception occurred
10310             */
10311            public int filterCountByG_UT(long groupId, String urlTitle)
10312                    throws SystemException {
10313                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10314                            return countByG_UT(groupId, urlTitle);
10315                    }
10316    
10317                    StringBundler query = new StringBundler(3);
10318    
10319                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
10320    
10321                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10322    
10323                    boolean bindUrlTitle = false;
10324    
10325                    if (urlTitle == null) {
10326                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10327                    }
10328                    else if (urlTitle.equals(StringPool.BLANK)) {
10329                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10330                    }
10331                    else {
10332                            bindUrlTitle = true;
10333    
10334                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10335                    }
10336    
10337                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10338                                    JournalArticle.class.getName(),
10339                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10340    
10341                    Session session = null;
10342    
10343                    try {
10344                            session = openSession();
10345    
10346                            SQLQuery q = session.createSQLQuery(sql);
10347    
10348                            q.addScalar(COUNT_COLUMN_NAME,
10349                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10350    
10351                            QueryPos qPos = QueryPos.getInstance(q);
10352    
10353                            qPos.add(groupId);
10354    
10355                            if (bindUrlTitle) {
10356                                    qPos.add(urlTitle);
10357                            }
10358    
10359                            Long count = (Long)q.uniqueResult();
10360    
10361                            return count.intValue();
10362                    }
10363                    catch (Exception e) {
10364                            throw processException(e);
10365                    }
10366                    finally {
10367                            closeSession(session);
10368                    }
10369            }
10370    
10371            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
10372            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
10373            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
10374            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '')";
10375            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10376                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10377                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10378                            "findByG_S",
10379                            new String[] {
10380                                    Long.class.getName(), String.class.getName(),
10381                                    
10382                            Integer.class.getName(), Integer.class.getName(),
10383                                    OrderByComparator.class.getName()
10384                            });
10385            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10386                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10387                            JournalArticleImpl.class,
10388                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
10389                            new String[] { Long.class.getName(), String.class.getName() },
10390                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
10391                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK |
10392                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
10393                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
10394            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10395                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
10396                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
10397                            new String[] { Long.class.getName(), String.class.getName() });
10398    
10399            /**
10400             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
10401             *
10402             * @param groupId the group ID
10403             * @param structureId the structure ID
10404             * @return the matching journal articles
10405             * @throws SystemException if a system exception occurred
10406             */
10407            public List<JournalArticle> findByG_S(long groupId, String structureId)
10408                    throws SystemException {
10409                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
10410                            QueryUtil.ALL_POS, null);
10411            }
10412    
10413            /**
10414             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
10415             *
10416             * <p>
10417             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10418             * </p>
10419             *
10420             * @param groupId the group ID
10421             * @param structureId the structure ID
10422             * @param start the lower bound of the range of journal articles
10423             * @param end the upper bound of the range of journal articles (not inclusive)
10424             * @return the range of matching journal articles
10425             * @throws SystemException if a system exception occurred
10426             */
10427            public List<JournalArticle> findByG_S(long groupId, String structureId,
10428                    int start, int end) throws SystemException {
10429                    return findByG_S(groupId, structureId, start, end, null);
10430            }
10431    
10432            /**
10433             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
10434             *
10435             * <p>
10436             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10437             * </p>
10438             *
10439             * @param groupId the group ID
10440             * @param structureId the structure ID
10441             * @param start the lower bound of the range of journal articles
10442             * @param end the upper bound of the range of journal articles (not inclusive)
10443             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10444             * @return the ordered range of matching journal articles
10445             * @throws SystemException if a system exception occurred
10446             */
10447            public List<JournalArticle> findByG_S(long groupId, String structureId,
10448                    int start, int end, OrderByComparator orderByComparator)
10449                    throws SystemException {
10450                    boolean pagination = true;
10451                    FinderPath finderPath = null;
10452                    Object[] finderArgs = null;
10453    
10454                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10455                                    (orderByComparator == null)) {
10456                            pagination = false;
10457                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
10458                            finderArgs = new Object[] { groupId, structureId };
10459                    }
10460                    else {
10461                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
10462                            finderArgs = new Object[] {
10463                                            groupId, structureId,
10464                                            
10465                                            start, end, orderByComparator
10466                                    };
10467                    }
10468    
10469                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10470                                    finderArgs, this);
10471    
10472                    if ((list != null) && !list.isEmpty()) {
10473                            for (JournalArticle journalArticle : list) {
10474                                    if ((groupId != journalArticle.getGroupId()) ||
10475                                                    !Validator.equals(structureId,
10476                                                            journalArticle.getStructureId())) {
10477                                            list = null;
10478    
10479                                            break;
10480                                    }
10481                            }
10482                    }
10483    
10484                    if (list == null) {
10485                            StringBundler query = null;
10486    
10487                            if (orderByComparator != null) {
10488                                    query = new StringBundler(4 +
10489                                                    (orderByComparator.getOrderByFields().length * 3));
10490                            }
10491                            else {
10492                                    query = new StringBundler(4);
10493                            }
10494    
10495                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10496    
10497                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10498    
10499                            boolean bindStructureId = false;
10500    
10501                            if (structureId == null) {
10502                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10503                            }
10504                            else if (structureId.equals(StringPool.BLANK)) {
10505                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10506                            }
10507                            else {
10508                                    bindStructureId = true;
10509    
10510                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10511                            }
10512    
10513                            if (orderByComparator != null) {
10514                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10515                                            orderByComparator);
10516                            }
10517                            else
10518                             if (pagination) {
10519                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10520                            }
10521    
10522                            String sql = query.toString();
10523    
10524                            Session session = null;
10525    
10526                            try {
10527                                    session = openSession();
10528    
10529                                    Query q = session.createQuery(sql);
10530    
10531                                    QueryPos qPos = QueryPos.getInstance(q);
10532    
10533                                    qPos.add(groupId);
10534    
10535                                    if (bindStructureId) {
10536                                            qPos.add(structureId);
10537                                    }
10538    
10539                                    if (!pagination) {
10540                                            list = (List<JournalArticle>)QueryUtil.list(q,
10541                                                            getDialect(), start, end, false);
10542    
10543                                            Collections.sort(list);
10544    
10545                                            list = new UnmodifiableList<JournalArticle>(list);
10546                                    }
10547                                    else {
10548                                            list = (List<JournalArticle>)QueryUtil.list(q,
10549                                                            getDialect(), start, end);
10550                                    }
10551    
10552                                    cacheResult(list);
10553    
10554                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10555                            }
10556                            catch (Exception e) {
10557                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10558    
10559                                    throw processException(e);
10560                            }
10561                            finally {
10562                                    closeSession(session);
10563                            }
10564                    }
10565    
10566                    return list;
10567            }
10568    
10569            /**
10570             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10571             *
10572             * @param groupId the group ID
10573             * @param structureId the structure ID
10574             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10575             * @return the first matching journal article
10576             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10577             * @throws SystemException if a system exception occurred
10578             */
10579            public JournalArticle findByG_S_First(long groupId, String structureId,
10580                    OrderByComparator orderByComparator)
10581                    throws NoSuchArticleException, SystemException {
10582                    JournalArticle journalArticle = fetchByG_S_First(groupId, structureId,
10583                                    orderByComparator);
10584    
10585                    if (journalArticle != null) {
10586                            return journalArticle;
10587                    }
10588    
10589                    StringBundler msg = new StringBundler(6);
10590    
10591                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10592    
10593                    msg.append("groupId=");
10594                    msg.append(groupId);
10595    
10596                    msg.append(", structureId=");
10597                    msg.append(structureId);
10598    
10599                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10600    
10601                    throw new NoSuchArticleException(msg.toString());
10602            }
10603    
10604            /**
10605             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10606             *
10607             * @param groupId the group ID
10608             * @param structureId the structure ID
10609             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10610             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10611             * @throws SystemException if a system exception occurred
10612             */
10613            public JournalArticle fetchByG_S_First(long groupId, String structureId,
10614                    OrderByComparator orderByComparator) throws SystemException {
10615                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
10616                                    orderByComparator);
10617    
10618                    if (!list.isEmpty()) {
10619                            return list.get(0);
10620                    }
10621    
10622                    return null;
10623            }
10624    
10625            /**
10626             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10627             *
10628             * @param groupId the group ID
10629             * @param structureId the structure ID
10630             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10631             * @return the last matching journal article
10632             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10633             * @throws SystemException if a system exception occurred
10634             */
10635            public JournalArticle findByG_S_Last(long groupId, String structureId,
10636                    OrderByComparator orderByComparator)
10637                    throws NoSuchArticleException, SystemException {
10638                    JournalArticle journalArticle = fetchByG_S_Last(groupId, structureId,
10639                                    orderByComparator);
10640    
10641                    if (journalArticle != null) {
10642                            return journalArticle;
10643                    }
10644    
10645                    StringBundler msg = new StringBundler(6);
10646    
10647                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10648    
10649                    msg.append("groupId=");
10650                    msg.append(groupId);
10651    
10652                    msg.append(", structureId=");
10653                    msg.append(structureId);
10654    
10655                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10656    
10657                    throw new NoSuchArticleException(msg.toString());
10658            }
10659    
10660            /**
10661             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10662             *
10663             * @param groupId the group ID
10664             * @param structureId the structure ID
10665             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10666             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10667             * @throws SystemException if a system exception occurred
10668             */
10669            public JournalArticle fetchByG_S_Last(long groupId, String structureId,
10670                    OrderByComparator orderByComparator) throws SystemException {
10671                    int count = countByG_S(groupId, structureId);
10672    
10673                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
10674                                    count, orderByComparator);
10675    
10676                    if (!list.isEmpty()) {
10677                            return list.get(0);
10678                    }
10679    
10680                    return null;
10681            }
10682    
10683            /**
10684             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10685             *
10686             * @param id the primary key of the current journal article
10687             * @param groupId the group ID
10688             * @param structureId the structure ID
10689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10690             * @return the previous, current, and next journal article
10691             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10692             * @throws SystemException if a system exception occurred
10693             */
10694            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
10695                    String structureId, OrderByComparator orderByComparator)
10696                    throws NoSuchArticleException, SystemException {
10697                    JournalArticle journalArticle = findByPrimaryKey(id);
10698    
10699                    Session session = null;
10700    
10701                    try {
10702                            session = openSession();
10703    
10704                            JournalArticle[] array = new JournalArticleImpl[3];
10705    
10706                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
10707                                            structureId, orderByComparator, true);
10708    
10709                            array[1] = journalArticle;
10710    
10711                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
10712                                            structureId, orderByComparator, false);
10713    
10714                            return array;
10715                    }
10716                    catch (Exception e) {
10717                            throw processException(e);
10718                    }
10719                    finally {
10720                            closeSession(session);
10721                    }
10722            }
10723    
10724            protected JournalArticle getByG_S_PrevAndNext(Session session,
10725                    JournalArticle journalArticle, long groupId, String structureId,
10726                    OrderByComparator orderByComparator, boolean previous) {
10727                    StringBundler query = null;
10728    
10729                    if (orderByComparator != null) {
10730                            query = new StringBundler(6 +
10731                                            (orderByComparator.getOrderByFields().length * 6));
10732                    }
10733                    else {
10734                            query = new StringBundler(3);
10735                    }
10736    
10737                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10738    
10739                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10740    
10741                    boolean bindStructureId = false;
10742    
10743                    if (structureId == null) {
10744                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10745                    }
10746                    else if (structureId.equals(StringPool.BLANK)) {
10747                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10748                    }
10749                    else {
10750                            bindStructureId = true;
10751    
10752                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10753                    }
10754    
10755                    if (orderByComparator != null) {
10756                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10757    
10758                            if (orderByConditionFields.length > 0) {
10759                                    query.append(WHERE_AND);
10760                            }
10761    
10762                            for (int i = 0; i < orderByConditionFields.length; i++) {
10763                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10764                                    query.append(orderByConditionFields[i]);
10765    
10766                                    if ((i + 1) < orderByConditionFields.length) {
10767                                            if (orderByComparator.isAscending() ^ previous) {
10768                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10769                                            }
10770                                            else {
10771                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10772                                            }
10773                                    }
10774                                    else {
10775                                            if (orderByComparator.isAscending() ^ previous) {
10776                                                    query.append(WHERE_GREATER_THAN);
10777                                            }
10778                                            else {
10779                                                    query.append(WHERE_LESSER_THAN);
10780                                            }
10781                                    }
10782                            }
10783    
10784                            query.append(ORDER_BY_CLAUSE);
10785    
10786                            String[] orderByFields = orderByComparator.getOrderByFields();
10787    
10788                            for (int i = 0; i < orderByFields.length; i++) {
10789                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10790                                    query.append(orderByFields[i]);
10791    
10792                                    if ((i + 1) < orderByFields.length) {
10793                                            if (orderByComparator.isAscending() ^ previous) {
10794                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10795                                            }
10796                                            else {
10797                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10798                                            }
10799                                    }
10800                                    else {
10801                                            if (orderByComparator.isAscending() ^ previous) {
10802                                                    query.append(ORDER_BY_ASC);
10803                                            }
10804                                            else {
10805                                                    query.append(ORDER_BY_DESC);
10806                                            }
10807                                    }
10808                            }
10809                    }
10810                    else {
10811                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10812                    }
10813    
10814                    String sql = query.toString();
10815    
10816                    Query q = session.createQuery(sql);
10817    
10818                    q.setFirstResult(0);
10819                    q.setMaxResults(2);
10820    
10821                    QueryPos qPos = QueryPos.getInstance(q);
10822    
10823                    qPos.add(groupId);
10824    
10825                    if (bindStructureId) {
10826                            qPos.add(structureId);
10827                    }
10828    
10829                    if (orderByComparator != null) {
10830                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10831    
10832                            for (Object value : values) {
10833                                    qPos.add(value);
10834                            }
10835                    }
10836    
10837                    List<JournalArticle> list = q.list();
10838    
10839                    if (list.size() == 2) {
10840                            return list.get(1);
10841                    }
10842                    else {
10843                            return null;
10844                    }
10845            }
10846    
10847            /**
10848             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
10849             *
10850             * @param groupId the group ID
10851             * @param structureId the structure ID
10852             * @return the matching journal articles that the user has permission to view
10853             * @throws SystemException if a system exception occurred
10854             */
10855            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
10856                    throws SystemException {
10857                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
10858                            QueryUtil.ALL_POS, null);
10859            }
10860    
10861            /**
10862             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
10863             *
10864             * <p>
10865             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10866             * </p>
10867             *
10868             * @param groupId the group ID
10869             * @param structureId the structure ID
10870             * @param start the lower bound of the range of journal articles
10871             * @param end the upper bound of the range of journal articles (not inclusive)
10872             * @return the range of matching journal articles that the user has permission to view
10873             * @throws SystemException if a system exception occurred
10874             */
10875            public List<JournalArticle> filterFindByG_S(long groupId,
10876                    String structureId, int start, int end) throws SystemException {
10877                    return filterFindByG_S(groupId, structureId, start, end, null);
10878            }
10879    
10880            /**
10881             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
10882             *
10883             * <p>
10884             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10885             * </p>
10886             *
10887             * @param groupId the group ID
10888             * @param structureId the structure ID
10889             * @param start the lower bound of the range of journal articles
10890             * @param end the upper bound of the range of journal articles (not inclusive)
10891             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10892             * @return the ordered range of matching journal articles that the user has permission to view
10893             * @throws SystemException if a system exception occurred
10894             */
10895            public List<JournalArticle> filterFindByG_S(long groupId,
10896                    String structureId, int start, int end,
10897                    OrderByComparator orderByComparator) throws SystemException {
10898                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10899                            return findByG_S(groupId, structureId, start, end, orderByComparator);
10900                    }
10901    
10902                    StringBundler query = null;
10903    
10904                    if (orderByComparator != null) {
10905                            query = new StringBundler(4 +
10906                                            (orderByComparator.getOrderByFields().length * 3));
10907                    }
10908                    else {
10909                            query = new StringBundler(4);
10910                    }
10911    
10912                    if (getDB().isSupportsInlineDistinct()) {
10913                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10914                    }
10915                    else {
10916                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10917                    }
10918    
10919                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10920    
10921                    boolean bindStructureId = false;
10922    
10923                    if (structureId == null) {
10924                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10925                    }
10926                    else if (structureId.equals(StringPool.BLANK)) {
10927                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10928                    }
10929                    else {
10930                            bindStructureId = true;
10931    
10932                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10933                    }
10934    
10935                    if (!getDB().isSupportsInlineDistinct()) {
10936                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10937                    }
10938    
10939                    if (orderByComparator != null) {
10940                            if (getDB().isSupportsInlineDistinct()) {
10941                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10942                                            orderByComparator, true);
10943                            }
10944                            else {
10945                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10946                                            orderByComparator, true);
10947                            }
10948                    }
10949                    else {
10950                            if (getDB().isSupportsInlineDistinct()) {
10951                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10952                            }
10953                            else {
10954                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10955                            }
10956                    }
10957    
10958                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10959                                    JournalArticle.class.getName(),
10960                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10961    
10962                    Session session = null;
10963    
10964                    try {
10965                            session = openSession();
10966    
10967                            SQLQuery q = session.createSQLQuery(sql);
10968    
10969                            if (getDB().isSupportsInlineDistinct()) {
10970                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10971                            }
10972                            else {
10973                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10974                            }
10975    
10976                            QueryPos qPos = QueryPos.getInstance(q);
10977    
10978                            qPos.add(groupId);
10979    
10980                            if (bindStructureId) {
10981                                    qPos.add(structureId);
10982                            }
10983    
10984                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10985                                    end);
10986                    }
10987                    catch (Exception e) {
10988                            throw processException(e);
10989                    }
10990                    finally {
10991                            closeSession(session);
10992                    }
10993            }
10994    
10995            /**
10996             * 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;.
10997             *
10998             * @param id the primary key of the current journal article
10999             * @param groupId the group ID
11000             * @param structureId the structure ID
11001             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11002             * @return the previous, current, and next journal article
11003             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11004             * @throws SystemException if a system exception occurred
11005             */
11006            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
11007                    String structureId, OrderByComparator orderByComparator)
11008                    throws NoSuchArticleException, SystemException {
11009                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11010                            return findByG_S_PrevAndNext(id, groupId, structureId,
11011                                    orderByComparator);
11012                    }
11013    
11014                    JournalArticle journalArticle = findByPrimaryKey(id);
11015    
11016                    Session session = null;
11017    
11018                    try {
11019                            session = openSession();
11020    
11021                            JournalArticle[] array = new JournalArticleImpl[3];
11022    
11023                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
11024                                            groupId, structureId, orderByComparator, true);
11025    
11026                            array[1] = journalArticle;
11027    
11028                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
11029                                            groupId, structureId, orderByComparator, false);
11030    
11031                            return array;
11032                    }
11033                    catch (Exception e) {
11034                            throw processException(e);
11035                    }
11036                    finally {
11037                            closeSession(session);
11038                    }
11039            }
11040    
11041            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
11042                    JournalArticle journalArticle, long groupId, String structureId,
11043                    OrderByComparator orderByComparator, boolean previous) {
11044                    StringBundler query = null;
11045    
11046                    if (orderByComparator != null) {
11047                            query = new StringBundler(6 +
11048                                            (orderByComparator.getOrderByFields().length * 6));
11049                    }
11050                    else {
11051                            query = new StringBundler(3);
11052                    }
11053    
11054                    if (getDB().isSupportsInlineDistinct()) {
11055                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11056                    }
11057                    else {
11058                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11059                    }
11060    
11061                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11062    
11063                    boolean bindStructureId = false;
11064    
11065                    if (structureId == null) {
11066                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11067                    }
11068                    else if (structureId.equals(StringPool.BLANK)) {
11069                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11070                    }
11071                    else {
11072                            bindStructureId = true;
11073    
11074                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11075                    }
11076    
11077                    if (!getDB().isSupportsInlineDistinct()) {
11078                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11079                    }
11080    
11081                    if (orderByComparator != null) {
11082                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11083    
11084                            if (orderByConditionFields.length > 0) {
11085                                    query.append(WHERE_AND);
11086                            }
11087    
11088                            for (int i = 0; i < orderByConditionFields.length; i++) {
11089                                    if (getDB().isSupportsInlineDistinct()) {
11090                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11091                                    }
11092                                    else {
11093                                            query.append(_ORDER_BY_ENTITY_TABLE);
11094                                    }
11095    
11096                                    query.append(orderByConditionFields[i]);
11097    
11098                                    if ((i + 1) < orderByConditionFields.length) {
11099                                            if (orderByComparator.isAscending() ^ previous) {
11100                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11101                                            }
11102                                            else {
11103                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11104                                            }
11105                                    }
11106                                    else {
11107                                            if (orderByComparator.isAscending() ^ previous) {
11108                                                    query.append(WHERE_GREATER_THAN);
11109                                            }
11110                                            else {
11111                                                    query.append(WHERE_LESSER_THAN);
11112                                            }
11113                                    }
11114                            }
11115    
11116                            query.append(ORDER_BY_CLAUSE);
11117    
11118                            String[] orderByFields = orderByComparator.getOrderByFields();
11119    
11120                            for (int i = 0; i < orderByFields.length; i++) {
11121                                    if (getDB().isSupportsInlineDistinct()) {
11122                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11123                                    }
11124                                    else {
11125                                            query.append(_ORDER_BY_ENTITY_TABLE);
11126                                    }
11127    
11128                                    query.append(orderByFields[i]);
11129    
11130                                    if ((i + 1) < orderByFields.length) {
11131                                            if (orderByComparator.isAscending() ^ previous) {
11132                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11133                                            }
11134                                            else {
11135                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11136                                            }
11137                                    }
11138                                    else {
11139                                            if (orderByComparator.isAscending() ^ previous) {
11140                                                    query.append(ORDER_BY_ASC);
11141                                            }
11142                                            else {
11143                                                    query.append(ORDER_BY_DESC);
11144                                            }
11145                                    }
11146                            }
11147                    }
11148                    else {
11149                            if (getDB().isSupportsInlineDistinct()) {
11150                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11151                            }
11152                            else {
11153                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11154                            }
11155                    }
11156    
11157                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11158                                    JournalArticle.class.getName(),
11159                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11160    
11161                    SQLQuery q = session.createSQLQuery(sql);
11162    
11163                    q.setFirstResult(0);
11164                    q.setMaxResults(2);
11165    
11166                    if (getDB().isSupportsInlineDistinct()) {
11167                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11168                    }
11169                    else {
11170                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11171                    }
11172    
11173                    QueryPos qPos = QueryPos.getInstance(q);
11174    
11175                    qPos.add(groupId);
11176    
11177                    if (bindStructureId) {
11178                            qPos.add(structureId);
11179                    }
11180    
11181                    if (orderByComparator != null) {
11182                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11183    
11184                            for (Object value : values) {
11185                                    qPos.add(value);
11186                            }
11187                    }
11188    
11189                    List<JournalArticle> list = q.list();
11190    
11191                    if (list.size() == 2) {
11192                            return list.get(1);
11193                    }
11194                    else {
11195                            return null;
11196                    }
11197            }
11198    
11199            /**
11200             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
11201             *
11202             * @param groupId the group ID
11203             * @param structureId the structure ID
11204             * @throws SystemException if a system exception occurred
11205             */
11206            public void removeByG_S(long groupId, String structureId)
11207                    throws SystemException {
11208                    for (JournalArticle journalArticle : findByG_S(groupId, structureId,
11209                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11210                            remove(journalArticle);
11211                    }
11212            }
11213    
11214            /**
11215             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
11216             *
11217             * @param groupId the group ID
11218             * @param structureId the structure ID
11219             * @return the number of matching journal articles
11220             * @throws SystemException if a system exception occurred
11221             */
11222            public int countByG_S(long groupId, String structureId)
11223                    throws SystemException {
11224                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
11225    
11226                    Object[] finderArgs = new Object[] { groupId, structureId };
11227    
11228                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11229                                    this);
11230    
11231                    if (count == null) {
11232                            StringBundler query = new StringBundler(3);
11233    
11234                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
11235    
11236                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11237    
11238                            boolean bindStructureId = false;
11239    
11240                            if (structureId == null) {
11241                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11242                            }
11243                            else if (structureId.equals(StringPool.BLANK)) {
11244                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11245                            }
11246                            else {
11247                                    bindStructureId = true;
11248    
11249                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11250                            }
11251    
11252                            String sql = query.toString();
11253    
11254                            Session session = null;
11255    
11256                            try {
11257                                    session = openSession();
11258    
11259                                    Query q = session.createQuery(sql);
11260    
11261                                    QueryPos qPos = QueryPos.getInstance(q);
11262    
11263                                    qPos.add(groupId);
11264    
11265                                    if (bindStructureId) {
11266                                            qPos.add(structureId);
11267                                    }
11268    
11269                                    count = (Long)q.uniqueResult();
11270    
11271                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11272                            }
11273                            catch (Exception e) {
11274                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11275    
11276                                    throw processException(e);
11277                            }
11278                            finally {
11279                                    closeSession(session);
11280                            }
11281                    }
11282    
11283                    return count.intValue();
11284            }
11285    
11286            /**
11287             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
11288             *
11289             * @param groupId the group ID
11290             * @param structureId the structure ID
11291             * @return the number of matching journal articles that the user has permission to view
11292             * @throws SystemException if a system exception occurred
11293             */
11294            public int filterCountByG_S(long groupId, String structureId)
11295                    throws SystemException {
11296                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11297                            return countByG_S(groupId, structureId);
11298                    }
11299    
11300                    StringBundler query = new StringBundler(3);
11301    
11302                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
11303    
11304                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
11305    
11306                    boolean bindStructureId = false;
11307    
11308                    if (structureId == null) {
11309                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
11310                    }
11311                    else if (structureId.equals(StringPool.BLANK)) {
11312                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
11313                    }
11314                    else {
11315                            bindStructureId = true;
11316    
11317                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
11318                    }
11319    
11320                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11321                                    JournalArticle.class.getName(),
11322                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11323    
11324                    Session session = null;
11325    
11326                    try {
11327                            session = openSession();
11328    
11329                            SQLQuery q = session.createSQLQuery(sql);
11330    
11331                            q.addScalar(COUNT_COLUMN_NAME,
11332                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11333    
11334                            QueryPos qPos = QueryPos.getInstance(q);
11335    
11336                            qPos.add(groupId);
11337    
11338                            if (bindStructureId) {
11339                                    qPos.add(structureId);
11340                            }
11341    
11342                            Long count = (Long)q.uniqueResult();
11343    
11344                            return count.intValue();
11345                    }
11346                    catch (Exception e) {
11347                            throw processException(e);
11348                    }
11349                    finally {
11350                            closeSession(session);
11351                    }
11352            }
11353    
11354            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
11355            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
11356            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
11357            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
11358            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11359                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11360                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
11361                            "findByG_T",
11362                            new String[] {
11363                                    Long.class.getName(), String.class.getName(),
11364                                    
11365                            Integer.class.getName(), Integer.class.getName(),
11366                                    OrderByComparator.class.getName()
11367                            });
11368            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11369                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11370                            JournalArticleImpl.class,
11371                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
11372                            new String[] { Long.class.getName(), String.class.getName() },
11373                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
11374                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
11375                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
11376                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
11377            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11378                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
11379                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
11380                            new String[] { Long.class.getName(), String.class.getName() });
11381    
11382            /**
11383             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
11384             *
11385             * @param groupId the group ID
11386             * @param templateId the template ID
11387             * @return the matching journal articles
11388             * @throws SystemException if a system exception occurred
11389             */
11390            public List<JournalArticle> findByG_T(long groupId, String templateId)
11391                    throws SystemException {
11392                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
11393                            QueryUtil.ALL_POS, null);
11394            }
11395    
11396            /**
11397             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
11398             *
11399             * <p>
11400             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11401             * </p>
11402             *
11403             * @param groupId the group ID
11404             * @param templateId the template ID
11405             * @param start the lower bound of the range of journal articles
11406             * @param end the upper bound of the range of journal articles (not inclusive)
11407             * @return the range of matching journal articles
11408             * @throws SystemException if a system exception occurred
11409             */
11410            public List<JournalArticle> findByG_T(long groupId, String templateId,
11411                    int start, int end) throws SystemException {
11412                    return findByG_T(groupId, templateId, start, end, null);
11413            }
11414    
11415            /**
11416             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
11417             *
11418             * <p>
11419             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11420             * </p>
11421             *
11422             * @param groupId the group ID
11423             * @param templateId the template ID
11424             * @param start the lower bound of the range of journal articles
11425             * @param end the upper bound of the range of journal articles (not inclusive)
11426             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11427             * @return the ordered range of matching journal articles
11428             * @throws SystemException if a system exception occurred
11429             */
11430            public List<JournalArticle> findByG_T(long groupId, String templateId,
11431                    int start, int end, OrderByComparator orderByComparator)
11432                    throws SystemException {
11433                    boolean pagination = true;
11434                    FinderPath finderPath = null;
11435                    Object[] finderArgs = null;
11436    
11437                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11438                                    (orderByComparator == null)) {
11439                            pagination = false;
11440                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
11441                            finderArgs = new Object[] { groupId, templateId };
11442                    }
11443                    else {
11444                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
11445                            finderArgs = new Object[] {
11446                                            groupId, templateId,
11447                                            
11448                                            start, end, orderByComparator
11449                                    };
11450                    }
11451    
11452                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11453                                    finderArgs, this);
11454    
11455                    if ((list != null) && !list.isEmpty()) {
11456                            for (JournalArticle journalArticle : list) {
11457                                    if ((groupId != journalArticle.getGroupId()) ||
11458                                                    !Validator.equals(templateId,
11459                                                            journalArticle.getTemplateId())) {
11460                                            list = null;
11461    
11462                                            break;
11463                                    }
11464                            }
11465                    }
11466    
11467                    if (list == null) {
11468                            StringBundler query = null;
11469    
11470                            if (orderByComparator != null) {
11471                                    query = new StringBundler(4 +
11472                                                    (orderByComparator.getOrderByFields().length * 3));
11473                            }
11474                            else {
11475                                    query = new StringBundler(4);
11476                            }
11477    
11478                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11479    
11480                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11481    
11482                            boolean bindTemplateId = false;
11483    
11484                            if (templateId == null) {
11485                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11486                            }
11487                            else if (templateId.equals(StringPool.BLANK)) {
11488                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11489                            }
11490                            else {
11491                                    bindTemplateId = true;
11492    
11493                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11494                            }
11495    
11496                            if (orderByComparator != null) {
11497                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11498                                            orderByComparator);
11499                            }
11500                            else
11501                             if (pagination) {
11502                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11503                            }
11504    
11505                            String sql = query.toString();
11506    
11507                            Session session = null;
11508    
11509                            try {
11510                                    session = openSession();
11511    
11512                                    Query q = session.createQuery(sql);
11513    
11514                                    QueryPos qPos = QueryPos.getInstance(q);
11515    
11516                                    qPos.add(groupId);
11517    
11518                                    if (bindTemplateId) {
11519                                            qPos.add(templateId);
11520                                    }
11521    
11522                                    if (!pagination) {
11523                                            list = (List<JournalArticle>)QueryUtil.list(q,
11524                                                            getDialect(), start, end, false);
11525    
11526                                            Collections.sort(list);
11527    
11528                                            list = new UnmodifiableList<JournalArticle>(list);
11529                                    }
11530                                    else {
11531                                            list = (List<JournalArticle>)QueryUtil.list(q,
11532                                                            getDialect(), start, end);
11533                                    }
11534    
11535                                    cacheResult(list);
11536    
11537                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11538                            }
11539                            catch (Exception e) {
11540                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11541    
11542                                    throw processException(e);
11543                            }
11544                            finally {
11545                                    closeSession(session);
11546                            }
11547                    }
11548    
11549                    return list;
11550            }
11551    
11552            /**
11553             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11554             *
11555             * @param groupId the group ID
11556             * @param templateId the template ID
11557             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11558             * @return the first matching journal article
11559             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11560             * @throws SystemException if a system exception occurred
11561             */
11562            public JournalArticle findByG_T_First(long groupId, String templateId,
11563                    OrderByComparator orderByComparator)
11564                    throws NoSuchArticleException, SystemException {
11565                    JournalArticle journalArticle = fetchByG_T_First(groupId, templateId,
11566                                    orderByComparator);
11567    
11568                    if (journalArticle != null) {
11569                            return journalArticle;
11570                    }
11571    
11572                    StringBundler msg = new StringBundler(6);
11573    
11574                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11575    
11576                    msg.append("groupId=");
11577                    msg.append(groupId);
11578    
11579                    msg.append(", templateId=");
11580                    msg.append(templateId);
11581    
11582                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11583    
11584                    throw new NoSuchArticleException(msg.toString());
11585            }
11586    
11587            /**
11588             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11589             *
11590             * @param groupId the group ID
11591             * @param templateId the template ID
11592             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11593             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11594             * @throws SystemException if a system exception occurred
11595             */
11596            public JournalArticle fetchByG_T_First(long groupId, String templateId,
11597                    OrderByComparator orderByComparator) throws SystemException {
11598                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
11599                                    orderByComparator);
11600    
11601                    if (!list.isEmpty()) {
11602                            return list.get(0);
11603                    }
11604    
11605                    return null;
11606            }
11607    
11608            /**
11609             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11610             *
11611             * @param groupId the group ID
11612             * @param templateId the template ID
11613             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11614             * @return the last matching journal article
11615             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11616             * @throws SystemException if a system exception occurred
11617             */
11618            public JournalArticle findByG_T_Last(long groupId, String templateId,
11619                    OrderByComparator orderByComparator)
11620                    throws NoSuchArticleException, SystemException {
11621                    JournalArticle journalArticle = fetchByG_T_Last(groupId, templateId,
11622                                    orderByComparator);
11623    
11624                    if (journalArticle != null) {
11625                            return journalArticle;
11626                    }
11627    
11628                    StringBundler msg = new StringBundler(6);
11629    
11630                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11631    
11632                    msg.append("groupId=");
11633                    msg.append(groupId);
11634    
11635                    msg.append(", templateId=");
11636                    msg.append(templateId);
11637    
11638                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11639    
11640                    throw new NoSuchArticleException(msg.toString());
11641            }
11642    
11643            /**
11644             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11645             *
11646             * @param groupId the group ID
11647             * @param templateId the template ID
11648             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11649             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
11650             * @throws SystemException if a system exception occurred
11651             */
11652            public JournalArticle fetchByG_T_Last(long groupId, String templateId,
11653                    OrderByComparator orderByComparator) throws SystemException {
11654                    int count = countByG_T(groupId, templateId);
11655    
11656                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
11657                                    count, orderByComparator);
11658    
11659                    if (!list.isEmpty()) {
11660                            return list.get(0);
11661                    }
11662    
11663                    return null;
11664            }
11665    
11666            /**
11667             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
11668             *
11669             * @param id the primary key of the current journal article
11670             * @param groupId the group ID
11671             * @param templateId the template ID
11672             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11673             * @return the previous, current, and next journal article
11674             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11675             * @throws SystemException if a system exception occurred
11676             */
11677            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
11678                    String templateId, OrderByComparator orderByComparator)
11679                    throws NoSuchArticleException, SystemException {
11680                    JournalArticle journalArticle = findByPrimaryKey(id);
11681    
11682                    Session session = null;
11683    
11684                    try {
11685                            session = openSession();
11686    
11687                            JournalArticle[] array = new JournalArticleImpl[3];
11688    
11689                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
11690                                            templateId, orderByComparator, true);
11691    
11692                            array[1] = journalArticle;
11693    
11694                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
11695                                            templateId, orderByComparator, false);
11696    
11697                            return array;
11698                    }
11699                    catch (Exception e) {
11700                            throw processException(e);
11701                    }
11702                    finally {
11703                            closeSession(session);
11704                    }
11705            }
11706    
11707            protected JournalArticle getByG_T_PrevAndNext(Session session,
11708                    JournalArticle journalArticle, long groupId, String templateId,
11709                    OrderByComparator orderByComparator, boolean previous) {
11710                    StringBundler query = null;
11711    
11712                    if (orderByComparator != null) {
11713                            query = new StringBundler(6 +
11714                                            (orderByComparator.getOrderByFields().length * 6));
11715                    }
11716                    else {
11717                            query = new StringBundler(3);
11718                    }
11719    
11720                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11721    
11722                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11723    
11724                    boolean bindTemplateId = false;
11725    
11726                    if (templateId == null) {
11727                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11728                    }
11729                    else if (templateId.equals(StringPool.BLANK)) {
11730                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11731                    }
11732                    else {
11733                            bindTemplateId = true;
11734    
11735                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11736                    }
11737    
11738                    if (orderByComparator != null) {
11739                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11740    
11741                            if (orderByConditionFields.length > 0) {
11742                                    query.append(WHERE_AND);
11743                            }
11744    
11745                            for (int i = 0; i < orderByConditionFields.length; i++) {
11746                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11747                                    query.append(orderByConditionFields[i]);
11748    
11749                                    if ((i + 1) < orderByConditionFields.length) {
11750                                            if (orderByComparator.isAscending() ^ previous) {
11751                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11752                                            }
11753                                            else {
11754                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11755                                            }
11756                                    }
11757                                    else {
11758                                            if (orderByComparator.isAscending() ^ previous) {
11759                                                    query.append(WHERE_GREATER_THAN);
11760                                            }
11761                                            else {
11762                                                    query.append(WHERE_LESSER_THAN);
11763                                            }
11764                                    }
11765                            }
11766    
11767                            query.append(ORDER_BY_CLAUSE);
11768    
11769                            String[] orderByFields = orderByComparator.getOrderByFields();
11770    
11771                            for (int i = 0; i < orderByFields.length; i++) {
11772                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11773                                    query.append(orderByFields[i]);
11774    
11775                                    if ((i + 1) < orderByFields.length) {
11776                                            if (orderByComparator.isAscending() ^ previous) {
11777                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11778                                            }
11779                                            else {
11780                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11781                                            }
11782                                    }
11783                                    else {
11784                                            if (orderByComparator.isAscending() ^ previous) {
11785                                                    query.append(ORDER_BY_ASC);
11786                                            }
11787                                            else {
11788                                                    query.append(ORDER_BY_DESC);
11789                                            }
11790                                    }
11791                            }
11792                    }
11793                    else {
11794                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11795                    }
11796    
11797                    String sql = query.toString();
11798    
11799                    Query q = session.createQuery(sql);
11800    
11801                    q.setFirstResult(0);
11802                    q.setMaxResults(2);
11803    
11804                    QueryPos qPos = QueryPos.getInstance(q);
11805    
11806                    qPos.add(groupId);
11807    
11808                    if (bindTemplateId) {
11809                            qPos.add(templateId);
11810                    }
11811    
11812                    if (orderByComparator != null) {
11813                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11814    
11815                            for (Object value : values) {
11816                                    qPos.add(value);
11817                            }
11818                    }
11819    
11820                    List<JournalArticle> list = q.list();
11821    
11822                    if (list.size() == 2) {
11823                            return list.get(1);
11824                    }
11825                    else {
11826                            return null;
11827                    }
11828            }
11829    
11830            /**
11831             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
11832             *
11833             * @param groupId the group ID
11834             * @param templateId the template ID
11835             * @return the matching journal articles that the user has permission to view
11836             * @throws SystemException if a system exception occurred
11837             */
11838            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
11839                    throws SystemException {
11840                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
11841                            QueryUtil.ALL_POS, null);
11842            }
11843    
11844            /**
11845             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
11846             *
11847             * <p>
11848             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11849             * </p>
11850             *
11851             * @param groupId the group ID
11852             * @param templateId the template ID
11853             * @param start the lower bound of the range of journal articles
11854             * @param end the upper bound of the range of journal articles (not inclusive)
11855             * @return the range of matching journal articles that the user has permission to view
11856             * @throws SystemException if a system exception occurred
11857             */
11858            public List<JournalArticle> filterFindByG_T(long groupId,
11859                    String templateId, int start, int end) throws SystemException {
11860                    return filterFindByG_T(groupId, templateId, start, end, null);
11861            }
11862    
11863            /**
11864             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
11865             *
11866             * <p>
11867             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11868             * </p>
11869             *
11870             * @param groupId the group ID
11871             * @param templateId the template ID
11872             * @param start the lower bound of the range of journal articles
11873             * @param end the upper bound of the range of journal articles (not inclusive)
11874             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11875             * @return the ordered range of matching journal articles that the user has permission to view
11876             * @throws SystemException if a system exception occurred
11877             */
11878            public List<JournalArticle> filterFindByG_T(long groupId,
11879                    String templateId, int start, int end,
11880                    OrderByComparator orderByComparator) throws SystemException {
11881                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11882                            return findByG_T(groupId, templateId, start, end, orderByComparator);
11883                    }
11884    
11885                    StringBundler query = null;
11886    
11887                    if (orderByComparator != null) {
11888                            query = new StringBundler(4 +
11889                                            (orderByComparator.getOrderByFields().length * 3));
11890                    }
11891                    else {
11892                            query = new StringBundler(4);
11893                    }
11894    
11895                    if (getDB().isSupportsInlineDistinct()) {
11896                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11897                    }
11898                    else {
11899                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11900                    }
11901    
11902                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11903    
11904                    boolean bindTemplateId = false;
11905    
11906                    if (templateId == null) {
11907                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11908                    }
11909                    else if (templateId.equals(StringPool.BLANK)) {
11910                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11911                    }
11912                    else {
11913                            bindTemplateId = true;
11914    
11915                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11916                    }
11917    
11918                    if (!getDB().isSupportsInlineDistinct()) {
11919                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11920                    }
11921    
11922                    if (orderByComparator != null) {
11923                            if (getDB().isSupportsInlineDistinct()) {
11924                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11925                                            orderByComparator, true);
11926                            }
11927                            else {
11928                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11929                                            orderByComparator, true);
11930                            }
11931                    }
11932                    else {
11933                            if (getDB().isSupportsInlineDistinct()) {
11934                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11935                            }
11936                            else {
11937                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11938                            }
11939                    }
11940    
11941                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11942                                    JournalArticle.class.getName(),
11943                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11944    
11945                    Session session = null;
11946    
11947                    try {
11948                            session = openSession();
11949    
11950                            SQLQuery q = session.createSQLQuery(sql);
11951    
11952                            if (getDB().isSupportsInlineDistinct()) {
11953                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11954                            }
11955                            else {
11956                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11957                            }
11958    
11959                            QueryPos qPos = QueryPos.getInstance(q);
11960    
11961                            qPos.add(groupId);
11962    
11963                            if (bindTemplateId) {
11964                                    qPos.add(templateId);
11965                            }
11966    
11967                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11968                                    end);
11969                    }
11970                    catch (Exception e) {
11971                            throw processException(e);
11972                    }
11973                    finally {
11974                            closeSession(session);
11975                    }
11976            }
11977    
11978            /**
11979             * 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;.
11980             *
11981             * @param id the primary key of the current journal article
11982             * @param groupId the group ID
11983             * @param templateId the template ID
11984             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11985             * @return the previous, current, and next journal article
11986             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11987             * @throws SystemException if a system exception occurred
11988             */
11989            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
11990                    String templateId, OrderByComparator orderByComparator)
11991                    throws NoSuchArticleException, SystemException {
11992                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11993                            return findByG_T_PrevAndNext(id, groupId, templateId,
11994                                    orderByComparator);
11995                    }
11996    
11997                    JournalArticle journalArticle = findByPrimaryKey(id);
11998    
11999                    Session session = null;
12000    
12001                    try {
12002                            session = openSession();
12003    
12004                            JournalArticle[] array = new JournalArticleImpl[3];
12005    
12006                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
12007                                            groupId, templateId, orderByComparator, true);
12008    
12009                            array[1] = journalArticle;
12010    
12011                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
12012                                            groupId, templateId, orderByComparator, false);
12013    
12014                            return array;
12015                    }
12016                    catch (Exception e) {
12017                            throw processException(e);
12018                    }
12019                    finally {
12020                            closeSession(session);
12021                    }
12022            }
12023    
12024            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
12025                    JournalArticle journalArticle, long groupId, String templateId,
12026                    OrderByComparator orderByComparator, boolean previous) {
12027                    StringBundler query = null;
12028    
12029                    if (orderByComparator != null) {
12030                            query = new StringBundler(6 +
12031                                            (orderByComparator.getOrderByFields().length * 6));
12032                    }
12033                    else {
12034                            query = new StringBundler(3);
12035                    }
12036    
12037                    if (getDB().isSupportsInlineDistinct()) {
12038                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12039                    }
12040                    else {
12041                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12042                    }
12043    
12044                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12045    
12046                    boolean bindTemplateId = false;
12047    
12048                    if (templateId == null) {
12049                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12050                    }
12051                    else if (templateId.equals(StringPool.BLANK)) {
12052                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12053                    }
12054                    else {
12055                            bindTemplateId = true;
12056    
12057                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12058                    }
12059    
12060                    if (!getDB().isSupportsInlineDistinct()) {
12061                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12062                    }
12063    
12064                    if (orderByComparator != null) {
12065                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12066    
12067                            if (orderByConditionFields.length > 0) {
12068                                    query.append(WHERE_AND);
12069                            }
12070    
12071                            for (int i = 0; i < orderByConditionFields.length; i++) {
12072                                    if (getDB().isSupportsInlineDistinct()) {
12073                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12074                                    }
12075                                    else {
12076                                            query.append(_ORDER_BY_ENTITY_TABLE);
12077                                    }
12078    
12079                                    query.append(orderByConditionFields[i]);
12080    
12081                                    if ((i + 1) < orderByConditionFields.length) {
12082                                            if (orderByComparator.isAscending() ^ previous) {
12083                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12084                                            }
12085                                            else {
12086                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12087                                            }
12088                                    }
12089                                    else {
12090                                            if (orderByComparator.isAscending() ^ previous) {
12091                                                    query.append(WHERE_GREATER_THAN);
12092                                            }
12093                                            else {
12094                                                    query.append(WHERE_LESSER_THAN);
12095                                            }
12096                                    }
12097                            }
12098    
12099                            query.append(ORDER_BY_CLAUSE);
12100    
12101                            String[] orderByFields = orderByComparator.getOrderByFields();
12102    
12103                            for (int i = 0; i < orderByFields.length; i++) {
12104                                    if (getDB().isSupportsInlineDistinct()) {
12105                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12106                                    }
12107                                    else {
12108                                            query.append(_ORDER_BY_ENTITY_TABLE);
12109                                    }
12110    
12111                                    query.append(orderByFields[i]);
12112    
12113                                    if ((i + 1) < orderByFields.length) {
12114                                            if (orderByComparator.isAscending() ^ previous) {
12115                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12116                                            }
12117                                            else {
12118                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12119                                            }
12120                                    }
12121                                    else {
12122                                            if (orderByComparator.isAscending() ^ previous) {
12123                                                    query.append(ORDER_BY_ASC);
12124                                            }
12125                                            else {
12126                                                    query.append(ORDER_BY_DESC);
12127                                            }
12128                                    }
12129                            }
12130                    }
12131                    else {
12132                            if (getDB().isSupportsInlineDistinct()) {
12133                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12134                            }
12135                            else {
12136                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12137                            }
12138                    }
12139    
12140                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12141                                    JournalArticle.class.getName(),
12142                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12143    
12144                    SQLQuery q = session.createSQLQuery(sql);
12145    
12146                    q.setFirstResult(0);
12147                    q.setMaxResults(2);
12148    
12149                    if (getDB().isSupportsInlineDistinct()) {
12150                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12151                    }
12152                    else {
12153                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12154                    }
12155    
12156                    QueryPos qPos = QueryPos.getInstance(q);
12157    
12158                    qPos.add(groupId);
12159    
12160                    if (bindTemplateId) {
12161                            qPos.add(templateId);
12162                    }
12163    
12164                    if (orderByComparator != null) {
12165                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12166    
12167                            for (Object value : values) {
12168                                    qPos.add(value);
12169                            }
12170                    }
12171    
12172                    List<JournalArticle> list = q.list();
12173    
12174                    if (list.size() == 2) {
12175                            return list.get(1);
12176                    }
12177                    else {
12178                            return null;
12179                    }
12180            }
12181    
12182            /**
12183             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
12184             *
12185             * @param groupId the group ID
12186             * @param templateId the template ID
12187             * @throws SystemException if a system exception occurred
12188             */
12189            public void removeByG_T(long groupId, String templateId)
12190                    throws SystemException {
12191                    for (JournalArticle journalArticle : findByG_T(groupId, templateId,
12192                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12193                            remove(journalArticle);
12194                    }
12195            }
12196    
12197            /**
12198             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
12199             *
12200             * @param groupId the group ID
12201             * @param templateId the template ID
12202             * @return the number of matching journal articles
12203             * @throws SystemException if a system exception occurred
12204             */
12205            public int countByG_T(long groupId, String templateId)
12206                    throws SystemException {
12207                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_T;
12208    
12209                    Object[] finderArgs = new Object[] { groupId, templateId };
12210    
12211                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12212                                    this);
12213    
12214                    if (count == null) {
12215                            StringBundler query = new StringBundler(3);
12216    
12217                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
12218    
12219                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12220    
12221                            boolean bindTemplateId = false;
12222    
12223                            if (templateId == null) {
12224                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12225                            }
12226                            else if (templateId.equals(StringPool.BLANK)) {
12227                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12228                            }
12229                            else {
12230                                    bindTemplateId = true;
12231    
12232                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12233                            }
12234    
12235                            String sql = query.toString();
12236    
12237                            Session session = null;
12238    
12239                            try {
12240                                    session = openSession();
12241    
12242                                    Query q = session.createQuery(sql);
12243    
12244                                    QueryPos qPos = QueryPos.getInstance(q);
12245    
12246                                    qPos.add(groupId);
12247    
12248                                    if (bindTemplateId) {
12249                                            qPos.add(templateId);
12250                                    }
12251    
12252                                    count = (Long)q.uniqueResult();
12253    
12254                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12255                            }
12256                            catch (Exception e) {
12257                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12258    
12259                                    throw processException(e);
12260                            }
12261                            finally {
12262                                    closeSession(session);
12263                            }
12264                    }
12265    
12266                    return count.intValue();
12267            }
12268    
12269            /**
12270             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
12271             *
12272             * @param groupId the group ID
12273             * @param templateId the template ID
12274             * @return the number of matching journal articles that the user has permission to view
12275             * @throws SystemException if a system exception occurred
12276             */
12277            public int filterCountByG_T(long groupId, String templateId)
12278                    throws SystemException {
12279                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12280                            return countByG_T(groupId, templateId);
12281                    }
12282    
12283                    StringBundler query = new StringBundler(3);
12284    
12285                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
12286    
12287                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
12288    
12289                    boolean bindTemplateId = false;
12290    
12291                    if (templateId == null) {
12292                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
12293                    }
12294                    else if (templateId.equals(StringPool.BLANK)) {
12295                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
12296                    }
12297                    else {
12298                            bindTemplateId = true;
12299    
12300                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
12301                    }
12302    
12303                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12304                                    JournalArticle.class.getName(),
12305                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12306    
12307                    Session session = null;
12308    
12309                    try {
12310                            session = openSession();
12311    
12312                            SQLQuery q = session.createSQLQuery(sql);
12313    
12314                            q.addScalar(COUNT_COLUMN_NAME,
12315                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12316    
12317                            QueryPos qPos = QueryPos.getInstance(q);
12318    
12319                            qPos.add(groupId);
12320    
12321                            if (bindTemplateId) {
12322                                    qPos.add(templateId);
12323                            }
12324    
12325                            Long count = (Long)q.uniqueResult();
12326    
12327                            return count.intValue();
12328                    }
12329                    catch (Exception e) {
12330                            throw processException(e);
12331                    }
12332                    finally {
12333                            closeSession(session);
12334                    }
12335            }
12336    
12337            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
12338            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
12339            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
12340            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
12341            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12342                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12343                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
12344                            "findByG_L",
12345                            new String[] {
12346                                    Long.class.getName(), String.class.getName(),
12347                                    
12348                            Integer.class.getName(), Integer.class.getName(),
12349                                    OrderByComparator.class.getName()
12350                            });
12351            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12352                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12353                            JournalArticleImpl.class,
12354                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
12355                            new String[] { Long.class.getName(), String.class.getName() },
12356                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
12357                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
12358                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
12359                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
12360            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12361                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
12362                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
12363                            new String[] { Long.class.getName(), String.class.getName() });
12364    
12365            /**
12366             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12367             *
12368             * @param groupId the group ID
12369             * @param layoutUuid the layout uuid
12370             * @return the matching journal articles
12371             * @throws SystemException if a system exception occurred
12372             */
12373            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
12374                    throws SystemException {
12375                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
12376                            QueryUtil.ALL_POS, null);
12377            }
12378    
12379            /**
12380             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12381             *
12382             * <p>
12383             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12384             * </p>
12385             *
12386             * @param groupId the group ID
12387             * @param layoutUuid the layout uuid
12388             * @param start the lower bound of the range of journal articles
12389             * @param end the upper bound of the range of journal articles (not inclusive)
12390             * @return the range of matching journal articles
12391             * @throws SystemException if a system exception occurred
12392             */
12393            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
12394                    int start, int end) throws SystemException {
12395                    return findByG_L(groupId, layoutUuid, start, end, null);
12396            }
12397    
12398            /**
12399             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
12400             *
12401             * <p>
12402             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12403             * </p>
12404             *
12405             * @param groupId the group ID
12406             * @param layoutUuid the layout uuid
12407             * @param start the lower bound of the range of journal articles
12408             * @param end the upper bound of the range of journal articles (not inclusive)
12409             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12410             * @return the ordered range of matching journal articles
12411             * @throws SystemException if a system exception occurred
12412             */
12413            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
12414                    int start, int end, OrderByComparator orderByComparator)
12415                    throws SystemException {
12416                    boolean pagination = true;
12417                    FinderPath finderPath = null;
12418                    Object[] finderArgs = null;
12419    
12420                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12421                                    (orderByComparator == null)) {
12422                            pagination = false;
12423                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
12424                            finderArgs = new Object[] { groupId, layoutUuid };
12425                    }
12426                    else {
12427                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
12428                            finderArgs = new Object[] {
12429                                            groupId, layoutUuid,
12430                                            
12431                                            start, end, orderByComparator
12432                                    };
12433                    }
12434    
12435                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12436                                    finderArgs, this);
12437    
12438                    if ((list != null) && !list.isEmpty()) {
12439                            for (JournalArticle journalArticle : list) {
12440                                    if ((groupId != journalArticle.getGroupId()) ||
12441                                                    !Validator.equals(layoutUuid,
12442                                                            journalArticle.getLayoutUuid())) {
12443                                            list = null;
12444    
12445                                            break;
12446                                    }
12447                            }
12448                    }
12449    
12450                    if (list == null) {
12451                            StringBundler query = null;
12452    
12453                            if (orderByComparator != null) {
12454                                    query = new StringBundler(4 +
12455                                                    (orderByComparator.getOrderByFields().length * 3));
12456                            }
12457                            else {
12458                                    query = new StringBundler(4);
12459                            }
12460    
12461                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12462    
12463                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12464    
12465                            boolean bindLayoutUuid = false;
12466    
12467                            if (layoutUuid == null) {
12468                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12469                            }
12470                            else if (layoutUuid.equals(StringPool.BLANK)) {
12471                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12472                            }
12473                            else {
12474                                    bindLayoutUuid = true;
12475    
12476                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12477                            }
12478    
12479                            if (orderByComparator != null) {
12480                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12481                                            orderByComparator);
12482                            }
12483                            else
12484                             if (pagination) {
12485                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12486                            }
12487    
12488                            String sql = query.toString();
12489    
12490                            Session session = null;
12491    
12492                            try {
12493                                    session = openSession();
12494    
12495                                    Query q = session.createQuery(sql);
12496    
12497                                    QueryPos qPos = QueryPos.getInstance(q);
12498    
12499                                    qPos.add(groupId);
12500    
12501                                    if (bindLayoutUuid) {
12502                                            qPos.add(layoutUuid);
12503                                    }
12504    
12505                                    if (!pagination) {
12506                                            list = (List<JournalArticle>)QueryUtil.list(q,
12507                                                            getDialect(), start, end, false);
12508    
12509                                            Collections.sort(list);
12510    
12511                                            list = new UnmodifiableList<JournalArticle>(list);
12512                                    }
12513                                    else {
12514                                            list = (List<JournalArticle>)QueryUtil.list(q,
12515                                                            getDialect(), start, end);
12516                                    }
12517    
12518                                    cacheResult(list);
12519    
12520                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12521                            }
12522                            catch (Exception e) {
12523                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12524    
12525                                    throw processException(e);
12526                            }
12527                            finally {
12528                                    closeSession(session);
12529                            }
12530                    }
12531    
12532                    return list;
12533            }
12534    
12535            /**
12536             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12537             *
12538             * @param groupId the group ID
12539             * @param layoutUuid the layout uuid
12540             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12541             * @return the first matching journal article
12542             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12543             * @throws SystemException if a system exception occurred
12544             */
12545            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
12546                    OrderByComparator orderByComparator)
12547                    throws NoSuchArticleException, SystemException {
12548                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
12549                                    orderByComparator);
12550    
12551                    if (journalArticle != null) {
12552                            return journalArticle;
12553                    }
12554    
12555                    StringBundler msg = new StringBundler(6);
12556    
12557                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12558    
12559                    msg.append("groupId=");
12560                    msg.append(groupId);
12561    
12562                    msg.append(", layoutUuid=");
12563                    msg.append(layoutUuid);
12564    
12565                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12566    
12567                    throw new NoSuchArticleException(msg.toString());
12568            }
12569    
12570            /**
12571             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12572             *
12573             * @param groupId the group ID
12574             * @param layoutUuid the layout uuid
12575             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12576             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12577             * @throws SystemException if a system exception occurred
12578             */
12579            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
12580                    OrderByComparator orderByComparator) throws SystemException {
12581                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
12582                                    orderByComparator);
12583    
12584                    if (!list.isEmpty()) {
12585                            return list.get(0);
12586                    }
12587    
12588                    return null;
12589            }
12590    
12591            /**
12592             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12593             *
12594             * @param groupId the group ID
12595             * @param layoutUuid the layout uuid
12596             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12597             * @return the last matching journal article
12598             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12599             * @throws SystemException if a system exception occurred
12600             */
12601            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
12602                    OrderByComparator orderByComparator)
12603                    throws NoSuchArticleException, SystemException {
12604                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
12605                                    orderByComparator);
12606    
12607                    if (journalArticle != null) {
12608                            return journalArticle;
12609                    }
12610    
12611                    StringBundler msg = new StringBundler(6);
12612    
12613                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12614    
12615                    msg.append("groupId=");
12616                    msg.append(groupId);
12617    
12618                    msg.append(", layoutUuid=");
12619                    msg.append(layoutUuid);
12620    
12621                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12622    
12623                    throw new NoSuchArticleException(msg.toString());
12624            }
12625    
12626            /**
12627             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12628             *
12629             * @param groupId the group ID
12630             * @param layoutUuid the layout uuid
12631             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12632             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12633             * @throws SystemException if a system exception occurred
12634             */
12635            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
12636                    OrderByComparator orderByComparator) throws SystemException {
12637                    int count = countByG_L(groupId, layoutUuid);
12638    
12639                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
12640                                    count, orderByComparator);
12641    
12642                    if (!list.isEmpty()) {
12643                            return list.get(0);
12644                    }
12645    
12646                    return null;
12647            }
12648    
12649            /**
12650             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
12651             *
12652             * @param id the primary key of the current journal article
12653             * @param groupId the group ID
12654             * @param layoutUuid the layout uuid
12655             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12656             * @return the previous, current, and next journal article
12657             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12658             * @throws SystemException if a system exception occurred
12659             */
12660            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
12661                    String layoutUuid, OrderByComparator orderByComparator)
12662                    throws NoSuchArticleException, SystemException {
12663                    JournalArticle journalArticle = findByPrimaryKey(id);
12664    
12665                    Session session = null;
12666    
12667                    try {
12668                            session = openSession();
12669    
12670                            JournalArticle[] array = new JournalArticleImpl[3];
12671    
12672                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
12673                                            layoutUuid, orderByComparator, true);
12674    
12675                            array[1] = journalArticle;
12676    
12677                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
12678                                            layoutUuid, orderByComparator, false);
12679    
12680                            return array;
12681                    }
12682                    catch (Exception e) {
12683                            throw processException(e);
12684                    }
12685                    finally {
12686                            closeSession(session);
12687                    }
12688            }
12689    
12690            protected JournalArticle getByG_L_PrevAndNext(Session session,
12691                    JournalArticle journalArticle, long groupId, String layoutUuid,
12692                    OrderByComparator orderByComparator, boolean previous) {
12693                    StringBundler query = null;
12694    
12695                    if (orderByComparator != null) {
12696                            query = new StringBundler(6 +
12697                                            (orderByComparator.getOrderByFields().length * 6));
12698                    }
12699                    else {
12700                            query = new StringBundler(3);
12701                    }
12702    
12703                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12704    
12705                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12706    
12707                    boolean bindLayoutUuid = false;
12708    
12709                    if (layoutUuid == null) {
12710                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12711                    }
12712                    else if (layoutUuid.equals(StringPool.BLANK)) {
12713                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12714                    }
12715                    else {
12716                            bindLayoutUuid = true;
12717    
12718                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12719                    }
12720    
12721                    if (orderByComparator != null) {
12722                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12723    
12724                            if (orderByConditionFields.length > 0) {
12725                                    query.append(WHERE_AND);
12726                            }
12727    
12728                            for (int i = 0; i < orderByConditionFields.length; i++) {
12729                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12730                                    query.append(orderByConditionFields[i]);
12731    
12732                                    if ((i + 1) < orderByConditionFields.length) {
12733                                            if (orderByComparator.isAscending() ^ previous) {
12734                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12735                                            }
12736                                            else {
12737                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12738                                            }
12739                                    }
12740                                    else {
12741                                            if (orderByComparator.isAscending() ^ previous) {
12742                                                    query.append(WHERE_GREATER_THAN);
12743                                            }
12744                                            else {
12745                                                    query.append(WHERE_LESSER_THAN);
12746                                            }
12747                                    }
12748                            }
12749    
12750                            query.append(ORDER_BY_CLAUSE);
12751    
12752                            String[] orderByFields = orderByComparator.getOrderByFields();
12753    
12754                            for (int i = 0; i < orderByFields.length; i++) {
12755                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12756                                    query.append(orderByFields[i]);
12757    
12758                                    if ((i + 1) < orderByFields.length) {
12759                                            if (orderByComparator.isAscending() ^ previous) {
12760                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12761                                            }
12762                                            else {
12763                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12764                                            }
12765                                    }
12766                                    else {
12767                                            if (orderByComparator.isAscending() ^ previous) {
12768                                                    query.append(ORDER_BY_ASC);
12769                                            }
12770                                            else {
12771                                                    query.append(ORDER_BY_DESC);
12772                                            }
12773                                    }
12774                            }
12775                    }
12776                    else {
12777                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12778                    }
12779    
12780                    String sql = query.toString();
12781    
12782                    Query q = session.createQuery(sql);
12783    
12784                    q.setFirstResult(0);
12785                    q.setMaxResults(2);
12786    
12787                    QueryPos qPos = QueryPos.getInstance(q);
12788    
12789                    qPos.add(groupId);
12790    
12791                    if (bindLayoutUuid) {
12792                            qPos.add(layoutUuid);
12793                    }
12794    
12795                    if (orderByComparator != null) {
12796                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12797    
12798                            for (Object value : values) {
12799                                    qPos.add(value);
12800                            }
12801                    }
12802    
12803                    List<JournalArticle> list = q.list();
12804    
12805                    if (list.size() == 2) {
12806                            return list.get(1);
12807                    }
12808                    else {
12809                            return null;
12810                    }
12811            }
12812    
12813            /**
12814             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
12815             *
12816             * @param groupId the group ID
12817             * @param layoutUuid the layout uuid
12818             * @return the matching journal articles that the user has permission to view
12819             * @throws SystemException if a system exception occurred
12820             */
12821            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
12822                    throws SystemException {
12823                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
12824                            QueryUtil.ALL_POS, null);
12825            }
12826    
12827            /**
12828             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
12829             *
12830             * <p>
12831             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12832             * </p>
12833             *
12834             * @param groupId the group ID
12835             * @param layoutUuid the layout uuid
12836             * @param start the lower bound of the range of journal articles
12837             * @param end the upper bound of the range of journal articles (not inclusive)
12838             * @return the range of matching journal articles that the user has permission to view
12839             * @throws SystemException if a system exception occurred
12840             */
12841            public List<JournalArticle> filterFindByG_L(long groupId,
12842                    String layoutUuid, int start, int end) throws SystemException {
12843                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
12844            }
12845    
12846            /**
12847             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
12848             *
12849             * <p>
12850             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12851             * </p>
12852             *
12853             * @param groupId the group ID
12854             * @param layoutUuid the layout uuid
12855             * @param start the lower bound of the range of journal articles
12856             * @param end the upper bound of the range of journal articles (not inclusive)
12857             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12858             * @return the ordered range of matching journal articles that the user has permission to view
12859             * @throws SystemException if a system exception occurred
12860             */
12861            public List<JournalArticle> filterFindByG_L(long groupId,
12862                    String layoutUuid, int start, int end,
12863                    OrderByComparator orderByComparator) throws SystemException {
12864                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12865                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
12866                    }
12867    
12868                    StringBundler query = null;
12869    
12870                    if (orderByComparator != null) {
12871                            query = new StringBundler(4 +
12872                                            (orderByComparator.getOrderByFields().length * 3));
12873                    }
12874                    else {
12875                            query = new StringBundler(4);
12876                    }
12877    
12878                    if (getDB().isSupportsInlineDistinct()) {
12879                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12880                    }
12881                    else {
12882                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12883                    }
12884    
12885                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
12886    
12887                    boolean bindLayoutUuid = false;
12888    
12889                    if (layoutUuid == null) {
12890                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
12891                    }
12892                    else if (layoutUuid.equals(StringPool.BLANK)) {
12893                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
12894                    }
12895                    else {
12896                            bindLayoutUuid = true;
12897    
12898                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
12899                    }
12900    
12901                    if (!getDB().isSupportsInlineDistinct()) {
12902                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12903                    }
12904    
12905                    if (orderByComparator != null) {
12906                            if (getDB().isSupportsInlineDistinct()) {
12907                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12908                                            orderByComparator, true);
12909                            }
12910                            else {
12911                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12912                                            orderByComparator, true);
12913                            }
12914                    }
12915                    else {
12916                            if (getDB().isSupportsInlineDistinct()) {
12917                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12918                            }
12919                            else {
12920                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12921                            }
12922                    }
12923    
12924                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12925                                    JournalArticle.class.getName(),
12926                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12927    
12928                    Session session = null;
12929    
12930                    try {
12931                            session = openSession();
12932    
12933                            SQLQuery q = session.createSQLQuery(sql);
12934    
12935                            if (getDB().isSupportsInlineDistinct()) {
12936                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12937                            }
12938                            else {
12939                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12940                            }
12941    
12942                            QueryPos qPos = QueryPos.getInstance(q);
12943    
12944                            qPos.add(groupId);
12945    
12946                            if (bindLayoutUuid) {
12947                                    qPos.add(layoutUuid);
12948                            }
12949    
12950                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12951                                    end);
12952                    }
12953                    catch (Exception e) {
12954                            throw processException(e);
12955                    }
12956                    finally {
12957                            closeSession(session);
12958                    }
12959            }
12960    
12961            /**
12962             * 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;.
12963             *
12964             * @param id the primary key of the current journal article
12965             * @param groupId the group ID
12966             * @param layoutUuid the layout uuid
12967             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12968             * @return the previous, current, and next journal article
12969             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12970             * @throws SystemException if a system exception occurred
12971             */
12972            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
12973                    String layoutUuid, OrderByComparator orderByComparator)
12974                    throws NoSuchArticleException, SystemException {
12975                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12976                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
12977                                    orderByComparator);
12978                    }
12979    
12980                    JournalArticle journalArticle = findByPrimaryKey(id);
12981    
12982                    Session session = null;
12983    
12984                    try {
12985                            session = openSession();
12986    
12987                            JournalArticle[] array = new JournalArticleImpl[3];
12988    
12989                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
12990                                            groupId, layoutUuid, orderByComparator, true);
12991    
12992                            array[1] = journalArticle;
12993    
12994                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
12995                                            groupId, layoutUuid, orderByComparator, false);
12996    
12997                            return array;
12998                    }
12999                    catch (Exception e) {
13000                            throw processException(e);
13001                    }
13002                    finally {
13003                            closeSession(session);
13004                    }
13005            }
13006    
13007            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
13008                    JournalArticle journalArticle, long groupId, String layoutUuid,
13009                    OrderByComparator orderByComparator, boolean previous) {
13010                    StringBundler query = null;
13011    
13012                    if (orderByComparator != null) {
13013                            query = new StringBundler(6 +
13014                                            (orderByComparator.getOrderByFields().length * 6));
13015                    }
13016                    else {
13017                            query = new StringBundler(3);
13018                    }
13019    
13020                    if (getDB().isSupportsInlineDistinct()) {
13021                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13022                    }
13023                    else {
13024                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13025                    }
13026    
13027                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13028    
13029                    boolean bindLayoutUuid = false;
13030    
13031                    if (layoutUuid == null) {
13032                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13033                    }
13034                    else if (layoutUuid.equals(StringPool.BLANK)) {
13035                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13036                    }
13037                    else {
13038                            bindLayoutUuid = true;
13039    
13040                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13041                    }
13042    
13043                    if (!getDB().isSupportsInlineDistinct()) {
13044                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13045                    }
13046    
13047                    if (orderByComparator != null) {
13048                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13049    
13050                            if (orderByConditionFields.length > 0) {
13051                                    query.append(WHERE_AND);
13052                            }
13053    
13054                            for (int i = 0; i < orderByConditionFields.length; i++) {
13055                                    if (getDB().isSupportsInlineDistinct()) {
13056                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13057                                    }
13058                                    else {
13059                                            query.append(_ORDER_BY_ENTITY_TABLE);
13060                                    }
13061    
13062                                    query.append(orderByConditionFields[i]);
13063    
13064                                    if ((i + 1) < orderByConditionFields.length) {
13065                                            if (orderByComparator.isAscending() ^ previous) {
13066                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13067                                            }
13068                                            else {
13069                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13070                                            }
13071                                    }
13072                                    else {
13073                                            if (orderByComparator.isAscending() ^ previous) {
13074                                                    query.append(WHERE_GREATER_THAN);
13075                                            }
13076                                            else {
13077                                                    query.append(WHERE_LESSER_THAN);
13078                                            }
13079                                    }
13080                            }
13081    
13082                            query.append(ORDER_BY_CLAUSE);
13083    
13084                            String[] orderByFields = orderByComparator.getOrderByFields();
13085    
13086                            for (int i = 0; i < orderByFields.length; i++) {
13087                                    if (getDB().isSupportsInlineDistinct()) {
13088                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13089                                    }
13090                                    else {
13091                                            query.append(_ORDER_BY_ENTITY_TABLE);
13092                                    }
13093    
13094                                    query.append(orderByFields[i]);
13095    
13096                                    if ((i + 1) < orderByFields.length) {
13097                                            if (orderByComparator.isAscending() ^ previous) {
13098                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13099                                            }
13100                                            else {
13101                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13102                                            }
13103                                    }
13104                                    else {
13105                                            if (orderByComparator.isAscending() ^ previous) {
13106                                                    query.append(ORDER_BY_ASC);
13107                                            }
13108                                            else {
13109                                                    query.append(ORDER_BY_DESC);
13110                                            }
13111                                    }
13112                            }
13113                    }
13114                    else {
13115                            if (getDB().isSupportsInlineDistinct()) {
13116                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13117                            }
13118                            else {
13119                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13120                            }
13121                    }
13122    
13123                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13124                                    JournalArticle.class.getName(),
13125                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13126    
13127                    SQLQuery q = session.createSQLQuery(sql);
13128    
13129                    q.setFirstResult(0);
13130                    q.setMaxResults(2);
13131    
13132                    if (getDB().isSupportsInlineDistinct()) {
13133                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13134                    }
13135                    else {
13136                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13137                    }
13138    
13139                    QueryPos qPos = QueryPos.getInstance(q);
13140    
13141                    qPos.add(groupId);
13142    
13143                    if (bindLayoutUuid) {
13144                            qPos.add(layoutUuid);
13145                    }
13146    
13147                    if (orderByComparator != null) {
13148                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13149    
13150                            for (Object value : values) {
13151                                    qPos.add(value);
13152                            }
13153                    }
13154    
13155                    List<JournalArticle> list = q.list();
13156    
13157                    if (list.size() == 2) {
13158                            return list.get(1);
13159                    }
13160                    else {
13161                            return null;
13162                    }
13163            }
13164    
13165            /**
13166             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
13167             *
13168             * @param groupId the group ID
13169             * @param layoutUuid the layout uuid
13170             * @throws SystemException if a system exception occurred
13171             */
13172            public void removeByG_L(long groupId, String layoutUuid)
13173                    throws SystemException {
13174                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid,
13175                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13176                            remove(journalArticle);
13177                    }
13178            }
13179    
13180            /**
13181             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
13182             *
13183             * @param groupId the group ID
13184             * @param layoutUuid the layout uuid
13185             * @return the number of matching journal articles
13186             * @throws SystemException if a system exception occurred
13187             */
13188            public int countByG_L(long groupId, String layoutUuid)
13189                    throws SystemException {
13190                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_L;
13191    
13192                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
13193    
13194                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13195                                    this);
13196    
13197                    if (count == null) {
13198                            StringBundler query = new StringBundler(3);
13199    
13200                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
13201    
13202                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13203    
13204                            boolean bindLayoutUuid = false;
13205    
13206                            if (layoutUuid == null) {
13207                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13208                            }
13209                            else if (layoutUuid.equals(StringPool.BLANK)) {
13210                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13211                            }
13212                            else {
13213                                    bindLayoutUuid = true;
13214    
13215                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13216                            }
13217    
13218                            String sql = query.toString();
13219    
13220                            Session session = null;
13221    
13222                            try {
13223                                    session = openSession();
13224    
13225                                    Query q = session.createQuery(sql);
13226    
13227                                    QueryPos qPos = QueryPos.getInstance(q);
13228    
13229                                    qPos.add(groupId);
13230    
13231                                    if (bindLayoutUuid) {
13232                                            qPos.add(layoutUuid);
13233                                    }
13234    
13235                                    count = (Long)q.uniqueResult();
13236    
13237                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13238                            }
13239                            catch (Exception e) {
13240                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13241    
13242                                    throw processException(e);
13243                            }
13244                            finally {
13245                                    closeSession(session);
13246                            }
13247                    }
13248    
13249                    return count.intValue();
13250            }
13251    
13252            /**
13253             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13254             *
13255             * @param groupId the group ID
13256             * @param layoutUuid the layout uuid
13257             * @return the number of matching journal articles that the user has permission to view
13258             * @throws SystemException if a system exception occurred
13259             */
13260            public int filterCountByG_L(long groupId, String layoutUuid)
13261                    throws SystemException {
13262                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13263                            return countByG_L(groupId, layoutUuid);
13264                    }
13265    
13266                    StringBundler query = new StringBundler(3);
13267    
13268                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
13269    
13270                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13271    
13272                    boolean bindLayoutUuid = false;
13273    
13274                    if (layoutUuid == null) {
13275                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13276                    }
13277                    else if (layoutUuid.equals(StringPool.BLANK)) {
13278                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13279                    }
13280                    else {
13281                            bindLayoutUuid = true;
13282    
13283                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13284                    }
13285    
13286                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13287                                    JournalArticle.class.getName(),
13288                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13289    
13290                    Session session = null;
13291    
13292                    try {
13293                            session = openSession();
13294    
13295                            SQLQuery q = session.createSQLQuery(sql);
13296    
13297                            q.addScalar(COUNT_COLUMN_NAME,
13298                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13299    
13300                            QueryPos qPos = QueryPos.getInstance(q);
13301    
13302                            qPos.add(groupId);
13303    
13304                            if (bindLayoutUuid) {
13305                                    qPos.add(layoutUuid);
13306                            }
13307    
13308                            Long count = (Long)q.uniqueResult();
13309    
13310                            return count.intValue();
13311                    }
13312                    catch (Exception e) {
13313                            throw processException(e);
13314                    }
13315                    finally {
13316                            closeSession(session);
13317                    }
13318            }
13319    
13320            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
13321            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
13322            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
13323            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
13324            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13325                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13326                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
13327                            "findByG_ST",
13328                            new String[] {
13329                                    Long.class.getName(), Integer.class.getName(),
13330                                    
13331                            Integer.class.getName(), Integer.class.getName(),
13332                                    OrderByComparator.class.getName()
13333                            });
13334            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13335                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13336                            JournalArticleImpl.class,
13337                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
13338                            new String[] { Long.class.getName(), Integer.class.getName() },
13339                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
13340                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
13341                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
13342                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
13343            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13344                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
13345                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
13346                            new String[] { Long.class.getName(), Integer.class.getName() });
13347    
13348            /**
13349             * Returns all the journal articles where groupId = &#63; and status = &#63;.
13350             *
13351             * @param groupId the group ID
13352             * @param status the status
13353             * @return the matching journal articles
13354             * @throws SystemException if a system exception occurred
13355             */
13356            public List<JournalArticle> findByG_ST(long groupId, int status)
13357                    throws SystemException {
13358                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
13359                            QueryUtil.ALL_POS, null);
13360            }
13361    
13362            /**
13363             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
13364             *
13365             * <p>
13366             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13367             * </p>
13368             *
13369             * @param groupId the group ID
13370             * @param status the status
13371             * @param start the lower bound of the range of journal articles
13372             * @param end the upper bound of the range of journal articles (not inclusive)
13373             * @return the range of matching journal articles
13374             * @throws SystemException if a system exception occurred
13375             */
13376            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
13377                    int end) throws SystemException {
13378                    return findByG_ST(groupId, status, start, end, null);
13379            }
13380    
13381            /**
13382             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
13383             *
13384             * <p>
13385             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13386             * </p>
13387             *
13388             * @param groupId the group ID
13389             * @param status the status
13390             * @param start the lower bound of the range of journal articles
13391             * @param end the upper bound of the range of journal articles (not inclusive)
13392             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13393             * @return the ordered range of matching journal articles
13394             * @throws SystemException if a system exception occurred
13395             */
13396            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
13397                    int end, OrderByComparator orderByComparator) throws SystemException {
13398                    boolean pagination = true;
13399                    FinderPath finderPath = null;
13400                    Object[] finderArgs = null;
13401    
13402                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13403                                    (orderByComparator == null)) {
13404                            pagination = false;
13405                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
13406                            finderArgs = new Object[] { groupId, status };
13407                    }
13408                    else {
13409                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
13410                            finderArgs = new Object[] {
13411                                            groupId, status,
13412                                            
13413                                            start, end, orderByComparator
13414                                    };
13415                    }
13416    
13417                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13418                                    finderArgs, this);
13419    
13420                    if ((list != null) && !list.isEmpty()) {
13421                            for (JournalArticle journalArticle : list) {
13422                                    if ((groupId != journalArticle.getGroupId()) ||
13423                                                    (status != journalArticle.getStatus())) {
13424                                            list = null;
13425    
13426                                            break;
13427                                    }
13428                            }
13429                    }
13430    
13431                    if (list == null) {
13432                            StringBundler query = null;
13433    
13434                            if (orderByComparator != null) {
13435                                    query = new StringBundler(4 +
13436                                                    (orderByComparator.getOrderByFields().length * 3));
13437                            }
13438                            else {
13439                                    query = new StringBundler(4);
13440                            }
13441    
13442                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13443    
13444                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13445    
13446                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13447    
13448                            if (orderByComparator != null) {
13449                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13450                                            orderByComparator);
13451                            }
13452                            else
13453                             if (pagination) {
13454                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13455                            }
13456    
13457                            String sql = query.toString();
13458    
13459                            Session session = null;
13460    
13461                            try {
13462                                    session = openSession();
13463    
13464                                    Query q = session.createQuery(sql);
13465    
13466                                    QueryPos qPos = QueryPos.getInstance(q);
13467    
13468                                    qPos.add(groupId);
13469    
13470                                    qPos.add(status);
13471    
13472                                    if (!pagination) {
13473                                            list = (List<JournalArticle>)QueryUtil.list(q,
13474                                                            getDialect(), start, end, false);
13475    
13476                                            Collections.sort(list);
13477    
13478                                            list = new UnmodifiableList<JournalArticle>(list);
13479                                    }
13480                                    else {
13481                                            list = (List<JournalArticle>)QueryUtil.list(q,
13482                                                            getDialect(), start, end);
13483                                    }
13484    
13485                                    cacheResult(list);
13486    
13487                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13488                            }
13489                            catch (Exception e) {
13490                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13491    
13492                                    throw processException(e);
13493                            }
13494                            finally {
13495                                    closeSession(session);
13496                            }
13497                    }
13498    
13499                    return list;
13500            }
13501    
13502            /**
13503             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
13504             *
13505             * @param groupId the group ID
13506             * @param status the status
13507             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13508             * @return the first matching journal article
13509             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13510             * @throws SystemException if a system exception occurred
13511             */
13512            public JournalArticle findByG_ST_First(long groupId, int status,
13513                    OrderByComparator orderByComparator)
13514                    throws NoSuchArticleException, SystemException {
13515                    JournalArticle journalArticle = fetchByG_ST_First(groupId, status,
13516                                    orderByComparator);
13517    
13518                    if (journalArticle != null) {
13519                            return journalArticle;
13520                    }
13521    
13522                    StringBundler msg = new StringBundler(6);
13523    
13524                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13525    
13526                    msg.append("groupId=");
13527                    msg.append(groupId);
13528    
13529                    msg.append(", status=");
13530                    msg.append(status);
13531    
13532                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13533    
13534                    throw new NoSuchArticleException(msg.toString());
13535            }
13536    
13537            /**
13538             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
13539             *
13540             * @param groupId the group ID
13541             * @param status the status
13542             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13543             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13544             * @throws SystemException if a system exception occurred
13545             */
13546            public JournalArticle fetchByG_ST_First(long groupId, int status,
13547                    OrderByComparator orderByComparator) throws SystemException {
13548                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
13549                                    orderByComparator);
13550    
13551                    if (!list.isEmpty()) {
13552                            return list.get(0);
13553                    }
13554    
13555                    return null;
13556            }
13557    
13558            /**
13559             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
13560             *
13561             * @param groupId the group ID
13562             * @param status the status
13563             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13564             * @return the last matching journal article
13565             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13566             * @throws SystemException if a system exception occurred
13567             */
13568            public JournalArticle findByG_ST_Last(long groupId, int status,
13569                    OrderByComparator orderByComparator)
13570                    throws NoSuchArticleException, SystemException {
13571                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
13572                                    orderByComparator);
13573    
13574                    if (journalArticle != null) {
13575                            return journalArticle;
13576                    }
13577    
13578                    StringBundler msg = new StringBundler(6);
13579    
13580                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13581    
13582                    msg.append("groupId=");
13583                    msg.append(groupId);
13584    
13585                    msg.append(", status=");
13586                    msg.append(status);
13587    
13588                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13589    
13590                    throw new NoSuchArticleException(msg.toString());
13591            }
13592    
13593            /**
13594             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
13595             *
13596             * @param groupId the group ID
13597             * @param status the status
13598             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13599             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13600             * @throws SystemException if a system exception occurred
13601             */
13602            public JournalArticle fetchByG_ST_Last(long groupId, int status,
13603                    OrderByComparator orderByComparator) throws SystemException {
13604                    int count = countByG_ST(groupId, status);
13605    
13606                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
13607                                    count, orderByComparator);
13608    
13609                    if (!list.isEmpty()) {
13610                            return list.get(0);
13611                    }
13612    
13613                    return null;
13614            }
13615    
13616            /**
13617             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
13618             *
13619             * @param id the primary key of the current journal article
13620             * @param groupId the group ID
13621             * @param status the status
13622             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13623             * @return the previous, current, and next journal article
13624             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13625             * @throws SystemException if a system exception occurred
13626             */
13627            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
13628                    int status, OrderByComparator orderByComparator)
13629                    throws NoSuchArticleException, SystemException {
13630                    JournalArticle journalArticle = findByPrimaryKey(id);
13631    
13632                    Session session = null;
13633    
13634                    try {
13635                            session = openSession();
13636    
13637                            JournalArticle[] array = new JournalArticleImpl[3];
13638    
13639                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
13640                                            status, orderByComparator, true);
13641    
13642                            array[1] = journalArticle;
13643    
13644                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
13645                                            status, orderByComparator, false);
13646    
13647                            return array;
13648                    }
13649                    catch (Exception e) {
13650                            throw processException(e);
13651                    }
13652                    finally {
13653                            closeSession(session);
13654                    }
13655            }
13656    
13657            protected JournalArticle getByG_ST_PrevAndNext(Session session,
13658                    JournalArticle journalArticle, long groupId, int status,
13659                    OrderByComparator orderByComparator, boolean previous) {
13660                    StringBundler query = null;
13661    
13662                    if (orderByComparator != null) {
13663                            query = new StringBundler(6 +
13664                                            (orderByComparator.getOrderByFields().length * 6));
13665                    }
13666                    else {
13667                            query = new StringBundler(3);
13668                    }
13669    
13670                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13671    
13672                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13673    
13674                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13675    
13676                    if (orderByComparator != null) {
13677                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13678    
13679                            if (orderByConditionFields.length > 0) {
13680                                    query.append(WHERE_AND);
13681                            }
13682    
13683                            for (int i = 0; i < orderByConditionFields.length; i++) {
13684                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13685                                    query.append(orderByConditionFields[i]);
13686    
13687                                    if ((i + 1) < orderByConditionFields.length) {
13688                                            if (orderByComparator.isAscending() ^ previous) {
13689                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13690                                            }
13691                                            else {
13692                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13693                                            }
13694                                    }
13695                                    else {
13696                                            if (orderByComparator.isAscending() ^ previous) {
13697                                                    query.append(WHERE_GREATER_THAN);
13698                                            }
13699                                            else {
13700                                                    query.append(WHERE_LESSER_THAN);
13701                                            }
13702                                    }
13703                            }
13704    
13705                            query.append(ORDER_BY_CLAUSE);
13706    
13707                            String[] orderByFields = orderByComparator.getOrderByFields();
13708    
13709                            for (int i = 0; i < orderByFields.length; i++) {
13710                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13711                                    query.append(orderByFields[i]);
13712    
13713                                    if ((i + 1) < orderByFields.length) {
13714                                            if (orderByComparator.isAscending() ^ previous) {
13715                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13716                                            }
13717                                            else {
13718                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13719                                            }
13720                                    }
13721                                    else {
13722                                            if (orderByComparator.isAscending() ^ previous) {
13723                                                    query.append(ORDER_BY_ASC);
13724                                            }
13725                                            else {
13726                                                    query.append(ORDER_BY_DESC);
13727                                            }
13728                                    }
13729                            }
13730                    }
13731                    else {
13732                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13733                    }
13734    
13735                    String sql = query.toString();
13736    
13737                    Query q = session.createQuery(sql);
13738    
13739                    q.setFirstResult(0);
13740                    q.setMaxResults(2);
13741    
13742                    QueryPos qPos = QueryPos.getInstance(q);
13743    
13744                    qPos.add(groupId);
13745    
13746                    qPos.add(status);
13747    
13748                    if (orderByComparator != null) {
13749                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13750    
13751                            for (Object value : values) {
13752                                    qPos.add(value);
13753                            }
13754                    }
13755    
13756                    List<JournalArticle> list = q.list();
13757    
13758                    if (list.size() == 2) {
13759                            return list.get(1);
13760                    }
13761                    else {
13762                            return null;
13763                    }
13764            }
13765    
13766            /**
13767             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
13768             *
13769             * @param groupId the group ID
13770             * @param status the status
13771             * @return the matching journal articles that the user has permission to view
13772             * @throws SystemException if a system exception occurred
13773             */
13774            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
13775                    throws SystemException {
13776                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
13777                            QueryUtil.ALL_POS, null);
13778            }
13779    
13780            /**
13781             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
13782             *
13783             * <p>
13784             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13785             * </p>
13786             *
13787             * @param groupId the group ID
13788             * @param status the status
13789             * @param start the lower bound of the range of journal articles
13790             * @param end the upper bound of the range of journal articles (not inclusive)
13791             * @return the range of matching journal articles that the user has permission to view
13792             * @throws SystemException if a system exception occurred
13793             */
13794            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
13795                    int start, int end) throws SystemException {
13796                    return filterFindByG_ST(groupId, status, start, end, null);
13797            }
13798    
13799            /**
13800             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
13801             *
13802             * <p>
13803             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13804             * </p>
13805             *
13806             * @param groupId the group ID
13807             * @param status the status
13808             * @param start the lower bound of the range of journal articles
13809             * @param end the upper bound of the range of journal articles (not inclusive)
13810             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13811             * @return the ordered range of matching journal articles that the user has permission to view
13812             * @throws SystemException if a system exception occurred
13813             */
13814            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
13815                    int start, int end, OrderByComparator orderByComparator)
13816                    throws SystemException {
13817                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13818                            return findByG_ST(groupId, status, start, end, orderByComparator);
13819                    }
13820    
13821                    StringBundler query = null;
13822    
13823                    if (orderByComparator != null) {
13824                            query = new StringBundler(4 +
13825                                            (orderByComparator.getOrderByFields().length * 3));
13826                    }
13827                    else {
13828                            query = new StringBundler(4);
13829                    }
13830    
13831                    if (getDB().isSupportsInlineDistinct()) {
13832                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13833                    }
13834                    else {
13835                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13836                    }
13837    
13838                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13839    
13840                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13841    
13842                    if (!getDB().isSupportsInlineDistinct()) {
13843                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13844                    }
13845    
13846                    if (orderByComparator != null) {
13847                            if (getDB().isSupportsInlineDistinct()) {
13848                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13849                                            orderByComparator, true);
13850                            }
13851                            else {
13852                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13853                                            orderByComparator, true);
13854                            }
13855                    }
13856                    else {
13857                            if (getDB().isSupportsInlineDistinct()) {
13858                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13859                            }
13860                            else {
13861                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13862                            }
13863                    }
13864    
13865                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13866                                    JournalArticle.class.getName(),
13867                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13868    
13869                    Session session = null;
13870    
13871                    try {
13872                            session = openSession();
13873    
13874                            SQLQuery q = session.createSQLQuery(sql);
13875    
13876                            if (getDB().isSupportsInlineDistinct()) {
13877                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13878                            }
13879                            else {
13880                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13881                            }
13882    
13883                            QueryPos qPos = QueryPos.getInstance(q);
13884    
13885                            qPos.add(groupId);
13886    
13887                            qPos.add(status);
13888    
13889                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13890                                    end);
13891                    }
13892                    catch (Exception e) {
13893                            throw processException(e);
13894                    }
13895                    finally {
13896                            closeSession(session);
13897                    }
13898            }
13899    
13900            /**
13901             * 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;.
13902             *
13903             * @param id the primary key of the current journal article
13904             * @param groupId the group ID
13905             * @param status the status
13906             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13907             * @return the previous, current, and next journal article
13908             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13909             * @throws SystemException if a system exception occurred
13910             */
13911            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
13912                    int status, OrderByComparator orderByComparator)
13913                    throws NoSuchArticleException, SystemException {
13914                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13915                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
13916                    }
13917    
13918                    JournalArticle journalArticle = findByPrimaryKey(id);
13919    
13920                    Session session = null;
13921    
13922                    try {
13923                            session = openSession();
13924    
13925                            JournalArticle[] array = new JournalArticleImpl[3];
13926    
13927                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
13928                                            groupId, status, orderByComparator, true);
13929    
13930                            array[1] = journalArticle;
13931    
13932                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
13933                                            groupId, status, orderByComparator, false);
13934    
13935                            return array;
13936                    }
13937                    catch (Exception e) {
13938                            throw processException(e);
13939                    }
13940                    finally {
13941                            closeSession(session);
13942                    }
13943            }
13944    
13945            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
13946                    JournalArticle journalArticle, long groupId, int status,
13947                    OrderByComparator orderByComparator, boolean previous) {
13948                    StringBundler query = null;
13949    
13950                    if (orderByComparator != null) {
13951                            query = new StringBundler(6 +
13952                                            (orderByComparator.getOrderByFields().length * 6));
13953                    }
13954                    else {
13955                            query = new StringBundler(3);
13956                    }
13957    
13958                    if (getDB().isSupportsInlineDistinct()) {
13959                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13960                    }
13961                    else {
13962                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13963                    }
13964    
13965                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
13966    
13967                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
13968    
13969                    if (!getDB().isSupportsInlineDistinct()) {
13970                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13971                    }
13972    
13973                    if (orderByComparator != null) {
13974                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13975    
13976                            if (orderByConditionFields.length > 0) {
13977                                    query.append(WHERE_AND);
13978                            }
13979    
13980                            for (int i = 0; i < orderByConditionFields.length; i++) {
13981                                    if (getDB().isSupportsInlineDistinct()) {
13982                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13983                                    }
13984                                    else {
13985                                            query.append(_ORDER_BY_ENTITY_TABLE);
13986                                    }
13987    
13988                                    query.append(orderByConditionFields[i]);
13989    
13990                                    if ((i + 1) < orderByConditionFields.length) {
13991                                            if (orderByComparator.isAscending() ^ previous) {
13992                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13993                                            }
13994                                            else {
13995                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13996                                            }
13997                                    }
13998                                    else {
13999                                            if (orderByComparator.isAscending() ^ previous) {
14000                                                    query.append(WHERE_GREATER_THAN);
14001                                            }
14002                                            else {
14003                                                    query.append(WHERE_LESSER_THAN);
14004                                            }
14005                                    }
14006                            }
14007    
14008                            query.append(ORDER_BY_CLAUSE);
14009    
14010                            String[] orderByFields = orderByComparator.getOrderByFields();
14011    
14012                            for (int i = 0; i < orderByFields.length; i++) {
14013                                    if (getDB().isSupportsInlineDistinct()) {
14014                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14015                                    }
14016                                    else {
14017                                            query.append(_ORDER_BY_ENTITY_TABLE);
14018                                    }
14019    
14020                                    query.append(orderByFields[i]);
14021    
14022                                    if ((i + 1) < orderByFields.length) {
14023                                            if (orderByComparator.isAscending() ^ previous) {
14024                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14025                                            }
14026                                            else {
14027                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14028                                            }
14029                                    }
14030                                    else {
14031                                            if (orderByComparator.isAscending() ^ previous) {
14032                                                    query.append(ORDER_BY_ASC);
14033                                            }
14034                                            else {
14035                                                    query.append(ORDER_BY_DESC);
14036                                            }
14037                                    }
14038                            }
14039                    }
14040                    else {
14041                            if (getDB().isSupportsInlineDistinct()) {
14042                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14043                            }
14044                            else {
14045                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14046                            }
14047                    }
14048    
14049                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14050                                    JournalArticle.class.getName(),
14051                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14052    
14053                    SQLQuery q = session.createSQLQuery(sql);
14054    
14055                    q.setFirstResult(0);
14056                    q.setMaxResults(2);
14057    
14058                    if (getDB().isSupportsInlineDistinct()) {
14059                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14060                    }
14061                    else {
14062                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14063                    }
14064    
14065                    QueryPos qPos = QueryPos.getInstance(q);
14066    
14067                    qPos.add(groupId);
14068    
14069                    qPos.add(status);
14070    
14071                    if (orderByComparator != null) {
14072                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14073    
14074                            for (Object value : values) {
14075                                    qPos.add(value);
14076                            }
14077                    }
14078    
14079                    List<JournalArticle> list = q.list();
14080    
14081                    if (list.size() == 2) {
14082                            return list.get(1);
14083                    }
14084                    else {
14085                            return null;
14086                    }
14087            }
14088    
14089            /**
14090             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
14091             *
14092             * @param groupId the group ID
14093             * @param status the status
14094             * @throws SystemException if a system exception occurred
14095             */
14096            public void removeByG_ST(long groupId, int status)
14097                    throws SystemException {
14098                    for (JournalArticle journalArticle : findByG_ST(groupId, status,
14099                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14100                            remove(journalArticle);
14101                    }
14102            }
14103    
14104            /**
14105             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
14106             *
14107             * @param groupId the group ID
14108             * @param status the status
14109             * @return the number of matching journal articles
14110             * @throws SystemException if a system exception occurred
14111             */
14112            public int countByG_ST(long groupId, int status) throws SystemException {
14113                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_ST;
14114    
14115                    Object[] finderArgs = new Object[] { groupId, status };
14116    
14117                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14118                                    this);
14119    
14120                    if (count == null) {
14121                            StringBundler query = new StringBundler(3);
14122    
14123                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14124    
14125                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14126    
14127                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14128    
14129                            String sql = query.toString();
14130    
14131                            Session session = null;
14132    
14133                            try {
14134                                    session = openSession();
14135    
14136                                    Query q = session.createQuery(sql);
14137    
14138                                    QueryPos qPos = QueryPos.getInstance(q);
14139    
14140                                    qPos.add(groupId);
14141    
14142                                    qPos.add(status);
14143    
14144                                    count = (Long)q.uniqueResult();
14145    
14146                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14147                            }
14148                            catch (Exception e) {
14149                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14150    
14151                                    throw processException(e);
14152                            }
14153                            finally {
14154                                    closeSession(session);
14155                            }
14156                    }
14157    
14158                    return count.intValue();
14159            }
14160    
14161            /**
14162             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14163             *
14164             * @param groupId the group ID
14165             * @param status the status
14166             * @return the number of matching journal articles that the user has permission to view
14167             * @throws SystemException if a system exception occurred
14168             */
14169            public int filterCountByG_ST(long groupId, int status)
14170                    throws SystemException {
14171                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14172                            return countByG_ST(groupId, status);
14173                    }
14174    
14175                    StringBundler query = new StringBundler(3);
14176    
14177                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14178    
14179                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14180    
14181                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14182    
14183                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14184                                    JournalArticle.class.getName(),
14185                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14186    
14187                    Session session = null;
14188    
14189                    try {
14190                            session = openSession();
14191    
14192                            SQLQuery q = session.createSQLQuery(sql);
14193    
14194                            q.addScalar(COUNT_COLUMN_NAME,
14195                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14196    
14197                            QueryPos qPos = QueryPos.getInstance(q);
14198    
14199                            qPos.add(groupId);
14200    
14201                            qPos.add(status);
14202    
14203                            Long count = (Long)q.uniqueResult();
14204    
14205                            return count.intValue();
14206                    }
14207                    catch (Exception e) {
14208                            throw processException(e);
14209                    }
14210                    finally {
14211                            closeSession(session);
14212                    }
14213            }
14214    
14215            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
14216            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
14217            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14218                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14219                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14220                            "findByC_V",
14221                            new String[] {
14222                                    Long.class.getName(), Double.class.getName(),
14223                                    
14224                            Integer.class.getName(), Integer.class.getName(),
14225                                    OrderByComparator.class.getName()
14226                            });
14227            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14228                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14229                            JournalArticleImpl.class,
14230                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
14231                            new String[] { Long.class.getName(), Double.class.getName() },
14232                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
14233                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
14234                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
14235            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14236                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14237                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
14238                            new String[] { Long.class.getName(), Double.class.getName() });
14239    
14240            /**
14241             * Returns all the journal articles where companyId = &#63; and version = &#63;.
14242             *
14243             * @param companyId the company ID
14244             * @param version the version
14245             * @return the matching journal articles
14246             * @throws SystemException if a system exception occurred
14247             */
14248            public List<JournalArticle> findByC_V(long companyId, double version)
14249                    throws SystemException {
14250                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
14251                            QueryUtil.ALL_POS, null);
14252            }
14253    
14254            /**
14255             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
14256             *
14257             * <p>
14258             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14259             * </p>
14260             *
14261             * @param companyId the company ID
14262             * @param version the version
14263             * @param start the lower bound of the range of journal articles
14264             * @param end the upper bound of the range of journal articles (not inclusive)
14265             * @return the range of matching journal articles
14266             * @throws SystemException if a system exception occurred
14267             */
14268            public List<JournalArticle> findByC_V(long companyId, double version,
14269                    int start, int end) throws SystemException {
14270                    return findByC_V(companyId, version, start, end, null);
14271            }
14272    
14273            /**
14274             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
14275             *
14276             * <p>
14277             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14278             * </p>
14279             *
14280             * @param companyId the company ID
14281             * @param version the version
14282             * @param start the lower bound of the range of journal articles
14283             * @param end the upper bound of the range of journal articles (not inclusive)
14284             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14285             * @return the ordered range of matching journal articles
14286             * @throws SystemException if a system exception occurred
14287             */
14288            public List<JournalArticle> findByC_V(long companyId, double version,
14289                    int start, int end, OrderByComparator orderByComparator)
14290                    throws SystemException {
14291                    boolean pagination = true;
14292                    FinderPath finderPath = null;
14293                    Object[] finderArgs = null;
14294    
14295                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14296                                    (orderByComparator == null)) {
14297                            pagination = false;
14298                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
14299                            finderArgs = new Object[] { companyId, version };
14300                    }
14301                    else {
14302                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
14303                            finderArgs = new Object[] {
14304                                            companyId, version,
14305                                            
14306                                            start, end, orderByComparator
14307                                    };
14308                    }
14309    
14310                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14311                                    finderArgs, this);
14312    
14313                    if ((list != null) && !list.isEmpty()) {
14314                            for (JournalArticle journalArticle : list) {
14315                                    if ((companyId != journalArticle.getCompanyId()) ||
14316                                                    (version != journalArticle.getVersion())) {
14317                                            list = null;
14318    
14319                                            break;
14320                                    }
14321                            }
14322                    }
14323    
14324                    if (list == null) {
14325                            StringBundler query = null;
14326    
14327                            if (orderByComparator != null) {
14328                                    query = new StringBundler(4 +
14329                                                    (orderByComparator.getOrderByFields().length * 3));
14330                            }
14331                            else {
14332                                    query = new StringBundler(4);
14333                            }
14334    
14335                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14336    
14337                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
14338    
14339                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
14340    
14341                            if (orderByComparator != null) {
14342                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14343                                            orderByComparator);
14344                            }
14345                            else
14346                             if (pagination) {
14347                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14348                            }
14349    
14350                            String sql = query.toString();
14351    
14352                            Session session = null;
14353    
14354                            try {
14355                                    session = openSession();
14356    
14357                                    Query q = session.createQuery(sql);
14358    
14359                                    QueryPos qPos = QueryPos.getInstance(q);
14360    
14361                                    qPos.add(companyId);
14362    
14363                                    qPos.add(version);
14364    
14365                                    if (!pagination) {
14366                                            list = (List<JournalArticle>)QueryUtil.list(q,
14367                                                            getDialect(), start, end, false);
14368    
14369                                            Collections.sort(list);
14370    
14371                                            list = new UnmodifiableList<JournalArticle>(list);
14372                                    }
14373                                    else {
14374                                            list = (List<JournalArticle>)QueryUtil.list(q,
14375                                                            getDialect(), start, end);
14376                                    }
14377    
14378                                    cacheResult(list);
14379    
14380                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14381                            }
14382                            catch (Exception e) {
14383                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14384    
14385                                    throw processException(e);
14386                            }
14387                            finally {
14388                                    closeSession(session);
14389                            }
14390                    }
14391    
14392                    return list;
14393            }
14394    
14395            /**
14396             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
14397             *
14398             * @param companyId the company ID
14399             * @param version the version
14400             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14401             * @return the first matching journal article
14402             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14403             * @throws SystemException if a system exception occurred
14404             */
14405            public JournalArticle findByC_V_First(long companyId, double version,
14406                    OrderByComparator orderByComparator)
14407                    throws NoSuchArticleException, SystemException {
14408                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
14409                                    orderByComparator);
14410    
14411                    if (journalArticle != null) {
14412                            return journalArticle;
14413                    }
14414    
14415                    StringBundler msg = new StringBundler(6);
14416    
14417                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14418    
14419                    msg.append("companyId=");
14420                    msg.append(companyId);
14421    
14422                    msg.append(", version=");
14423                    msg.append(version);
14424    
14425                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14426    
14427                    throw new NoSuchArticleException(msg.toString());
14428            }
14429    
14430            /**
14431             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
14432             *
14433             * @param companyId the company ID
14434             * @param version the version
14435             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14436             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14437             * @throws SystemException if a system exception occurred
14438             */
14439            public JournalArticle fetchByC_V_First(long companyId, double version,
14440                    OrderByComparator orderByComparator) throws SystemException {
14441                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
14442                                    orderByComparator);
14443    
14444                    if (!list.isEmpty()) {
14445                            return list.get(0);
14446                    }
14447    
14448                    return null;
14449            }
14450    
14451            /**
14452             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
14453             *
14454             * @param companyId the company ID
14455             * @param version the version
14456             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14457             * @return the last matching journal article
14458             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14459             * @throws SystemException if a system exception occurred
14460             */
14461            public JournalArticle findByC_V_Last(long companyId, double version,
14462                    OrderByComparator orderByComparator)
14463                    throws NoSuchArticleException, SystemException {
14464                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
14465                                    orderByComparator);
14466    
14467                    if (journalArticle != null) {
14468                            return journalArticle;
14469                    }
14470    
14471                    StringBundler msg = new StringBundler(6);
14472    
14473                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14474    
14475                    msg.append("companyId=");
14476                    msg.append(companyId);
14477    
14478                    msg.append(", version=");
14479                    msg.append(version);
14480    
14481                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14482    
14483                    throw new NoSuchArticleException(msg.toString());
14484            }
14485    
14486            /**
14487             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
14488             *
14489             * @param companyId the company ID
14490             * @param version the version
14491             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14492             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14493             * @throws SystemException if a system exception occurred
14494             */
14495            public JournalArticle fetchByC_V_Last(long companyId, double version,
14496                    OrderByComparator orderByComparator) throws SystemException {
14497                    int count = countByC_V(companyId, version);
14498    
14499                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
14500                                    count, orderByComparator);
14501    
14502                    if (!list.isEmpty()) {
14503                            return list.get(0);
14504                    }
14505    
14506                    return null;
14507            }
14508    
14509            /**
14510             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
14511             *
14512             * @param id the primary key of the current journal article
14513             * @param companyId the company ID
14514             * @param version the version
14515             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14516             * @return the previous, current, and next journal article
14517             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14518             * @throws SystemException if a system exception occurred
14519             */
14520            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
14521                    double version, OrderByComparator orderByComparator)
14522                    throws NoSuchArticleException, SystemException {
14523                    JournalArticle journalArticle = findByPrimaryKey(id);
14524    
14525                    Session session = null;
14526    
14527                    try {
14528                            session = openSession();
14529    
14530                            JournalArticle[] array = new JournalArticleImpl[3];
14531    
14532                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
14533                                            version, orderByComparator, true);
14534    
14535                            array[1] = journalArticle;
14536    
14537                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
14538                                            version, orderByComparator, false);
14539    
14540                            return array;
14541                    }
14542                    catch (Exception e) {
14543                            throw processException(e);
14544                    }
14545                    finally {
14546                            closeSession(session);
14547                    }
14548            }
14549    
14550            protected JournalArticle getByC_V_PrevAndNext(Session session,
14551                    JournalArticle journalArticle, long companyId, double version,
14552                    OrderByComparator orderByComparator, boolean previous) {
14553                    StringBundler query = null;
14554    
14555                    if (orderByComparator != null) {
14556                            query = new StringBundler(6 +
14557                                            (orderByComparator.getOrderByFields().length * 6));
14558                    }
14559                    else {
14560                            query = new StringBundler(3);
14561                    }
14562    
14563                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14564    
14565                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
14566    
14567                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
14568    
14569                    if (orderByComparator != null) {
14570                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14571    
14572                            if (orderByConditionFields.length > 0) {
14573                                    query.append(WHERE_AND);
14574                            }
14575    
14576                            for (int i = 0; i < orderByConditionFields.length; i++) {
14577                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14578                                    query.append(orderByConditionFields[i]);
14579    
14580                                    if ((i + 1) < orderByConditionFields.length) {
14581                                            if (orderByComparator.isAscending() ^ previous) {
14582                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14583                                            }
14584                                            else {
14585                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14586                                            }
14587                                    }
14588                                    else {
14589                                            if (orderByComparator.isAscending() ^ previous) {
14590                                                    query.append(WHERE_GREATER_THAN);
14591                                            }
14592                                            else {
14593                                                    query.append(WHERE_LESSER_THAN);
14594                                            }
14595                                    }
14596                            }
14597    
14598                            query.append(ORDER_BY_CLAUSE);
14599    
14600                            String[] orderByFields = orderByComparator.getOrderByFields();
14601    
14602                            for (int i = 0; i < orderByFields.length; i++) {
14603                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14604                                    query.append(orderByFields[i]);
14605    
14606                                    if ((i + 1) < orderByFields.length) {
14607                                            if (orderByComparator.isAscending() ^ previous) {
14608                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14609                                            }
14610                                            else {
14611                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14612                                            }
14613                                    }
14614                                    else {
14615                                            if (orderByComparator.isAscending() ^ previous) {
14616                                                    query.append(ORDER_BY_ASC);
14617                                            }
14618                                            else {
14619                                                    query.append(ORDER_BY_DESC);
14620                                            }
14621                                    }
14622                            }
14623                    }
14624                    else {
14625                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14626                    }
14627    
14628                    String sql = query.toString();
14629    
14630                    Query q = session.createQuery(sql);
14631    
14632                    q.setFirstResult(0);
14633                    q.setMaxResults(2);
14634    
14635                    QueryPos qPos = QueryPos.getInstance(q);
14636    
14637                    qPos.add(companyId);
14638    
14639                    qPos.add(version);
14640    
14641                    if (orderByComparator != null) {
14642                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14643    
14644                            for (Object value : values) {
14645                                    qPos.add(value);
14646                            }
14647                    }
14648    
14649                    List<JournalArticle> list = q.list();
14650    
14651                    if (list.size() == 2) {
14652                            return list.get(1);
14653                    }
14654                    else {
14655                            return null;
14656                    }
14657            }
14658    
14659            /**
14660             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
14661             *
14662             * @param companyId the company ID
14663             * @param version the version
14664             * @throws SystemException if a system exception occurred
14665             */
14666            public void removeByC_V(long companyId, double version)
14667                    throws SystemException {
14668                    for (JournalArticle journalArticle : findByC_V(companyId, version,
14669                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14670                            remove(journalArticle);
14671                    }
14672            }
14673    
14674            /**
14675             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
14676             *
14677             * @param companyId the company ID
14678             * @param version the version
14679             * @return the number of matching journal articles
14680             * @throws SystemException if a system exception occurred
14681             */
14682            public int countByC_V(long companyId, double version)
14683                    throws SystemException {
14684                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V;
14685    
14686                    Object[] finderArgs = new Object[] { companyId, version };
14687    
14688                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14689                                    this);
14690    
14691                    if (count == null) {
14692                            StringBundler query = new StringBundler(3);
14693    
14694                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14695    
14696                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
14697    
14698                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
14699    
14700                            String sql = query.toString();
14701    
14702                            Session session = null;
14703    
14704                            try {
14705                                    session = openSession();
14706    
14707                                    Query q = session.createQuery(sql);
14708    
14709                                    QueryPos qPos = QueryPos.getInstance(q);
14710    
14711                                    qPos.add(companyId);
14712    
14713                                    qPos.add(version);
14714    
14715                                    count = (Long)q.uniqueResult();
14716    
14717                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14718                            }
14719                            catch (Exception e) {
14720                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14721    
14722                                    throw processException(e);
14723                            }
14724                            finally {
14725                                    closeSession(session);
14726                            }
14727                    }
14728    
14729                    return count.intValue();
14730            }
14731    
14732            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
14733            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
14734            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14735                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14736                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14737                            "findByC_ST",
14738                            new String[] {
14739                                    Long.class.getName(), Integer.class.getName(),
14740                                    
14741                            Integer.class.getName(), Integer.class.getName(),
14742                                    OrderByComparator.class.getName()
14743                            });
14744            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14745                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14746                            JournalArticleImpl.class,
14747                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
14748                            new String[] { Long.class.getName(), Integer.class.getName() },
14749                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
14750                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
14751                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
14752                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
14753            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14754                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14755                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
14756                            new String[] { Long.class.getName(), Integer.class.getName() });
14757    
14758            /**
14759             * Returns all the journal articles where companyId = &#63; and status = &#63;.
14760             *
14761             * @param companyId the company ID
14762             * @param status the status
14763             * @return the matching journal articles
14764             * @throws SystemException if a system exception occurred
14765             */
14766            public List<JournalArticle> findByC_ST(long companyId, int status)
14767                    throws SystemException {
14768                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
14769                            QueryUtil.ALL_POS, null);
14770            }
14771    
14772            /**
14773             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
14774             *
14775             * <p>
14776             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14777             * </p>
14778             *
14779             * @param companyId the company ID
14780             * @param status the status
14781             * @param start the lower bound of the range of journal articles
14782             * @param end the upper bound of the range of journal articles (not inclusive)
14783             * @return the range of matching journal articles
14784             * @throws SystemException if a system exception occurred
14785             */
14786            public List<JournalArticle> findByC_ST(long companyId, int status,
14787                    int start, int end) throws SystemException {
14788                    return findByC_ST(companyId, status, start, end, null);
14789            }
14790    
14791            /**
14792             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
14793             *
14794             * <p>
14795             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14796             * </p>
14797             *
14798             * @param companyId the company ID
14799             * @param status the status
14800             * @param start the lower bound of the range of journal articles
14801             * @param end the upper bound of the range of journal articles (not inclusive)
14802             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14803             * @return the ordered range of matching journal articles
14804             * @throws SystemException if a system exception occurred
14805             */
14806            public List<JournalArticle> findByC_ST(long companyId, int status,
14807                    int start, int end, OrderByComparator orderByComparator)
14808                    throws SystemException {
14809                    boolean pagination = true;
14810                    FinderPath finderPath = null;
14811                    Object[] finderArgs = null;
14812    
14813                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14814                                    (orderByComparator == null)) {
14815                            pagination = false;
14816                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
14817                            finderArgs = new Object[] { companyId, status };
14818                    }
14819                    else {
14820                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
14821                            finderArgs = new Object[] {
14822                                            companyId, status,
14823                                            
14824                                            start, end, orderByComparator
14825                                    };
14826                    }
14827    
14828                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14829                                    finderArgs, this);
14830    
14831                    if ((list != null) && !list.isEmpty()) {
14832                            for (JournalArticle journalArticle : list) {
14833                                    if ((companyId != journalArticle.getCompanyId()) ||
14834                                                    (status != journalArticle.getStatus())) {
14835                                            list = null;
14836    
14837                                            break;
14838                                    }
14839                            }
14840                    }
14841    
14842                    if (list == null) {
14843                            StringBundler query = null;
14844    
14845                            if (orderByComparator != null) {
14846                                    query = new StringBundler(4 +
14847                                                    (orderByComparator.getOrderByFields().length * 3));
14848                            }
14849                            else {
14850                                    query = new StringBundler(4);
14851                            }
14852    
14853                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14854    
14855                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
14856    
14857                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
14858    
14859                            if (orderByComparator != null) {
14860                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14861                                            orderByComparator);
14862                            }
14863                            else
14864                             if (pagination) {
14865                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14866                            }
14867    
14868                            String sql = query.toString();
14869    
14870                            Session session = null;
14871    
14872                            try {
14873                                    session = openSession();
14874    
14875                                    Query q = session.createQuery(sql);
14876    
14877                                    QueryPos qPos = QueryPos.getInstance(q);
14878    
14879                                    qPos.add(companyId);
14880    
14881                                    qPos.add(status);
14882    
14883                                    if (!pagination) {
14884                                            list = (List<JournalArticle>)QueryUtil.list(q,
14885                                                            getDialect(), start, end, false);
14886    
14887                                            Collections.sort(list);
14888    
14889                                            list = new UnmodifiableList<JournalArticle>(list);
14890                                    }
14891                                    else {
14892                                            list = (List<JournalArticle>)QueryUtil.list(q,
14893                                                            getDialect(), start, end);
14894                                    }
14895    
14896                                    cacheResult(list);
14897    
14898                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14899                            }
14900                            catch (Exception e) {
14901                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14902    
14903                                    throw processException(e);
14904                            }
14905                            finally {
14906                                    closeSession(session);
14907                            }
14908                    }
14909    
14910                    return list;
14911            }
14912    
14913            /**
14914             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
14915             *
14916             * @param companyId the company ID
14917             * @param status the status
14918             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14919             * @return the first matching journal article
14920             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14921             * @throws SystemException if a system exception occurred
14922             */
14923            public JournalArticle findByC_ST_First(long companyId, int status,
14924                    OrderByComparator orderByComparator)
14925                    throws NoSuchArticleException, SystemException {
14926                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
14927                                    orderByComparator);
14928    
14929                    if (journalArticle != null) {
14930                            return journalArticle;
14931                    }
14932    
14933                    StringBundler msg = new StringBundler(6);
14934    
14935                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14936    
14937                    msg.append("companyId=");
14938                    msg.append(companyId);
14939    
14940                    msg.append(", status=");
14941                    msg.append(status);
14942    
14943                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14944    
14945                    throw new NoSuchArticleException(msg.toString());
14946            }
14947    
14948            /**
14949             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
14950             *
14951             * @param companyId the company ID
14952             * @param status the status
14953             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14954             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14955             * @throws SystemException if a system exception occurred
14956             */
14957            public JournalArticle fetchByC_ST_First(long companyId, int status,
14958                    OrderByComparator orderByComparator) throws SystemException {
14959                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
14960                                    orderByComparator);
14961    
14962                    if (!list.isEmpty()) {
14963                            return list.get(0);
14964                    }
14965    
14966                    return null;
14967            }
14968    
14969            /**
14970             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
14971             *
14972             * @param companyId the company ID
14973             * @param status the status
14974             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14975             * @return the last matching journal article
14976             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14977             * @throws SystemException if a system exception occurred
14978             */
14979            public JournalArticle findByC_ST_Last(long companyId, int status,
14980                    OrderByComparator orderByComparator)
14981                    throws NoSuchArticleException, SystemException {
14982                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
14983                                    orderByComparator);
14984    
14985                    if (journalArticle != null) {
14986                            return journalArticle;
14987                    }
14988    
14989                    StringBundler msg = new StringBundler(6);
14990    
14991                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14992    
14993                    msg.append("companyId=");
14994                    msg.append(companyId);
14995    
14996                    msg.append(", status=");
14997                    msg.append(status);
14998    
14999                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15000    
15001                    throw new NoSuchArticleException(msg.toString());
15002            }
15003    
15004            /**
15005             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
15006             *
15007             * @param companyId the company ID
15008             * @param status the status
15009             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15010             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15011             * @throws SystemException if a system exception occurred
15012             */
15013            public JournalArticle fetchByC_ST_Last(long companyId, int status,
15014                    OrderByComparator orderByComparator) throws SystemException {
15015                    int count = countByC_ST(companyId, status);
15016    
15017                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
15018                                    count, orderByComparator);
15019    
15020                    if (!list.isEmpty()) {
15021                            return list.get(0);
15022                    }
15023    
15024                    return null;
15025            }
15026    
15027            /**
15028             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
15029             *
15030             * @param id the primary key of the current journal article
15031             * @param companyId the company ID
15032             * @param status the status
15033             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15034             * @return the previous, current, and next journal article
15035             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15036             * @throws SystemException if a system exception occurred
15037             */
15038            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
15039                    int status, OrderByComparator orderByComparator)
15040                    throws NoSuchArticleException, SystemException {
15041                    JournalArticle journalArticle = findByPrimaryKey(id);
15042    
15043                    Session session = null;
15044    
15045                    try {
15046                            session = openSession();
15047    
15048                            JournalArticle[] array = new JournalArticleImpl[3];
15049    
15050                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
15051                                            companyId, status, orderByComparator, true);
15052    
15053                            array[1] = journalArticle;
15054    
15055                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
15056                                            companyId, status, orderByComparator, false);
15057    
15058                            return array;
15059                    }
15060                    catch (Exception e) {
15061                            throw processException(e);
15062                    }
15063                    finally {
15064                            closeSession(session);
15065                    }
15066            }
15067    
15068            protected JournalArticle getByC_ST_PrevAndNext(Session session,
15069                    JournalArticle journalArticle, long companyId, int status,
15070                    OrderByComparator orderByComparator, boolean previous) {
15071                    StringBundler query = null;
15072    
15073                    if (orderByComparator != null) {
15074                            query = new StringBundler(6 +
15075                                            (orderByComparator.getOrderByFields().length * 6));
15076                    }
15077                    else {
15078                            query = new StringBundler(3);
15079                    }
15080    
15081                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15082    
15083                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15084    
15085                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15086    
15087                    if (orderByComparator != null) {
15088                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15089    
15090                            if (orderByConditionFields.length > 0) {
15091                                    query.append(WHERE_AND);
15092                            }
15093    
15094                            for (int i = 0; i < orderByConditionFields.length; i++) {
15095                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15096                                    query.append(orderByConditionFields[i]);
15097    
15098                                    if ((i + 1) < orderByConditionFields.length) {
15099                                            if (orderByComparator.isAscending() ^ previous) {
15100                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15101                                            }
15102                                            else {
15103                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15104                                            }
15105                                    }
15106                                    else {
15107                                            if (orderByComparator.isAscending() ^ previous) {
15108                                                    query.append(WHERE_GREATER_THAN);
15109                                            }
15110                                            else {
15111                                                    query.append(WHERE_LESSER_THAN);
15112                                            }
15113                                    }
15114                            }
15115    
15116                            query.append(ORDER_BY_CLAUSE);
15117    
15118                            String[] orderByFields = orderByComparator.getOrderByFields();
15119    
15120                            for (int i = 0; i < orderByFields.length; i++) {
15121                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15122                                    query.append(orderByFields[i]);
15123    
15124                                    if ((i + 1) < orderByFields.length) {
15125                                            if (orderByComparator.isAscending() ^ previous) {
15126                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15127                                            }
15128                                            else {
15129                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15130                                            }
15131                                    }
15132                                    else {
15133                                            if (orderByComparator.isAscending() ^ previous) {
15134                                                    query.append(ORDER_BY_ASC);
15135                                            }
15136                                            else {
15137                                                    query.append(ORDER_BY_DESC);
15138                                            }
15139                                    }
15140                            }
15141                    }
15142                    else {
15143                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15144                    }
15145    
15146                    String sql = query.toString();
15147    
15148                    Query q = session.createQuery(sql);
15149    
15150                    q.setFirstResult(0);
15151                    q.setMaxResults(2);
15152    
15153                    QueryPos qPos = QueryPos.getInstance(q);
15154    
15155                    qPos.add(companyId);
15156    
15157                    qPos.add(status);
15158    
15159                    if (orderByComparator != null) {
15160                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15161    
15162                            for (Object value : values) {
15163                                    qPos.add(value);
15164                            }
15165                    }
15166    
15167                    List<JournalArticle> list = q.list();
15168    
15169                    if (list.size() == 2) {
15170                            return list.get(1);
15171                    }
15172                    else {
15173                            return null;
15174                    }
15175            }
15176    
15177            /**
15178             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
15179             *
15180             * @param companyId the company ID
15181             * @param status the status
15182             * @throws SystemException if a system exception occurred
15183             */
15184            public void removeByC_ST(long companyId, int status)
15185                    throws SystemException {
15186                    for (JournalArticle journalArticle : findByC_ST(companyId, status,
15187                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15188                            remove(journalArticle);
15189                    }
15190            }
15191    
15192            /**
15193             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
15194             *
15195             * @param companyId the company ID
15196             * @param status the status
15197             * @return the number of matching journal articles
15198             * @throws SystemException if a system exception occurred
15199             */
15200            public int countByC_ST(long companyId, int status)
15201                    throws SystemException {
15202                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_ST;
15203    
15204                    Object[] finderArgs = new Object[] { companyId, status };
15205    
15206                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15207                                    this);
15208    
15209                    if (count == null) {
15210                            StringBundler query = new StringBundler(3);
15211    
15212                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15213    
15214                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15215    
15216                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15217    
15218                            String sql = query.toString();
15219    
15220                            Session session = null;
15221    
15222                            try {
15223                                    session = openSession();
15224    
15225                                    Query q = session.createQuery(sql);
15226    
15227                                    QueryPos qPos = QueryPos.getInstance(q);
15228    
15229                                    qPos.add(companyId);
15230    
15231                                    qPos.add(status);
15232    
15233                                    count = (Long)q.uniqueResult();
15234    
15235                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15236                            }
15237                            catch (Exception e) {
15238                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15239    
15240                                    throw processException(e);
15241                            }
15242                            finally {
15243                                    closeSession(session);
15244                            }
15245                    }
15246    
15247                    return count.intValue();
15248            }
15249    
15250            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
15251            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
15252            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15253                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15254                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15255                            "findByG_F_ST",
15256                            new String[] {
15257                                    Long.class.getName(), Long.class.getName(),
15258                                    Integer.class.getName(),
15259                                    
15260                            Integer.class.getName(), Integer.class.getName(),
15261                                    OrderByComparator.class.getName()
15262                            });
15263            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
15264                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15265                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15266                            JournalArticleImpl.class,
15267                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
15268                            new String[] {
15269                                    Long.class.getName(), Long.class.getName(),
15270                                    Integer.class.getName()
15271                            },
15272                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
15273                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
15274                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
15275                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
15276                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
15277            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15278                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15279                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
15280                            new String[] {
15281                                    Long.class.getName(), Long.class.getName(),
15282                                    Integer.class.getName()
15283                            });
15284            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15285                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15286                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
15287                            new String[] {
15288                                    Long.class.getName(), Long.class.getName(),
15289                                    Integer.class.getName()
15290                            });
15291    
15292            /**
15293             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
15294             *
15295             * @param groupId the group ID
15296             * @param folderId the folder ID
15297             * @param status the status
15298             * @return the matching journal articles
15299             * @throws SystemException if a system exception occurred
15300             */
15301            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
15302                    int status) throws SystemException {
15303                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
15304                            QueryUtil.ALL_POS, null);
15305            }
15306    
15307            /**
15308             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
15309             *
15310             * <p>
15311             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15312             * </p>
15313             *
15314             * @param groupId the group ID
15315             * @param folderId the folder ID
15316             * @param status the status
15317             * @param start the lower bound of the range of journal articles
15318             * @param end the upper bound of the range of journal articles (not inclusive)
15319             * @return the range of matching journal articles
15320             * @throws SystemException if a system exception occurred
15321             */
15322            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
15323                    int status, int start, int end) throws SystemException {
15324                    return findByG_F_ST(groupId, folderId, status, start, end, null);
15325            }
15326    
15327            /**
15328             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
15329             *
15330             * <p>
15331             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15332             * </p>
15333             *
15334             * @param groupId the group ID
15335             * @param folderId the folder ID
15336             * @param status the status
15337             * @param start the lower bound of the range of journal articles
15338             * @param end the upper bound of the range of journal articles (not inclusive)
15339             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15340             * @return the ordered range of matching journal articles
15341             * @throws SystemException if a system exception occurred
15342             */
15343            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
15344                    int status, int start, int end, OrderByComparator orderByComparator)
15345                    throws SystemException {
15346                    boolean pagination = true;
15347                    FinderPath finderPath = null;
15348                    Object[] finderArgs = null;
15349    
15350                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15351                                    (orderByComparator == null)) {
15352                            pagination = false;
15353                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
15354                            finderArgs = new Object[] { groupId, folderId, status };
15355                    }
15356                    else {
15357                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
15358                            finderArgs = new Object[] {
15359                                            groupId, folderId, status,
15360                                            
15361                                            start, end, orderByComparator
15362                                    };
15363                    }
15364    
15365                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15366                                    finderArgs, this);
15367    
15368                    if ((list != null) && !list.isEmpty()) {
15369                            for (JournalArticle journalArticle : list) {
15370                                    if ((groupId != journalArticle.getGroupId()) ||
15371                                                    (folderId != journalArticle.getFolderId()) ||
15372                                                    (status != journalArticle.getStatus())) {
15373                                            list = null;
15374    
15375                                            break;
15376                                    }
15377                            }
15378                    }
15379    
15380                    if (list == null) {
15381                            StringBundler query = null;
15382    
15383                            if (orderByComparator != null) {
15384                                    query = new StringBundler(5 +
15385                                                    (orderByComparator.getOrderByFields().length * 3));
15386                            }
15387                            else {
15388                                    query = new StringBundler(5);
15389                            }
15390    
15391                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15392    
15393                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15394    
15395                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15396    
15397                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15398    
15399                            if (orderByComparator != null) {
15400                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15401                                            orderByComparator);
15402                            }
15403                            else
15404                             if (pagination) {
15405                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15406                            }
15407    
15408                            String sql = query.toString();
15409    
15410                            Session session = null;
15411    
15412                            try {
15413                                    session = openSession();
15414    
15415                                    Query q = session.createQuery(sql);
15416    
15417                                    QueryPos qPos = QueryPos.getInstance(q);
15418    
15419                                    qPos.add(groupId);
15420    
15421                                    qPos.add(folderId);
15422    
15423                                    qPos.add(status);
15424    
15425                                    if (!pagination) {
15426                                            list = (List<JournalArticle>)QueryUtil.list(q,
15427                                                            getDialect(), start, end, false);
15428    
15429                                            Collections.sort(list);
15430    
15431                                            list = new UnmodifiableList<JournalArticle>(list);
15432                                    }
15433                                    else {
15434                                            list = (List<JournalArticle>)QueryUtil.list(q,
15435                                                            getDialect(), start, end);
15436                                    }
15437    
15438                                    cacheResult(list);
15439    
15440                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15441                            }
15442                            catch (Exception e) {
15443                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15444    
15445                                    throw processException(e);
15446                            }
15447                            finally {
15448                                    closeSession(session);
15449                            }
15450                    }
15451    
15452                    return list;
15453            }
15454    
15455            /**
15456             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15457             *
15458             * @param groupId the group ID
15459             * @param folderId the folder ID
15460             * @param status the status
15461             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15462             * @return the first matching journal article
15463             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15464             * @throws SystemException if a system exception occurred
15465             */
15466            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
15467                    int status, OrderByComparator orderByComparator)
15468                    throws NoSuchArticleException, SystemException {
15469                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
15470                                    status, orderByComparator);
15471    
15472                    if (journalArticle != null) {
15473                            return journalArticle;
15474                    }
15475    
15476                    StringBundler msg = new StringBundler(8);
15477    
15478                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15479    
15480                    msg.append("groupId=");
15481                    msg.append(groupId);
15482    
15483                    msg.append(", folderId=");
15484                    msg.append(folderId);
15485    
15486                    msg.append(", status=");
15487                    msg.append(status);
15488    
15489                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15490    
15491                    throw new NoSuchArticleException(msg.toString());
15492            }
15493    
15494            /**
15495             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15496             *
15497             * @param groupId the group ID
15498             * @param folderId the folder ID
15499             * @param status the status
15500             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15501             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15502             * @throws SystemException if a system exception occurred
15503             */
15504            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
15505                    int status, OrderByComparator orderByComparator)
15506                    throws SystemException {
15507                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
15508                                    1, orderByComparator);
15509    
15510                    if (!list.isEmpty()) {
15511                            return list.get(0);
15512                    }
15513    
15514                    return null;
15515            }
15516    
15517            /**
15518             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15519             *
15520             * @param groupId the group ID
15521             * @param folderId the folder ID
15522             * @param status the status
15523             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15524             * @return the last matching journal article
15525             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15526             * @throws SystemException if a system exception occurred
15527             */
15528            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
15529                    int status, OrderByComparator orderByComparator)
15530                    throws NoSuchArticleException, SystemException {
15531                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
15532                                    status, orderByComparator);
15533    
15534                    if (journalArticle != null) {
15535                            return journalArticle;
15536                    }
15537    
15538                    StringBundler msg = new StringBundler(8);
15539    
15540                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15541    
15542                    msg.append("groupId=");
15543                    msg.append(groupId);
15544    
15545                    msg.append(", folderId=");
15546                    msg.append(folderId);
15547    
15548                    msg.append(", status=");
15549                    msg.append(status);
15550    
15551                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15552    
15553                    throw new NoSuchArticleException(msg.toString());
15554            }
15555    
15556            /**
15557             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15558             *
15559             * @param groupId the group ID
15560             * @param folderId the folder ID
15561             * @param status the status
15562             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15563             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15564             * @throws SystemException if a system exception occurred
15565             */
15566            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
15567                    int status, OrderByComparator orderByComparator)
15568                    throws SystemException {
15569                    int count = countByG_F_ST(groupId, folderId, status);
15570    
15571                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
15572                                    count - 1, count, orderByComparator);
15573    
15574                    if (!list.isEmpty()) {
15575                            return list.get(0);
15576                    }
15577    
15578                    return null;
15579            }
15580    
15581            /**
15582             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
15583             *
15584             * @param id the primary key of the current journal article
15585             * @param groupId the group ID
15586             * @param folderId the folder ID
15587             * @param status the status
15588             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15589             * @return the previous, current, and next journal article
15590             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15591             * @throws SystemException if a system exception occurred
15592             */
15593            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
15594                    long folderId, int status, OrderByComparator orderByComparator)
15595                    throws NoSuchArticleException, SystemException {
15596                    JournalArticle journalArticle = findByPrimaryKey(id);
15597    
15598                    Session session = null;
15599    
15600                    try {
15601                            session = openSession();
15602    
15603                            JournalArticle[] array = new JournalArticleImpl[3];
15604    
15605                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
15606                                            groupId, folderId, status, orderByComparator, true);
15607    
15608                            array[1] = journalArticle;
15609    
15610                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
15611                                            groupId, folderId, status, orderByComparator, false);
15612    
15613                            return array;
15614                    }
15615                    catch (Exception e) {
15616                            throw processException(e);
15617                    }
15618                    finally {
15619                            closeSession(session);
15620                    }
15621            }
15622    
15623            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
15624                    JournalArticle journalArticle, long groupId, long folderId, int status,
15625                    OrderByComparator orderByComparator, boolean previous) {
15626                    StringBundler query = null;
15627    
15628                    if (orderByComparator != null) {
15629                            query = new StringBundler(6 +
15630                                            (orderByComparator.getOrderByFields().length * 6));
15631                    }
15632                    else {
15633                            query = new StringBundler(3);
15634                    }
15635    
15636                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15637    
15638                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15639    
15640                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15641    
15642                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15643    
15644                    if (orderByComparator != null) {
15645                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15646    
15647                            if (orderByConditionFields.length > 0) {
15648                                    query.append(WHERE_AND);
15649                            }
15650    
15651                            for (int i = 0; i < orderByConditionFields.length; i++) {
15652                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15653                                    query.append(orderByConditionFields[i]);
15654    
15655                                    if ((i + 1) < orderByConditionFields.length) {
15656                                            if (orderByComparator.isAscending() ^ previous) {
15657                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15658                                            }
15659                                            else {
15660                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15661                                            }
15662                                    }
15663                                    else {
15664                                            if (orderByComparator.isAscending() ^ previous) {
15665                                                    query.append(WHERE_GREATER_THAN);
15666                                            }
15667                                            else {
15668                                                    query.append(WHERE_LESSER_THAN);
15669                                            }
15670                                    }
15671                            }
15672    
15673                            query.append(ORDER_BY_CLAUSE);
15674    
15675                            String[] orderByFields = orderByComparator.getOrderByFields();
15676    
15677                            for (int i = 0; i < orderByFields.length; i++) {
15678                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15679                                    query.append(orderByFields[i]);
15680    
15681                                    if ((i + 1) < orderByFields.length) {
15682                                            if (orderByComparator.isAscending() ^ previous) {
15683                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15684                                            }
15685                                            else {
15686                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15687                                            }
15688                                    }
15689                                    else {
15690                                            if (orderByComparator.isAscending() ^ previous) {
15691                                                    query.append(ORDER_BY_ASC);
15692                                            }
15693                                            else {
15694                                                    query.append(ORDER_BY_DESC);
15695                                            }
15696                                    }
15697                            }
15698                    }
15699                    else {
15700                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15701                    }
15702    
15703                    String sql = query.toString();
15704    
15705                    Query q = session.createQuery(sql);
15706    
15707                    q.setFirstResult(0);
15708                    q.setMaxResults(2);
15709    
15710                    QueryPos qPos = QueryPos.getInstance(q);
15711    
15712                    qPos.add(groupId);
15713    
15714                    qPos.add(folderId);
15715    
15716                    qPos.add(status);
15717    
15718                    if (orderByComparator != null) {
15719                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15720    
15721                            for (Object value : values) {
15722                                    qPos.add(value);
15723                            }
15724                    }
15725    
15726                    List<JournalArticle> list = q.list();
15727    
15728                    if (list.size() == 2) {
15729                            return list.get(1);
15730                    }
15731                    else {
15732                            return null;
15733                    }
15734            }
15735    
15736            /**
15737             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
15738             *
15739             * @param groupId the group ID
15740             * @param folderId the folder ID
15741             * @param status the status
15742             * @return the matching journal articles that the user has permission to view
15743             * @throws SystemException if a system exception occurred
15744             */
15745            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15746                    int status) throws SystemException {
15747                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
15748                            QueryUtil.ALL_POS, null);
15749            }
15750    
15751            /**
15752             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
15753             *
15754             * <p>
15755             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15756             * </p>
15757             *
15758             * @param groupId the group ID
15759             * @param folderId the folder ID
15760             * @param status the status
15761             * @param start the lower bound of the range of journal articles
15762             * @param end the upper bound of the range of journal articles (not inclusive)
15763             * @return the range of matching journal articles that the user has permission to view
15764             * @throws SystemException if a system exception occurred
15765             */
15766            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15767                    int status, int start, int end) throws SystemException {
15768                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
15769            }
15770    
15771            /**
15772             * 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;.
15773             *
15774             * <p>
15775             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15776             * </p>
15777             *
15778             * @param groupId the group ID
15779             * @param folderId the folder ID
15780             * @param status the status
15781             * @param start the lower bound of the range of journal articles
15782             * @param end the upper bound of the range of journal articles (not inclusive)
15783             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15784             * @return the ordered range of matching journal articles that the user has permission to view
15785             * @throws SystemException if a system exception occurred
15786             */
15787            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
15788                    int status, int start, int end, OrderByComparator orderByComparator)
15789                    throws SystemException {
15790                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15791                            return findByG_F_ST(groupId, folderId, status, start, end,
15792                                    orderByComparator);
15793                    }
15794    
15795                    StringBundler query = null;
15796    
15797                    if (orderByComparator != null) {
15798                            query = new StringBundler(5 +
15799                                            (orderByComparator.getOrderByFields().length * 3));
15800                    }
15801                    else {
15802                            query = new StringBundler(5);
15803                    }
15804    
15805                    if (getDB().isSupportsInlineDistinct()) {
15806                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15807                    }
15808                    else {
15809                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15810                    }
15811    
15812                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15813    
15814                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15815    
15816                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15817    
15818                    if (!getDB().isSupportsInlineDistinct()) {
15819                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15820                    }
15821    
15822                    if (orderByComparator != null) {
15823                            if (getDB().isSupportsInlineDistinct()) {
15824                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15825                                            orderByComparator, true);
15826                            }
15827                            else {
15828                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15829                                            orderByComparator, true);
15830                            }
15831                    }
15832                    else {
15833                            if (getDB().isSupportsInlineDistinct()) {
15834                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15835                            }
15836                            else {
15837                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15838                            }
15839                    }
15840    
15841                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15842                                    JournalArticle.class.getName(),
15843                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15844    
15845                    Session session = null;
15846    
15847                    try {
15848                            session = openSession();
15849    
15850                            SQLQuery q = session.createSQLQuery(sql);
15851    
15852                            if (getDB().isSupportsInlineDistinct()) {
15853                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15854                            }
15855                            else {
15856                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15857                            }
15858    
15859                            QueryPos qPos = QueryPos.getInstance(q);
15860    
15861                            qPos.add(groupId);
15862    
15863                            qPos.add(folderId);
15864    
15865                            qPos.add(status);
15866    
15867                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
15868                                    end);
15869                    }
15870                    catch (Exception e) {
15871                            throw processException(e);
15872                    }
15873                    finally {
15874                            closeSession(session);
15875                    }
15876            }
15877    
15878            /**
15879             * 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;.
15880             *
15881             * @param id the primary key of the current journal article
15882             * @param groupId the group ID
15883             * @param folderId the folder ID
15884             * @param status the status
15885             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15886             * @return the previous, current, and next journal article
15887             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15888             * @throws SystemException if a system exception occurred
15889             */
15890            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
15891                    long groupId, long folderId, int status,
15892                    OrderByComparator orderByComparator)
15893                    throws NoSuchArticleException, SystemException {
15894                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15895                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
15896                                    orderByComparator);
15897                    }
15898    
15899                    JournalArticle journalArticle = findByPrimaryKey(id);
15900    
15901                    Session session = null;
15902    
15903                    try {
15904                            session = openSession();
15905    
15906                            JournalArticle[] array = new JournalArticleImpl[3];
15907    
15908                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
15909                                            groupId, folderId, status, orderByComparator, true);
15910    
15911                            array[1] = journalArticle;
15912    
15913                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
15914                                            groupId, folderId, status, orderByComparator, false);
15915    
15916                            return array;
15917                    }
15918                    catch (Exception e) {
15919                            throw processException(e);
15920                    }
15921                    finally {
15922                            closeSession(session);
15923                    }
15924            }
15925    
15926            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
15927                    JournalArticle journalArticle, long groupId, long folderId, int status,
15928                    OrderByComparator orderByComparator, boolean previous) {
15929                    StringBundler query = null;
15930    
15931                    if (orderByComparator != null) {
15932                            query = new StringBundler(6 +
15933                                            (orderByComparator.getOrderByFields().length * 6));
15934                    }
15935                    else {
15936                            query = new StringBundler(3);
15937                    }
15938    
15939                    if (getDB().isSupportsInlineDistinct()) {
15940                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15941                    }
15942                    else {
15943                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15944                    }
15945    
15946                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
15947    
15948                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
15949    
15950                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
15951    
15952                    if (!getDB().isSupportsInlineDistinct()) {
15953                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15954                    }
15955    
15956                    if (orderByComparator != null) {
15957                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15958    
15959                            if (orderByConditionFields.length > 0) {
15960                                    query.append(WHERE_AND);
15961                            }
15962    
15963                            for (int i = 0; i < orderByConditionFields.length; i++) {
15964                                    if (getDB().isSupportsInlineDistinct()) {
15965                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15966                                    }
15967                                    else {
15968                                            query.append(_ORDER_BY_ENTITY_TABLE);
15969                                    }
15970    
15971                                    query.append(orderByConditionFields[i]);
15972    
15973                                    if ((i + 1) < orderByConditionFields.length) {
15974                                            if (orderByComparator.isAscending() ^ previous) {
15975                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15976                                            }
15977                                            else {
15978                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15979                                            }
15980                                    }
15981                                    else {
15982                                            if (orderByComparator.isAscending() ^ previous) {
15983                                                    query.append(WHERE_GREATER_THAN);
15984                                            }
15985                                            else {
15986                                                    query.append(WHERE_LESSER_THAN);
15987                                            }
15988                                    }
15989                            }
15990    
15991                            query.append(ORDER_BY_CLAUSE);
15992    
15993                            String[] orderByFields = orderByComparator.getOrderByFields();
15994    
15995                            for (int i = 0; i < orderByFields.length; i++) {
15996                                    if (getDB().isSupportsInlineDistinct()) {
15997                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15998                                    }
15999                                    else {
16000                                            query.append(_ORDER_BY_ENTITY_TABLE);
16001                                    }
16002    
16003                                    query.append(orderByFields[i]);
16004    
16005                                    if ((i + 1) < orderByFields.length) {
16006                                            if (orderByComparator.isAscending() ^ previous) {
16007                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16008                                            }
16009                                            else {
16010                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16011                                            }
16012                                    }
16013                                    else {
16014                                            if (orderByComparator.isAscending() ^ previous) {
16015                                                    query.append(ORDER_BY_ASC);
16016                                            }
16017                                            else {
16018                                                    query.append(ORDER_BY_DESC);
16019                                            }
16020                                    }
16021                            }
16022                    }
16023                    else {
16024                            if (getDB().isSupportsInlineDistinct()) {
16025                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16026                            }
16027                            else {
16028                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
16029                            }
16030                    }
16031    
16032                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16033                                    JournalArticle.class.getName(),
16034                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16035    
16036                    SQLQuery q = session.createSQLQuery(sql);
16037    
16038                    q.setFirstResult(0);
16039                    q.setMaxResults(2);
16040    
16041                    if (getDB().isSupportsInlineDistinct()) {
16042                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
16043                    }
16044                    else {
16045                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
16046                    }
16047    
16048                    QueryPos qPos = QueryPos.getInstance(q);
16049    
16050                    qPos.add(groupId);
16051    
16052                    qPos.add(folderId);
16053    
16054                    qPos.add(status);
16055    
16056                    if (orderByComparator != null) {
16057                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16058    
16059                            for (Object value : values) {
16060                                    qPos.add(value);
16061                            }
16062                    }
16063    
16064                    List<JournalArticle> list = q.list();
16065    
16066                    if (list.size() == 2) {
16067                            return list.get(1);
16068                    }
16069                    else {
16070                            return null;
16071                    }
16072            }
16073    
16074            /**
16075             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
16076             *
16077             * @param groupId the group ID
16078             * @param folderId the folder ID
16079             * @param statuses the statuses
16080             * @return the matching journal articles that the user has permission to view
16081             * @throws SystemException if a system exception occurred
16082             */
16083            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
16084                    int[] statuses) throws SystemException {
16085                    return filterFindByG_F_ST(groupId, folderId, statuses,
16086                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16087            }
16088    
16089            /**
16090             * 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;.
16091             *
16092             * <p>
16093             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16094             * </p>
16095             *
16096             * @param groupId the group ID
16097             * @param folderId the folder ID
16098             * @param statuses the statuses
16099             * @param start the lower bound of the range of journal articles
16100             * @param end the upper bound of the range of journal articles (not inclusive)
16101             * @return the range of matching journal articles that the user has permission to view
16102             * @throws SystemException if a system exception occurred
16103             */
16104            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
16105                    int[] statuses, int start, int end) throws SystemException {
16106                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
16107            }
16108    
16109            /**
16110             * 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;.
16111             *
16112             * <p>
16113             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16114             * </p>
16115             *
16116             * @param groupId the group ID
16117             * @param folderId the folder ID
16118             * @param statuses the statuses
16119             * @param start the lower bound of the range of journal articles
16120             * @param end the upper bound of the range of journal articles (not inclusive)
16121             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16122             * @return the ordered range of matching journal articles that the user has permission to view
16123             * @throws SystemException if a system exception occurred
16124             */
16125            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
16126                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
16127                    throws SystemException {
16128                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16129                            return findByG_F_ST(groupId, folderId, statuses, start, end,
16130                                    orderByComparator);
16131                    }
16132    
16133                    StringBundler query = new StringBundler();
16134    
16135                    if (getDB().isSupportsInlineDistinct()) {
16136                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
16137                    }
16138                    else {
16139                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
16140                    }
16141    
16142                    boolean conjunctionable = false;
16143    
16144                    if (conjunctionable) {
16145                            query.append(WHERE_AND);
16146                    }
16147    
16148                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
16149    
16150                    conjunctionable = true;
16151    
16152                    if (conjunctionable) {
16153                            query.append(WHERE_AND);
16154                    }
16155    
16156                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
16157    
16158                    conjunctionable = true;
16159    
16160                    if ((statuses == null) || (statuses.length > 0)) {
16161                            if (conjunctionable) {
16162                                    query.append(WHERE_AND);
16163                            }
16164    
16165                            query.append(StringPool.OPEN_PARENTHESIS);
16166    
16167                            for (int i = 0; i < statuses.length; i++) {
16168                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
16169    
16170                                    if ((i + 1) < statuses.length) {
16171                                            query.append(WHERE_OR);
16172                                    }
16173                            }
16174    
16175                            query.append(StringPool.CLOSE_PARENTHESIS);
16176    
16177                            conjunctionable = true;
16178                    }
16179    
16180                    if (!getDB().isSupportsInlineDistinct()) {
16181                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
16182                    }
16183    
16184                    if (orderByComparator != null) {
16185                            if (getDB().isSupportsInlineDistinct()) {
16186                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16187                                            orderByComparator, true);
16188                            }
16189                            else {
16190                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16191                                            orderByComparator, true);
16192                            }
16193                    }
16194                    else {
16195                            if (getDB().isSupportsInlineDistinct()) {
16196                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16197                            }
16198                            else {
16199                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
16200                            }
16201                    }
16202    
16203                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16204                                    JournalArticle.class.getName(),
16205                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16206    
16207                    Session session = null;
16208    
16209                    try {
16210                            session = openSession();
16211    
16212                            SQLQuery q = session.createSQLQuery(sql);
16213    
16214                            if (getDB().isSupportsInlineDistinct()) {
16215                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
16216                            }
16217                            else {
16218                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
16219                            }
16220    
16221                            QueryPos qPos = QueryPos.getInstance(q);
16222    
16223                            qPos.add(groupId);
16224    
16225                            qPos.add(folderId);
16226    
16227                            if (statuses != null) {
16228                                    qPos.add(statuses);
16229                            }
16230    
16231                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
16232                                    end);
16233                    }
16234                    catch (Exception e) {
16235                            throw processException(e);
16236                    }
16237                    finally {
16238                            closeSession(session);
16239                    }
16240            }
16241    
16242            /**
16243             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
16244             *
16245             * <p>
16246             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16247             * </p>
16248             *
16249             * @param groupId the group ID
16250             * @param folderId the folder ID
16251             * @param statuses the statuses
16252             * @return the matching journal articles
16253             * @throws SystemException if a system exception occurred
16254             */
16255            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
16256                    int[] statuses) throws SystemException {
16257                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
16258                            QueryUtil.ALL_POS, null);
16259            }
16260    
16261            /**
16262             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
16263             *
16264             * <p>
16265             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16266             * </p>
16267             *
16268             * @param groupId the group ID
16269             * @param folderId the folder ID
16270             * @param statuses the statuses
16271             * @param start the lower bound of the range of journal articles
16272             * @param end the upper bound of the range of journal articles (not inclusive)
16273             * @return the range of matching journal articles
16274             * @throws SystemException if a system exception occurred
16275             */
16276            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
16277                    int[] statuses, int start, int end) throws SystemException {
16278                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
16279            }
16280    
16281            /**
16282             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
16283             *
16284             * <p>
16285             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16286             * </p>
16287             *
16288             * @param groupId the group ID
16289             * @param folderId the folder ID
16290             * @param statuses the statuses
16291             * @param start the lower bound of the range of journal articles
16292             * @param end the upper bound of the range of journal articles (not inclusive)
16293             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16294             * @return the ordered range of matching journal articles
16295             * @throws SystemException if a system exception occurred
16296             */
16297            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
16298                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
16299                    throws SystemException {
16300                    if ((statuses != null) && (statuses.length == 1)) {
16301                            return findByG_F_ST(groupId, folderId, statuses[0], start, end,
16302                                    orderByComparator);
16303                    }
16304    
16305                    boolean pagination = true;
16306                    Object[] finderArgs = null;
16307    
16308                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16309                                    (orderByComparator == null)) {
16310                            pagination = false;
16311                            finderArgs = new Object[] {
16312                                            groupId, folderId, StringUtil.merge(statuses)
16313                                    };
16314                    }
16315                    else {
16316                            finderArgs = new Object[] {
16317                                            groupId, folderId, StringUtil.merge(statuses),
16318                                            
16319                                            start, end, orderByComparator
16320                                    };
16321                    }
16322    
16323                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
16324                                    finderArgs, this);
16325    
16326                    if ((list != null) && !list.isEmpty()) {
16327                            for (JournalArticle journalArticle : list) {
16328                                    if ((groupId != journalArticle.getGroupId()) ||
16329                                                    (folderId != journalArticle.getFolderId()) ||
16330                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
16331                                            list = null;
16332    
16333                                            break;
16334                                    }
16335                            }
16336                    }
16337    
16338                    if (list == null) {
16339                            StringBundler query = new StringBundler();
16340    
16341                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16342    
16343                            boolean conjunctionable = false;
16344    
16345                            if (conjunctionable) {
16346                                    query.append(WHERE_AND);
16347                            }
16348    
16349                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
16350    
16351                            conjunctionable = true;
16352    
16353                            if (conjunctionable) {
16354                                    query.append(WHERE_AND);
16355                            }
16356    
16357                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
16358    
16359                            conjunctionable = true;
16360    
16361                            if ((statuses == null) || (statuses.length > 0)) {
16362                                    if (conjunctionable) {
16363                                            query.append(WHERE_AND);
16364                                    }
16365    
16366                                    query.append(StringPool.OPEN_PARENTHESIS);
16367    
16368                                    for (int i = 0; i < statuses.length; i++) {
16369                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
16370    
16371                                            if ((i + 1) < statuses.length) {
16372                                                    query.append(WHERE_OR);
16373                                            }
16374                                    }
16375    
16376                                    query.append(StringPool.CLOSE_PARENTHESIS);
16377    
16378                                    conjunctionable = true;
16379                            }
16380    
16381                            if (orderByComparator != null) {
16382                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16383                                            orderByComparator);
16384                            }
16385                            else
16386                             if (pagination) {
16387                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16388                            }
16389    
16390                            String sql = query.toString();
16391    
16392                            Session session = null;
16393    
16394                            try {
16395                                    session = openSession();
16396    
16397                                    Query q = session.createQuery(sql);
16398    
16399                                    QueryPos qPos = QueryPos.getInstance(q);
16400    
16401                                    qPos.add(groupId);
16402    
16403                                    qPos.add(folderId);
16404    
16405                                    if (statuses != null) {
16406                                            qPos.add(statuses);
16407                                    }
16408    
16409                                    if (!pagination) {
16410                                            list = (List<JournalArticle>)QueryUtil.list(q,
16411                                                            getDialect(), start, end, false);
16412    
16413                                            Collections.sort(list);
16414    
16415                                            list = new UnmodifiableList<JournalArticle>(list);
16416                                    }
16417                                    else {
16418                                            list = (List<JournalArticle>)QueryUtil.list(q,
16419                                                            getDialect(), start, end);
16420                                    }
16421    
16422                                    cacheResult(list);
16423    
16424                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
16425                                            finderArgs, list);
16426                            }
16427                            catch (Exception e) {
16428                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
16429                                            finderArgs);
16430    
16431                                    throw processException(e);
16432                            }
16433                            finally {
16434                                    closeSession(session);
16435                            }
16436                    }
16437    
16438                    return list;
16439            }
16440    
16441            /**
16442             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
16443             *
16444             * @param groupId the group ID
16445             * @param folderId the folder ID
16446             * @param status the status
16447             * @throws SystemException if a system exception occurred
16448             */
16449            public void removeByG_F_ST(long groupId, long folderId, int status)
16450                    throws SystemException {
16451                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
16452                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16453                            remove(journalArticle);
16454                    }
16455            }
16456    
16457            /**
16458             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
16459             *
16460             * @param groupId the group ID
16461             * @param folderId the folder ID
16462             * @param status the status
16463             * @return the number of matching journal articles
16464             * @throws SystemException if a system exception occurred
16465             */
16466            public int countByG_F_ST(long groupId, long folderId, int status)
16467                    throws SystemException {
16468                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_ST;
16469    
16470                    Object[] finderArgs = new Object[] { groupId, folderId, status };
16471    
16472                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16473                                    this);
16474    
16475                    if (count == null) {
16476                            StringBundler query = new StringBundler(4);
16477    
16478                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16479    
16480                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
16481    
16482                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
16483    
16484                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
16485    
16486                            String sql = query.toString();
16487    
16488                            Session session = null;
16489    
16490                            try {
16491                                    session = openSession();
16492    
16493                                    Query q = session.createQuery(sql);
16494    
16495                                    QueryPos qPos = QueryPos.getInstance(q);
16496    
16497                                    qPos.add(groupId);
16498    
16499                                    qPos.add(folderId);
16500    
16501                                    qPos.add(status);
16502    
16503                                    count = (Long)q.uniqueResult();
16504    
16505                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16506                            }
16507                            catch (Exception e) {
16508                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16509    
16510                                    throw processException(e);
16511                            }
16512                            finally {
16513                                    closeSession(session);
16514                            }
16515                    }
16516    
16517                    return count.intValue();
16518            }
16519    
16520            /**
16521             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
16522             *
16523             * @param groupId the group ID
16524             * @param folderId the folder ID
16525             * @param statuses the statuses
16526             * @return the number of matching journal articles
16527             * @throws SystemException if a system exception occurred
16528             */
16529            public int countByG_F_ST(long groupId, long folderId, int[] statuses)
16530                    throws SystemException {
16531                    Object[] finderArgs = new Object[] {
16532                                    groupId, folderId, StringUtil.merge(statuses)
16533                            };
16534    
16535                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
16536                                    finderArgs, this);
16537    
16538                    if (count == null) {
16539                            StringBundler query = new StringBundler();
16540    
16541                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16542    
16543                            boolean conjunctionable = false;
16544    
16545                            if (conjunctionable) {
16546                                    query.append(WHERE_AND);
16547                            }
16548    
16549                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
16550    
16551                            conjunctionable = true;
16552    
16553                            if (conjunctionable) {
16554                                    query.append(WHERE_AND);
16555                            }
16556    
16557                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
16558    
16559                            conjunctionable = true;
16560    
16561                            if ((statuses == null) || (statuses.length > 0)) {
16562                                    if (conjunctionable) {
16563                                            query.append(WHERE_AND);
16564                                    }
16565    
16566                                    query.append(StringPool.OPEN_PARENTHESIS);
16567    
16568                                    for (int i = 0; i < statuses.length; i++) {
16569                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
16570    
16571                                            if ((i + 1) < statuses.length) {
16572                                                    query.append(WHERE_OR);
16573                                            }
16574                                    }
16575    
16576                                    query.append(StringPool.CLOSE_PARENTHESIS);
16577    
16578                                    conjunctionable = true;
16579                            }
16580    
16581                            String sql = query.toString();
16582    
16583                            Session session = null;
16584    
16585                            try {
16586                                    session = openSession();
16587    
16588                                    Query q = session.createQuery(sql);
16589    
16590                                    QueryPos qPos = QueryPos.getInstance(q);
16591    
16592                                    qPos.add(groupId);
16593    
16594                                    qPos.add(folderId);
16595    
16596                                    if (statuses != null) {
16597                                            qPos.add(statuses);
16598                                    }
16599    
16600                                    count = (Long)q.uniqueResult();
16601    
16602                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
16603                                            finderArgs, count);
16604                            }
16605                            catch (Exception e) {
16606                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
16607                                            finderArgs);
16608    
16609                                    throw processException(e);
16610                            }
16611                            finally {
16612                                    closeSession(session);
16613                            }
16614                    }
16615    
16616                    return count.intValue();
16617            }
16618    
16619            /**
16620             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
16621             *
16622             * @param groupId the group ID
16623             * @param folderId the folder ID
16624             * @param status the status
16625             * @return the number of matching journal articles that the user has permission to view
16626             * @throws SystemException if a system exception occurred
16627             */
16628            public int filterCountByG_F_ST(long groupId, long folderId, int status)
16629                    throws SystemException {
16630                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16631                            return countByG_F_ST(groupId, folderId, status);
16632                    }
16633    
16634                    StringBundler query = new StringBundler(4);
16635    
16636                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16637    
16638                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
16639    
16640                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
16641    
16642                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
16643    
16644                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16645                                    JournalArticle.class.getName(),
16646                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16647    
16648                    Session session = null;
16649    
16650                    try {
16651                            session = openSession();
16652    
16653                            SQLQuery q = session.createSQLQuery(sql);
16654    
16655                            q.addScalar(COUNT_COLUMN_NAME,
16656                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16657    
16658                            QueryPos qPos = QueryPos.getInstance(q);
16659    
16660                            qPos.add(groupId);
16661    
16662                            qPos.add(folderId);
16663    
16664                            qPos.add(status);
16665    
16666                            Long count = (Long)q.uniqueResult();
16667    
16668                            return count.intValue();
16669                    }
16670                    catch (Exception e) {
16671                            throw processException(e);
16672                    }
16673                    finally {
16674                            closeSession(session);
16675                    }
16676            }
16677    
16678            /**
16679             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
16680             *
16681             * @param groupId the group ID
16682             * @param folderId the folder ID
16683             * @param statuses the statuses
16684             * @return the number of matching journal articles that the user has permission to view
16685             * @throws SystemException if a system exception occurred
16686             */
16687            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses)
16688                    throws SystemException {
16689                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16690                            return countByG_F_ST(groupId, folderId, statuses);
16691                    }
16692    
16693                    StringBundler query = new StringBundler();
16694    
16695                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16696    
16697                    boolean conjunctionable = false;
16698    
16699                    if (conjunctionable) {
16700                            query.append(WHERE_AND);
16701                    }
16702    
16703                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
16704    
16705                    conjunctionable = true;
16706    
16707                    if (conjunctionable) {
16708                            query.append(WHERE_AND);
16709                    }
16710    
16711                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
16712    
16713                    conjunctionable = true;
16714    
16715                    if ((statuses == null) || (statuses.length > 0)) {
16716                            if (conjunctionable) {
16717                                    query.append(WHERE_AND);
16718                            }
16719    
16720                            query.append(StringPool.OPEN_PARENTHESIS);
16721    
16722                            for (int i = 0; i < statuses.length; i++) {
16723                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
16724    
16725                                    if ((i + 1) < statuses.length) {
16726                                            query.append(WHERE_OR);
16727                                    }
16728                            }
16729    
16730                            query.append(StringPool.CLOSE_PARENTHESIS);
16731    
16732                            conjunctionable = true;
16733                    }
16734    
16735                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16736                                    JournalArticle.class.getName(),
16737                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16738    
16739                    Session session = null;
16740    
16741                    try {
16742                            session = openSession();
16743    
16744                            SQLQuery q = session.createSQLQuery(sql);
16745    
16746                            q.addScalar(COUNT_COLUMN_NAME,
16747                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16748    
16749                            QueryPos qPos = QueryPos.getInstance(q);
16750    
16751                            qPos.add(groupId);
16752    
16753                            qPos.add(folderId);
16754    
16755                            if (statuses != null) {
16756                                    qPos.add(statuses);
16757                            }
16758    
16759                            Long count = (Long)q.uniqueResult();
16760    
16761                            return count.intValue();
16762                    }
16763                    catch (Exception e) {
16764                            throw processException(e);
16765                    }
16766                    finally {
16767                            closeSession(session);
16768                    }
16769            }
16770    
16771            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
16772            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_5 = "(" +
16773                    removeConjunction(_FINDER_COLUMN_G_F_ST_GROUPID_2) + ")";
16774            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
16775            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_5 = "(" +
16776                    removeConjunction(_FINDER_COLUMN_G_F_ST_FOLDERID_2) + ")";
16777            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
16778            private static final String _FINDER_COLUMN_G_F_ST_STATUS_5 = "(" +
16779                    removeConjunction(_FINDER_COLUMN_G_F_ST_STATUS_2) + ")";
16780            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16781                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16782                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16783                            "findByG_C_C",
16784                            new String[] {
16785                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
16786                                    
16787                            Integer.class.getName(), Integer.class.getName(),
16788                                    OrderByComparator.class.getName()
16789                            });
16790            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16791                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16792                            JournalArticleImpl.class,
16793                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
16794                            new String[] {
16795                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
16796                            },
16797                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
16798                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
16799                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK |
16800                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
16801                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
16802            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16803                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16804                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
16805                            new String[] {
16806                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
16807                            });
16808    
16809            /**
16810             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16811             *
16812             * @param groupId the group ID
16813             * @param classNameId the class name ID
16814             * @param classPK the class p k
16815             * @return the matching journal articles
16816             * @throws SystemException if a system exception occurred
16817             */
16818            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
16819                    long classPK) throws SystemException {
16820                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
16821                            QueryUtil.ALL_POS, null);
16822            }
16823    
16824            /**
16825             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16826             *
16827             * <p>
16828             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16829             * </p>
16830             *
16831             * @param groupId the group ID
16832             * @param classNameId the class name ID
16833             * @param classPK the class p k
16834             * @param start the lower bound of the range of journal articles
16835             * @param end the upper bound of the range of journal articles (not inclusive)
16836             * @return the range of matching journal articles
16837             * @throws SystemException if a system exception occurred
16838             */
16839            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
16840                    long classPK, int start, int end) throws SystemException {
16841                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
16842            }
16843    
16844            /**
16845             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16846             *
16847             * <p>
16848             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16849             * </p>
16850             *
16851             * @param groupId the group ID
16852             * @param classNameId the class name ID
16853             * @param classPK the class p k
16854             * @param start the lower bound of the range of journal articles
16855             * @param end the upper bound of the range of journal articles (not inclusive)
16856             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16857             * @return the ordered range of matching journal articles
16858             * @throws SystemException if a system exception occurred
16859             */
16860            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
16861                    long classPK, int start, int end, OrderByComparator orderByComparator)
16862                    throws SystemException {
16863                    boolean pagination = true;
16864                    FinderPath finderPath = null;
16865                    Object[] finderArgs = null;
16866    
16867                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16868                                    (orderByComparator == null)) {
16869                            pagination = false;
16870                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
16871                            finderArgs = new Object[] { groupId, classNameId, classPK };
16872                    }
16873                    else {
16874                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
16875                            finderArgs = new Object[] {
16876                                            groupId, classNameId, classPK,
16877                                            
16878                                            start, end, orderByComparator
16879                                    };
16880                    }
16881    
16882                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16883                                    finderArgs, this);
16884    
16885                    if ((list != null) && !list.isEmpty()) {
16886                            for (JournalArticle journalArticle : list) {
16887                                    if ((groupId != journalArticle.getGroupId()) ||
16888                                                    (classNameId != journalArticle.getClassNameId()) ||
16889                                                    (classPK != journalArticle.getClassPK())) {
16890                                            list = null;
16891    
16892                                            break;
16893                                    }
16894                            }
16895                    }
16896    
16897                    if (list == null) {
16898                            StringBundler query = null;
16899    
16900                            if (orderByComparator != null) {
16901                                    query = new StringBundler(5 +
16902                                                    (orderByComparator.getOrderByFields().length * 3));
16903                            }
16904                            else {
16905                                    query = new StringBundler(5);
16906                            }
16907    
16908                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16909    
16910                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
16911    
16912                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
16913    
16914                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
16915    
16916                            if (orderByComparator != null) {
16917                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16918                                            orderByComparator);
16919                            }
16920                            else
16921                             if (pagination) {
16922                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16923                            }
16924    
16925                            String sql = query.toString();
16926    
16927                            Session session = null;
16928    
16929                            try {
16930                                    session = openSession();
16931    
16932                                    Query q = session.createQuery(sql);
16933    
16934                                    QueryPos qPos = QueryPos.getInstance(q);
16935    
16936                                    qPos.add(groupId);
16937    
16938                                    qPos.add(classNameId);
16939    
16940                                    qPos.add(classPK);
16941    
16942                                    if (!pagination) {
16943                                            list = (List<JournalArticle>)QueryUtil.list(q,
16944                                                            getDialect(), start, end, false);
16945    
16946                                            Collections.sort(list);
16947    
16948                                            list = new UnmodifiableList<JournalArticle>(list);
16949                                    }
16950                                    else {
16951                                            list = (List<JournalArticle>)QueryUtil.list(q,
16952                                                            getDialect(), start, end);
16953                                    }
16954    
16955                                    cacheResult(list);
16956    
16957                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16958                            }
16959                            catch (Exception e) {
16960                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16961    
16962                                    throw processException(e);
16963                            }
16964                            finally {
16965                                    closeSession(session);
16966                            }
16967                    }
16968    
16969                    return list;
16970            }
16971    
16972            /**
16973             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16974             *
16975             * @param groupId the group ID
16976             * @param classNameId the class name ID
16977             * @param classPK the class p k
16978             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16979             * @return the first matching journal article
16980             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16981             * @throws SystemException if a system exception occurred
16982             */
16983            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
16984                    long classPK, OrderByComparator orderByComparator)
16985                    throws NoSuchArticleException, SystemException {
16986                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
16987                                    classNameId, classPK, orderByComparator);
16988    
16989                    if (journalArticle != null) {
16990                            return journalArticle;
16991                    }
16992    
16993                    StringBundler msg = new StringBundler(8);
16994    
16995                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16996    
16997                    msg.append("groupId=");
16998                    msg.append(groupId);
16999    
17000                    msg.append(", classNameId=");
17001                    msg.append(classNameId);
17002    
17003                    msg.append(", classPK=");
17004                    msg.append(classPK);
17005    
17006                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17007    
17008                    throw new NoSuchArticleException(msg.toString());
17009            }
17010    
17011            /**
17012             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17013             *
17014             * @param groupId the group ID
17015             * @param classNameId the class name ID
17016             * @param classPK the class p k
17017             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17018             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17019             * @throws SystemException if a system exception occurred
17020             */
17021            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
17022                    long classPK, OrderByComparator orderByComparator)
17023                    throws SystemException {
17024                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
17025                                    0, 1, orderByComparator);
17026    
17027                    if (!list.isEmpty()) {
17028                            return list.get(0);
17029                    }
17030    
17031                    return null;
17032            }
17033    
17034            /**
17035             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17036             *
17037             * @param groupId the group ID
17038             * @param classNameId the class name ID
17039             * @param classPK the class p k
17040             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17041             * @return the last matching journal article
17042             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17043             * @throws SystemException if a system exception occurred
17044             */
17045            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
17046                    long classPK, OrderByComparator orderByComparator)
17047                    throws NoSuchArticleException, SystemException {
17048                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
17049                                    classPK, orderByComparator);
17050    
17051                    if (journalArticle != null) {
17052                            return journalArticle;
17053                    }
17054    
17055                    StringBundler msg = new StringBundler(8);
17056    
17057                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17058    
17059                    msg.append("groupId=");
17060                    msg.append(groupId);
17061    
17062                    msg.append(", classNameId=");
17063                    msg.append(classNameId);
17064    
17065                    msg.append(", classPK=");
17066                    msg.append(classPK);
17067    
17068                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17069    
17070                    throw new NoSuchArticleException(msg.toString());
17071            }
17072    
17073            /**
17074             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17075             *
17076             * @param groupId the group ID
17077             * @param classNameId the class name ID
17078             * @param classPK the class p k
17079             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17080             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17081             * @throws SystemException if a system exception occurred
17082             */
17083            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
17084                    long classPK, OrderByComparator orderByComparator)
17085                    throws SystemException {
17086                    int count = countByG_C_C(groupId, classNameId, classPK);
17087    
17088                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
17089                                    count - 1, count, orderByComparator);
17090    
17091                    if (!list.isEmpty()) {
17092                            return list.get(0);
17093                    }
17094    
17095                    return null;
17096            }
17097    
17098            /**
17099             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17100             *
17101             * @param id the primary key of the current journal article
17102             * @param groupId the group ID
17103             * @param classNameId the class name ID
17104             * @param classPK the class p k
17105             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17106             * @return the previous, current, and next journal article
17107             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17108             * @throws SystemException if a system exception occurred
17109             */
17110            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
17111                    long classNameId, long classPK, OrderByComparator orderByComparator)
17112                    throws NoSuchArticleException, SystemException {
17113                    JournalArticle journalArticle = findByPrimaryKey(id);
17114    
17115                    Session session = null;
17116    
17117                    try {
17118                            session = openSession();
17119    
17120                            JournalArticle[] array = new JournalArticleImpl[3];
17121    
17122                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
17123                                            classNameId, classPK, orderByComparator, true);
17124    
17125                            array[1] = journalArticle;
17126    
17127                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
17128                                            classNameId, classPK, orderByComparator, false);
17129    
17130                            return array;
17131                    }
17132                    catch (Exception e) {
17133                            throw processException(e);
17134                    }
17135                    finally {
17136                            closeSession(session);
17137                    }
17138            }
17139    
17140            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
17141                    JournalArticle journalArticle, long groupId, long classNameId,
17142                    long classPK, OrderByComparator orderByComparator, boolean previous) {
17143                    StringBundler query = null;
17144    
17145                    if (orderByComparator != null) {
17146                            query = new StringBundler(6 +
17147                                            (orderByComparator.getOrderByFields().length * 6));
17148                    }
17149                    else {
17150                            query = new StringBundler(3);
17151                    }
17152    
17153                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17154    
17155                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17156    
17157                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17158    
17159                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17160    
17161                    if (orderByComparator != null) {
17162                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17163    
17164                            if (orderByConditionFields.length > 0) {
17165                                    query.append(WHERE_AND);
17166                            }
17167    
17168                            for (int i = 0; i < orderByConditionFields.length; i++) {
17169                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17170                                    query.append(orderByConditionFields[i]);
17171    
17172                                    if ((i + 1) < orderByConditionFields.length) {
17173                                            if (orderByComparator.isAscending() ^ previous) {
17174                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17175                                            }
17176                                            else {
17177                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17178                                            }
17179                                    }
17180                                    else {
17181                                            if (orderByComparator.isAscending() ^ previous) {
17182                                                    query.append(WHERE_GREATER_THAN);
17183                                            }
17184                                            else {
17185                                                    query.append(WHERE_LESSER_THAN);
17186                                            }
17187                                    }
17188                            }
17189    
17190                            query.append(ORDER_BY_CLAUSE);
17191    
17192                            String[] orderByFields = orderByComparator.getOrderByFields();
17193    
17194                            for (int i = 0; i < orderByFields.length; i++) {
17195                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17196                                    query.append(orderByFields[i]);
17197    
17198                                    if ((i + 1) < orderByFields.length) {
17199                                            if (orderByComparator.isAscending() ^ previous) {
17200                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17201                                            }
17202                                            else {
17203                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17204                                            }
17205                                    }
17206                                    else {
17207                                            if (orderByComparator.isAscending() ^ previous) {
17208                                                    query.append(ORDER_BY_ASC);
17209                                            }
17210                                            else {
17211                                                    query.append(ORDER_BY_DESC);
17212                                            }
17213                                    }
17214                            }
17215                    }
17216                    else {
17217                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17218                    }
17219    
17220                    String sql = query.toString();
17221    
17222                    Query q = session.createQuery(sql);
17223    
17224                    q.setFirstResult(0);
17225                    q.setMaxResults(2);
17226    
17227                    QueryPos qPos = QueryPos.getInstance(q);
17228    
17229                    qPos.add(groupId);
17230    
17231                    qPos.add(classNameId);
17232    
17233                    qPos.add(classPK);
17234    
17235                    if (orderByComparator != null) {
17236                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17237    
17238                            for (Object value : values) {
17239                                    qPos.add(value);
17240                            }
17241                    }
17242    
17243                    List<JournalArticle> list = q.list();
17244    
17245                    if (list.size() == 2) {
17246                            return list.get(1);
17247                    }
17248                    else {
17249                            return null;
17250                    }
17251            }
17252    
17253            /**
17254             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17255             *
17256             * @param groupId the group ID
17257             * @param classNameId the class name ID
17258             * @param classPK the class p k
17259             * @return the matching journal articles that the user has permission to view
17260             * @throws SystemException if a system exception occurred
17261             */
17262            public List<JournalArticle> filterFindByG_C_C(long groupId,
17263                    long classNameId, long classPK) throws SystemException {
17264                    return filterFindByG_C_C(groupId, classNameId, classPK,
17265                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17266            }
17267    
17268            /**
17269             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17270             *
17271             * <p>
17272             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17273             * </p>
17274             *
17275             * @param groupId the group ID
17276             * @param classNameId the class name ID
17277             * @param classPK the class p k
17278             * @param start the lower bound of the range of journal articles
17279             * @param end the upper bound of the range of journal articles (not inclusive)
17280             * @return the range of matching journal articles that the user has permission to view
17281             * @throws SystemException if a system exception occurred
17282             */
17283            public List<JournalArticle> filterFindByG_C_C(long groupId,
17284                    long classNameId, long classPK, int start, int end)
17285                    throws SystemException {
17286                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
17287            }
17288    
17289            /**
17290             * 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;.
17291             *
17292             * <p>
17293             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17294             * </p>
17295             *
17296             * @param groupId the group ID
17297             * @param classNameId the class name ID
17298             * @param classPK the class p k
17299             * @param start the lower bound of the range of journal articles
17300             * @param end the upper bound of the range of journal articles (not inclusive)
17301             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17302             * @return the ordered range of matching journal articles that the user has permission to view
17303             * @throws SystemException if a system exception occurred
17304             */
17305            public List<JournalArticle> filterFindByG_C_C(long groupId,
17306                    long classNameId, long classPK, int start, int end,
17307                    OrderByComparator orderByComparator) throws SystemException {
17308                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17309                            return findByG_C_C(groupId, classNameId, classPK, start, end,
17310                                    orderByComparator);
17311                    }
17312    
17313                    StringBundler query = null;
17314    
17315                    if (orderByComparator != null) {
17316                            query = new StringBundler(5 +
17317                                            (orderByComparator.getOrderByFields().length * 3));
17318                    }
17319                    else {
17320                            query = new StringBundler(5);
17321                    }
17322    
17323                    if (getDB().isSupportsInlineDistinct()) {
17324                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
17325                    }
17326                    else {
17327                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
17328                    }
17329    
17330                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17331    
17332                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17333    
17334                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17335    
17336                    if (!getDB().isSupportsInlineDistinct()) {
17337                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
17338                    }
17339    
17340                    if (orderByComparator != null) {
17341                            if (getDB().isSupportsInlineDistinct()) {
17342                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17343                                            orderByComparator, true);
17344                            }
17345                            else {
17346                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17347                                            orderByComparator, true);
17348                            }
17349                    }
17350                    else {
17351                            if (getDB().isSupportsInlineDistinct()) {
17352                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17353                            }
17354                            else {
17355                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
17356                            }
17357                    }
17358    
17359                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17360                                    JournalArticle.class.getName(),
17361                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17362    
17363                    Session session = null;
17364    
17365                    try {
17366                            session = openSession();
17367    
17368                            SQLQuery q = session.createSQLQuery(sql);
17369    
17370                            if (getDB().isSupportsInlineDistinct()) {
17371                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
17372                            }
17373                            else {
17374                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
17375                            }
17376    
17377                            QueryPos qPos = QueryPos.getInstance(q);
17378    
17379                            qPos.add(groupId);
17380    
17381                            qPos.add(classNameId);
17382    
17383                            qPos.add(classPK);
17384    
17385                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
17386                                    end);
17387                    }
17388                    catch (Exception e) {
17389                            throw processException(e);
17390                    }
17391                    finally {
17392                            closeSession(session);
17393                    }
17394            }
17395    
17396            /**
17397             * 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;.
17398             *
17399             * @param id the primary key of the current journal article
17400             * @param groupId the group ID
17401             * @param classNameId the class name ID
17402             * @param classPK the class p k
17403             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17404             * @return the previous, current, and next journal article
17405             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17406             * @throws SystemException if a system exception occurred
17407             */
17408            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
17409                    long groupId, long classNameId, long classPK,
17410                    OrderByComparator orderByComparator)
17411                    throws NoSuchArticleException, SystemException {
17412                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17413                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
17414                                    orderByComparator);
17415                    }
17416    
17417                    JournalArticle journalArticle = findByPrimaryKey(id);
17418    
17419                    Session session = null;
17420    
17421                    try {
17422                            session = openSession();
17423    
17424                            JournalArticle[] array = new JournalArticleImpl[3];
17425    
17426                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
17427                                            groupId, classNameId, classPK, orderByComparator, true);
17428    
17429                            array[1] = journalArticle;
17430    
17431                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
17432                                            groupId, classNameId, classPK, orderByComparator, false);
17433    
17434                            return array;
17435                    }
17436                    catch (Exception e) {
17437                            throw processException(e);
17438                    }
17439                    finally {
17440                            closeSession(session);
17441                    }
17442            }
17443    
17444            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
17445                    JournalArticle journalArticle, long groupId, long classNameId,
17446                    long classPK, OrderByComparator orderByComparator, boolean previous) {
17447                    StringBundler query = null;
17448    
17449                    if (orderByComparator != null) {
17450                            query = new StringBundler(6 +
17451                                            (orderByComparator.getOrderByFields().length * 6));
17452                    }
17453                    else {
17454                            query = new StringBundler(3);
17455                    }
17456    
17457                    if (getDB().isSupportsInlineDistinct()) {
17458                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
17459                    }
17460                    else {
17461                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
17462                    }
17463    
17464                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17465    
17466                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17467    
17468                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17469    
17470                    if (!getDB().isSupportsInlineDistinct()) {
17471                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
17472                    }
17473    
17474                    if (orderByComparator != null) {
17475                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17476    
17477                            if (orderByConditionFields.length > 0) {
17478                                    query.append(WHERE_AND);
17479                            }
17480    
17481                            for (int i = 0; i < orderByConditionFields.length; i++) {
17482                                    if (getDB().isSupportsInlineDistinct()) {
17483                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17484                                    }
17485                                    else {
17486                                            query.append(_ORDER_BY_ENTITY_TABLE);
17487                                    }
17488    
17489                                    query.append(orderByConditionFields[i]);
17490    
17491                                    if ((i + 1) < orderByConditionFields.length) {
17492                                            if (orderByComparator.isAscending() ^ previous) {
17493                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17494                                            }
17495                                            else {
17496                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17497                                            }
17498                                    }
17499                                    else {
17500                                            if (orderByComparator.isAscending() ^ previous) {
17501                                                    query.append(WHERE_GREATER_THAN);
17502                                            }
17503                                            else {
17504                                                    query.append(WHERE_LESSER_THAN);
17505                                            }
17506                                    }
17507                            }
17508    
17509                            query.append(ORDER_BY_CLAUSE);
17510    
17511                            String[] orderByFields = orderByComparator.getOrderByFields();
17512    
17513                            for (int i = 0; i < orderByFields.length; i++) {
17514                                    if (getDB().isSupportsInlineDistinct()) {
17515                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17516                                    }
17517                                    else {
17518                                            query.append(_ORDER_BY_ENTITY_TABLE);
17519                                    }
17520    
17521                                    query.append(orderByFields[i]);
17522    
17523                                    if ((i + 1) < orderByFields.length) {
17524                                            if (orderByComparator.isAscending() ^ previous) {
17525                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17526                                            }
17527                                            else {
17528                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17529                                            }
17530                                    }
17531                                    else {
17532                                            if (orderByComparator.isAscending() ^ previous) {
17533                                                    query.append(ORDER_BY_ASC);
17534                                            }
17535                                            else {
17536                                                    query.append(ORDER_BY_DESC);
17537                                            }
17538                                    }
17539                            }
17540                    }
17541                    else {
17542                            if (getDB().isSupportsInlineDistinct()) {
17543                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17544                            }
17545                            else {
17546                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
17547                            }
17548                    }
17549    
17550                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17551                                    JournalArticle.class.getName(),
17552                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17553    
17554                    SQLQuery q = session.createSQLQuery(sql);
17555    
17556                    q.setFirstResult(0);
17557                    q.setMaxResults(2);
17558    
17559                    if (getDB().isSupportsInlineDistinct()) {
17560                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
17561                    }
17562                    else {
17563                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
17564                    }
17565    
17566                    QueryPos qPos = QueryPos.getInstance(q);
17567    
17568                    qPos.add(groupId);
17569    
17570                    qPos.add(classNameId);
17571    
17572                    qPos.add(classPK);
17573    
17574                    if (orderByComparator != null) {
17575                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17576    
17577                            for (Object value : values) {
17578                                    qPos.add(value);
17579                            }
17580                    }
17581    
17582                    List<JournalArticle> list = q.list();
17583    
17584                    if (list.size() == 2) {
17585                            return list.get(1);
17586                    }
17587                    else {
17588                            return null;
17589                    }
17590            }
17591    
17592            /**
17593             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
17594             *
17595             * @param groupId the group ID
17596             * @param classNameId the class name ID
17597             * @param classPK the class p k
17598             * @throws SystemException if a system exception occurred
17599             */
17600            public void removeByG_C_C(long groupId, long classNameId, long classPK)
17601                    throws SystemException {
17602                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
17603                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17604                            remove(journalArticle);
17605                    }
17606            }
17607    
17608            /**
17609             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17610             *
17611             * @param groupId the group ID
17612             * @param classNameId the class name ID
17613             * @param classPK the class p k
17614             * @return the number of matching journal articles
17615             * @throws SystemException if a system exception occurred
17616             */
17617            public int countByG_C_C(long groupId, long classNameId, long classPK)
17618                    throws SystemException {
17619                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
17620    
17621                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
17622    
17623                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17624                                    this);
17625    
17626                    if (count == null) {
17627                            StringBundler query = new StringBundler(4);
17628    
17629                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17630    
17631                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17632    
17633                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17634    
17635                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17636    
17637                            String sql = query.toString();
17638    
17639                            Session session = null;
17640    
17641                            try {
17642                                    session = openSession();
17643    
17644                                    Query q = session.createQuery(sql);
17645    
17646                                    QueryPos qPos = QueryPos.getInstance(q);
17647    
17648                                    qPos.add(groupId);
17649    
17650                                    qPos.add(classNameId);
17651    
17652                                    qPos.add(classPK);
17653    
17654                                    count = (Long)q.uniqueResult();
17655    
17656                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17657                            }
17658                            catch (Exception e) {
17659                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17660    
17661                                    throw processException(e);
17662                            }
17663                            finally {
17664                                    closeSession(session);
17665                            }
17666                    }
17667    
17668                    return count.intValue();
17669            }
17670    
17671            /**
17672             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17673             *
17674             * @param groupId the group ID
17675             * @param classNameId the class name ID
17676             * @param classPK the class p k
17677             * @return the number of matching journal articles that the user has permission to view
17678             * @throws SystemException if a system exception occurred
17679             */
17680            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
17681                    throws SystemException {
17682                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17683                            return countByG_C_C(groupId, classNameId, classPK);
17684                    }
17685    
17686                    StringBundler query = new StringBundler(4);
17687    
17688                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17689    
17690                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17691    
17692                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17693    
17694                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17695    
17696                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17697                                    JournalArticle.class.getName(),
17698                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17699    
17700                    Session session = null;
17701    
17702                    try {
17703                            session = openSession();
17704    
17705                            SQLQuery q = session.createSQLQuery(sql);
17706    
17707                            q.addScalar(COUNT_COLUMN_NAME,
17708                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17709    
17710                            QueryPos qPos = QueryPos.getInstance(q);
17711    
17712                            qPos.add(groupId);
17713    
17714                            qPos.add(classNameId);
17715    
17716                            qPos.add(classPK);
17717    
17718                            Long count = (Long)q.uniqueResult();
17719    
17720                            return count.intValue();
17721                    }
17722                    catch (Exception e) {
17723                            throw processException(e);
17724                    }
17725                    finally {
17726                            closeSession(session);
17727                    }
17728            }
17729    
17730            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
17731            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
17732            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
17733            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17734                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17735                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
17736                            new String[] {
17737                                    Long.class.getName(), Long.class.getName(),
17738                                    String.class.getName()
17739                            },
17740                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
17741                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
17742                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
17743            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17744                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17745                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
17746                            new String[] {
17747                                    Long.class.getName(), Long.class.getName(),
17748                                    String.class.getName()
17749                            });
17750    
17751            /**
17752             * 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.
17753             *
17754             * @param groupId the group ID
17755             * @param classNameId the class name ID
17756             * @param structureId the structure ID
17757             * @return the matching journal article
17758             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17759             * @throws SystemException if a system exception occurred
17760             */
17761            public JournalArticle findByG_C_S(long groupId, long classNameId,
17762                    String structureId) throws NoSuchArticleException, SystemException {
17763                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
17764                                    structureId);
17765    
17766                    if (journalArticle == null) {
17767                            StringBundler msg = new StringBundler(8);
17768    
17769                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17770    
17771                            msg.append("groupId=");
17772                            msg.append(groupId);
17773    
17774                            msg.append(", classNameId=");
17775                            msg.append(classNameId);
17776    
17777                            msg.append(", structureId=");
17778                            msg.append(structureId);
17779    
17780                            msg.append(StringPool.CLOSE_CURLY_BRACE);
17781    
17782                            if (_log.isWarnEnabled()) {
17783                                    _log.warn(msg.toString());
17784                            }
17785    
17786                            throw new NoSuchArticleException(msg.toString());
17787                    }
17788    
17789                    return journalArticle;
17790            }
17791    
17792            /**
17793             * 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.
17794             *
17795             * @param groupId the group ID
17796             * @param classNameId the class name ID
17797             * @param structureId the structure ID
17798             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
17799             * @throws SystemException if a system exception occurred
17800             */
17801            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
17802                    String structureId) throws SystemException {
17803                    return fetchByG_C_S(groupId, classNameId, structureId, true);
17804            }
17805    
17806            /**
17807             * 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.
17808             *
17809             * @param groupId the group ID
17810             * @param classNameId the class name ID
17811             * @param structureId the structure ID
17812             * @param retrieveFromCache whether to use the finder cache
17813             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
17814             * @throws SystemException if a system exception occurred
17815             */
17816            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
17817                    String structureId, boolean retrieveFromCache)
17818                    throws SystemException {
17819                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
17820    
17821                    Object result = null;
17822    
17823                    if (retrieveFromCache) {
17824                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
17825                                            finderArgs, this);
17826                    }
17827    
17828                    if (result instanceof JournalArticle) {
17829                            JournalArticle journalArticle = (JournalArticle)result;
17830    
17831                            if ((groupId != journalArticle.getGroupId()) ||
17832                                            (classNameId != journalArticle.getClassNameId()) ||
17833                                            !Validator.equals(structureId,
17834                                                    journalArticle.getStructureId())) {
17835                                    result = null;
17836                            }
17837                    }
17838    
17839                    if (result == null) {
17840                            StringBundler query = new StringBundler(5);
17841    
17842                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17843    
17844                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
17845    
17846                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
17847    
17848                            boolean bindStructureId = false;
17849    
17850                            if (structureId == null) {
17851                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
17852                            }
17853                            else if (structureId.equals(StringPool.BLANK)) {
17854                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
17855                            }
17856                            else {
17857                                    bindStructureId = true;
17858    
17859                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
17860                            }
17861    
17862                            String sql = query.toString();
17863    
17864                            Session session = null;
17865    
17866                            try {
17867                                    session = openSession();
17868    
17869                                    Query q = session.createQuery(sql);
17870    
17871                                    QueryPos qPos = QueryPos.getInstance(q);
17872    
17873                                    qPos.add(groupId);
17874    
17875                                    qPos.add(classNameId);
17876    
17877                                    if (bindStructureId) {
17878                                            qPos.add(structureId);
17879                                    }
17880    
17881                                    List<JournalArticle> list = q.list();
17882    
17883                                    if (list.isEmpty()) {
17884                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
17885                                                    finderArgs, list);
17886                                    }
17887                                    else {
17888                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
17889                                                    _log.warn(
17890                                                            "JournalArticlePersistenceImpl.fetchByG_C_S(long, long, String, boolean) with parameters (" +
17891                                                            StringUtil.merge(finderArgs) +
17892                                                            ") 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.");
17893                                            }
17894    
17895                                            JournalArticle journalArticle = list.get(0);
17896    
17897                                            result = journalArticle;
17898    
17899                                            cacheResult(journalArticle);
17900    
17901                                            if ((journalArticle.getGroupId() != groupId) ||
17902                                                            (journalArticle.getClassNameId() != classNameId) ||
17903                                                            (journalArticle.getStructureId() == null) ||
17904                                                            !journalArticle.getStructureId().equals(structureId)) {
17905                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
17906                                                            finderArgs, journalArticle);
17907                                            }
17908                                    }
17909                            }
17910                            catch (Exception e) {
17911                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
17912                                            finderArgs);
17913    
17914                                    throw processException(e);
17915                            }
17916                            finally {
17917                                    closeSession(session);
17918                            }
17919                    }
17920    
17921                    if (result instanceof List<?>) {
17922                            return null;
17923                    }
17924                    else {
17925                            return (JournalArticle)result;
17926                    }
17927            }
17928    
17929            /**
17930             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
17931             *
17932             * @param groupId the group ID
17933             * @param classNameId the class name ID
17934             * @param structureId the structure ID
17935             * @return the journal article that was removed
17936             * @throws SystemException if a system exception occurred
17937             */
17938            public JournalArticle removeByG_C_S(long groupId, long classNameId,
17939                    String structureId) throws NoSuchArticleException, SystemException {
17940                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
17941                                    structureId);
17942    
17943                    return remove(journalArticle);
17944            }
17945    
17946            /**
17947             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
17948             *
17949             * @param groupId the group ID
17950             * @param classNameId the class name ID
17951             * @param structureId the structure ID
17952             * @return the number of matching journal articles
17953             * @throws SystemException if a system exception occurred
17954             */
17955            public int countByG_C_S(long groupId, long classNameId, String structureId)
17956                    throws SystemException {
17957                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_S;
17958    
17959                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
17960    
17961                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17962                                    this);
17963    
17964                    if (count == null) {
17965                            StringBundler query = new StringBundler(4);
17966    
17967                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17968    
17969                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
17970    
17971                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
17972    
17973                            boolean bindStructureId = false;
17974    
17975                            if (structureId == null) {
17976                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
17977                            }
17978                            else if (structureId.equals(StringPool.BLANK)) {
17979                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
17980                            }
17981                            else {
17982                                    bindStructureId = true;
17983    
17984                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
17985                            }
17986    
17987                            String sql = query.toString();
17988    
17989                            Session session = null;
17990    
17991                            try {
17992                                    session = openSession();
17993    
17994                                    Query q = session.createQuery(sql);
17995    
17996                                    QueryPos qPos = QueryPos.getInstance(q);
17997    
17998                                    qPos.add(groupId);
17999    
18000                                    qPos.add(classNameId);
18001    
18002                                    if (bindStructureId) {
18003                                            qPos.add(structureId);
18004                                    }
18005    
18006                                    count = (Long)q.uniqueResult();
18007    
18008                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18009                            }
18010                            catch (Exception e) {
18011                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18012    
18013                                    throw processException(e);
18014                            }
18015                            finally {
18016                                    closeSession(session);
18017                            }
18018                    }
18019    
18020                    return count.intValue();
18021            }
18022    
18023            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
18024            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
18025            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
18026            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
18027            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = '')";
18028            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18029                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18030                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18031                            "findByG_C_T",
18032                            new String[] {
18033                                    Long.class.getName(), Long.class.getName(),
18034                                    String.class.getName(),
18035                                    
18036                            Integer.class.getName(), Integer.class.getName(),
18037                                    OrderByComparator.class.getName()
18038                            });
18039            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18040                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18041                            JournalArticleImpl.class,
18042                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
18043                            new String[] {
18044                                    Long.class.getName(), Long.class.getName(),
18045                                    String.class.getName()
18046                            },
18047                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
18048                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
18049                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK |
18050                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18051                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18052            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18053                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18054                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
18055                            new String[] {
18056                                    Long.class.getName(), Long.class.getName(),
18057                                    String.class.getName()
18058                            });
18059    
18060            /**
18061             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18062             *
18063             * @param groupId the group ID
18064             * @param classNameId the class name ID
18065             * @param templateId the template ID
18066             * @return the matching journal articles
18067             * @throws SystemException if a system exception occurred
18068             */
18069            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
18070                    String templateId) throws SystemException {
18071                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
18072                            QueryUtil.ALL_POS, null);
18073            }
18074    
18075            /**
18076             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18077             *
18078             * <p>
18079             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18080             * </p>
18081             *
18082             * @param groupId the group ID
18083             * @param classNameId the class name ID
18084             * @param templateId the template ID
18085             * @param start the lower bound of the range of journal articles
18086             * @param end the upper bound of the range of journal articles (not inclusive)
18087             * @return the range of matching journal articles
18088             * @throws SystemException if a system exception occurred
18089             */
18090            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
18091                    String templateId, int start, int end) throws SystemException {
18092                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
18093            }
18094    
18095            /**
18096             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18097             *
18098             * <p>
18099             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18100             * </p>
18101             *
18102             * @param groupId the group ID
18103             * @param classNameId the class name ID
18104             * @param templateId the template ID
18105             * @param start the lower bound of the range of journal articles
18106             * @param end the upper bound of the range of journal articles (not inclusive)
18107             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18108             * @return the ordered range of matching journal articles
18109             * @throws SystemException if a system exception occurred
18110             */
18111            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
18112                    String templateId, int start, int end,
18113                    OrderByComparator orderByComparator) throws SystemException {
18114                    boolean pagination = true;
18115                    FinderPath finderPath = null;
18116                    Object[] finderArgs = null;
18117    
18118                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18119                                    (orderByComparator == null)) {
18120                            pagination = false;
18121                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
18122                            finderArgs = new Object[] { groupId, classNameId, templateId };
18123                    }
18124                    else {
18125                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
18126                            finderArgs = new Object[] {
18127                                            groupId, classNameId, templateId,
18128                                            
18129                                            start, end, orderByComparator
18130                                    };
18131                    }
18132    
18133                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18134                                    finderArgs, this);
18135    
18136                    if ((list != null) && !list.isEmpty()) {
18137                            for (JournalArticle journalArticle : list) {
18138                                    if ((groupId != journalArticle.getGroupId()) ||
18139                                                    (classNameId != journalArticle.getClassNameId()) ||
18140                                                    !Validator.equals(templateId,
18141                                                            journalArticle.getTemplateId())) {
18142                                            list = null;
18143    
18144                                            break;
18145                                    }
18146                            }
18147                    }
18148    
18149                    if (list == null) {
18150                            StringBundler query = null;
18151    
18152                            if (orderByComparator != null) {
18153                                    query = new StringBundler(5 +
18154                                                    (orderByComparator.getOrderByFields().length * 3));
18155                            }
18156                            else {
18157                                    query = new StringBundler(5);
18158                            }
18159    
18160                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18161    
18162                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18163    
18164                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18165    
18166                            boolean bindTemplateId = false;
18167    
18168                            if (templateId == null) {
18169                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18170                            }
18171                            else if (templateId.equals(StringPool.BLANK)) {
18172                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18173                            }
18174                            else {
18175                                    bindTemplateId = true;
18176    
18177                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18178                            }
18179    
18180                            if (orderByComparator != null) {
18181                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18182                                            orderByComparator);
18183                            }
18184                            else
18185                             if (pagination) {
18186                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18187                            }
18188    
18189                            String sql = query.toString();
18190    
18191                            Session session = null;
18192    
18193                            try {
18194                                    session = openSession();
18195    
18196                                    Query q = session.createQuery(sql);
18197    
18198                                    QueryPos qPos = QueryPos.getInstance(q);
18199    
18200                                    qPos.add(groupId);
18201    
18202                                    qPos.add(classNameId);
18203    
18204                                    if (bindTemplateId) {
18205                                            qPos.add(templateId);
18206                                    }
18207    
18208                                    if (!pagination) {
18209                                            list = (List<JournalArticle>)QueryUtil.list(q,
18210                                                            getDialect(), start, end, false);
18211    
18212                                            Collections.sort(list);
18213    
18214                                            list = new UnmodifiableList<JournalArticle>(list);
18215                                    }
18216                                    else {
18217                                            list = (List<JournalArticle>)QueryUtil.list(q,
18218                                                            getDialect(), start, end);
18219                                    }
18220    
18221                                    cacheResult(list);
18222    
18223                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18224                            }
18225                            catch (Exception e) {
18226                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18227    
18228                                    throw processException(e);
18229                            }
18230                            finally {
18231                                    closeSession(session);
18232                            }
18233                    }
18234    
18235                    return list;
18236            }
18237    
18238            /**
18239             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18240             *
18241             * @param groupId the group ID
18242             * @param classNameId the class name ID
18243             * @param templateId the template ID
18244             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18245             * @return the first matching journal article
18246             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18247             * @throws SystemException if a system exception occurred
18248             */
18249            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
18250                    String templateId, OrderByComparator orderByComparator)
18251                    throws NoSuchArticleException, SystemException {
18252                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
18253                                    classNameId, templateId, orderByComparator);
18254    
18255                    if (journalArticle != null) {
18256                            return journalArticle;
18257                    }
18258    
18259                    StringBundler msg = new StringBundler(8);
18260    
18261                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18262    
18263                    msg.append("groupId=");
18264                    msg.append(groupId);
18265    
18266                    msg.append(", classNameId=");
18267                    msg.append(classNameId);
18268    
18269                    msg.append(", templateId=");
18270                    msg.append(templateId);
18271    
18272                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18273    
18274                    throw new NoSuchArticleException(msg.toString());
18275            }
18276    
18277            /**
18278             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18279             *
18280             * @param groupId the group ID
18281             * @param classNameId the class name ID
18282             * @param templateId the template ID
18283             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18284             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
18285             * @throws SystemException if a system exception occurred
18286             */
18287            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
18288                    String templateId, OrderByComparator orderByComparator)
18289                    throws SystemException {
18290                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
18291                                    templateId, 0, 1, orderByComparator);
18292    
18293                    if (!list.isEmpty()) {
18294                            return list.get(0);
18295                    }
18296    
18297                    return null;
18298            }
18299    
18300            /**
18301             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18302             *
18303             * @param groupId the group ID
18304             * @param classNameId the class name ID
18305             * @param templateId the template ID
18306             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18307             * @return the last matching journal article
18308             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18309             * @throws SystemException if a system exception occurred
18310             */
18311            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
18312                    String templateId, OrderByComparator orderByComparator)
18313                    throws NoSuchArticleException, SystemException {
18314                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
18315                                    templateId, orderByComparator);
18316    
18317                    if (journalArticle != null) {
18318                            return journalArticle;
18319                    }
18320    
18321                    StringBundler msg = new StringBundler(8);
18322    
18323                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18324    
18325                    msg.append("groupId=");
18326                    msg.append(groupId);
18327    
18328                    msg.append(", classNameId=");
18329                    msg.append(classNameId);
18330    
18331                    msg.append(", templateId=");
18332                    msg.append(templateId);
18333    
18334                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18335    
18336                    throw new NoSuchArticleException(msg.toString());
18337            }
18338    
18339            /**
18340             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18341             *
18342             * @param groupId the group ID
18343             * @param classNameId the class name ID
18344             * @param templateId the template ID
18345             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18346             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
18347             * @throws SystemException if a system exception occurred
18348             */
18349            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
18350                    String templateId, OrderByComparator orderByComparator)
18351                    throws SystemException {
18352                    int count = countByG_C_T(groupId, classNameId, templateId);
18353    
18354                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
18355                                    templateId, count - 1, count, orderByComparator);
18356    
18357                    if (!list.isEmpty()) {
18358                            return list.get(0);
18359                    }
18360    
18361                    return null;
18362            }
18363    
18364            /**
18365             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18366             *
18367             * @param id the primary key of the current journal article
18368             * @param groupId the group ID
18369             * @param classNameId the class name ID
18370             * @param templateId the template ID
18371             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18372             * @return the previous, current, and next journal article
18373             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18374             * @throws SystemException if a system exception occurred
18375             */
18376            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
18377                    long classNameId, String templateId, OrderByComparator orderByComparator)
18378                    throws NoSuchArticleException, SystemException {
18379                    JournalArticle journalArticle = findByPrimaryKey(id);
18380    
18381                    Session session = null;
18382    
18383                    try {
18384                            session = openSession();
18385    
18386                            JournalArticle[] array = new JournalArticleImpl[3];
18387    
18388                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
18389                                            classNameId, templateId, orderByComparator, true);
18390    
18391                            array[1] = journalArticle;
18392    
18393                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
18394                                            classNameId, templateId, orderByComparator, false);
18395    
18396                            return array;
18397                    }
18398                    catch (Exception e) {
18399                            throw processException(e);
18400                    }
18401                    finally {
18402                            closeSession(session);
18403                    }
18404            }
18405    
18406            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
18407                    JournalArticle journalArticle, long groupId, long classNameId,
18408                    String templateId, OrderByComparator orderByComparator, boolean previous) {
18409                    StringBundler query = null;
18410    
18411                    if (orderByComparator != null) {
18412                            query = new StringBundler(6 +
18413                                            (orderByComparator.getOrderByFields().length * 6));
18414                    }
18415                    else {
18416                            query = new StringBundler(3);
18417                    }
18418    
18419                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18420    
18421                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18422    
18423                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18424    
18425                    boolean bindTemplateId = false;
18426    
18427                    if (templateId == null) {
18428                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18429                    }
18430                    else if (templateId.equals(StringPool.BLANK)) {
18431                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18432                    }
18433                    else {
18434                            bindTemplateId = true;
18435    
18436                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18437                    }
18438    
18439                    if (orderByComparator != null) {
18440                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18441    
18442                            if (orderByConditionFields.length > 0) {
18443                                    query.append(WHERE_AND);
18444                            }
18445    
18446                            for (int i = 0; i < orderByConditionFields.length; i++) {
18447                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18448                                    query.append(orderByConditionFields[i]);
18449    
18450                                    if ((i + 1) < orderByConditionFields.length) {
18451                                            if (orderByComparator.isAscending() ^ previous) {
18452                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18453                                            }
18454                                            else {
18455                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18456                                            }
18457                                    }
18458                                    else {
18459                                            if (orderByComparator.isAscending() ^ previous) {
18460                                                    query.append(WHERE_GREATER_THAN);
18461                                            }
18462                                            else {
18463                                                    query.append(WHERE_LESSER_THAN);
18464                                            }
18465                                    }
18466                            }
18467    
18468                            query.append(ORDER_BY_CLAUSE);
18469    
18470                            String[] orderByFields = orderByComparator.getOrderByFields();
18471    
18472                            for (int i = 0; i < orderByFields.length; i++) {
18473                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18474                                    query.append(orderByFields[i]);
18475    
18476                                    if ((i + 1) < orderByFields.length) {
18477                                            if (orderByComparator.isAscending() ^ previous) {
18478                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18479                                            }
18480                                            else {
18481                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18482                                            }
18483                                    }
18484                                    else {
18485                                            if (orderByComparator.isAscending() ^ previous) {
18486                                                    query.append(ORDER_BY_ASC);
18487                                            }
18488                                            else {
18489                                                    query.append(ORDER_BY_DESC);
18490                                            }
18491                                    }
18492                            }
18493                    }
18494                    else {
18495                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18496                    }
18497    
18498                    String sql = query.toString();
18499    
18500                    Query q = session.createQuery(sql);
18501    
18502                    q.setFirstResult(0);
18503                    q.setMaxResults(2);
18504    
18505                    QueryPos qPos = QueryPos.getInstance(q);
18506    
18507                    qPos.add(groupId);
18508    
18509                    qPos.add(classNameId);
18510    
18511                    if (bindTemplateId) {
18512                            qPos.add(templateId);
18513                    }
18514    
18515                    if (orderByComparator != null) {
18516                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18517    
18518                            for (Object value : values) {
18519                                    qPos.add(value);
18520                            }
18521                    }
18522    
18523                    List<JournalArticle> list = q.list();
18524    
18525                    if (list.size() == 2) {
18526                            return list.get(1);
18527                    }
18528                    else {
18529                            return null;
18530                    }
18531            }
18532    
18533            /**
18534             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18535             *
18536             * @param groupId the group ID
18537             * @param classNameId the class name ID
18538             * @param templateId the template ID
18539             * @return the matching journal articles that the user has permission to view
18540             * @throws SystemException if a system exception occurred
18541             */
18542            public List<JournalArticle> filterFindByG_C_T(long groupId,
18543                    long classNameId, String templateId) throws SystemException {
18544                    return filterFindByG_C_T(groupId, classNameId, templateId,
18545                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18546            }
18547    
18548            /**
18549             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18550             *
18551             * <p>
18552             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18553             * </p>
18554             *
18555             * @param groupId the group ID
18556             * @param classNameId the class name ID
18557             * @param templateId the template ID
18558             * @param start the lower bound of the range of journal articles
18559             * @param end the upper bound of the range of journal articles (not inclusive)
18560             * @return the range of matching journal articles that the user has permission to view
18561             * @throws SystemException if a system exception occurred
18562             */
18563            public List<JournalArticle> filterFindByG_C_T(long groupId,
18564                    long classNameId, String templateId, int start, int end)
18565                    throws SystemException {
18566                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
18567                            null);
18568            }
18569    
18570            /**
18571             * 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;.
18572             *
18573             * <p>
18574             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18575             * </p>
18576             *
18577             * @param groupId the group ID
18578             * @param classNameId the class name ID
18579             * @param templateId the template ID
18580             * @param start the lower bound of the range of journal articles
18581             * @param end the upper bound of the range of journal articles (not inclusive)
18582             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18583             * @return the ordered range of matching journal articles that the user has permission to view
18584             * @throws SystemException if a system exception occurred
18585             */
18586            public List<JournalArticle> filterFindByG_C_T(long groupId,
18587                    long classNameId, String templateId, int start, int end,
18588                    OrderByComparator orderByComparator) throws SystemException {
18589                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18590                            return findByG_C_T(groupId, classNameId, templateId, start, end,
18591                                    orderByComparator);
18592                    }
18593    
18594                    StringBundler query = null;
18595    
18596                    if (orderByComparator != null) {
18597                            query = new StringBundler(5 +
18598                                            (orderByComparator.getOrderByFields().length * 3));
18599                    }
18600                    else {
18601                            query = new StringBundler(5);
18602                    }
18603    
18604                    if (getDB().isSupportsInlineDistinct()) {
18605                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18606                    }
18607                    else {
18608                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18609                    }
18610    
18611                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18612    
18613                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18614    
18615                    boolean bindTemplateId = false;
18616    
18617                    if (templateId == null) {
18618                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18619                    }
18620                    else if (templateId.equals(StringPool.BLANK)) {
18621                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18622                    }
18623                    else {
18624                            bindTemplateId = true;
18625    
18626                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18627                    }
18628    
18629                    if (!getDB().isSupportsInlineDistinct()) {
18630                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18631                    }
18632    
18633                    if (orderByComparator != null) {
18634                            if (getDB().isSupportsInlineDistinct()) {
18635                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18636                                            orderByComparator, true);
18637                            }
18638                            else {
18639                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18640                                            orderByComparator, true);
18641                            }
18642                    }
18643                    else {
18644                            if (getDB().isSupportsInlineDistinct()) {
18645                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18646                            }
18647                            else {
18648                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18649                            }
18650                    }
18651    
18652                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18653                                    JournalArticle.class.getName(),
18654                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18655    
18656                    Session session = null;
18657    
18658                    try {
18659                            session = openSession();
18660    
18661                            SQLQuery q = session.createSQLQuery(sql);
18662    
18663                            if (getDB().isSupportsInlineDistinct()) {
18664                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18665                            }
18666                            else {
18667                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18668                            }
18669    
18670                            QueryPos qPos = QueryPos.getInstance(q);
18671    
18672                            qPos.add(groupId);
18673    
18674                            qPos.add(classNameId);
18675    
18676                            if (bindTemplateId) {
18677                                    qPos.add(templateId);
18678                            }
18679    
18680                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
18681                                    end);
18682                    }
18683                    catch (Exception e) {
18684                            throw processException(e);
18685                    }
18686                    finally {
18687                            closeSession(session);
18688                    }
18689            }
18690    
18691            /**
18692             * 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;.
18693             *
18694             * @param id the primary key of the current journal article
18695             * @param groupId the group ID
18696             * @param classNameId the class name ID
18697             * @param templateId the template ID
18698             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18699             * @return the previous, current, and next journal article
18700             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18701             * @throws SystemException if a system exception occurred
18702             */
18703            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
18704                    long groupId, long classNameId, String templateId,
18705                    OrderByComparator orderByComparator)
18706                    throws NoSuchArticleException, SystemException {
18707                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18708                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
18709                                    templateId, orderByComparator);
18710                    }
18711    
18712                    JournalArticle journalArticle = findByPrimaryKey(id);
18713    
18714                    Session session = null;
18715    
18716                    try {
18717                            session = openSession();
18718    
18719                            JournalArticle[] array = new JournalArticleImpl[3];
18720    
18721                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
18722                                            groupId, classNameId, templateId, orderByComparator, true);
18723    
18724                            array[1] = journalArticle;
18725    
18726                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
18727                                            groupId, classNameId, templateId, orderByComparator, false);
18728    
18729                            return array;
18730                    }
18731                    catch (Exception e) {
18732                            throw processException(e);
18733                    }
18734                    finally {
18735                            closeSession(session);
18736                    }
18737            }
18738    
18739            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
18740                    JournalArticle journalArticle, long groupId, long classNameId,
18741                    String templateId, OrderByComparator orderByComparator, boolean previous) {
18742                    StringBundler query = null;
18743    
18744                    if (orderByComparator != null) {
18745                            query = new StringBundler(6 +
18746                                            (orderByComparator.getOrderByFields().length * 6));
18747                    }
18748                    else {
18749                            query = new StringBundler(3);
18750                    }
18751    
18752                    if (getDB().isSupportsInlineDistinct()) {
18753                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18754                    }
18755                    else {
18756                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18757                    }
18758    
18759                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18760    
18761                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18762    
18763                    boolean bindTemplateId = false;
18764    
18765                    if (templateId == null) {
18766                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18767                    }
18768                    else if (templateId.equals(StringPool.BLANK)) {
18769                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18770                    }
18771                    else {
18772                            bindTemplateId = true;
18773    
18774                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18775                    }
18776    
18777                    if (!getDB().isSupportsInlineDistinct()) {
18778                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18779                    }
18780    
18781                    if (orderByComparator != null) {
18782                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18783    
18784                            if (orderByConditionFields.length > 0) {
18785                                    query.append(WHERE_AND);
18786                            }
18787    
18788                            for (int i = 0; i < orderByConditionFields.length; i++) {
18789                                    if (getDB().isSupportsInlineDistinct()) {
18790                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18791                                    }
18792                                    else {
18793                                            query.append(_ORDER_BY_ENTITY_TABLE);
18794                                    }
18795    
18796                                    query.append(orderByConditionFields[i]);
18797    
18798                                    if ((i + 1) < orderByConditionFields.length) {
18799                                            if (orderByComparator.isAscending() ^ previous) {
18800                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18801                                            }
18802                                            else {
18803                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18804                                            }
18805                                    }
18806                                    else {
18807                                            if (orderByComparator.isAscending() ^ previous) {
18808                                                    query.append(WHERE_GREATER_THAN);
18809                                            }
18810                                            else {
18811                                                    query.append(WHERE_LESSER_THAN);
18812                                            }
18813                                    }
18814                            }
18815    
18816                            query.append(ORDER_BY_CLAUSE);
18817    
18818                            String[] orderByFields = orderByComparator.getOrderByFields();
18819    
18820                            for (int i = 0; i < orderByFields.length; i++) {
18821                                    if (getDB().isSupportsInlineDistinct()) {
18822                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18823                                    }
18824                                    else {
18825                                            query.append(_ORDER_BY_ENTITY_TABLE);
18826                                    }
18827    
18828                                    query.append(orderByFields[i]);
18829    
18830                                    if ((i + 1) < orderByFields.length) {
18831                                            if (orderByComparator.isAscending() ^ previous) {
18832                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18833                                            }
18834                                            else {
18835                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18836                                            }
18837                                    }
18838                                    else {
18839                                            if (orderByComparator.isAscending() ^ previous) {
18840                                                    query.append(ORDER_BY_ASC);
18841                                            }
18842                                            else {
18843                                                    query.append(ORDER_BY_DESC);
18844                                            }
18845                                    }
18846                            }
18847                    }
18848                    else {
18849                            if (getDB().isSupportsInlineDistinct()) {
18850                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18851                            }
18852                            else {
18853                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18854                            }
18855                    }
18856    
18857                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18858                                    JournalArticle.class.getName(),
18859                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18860    
18861                    SQLQuery q = session.createSQLQuery(sql);
18862    
18863                    q.setFirstResult(0);
18864                    q.setMaxResults(2);
18865    
18866                    if (getDB().isSupportsInlineDistinct()) {
18867                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18868                    }
18869                    else {
18870                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18871                    }
18872    
18873                    QueryPos qPos = QueryPos.getInstance(q);
18874    
18875                    qPos.add(groupId);
18876    
18877                    qPos.add(classNameId);
18878    
18879                    if (bindTemplateId) {
18880                            qPos.add(templateId);
18881                    }
18882    
18883                    if (orderByComparator != null) {
18884                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18885    
18886                            for (Object value : values) {
18887                                    qPos.add(value);
18888                            }
18889                    }
18890    
18891                    List<JournalArticle> list = q.list();
18892    
18893                    if (list.size() == 2) {
18894                            return list.get(1);
18895                    }
18896                    else {
18897                            return null;
18898                    }
18899            }
18900    
18901            /**
18902             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
18903             *
18904             * @param groupId the group ID
18905             * @param classNameId the class name ID
18906             * @param templateId the template ID
18907             * @throws SystemException if a system exception occurred
18908             */
18909            public void removeByG_C_T(long groupId, long classNameId, String templateId)
18910                    throws SystemException {
18911                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
18912                                    templateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18913                            remove(journalArticle);
18914                    }
18915            }
18916    
18917            /**
18918             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18919             *
18920             * @param groupId the group ID
18921             * @param classNameId the class name ID
18922             * @param templateId the template ID
18923             * @return the number of matching journal articles
18924             * @throws SystemException if a system exception occurred
18925             */
18926            public int countByG_C_T(long groupId, long classNameId, String templateId)
18927                    throws SystemException {
18928                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_T;
18929    
18930                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
18931    
18932                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18933                                    this);
18934    
18935                    if (count == null) {
18936                            StringBundler query = new StringBundler(4);
18937    
18938                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18939    
18940                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18941    
18942                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18943    
18944                            boolean bindTemplateId = false;
18945    
18946                            if (templateId == null) {
18947                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18948                            }
18949                            else if (templateId.equals(StringPool.BLANK)) {
18950                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18951                            }
18952                            else {
18953                                    bindTemplateId = true;
18954    
18955                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18956                            }
18957    
18958                            String sql = query.toString();
18959    
18960                            Session session = null;
18961    
18962                            try {
18963                                    session = openSession();
18964    
18965                                    Query q = session.createQuery(sql);
18966    
18967                                    QueryPos qPos = QueryPos.getInstance(q);
18968    
18969                                    qPos.add(groupId);
18970    
18971                                    qPos.add(classNameId);
18972    
18973                                    if (bindTemplateId) {
18974                                            qPos.add(templateId);
18975                                    }
18976    
18977                                    count = (Long)q.uniqueResult();
18978    
18979                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18980                            }
18981                            catch (Exception e) {
18982                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18983    
18984                                    throw processException(e);
18985                            }
18986                            finally {
18987                                    closeSession(session);
18988                            }
18989                    }
18990    
18991                    return count.intValue();
18992            }
18993    
18994            /**
18995             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18996             *
18997             * @param groupId the group ID
18998             * @param classNameId the class name ID
18999             * @param templateId the template ID
19000             * @return the number of matching journal articles that the user has permission to view
19001             * @throws SystemException if a system exception occurred
19002             */
19003            public int filterCountByG_C_T(long groupId, long classNameId,
19004                    String templateId) throws SystemException {
19005                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19006                            return countByG_C_T(groupId, classNameId, templateId);
19007                    }
19008    
19009                    StringBundler query = new StringBundler(4);
19010    
19011                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
19012    
19013                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
19014    
19015                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
19016    
19017                    boolean bindTemplateId = false;
19018    
19019                    if (templateId == null) {
19020                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
19021                    }
19022                    else if (templateId.equals(StringPool.BLANK)) {
19023                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
19024                    }
19025                    else {
19026                            bindTemplateId = true;
19027    
19028                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
19029                    }
19030    
19031                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19032                                    JournalArticle.class.getName(),
19033                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19034    
19035                    Session session = null;
19036    
19037                    try {
19038                            session = openSession();
19039    
19040                            SQLQuery q = session.createSQLQuery(sql);
19041    
19042                            q.addScalar(COUNT_COLUMN_NAME,
19043                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
19044    
19045                            QueryPos qPos = QueryPos.getInstance(q);
19046    
19047                            qPos.add(groupId);
19048    
19049                            qPos.add(classNameId);
19050    
19051                            if (bindTemplateId) {
19052                                    qPos.add(templateId);
19053                            }
19054    
19055                            Long count = (Long)q.uniqueResult();
19056    
19057                            return count.intValue();
19058                    }
19059                    catch (Exception e) {
19060                            throw processException(e);
19061                    }
19062                    finally {
19063                            closeSession(session);
19064                    }
19065            }
19066    
19067            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
19068            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
19069            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
19070            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
19071            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = '')";
19072            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19073                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19074                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19075                            "findByG_C_L",
19076                            new String[] {
19077                                    Long.class.getName(), Long.class.getName(),
19078                                    String.class.getName(),
19079                                    
19080                            Integer.class.getName(), Integer.class.getName(),
19081                                    OrderByComparator.class.getName()
19082                            });
19083            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19084                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19085                            JournalArticleImpl.class,
19086                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
19087                            new String[] {
19088                                    Long.class.getName(), Long.class.getName(),
19089                                    String.class.getName()
19090                            },
19091                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
19092                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
19093                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
19094                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
19095                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
19096            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19097                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19098                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
19099                            new String[] {
19100                                    Long.class.getName(), Long.class.getName(),
19101                                    String.class.getName()
19102                            });
19103    
19104            /**
19105             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19106             *
19107             * @param groupId the group ID
19108             * @param classNameId the class name ID
19109             * @param layoutUuid the layout uuid
19110             * @return the matching journal articles
19111             * @throws SystemException if a system exception occurred
19112             */
19113            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
19114                    String layoutUuid) throws SystemException {
19115                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
19116                            QueryUtil.ALL_POS, null);
19117            }
19118    
19119            /**
19120             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19121             *
19122             * <p>
19123             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19124             * </p>
19125             *
19126             * @param groupId the group ID
19127             * @param classNameId the class name ID
19128             * @param layoutUuid the layout uuid
19129             * @param start the lower bound of the range of journal articles
19130             * @param end the upper bound of the range of journal articles (not inclusive)
19131             * @return the range of matching journal articles
19132             * @throws SystemException if a system exception occurred
19133             */
19134            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
19135                    String layoutUuid, int start, int end) throws SystemException {
19136                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
19137            }
19138    
19139            /**
19140             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19141             *
19142             * <p>
19143             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19144             * </p>
19145             *
19146             * @param groupId the group ID
19147             * @param classNameId the class name ID
19148             * @param layoutUuid the layout uuid
19149             * @param start the lower bound of the range of journal articles
19150             * @param end the upper bound of the range of journal articles (not inclusive)
19151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19152             * @return the ordered range of matching journal articles
19153             * @throws SystemException if a system exception occurred
19154             */
19155            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
19156                    String layoutUuid, int start, int end,
19157                    OrderByComparator orderByComparator) throws SystemException {
19158                    boolean pagination = true;
19159                    FinderPath finderPath = null;
19160                    Object[] finderArgs = null;
19161    
19162                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19163                                    (orderByComparator == null)) {
19164                            pagination = false;
19165                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
19166                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
19167                    }
19168                    else {
19169                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
19170                            finderArgs = new Object[] {
19171                                            groupId, classNameId, layoutUuid,
19172                                            
19173                                            start, end, orderByComparator
19174                                    };
19175                    }
19176    
19177                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19178                                    finderArgs, this);
19179    
19180                    if ((list != null) && !list.isEmpty()) {
19181                            for (JournalArticle journalArticle : list) {
19182                                    if ((groupId != journalArticle.getGroupId()) ||
19183                                                    (classNameId != journalArticle.getClassNameId()) ||
19184                                                    !Validator.equals(layoutUuid,
19185                                                            journalArticle.getLayoutUuid())) {
19186                                            list = null;
19187    
19188                                            break;
19189                                    }
19190                            }
19191                    }
19192    
19193                    if (list == null) {
19194                            StringBundler query = null;
19195    
19196                            if (orderByComparator != null) {
19197                                    query = new StringBundler(5 +
19198                                                    (orderByComparator.getOrderByFields().length * 3));
19199                            }
19200                            else {
19201                                    query = new StringBundler(5);
19202                            }
19203    
19204                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19205    
19206                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
19207    
19208                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
19209    
19210                            boolean bindLayoutUuid = false;
19211    
19212                            if (layoutUuid == null) {
19213                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
19214                            }
19215                            else if (layoutUuid.equals(StringPool.BLANK)) {
19216                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
19217                            }
19218                            else {
19219                                    bindLayoutUuid = true;
19220    
19221                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
19222                            }
19223    
19224                            if (orderByComparator != null) {
19225                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19226                                            orderByComparator);
19227                            }
19228                            else
19229                             if (pagination) {
19230                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19231                            }
19232    
19233                            String sql = query.toString();
19234    
19235                            Session session = null;
19236    
19237                            try {
19238                                    session = openSession();
19239    
19240                                    Query q = session.createQuery(sql);
19241    
19242                                    QueryPos qPos = QueryPos.getInstance(q);
19243    
19244                                    qPos.add(groupId);
19245    
19246                                    qPos.add(classNameId);
19247    
19248                                    if (bindLayoutUuid) {
19249                                            qPos.add(layoutUuid);
19250                                    }
19251    
19252                                    if (!pagination) {
19253                                            list = (List<JournalArticle>)QueryUtil.list(q,
19254                                                            getDialect(), start, end, false);
19255    
19256                                            Collections.sort(list);
19257    
19258                                            list = new UnmodifiableList<JournalArticle>(list);
19259                                    }
19260                                    else {
19261                                            list = (List<JournalArticle>)QueryUtil.list(q,
19262                                                            getDialect(), start, end);
19263                                    }
19264    
19265                                    cacheResult(list);
19266    
19267                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19268                            }
19269                            catch (Exception e) {
19270                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19271    
19272                                    throw processException(e);
19273                            }
19274                            finally {
19275                                    closeSession(session);
19276                            }
19277                    }
19278    
19279                    return list;
19280            }
19281    
19282            /**
19283             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19284             *
19285             * @param groupId the group ID
19286             * @param classNameId the class name ID
19287             * @param layoutUuid the layout uuid
19288             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19289             * @return the first matching journal article
19290             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19291             * @throws SystemException if a system exception occurred
19292             */
19293            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
19294                    String layoutUuid, OrderByComparator orderByComparator)
19295                    throws NoSuchArticleException, SystemException {
19296                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
19297                                    classNameId, layoutUuid, orderByComparator);
19298    
19299                    if (journalArticle != null) {
19300                            return journalArticle;
19301                    }
19302    
19303                    StringBundler msg = new StringBundler(8);
19304    
19305                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19306    
19307                    msg.append("groupId=");
19308                    msg.append(groupId);
19309    
19310                    msg.append(", classNameId=");
19311                    msg.append(classNameId);
19312    
19313                    msg.append(", layoutUuid=");
19314                    msg.append(layoutUuid);
19315    
19316                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19317    
19318                    throw new NoSuchArticleException(msg.toString());
19319            }
19320    
19321            /**
19322             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19323             *
19324             * @param groupId the group ID
19325             * @param classNameId the class name ID
19326             * @param layoutUuid the layout uuid
19327             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19328             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19329             * @throws SystemException if a system exception occurred
19330             */
19331            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
19332                    String layoutUuid, OrderByComparator orderByComparator)
19333                    throws SystemException {
19334                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
19335                                    layoutUuid, 0, 1, orderByComparator);
19336    
19337                    if (!list.isEmpty()) {
19338                            return list.get(0);
19339                    }
19340    
19341                    return null;
19342            }
19343    
19344            /**
19345             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19346             *
19347             * @param groupId the group ID
19348             * @param classNameId the class name ID
19349             * @param layoutUuid the layout uuid
19350             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19351             * @return the last matching journal article
19352             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19353             * @throws SystemException if a system exception occurred
19354             */
19355            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
19356                    String layoutUuid, OrderByComparator orderByComparator)
19357                    throws NoSuchArticleException, SystemException {
19358                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
19359                                    layoutUuid, orderByComparator);
19360    
19361                    if (journalArticle != null) {
19362                            return journalArticle;
19363                    }
19364    
19365                    StringBundler msg = new StringBundler(8);
19366    
19367                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19368    
19369                    msg.append("groupId=");
19370                    msg.append(groupId);
19371    
19372                    msg.append(", classNameId=");
19373                    msg.append(classNameId);
19374    
19375                    msg.append(", layoutUuid=");
19376                    msg.append(layoutUuid);
19377    
19378                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19379    
19380                    throw new NoSuchArticleException(msg.toString());
19381            }
19382    
19383            /**
19384             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19385             *
19386             * @param groupId the group ID
19387             * @param classNameId the class name ID
19388             * @param layoutUuid the layout uuid
19389             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19390             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19391             * @throws SystemException if a system exception occurred
19392             */
19393            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
19394                    String layoutUuid, OrderByComparator orderByComparator)
19395                    throws SystemException {
19396                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
19397    
19398                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
19399                                    layoutUuid, count - 1, count, orderByComparator);
19400    
19401                    if (!list.isEmpty()) {
19402                            return list.get(0);
19403                    }
19404    
19405                    return null;
19406            }
19407    
19408            /**
19409             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19410             *
19411             * @param id the primary key of the current journal article
19412             * @param groupId the group ID
19413             * @param classNameId the class name ID
19414             * @param layoutUuid the layout uuid
19415             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19416             * @return the previous, current, and next journal article
19417             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19418             * @throws SystemException if a system exception occurred
19419             */
19420            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
19421                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
19422                    throws NoSuchArticleException, SystemException {
19423                    JournalArticle journalArticle = findByPrimaryKey(id);
19424    
19425                    Session session = null;
19426    
19427                    try {
19428                            session = openSession();
19429    
19430                            JournalArticle[] array = new JournalArticleImpl[3];
19431    
19432                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
19433                                            classNameId, layoutUuid, orderByComparator, true);
19434    
19435                            array[1] = journalArticle;
19436    
19437                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
19438                                            classNameId, layoutUuid, orderByComparator, false);
19439    
19440                            return array;
19441                    }
19442                    catch (Exception e) {
19443                            throw processException(e);
19444                    }
19445                    finally {
19446                            closeSession(session);
19447                    }
19448            }
19449    
19450            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
19451                    JournalArticle journalArticle, long groupId, long classNameId,
19452                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
19453                    StringBundler query = null;
19454    
19455                    if (orderByComparator != null) {
19456                            query = new StringBundler(6 +
19457                                            (orderByComparator.getOrderByFields().length * 6));
19458                    }
19459                    else {
19460                            query = new StringBundler(3);
19461                    }
19462    
19463                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19464    
19465                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
19466    
19467                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
19468    
19469                    boolean bindLayoutUuid = false;
19470    
19471                    if (layoutUuid == null) {
19472                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
19473                    }
19474                    else if (layoutUuid.equals(StringPool.BLANK)) {
19475                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
19476                    }
19477                    else {
19478                            bindLayoutUuid = true;
19479    
19480                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
19481                    }
19482    
19483                    if (orderByComparator != null) {
19484                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19485    
19486                            if (orderByConditionFields.length > 0) {
19487                                    query.append(WHERE_AND);
19488                            }
19489    
19490                            for (int i = 0; i < orderByConditionFields.length; i++) {
19491                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19492                                    query.append(orderByConditionFields[i]);
19493    
19494                                    if ((i + 1) < orderByConditionFields.length) {
19495                                            if (orderByComparator.isAscending() ^ previous) {
19496                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19497                                            }
19498                                            else {
19499                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19500                                            }
19501                                    }
19502                                    else {
19503                                            if (orderByComparator.isAscending() ^ previous) {
19504                                                    query.append(WHERE_GREATER_THAN);
19505                                            }
19506                                            else {
19507                                                    query.append(WHERE_LESSER_THAN);
19508                                            }
19509                                    }
19510                            }
19511    
19512                            query.append(ORDER_BY_CLAUSE);
19513    
19514                            String[] orderByFields = orderByComparator.getOrderByFields();
19515    
19516                            for (int i = 0; i < orderByFields.length; i++) {
19517                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19518                                    query.append(orderByFields[i]);
19519    
19520                                    if ((i + 1) < orderByFields.length) {
19521                                            if (orderByComparator.isAscending() ^ previous) {
19522                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19523                                            }
19524                                            else {
19525                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19526                                            }
19527                                    }
19528                                    else {
19529                                            if (orderByComparator.isAscending() ^ previous) {
19530                                                    query.append(ORDER_BY_ASC);
19531                                            }
19532                                            else {
19533                                                    query.append(ORDER_BY_DESC);
19534                                            }
19535                                    }
19536                            }
19537                    }
19538                    else {
19539                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19540                    }
19541    
19542                    String sql = query.toString();
19543    
19544                    Query q = session.createQuery(sql);
19545    
19546                    q.setFirstResult(0);
19547                    q.setMaxResults(2);
19548    
19549                    QueryPos qPos = QueryPos.getInstance(q);
19550    
19551                    qPos.add(groupId);
19552    
19553                    qPos.add(classNameId);
19554    
19555                    if (bindLayoutUuid) {
19556                            qPos.add(layoutUuid);
19557                    }
19558    
19559                    if (orderByComparator != null) {
19560                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19561    
19562                            for (Object value : values) {
19563                                    qPos.add(value);
19564                            }
19565                    }
19566    
19567                    List<JournalArticle> list = q.list();
19568    
19569                    if (list.size() == 2) {
19570                            return list.get(1);
19571                    }
19572                    else {
19573                            return null;
19574                    }
19575            }
19576    
19577            /**
19578             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19579             *
19580             * @param groupId the group ID
19581             * @param classNameId the class name ID
19582             * @param layoutUuid the layout uuid
19583             * @return the matching journal articles that the user has permission to view
19584             * @throws SystemException if a system exception occurred
19585             */
19586            public List<JournalArticle> filterFindByG_C_L(long groupId,
19587                    long classNameId, String layoutUuid) throws SystemException {
19588                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
19589                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19590            }
19591    
19592            /**
19593             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19594             *
19595             * <p>
19596             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19597             * </p>
19598             *
19599             * @param groupId the group ID
19600             * @param classNameId the class name ID
19601             * @param layoutUuid the layout uuid
19602             * @param start the lower bound of the range of journal articles
19603             * @param end the upper bound of the range of journal articles (not inclusive)
19604             * @return the range of matching journal articles that the user has permission to view
19605             * @throws SystemException if a system exception occurred
19606             */
19607            public List<JournalArticle> filterFindByG_C_L(long groupId,
19608                    long classNameId, String layoutUuid, int start, int end)
19609                    throws SystemException {
19610                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
19611                            null);
19612            }
19613    
19614            /**
19615             * 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;.
19616             *
19617             * <p>
19618             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19619             * </p>
19620             *
19621             * @param groupId the group ID
19622             * @param classNameId the class name ID
19623             * @param layoutUuid the layout uuid
19624             * @param start the lower bound of the range of journal articles
19625             * @param end the upper bound of the range of journal articles (not inclusive)
19626             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19627             * @return the ordered range of matching journal articles that the user has permission to view
19628             * @throws SystemException if a system exception occurred
19629             */
19630            public List<JournalArticle> filterFindByG_C_L(long groupId,
19631                    long classNameId, String layoutUuid, int start, int end,
19632                    OrderByComparator orderByComparator) throws SystemException {
19633                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19634                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
19635                                    orderByComparator);
19636                    }
19637    
19638                    StringBundler query = null;
19639    
19640                    if (orderByComparator != null) {
19641                            query = new StringBundler(5 +
19642                                            (orderByComparator.getOrderByFields().length * 3));
19643                    }
19644                    else {
19645                            query = new StringBundler(5);
19646                    }
19647    
19648                    if (getDB().isSupportsInlineDistinct()) {
19649                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19650                    }
19651                    else {
19652                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19653                    }
19654    
19655                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
19656    
19657                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
19658    
19659                    boolean bindLayoutUuid = false;
19660    
19661                    if (layoutUuid == null) {
19662                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
19663                    }
19664                    else if (layoutUuid.equals(StringPool.BLANK)) {
19665                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
19666                    }
19667                    else {
19668                            bindLayoutUuid = true;
19669    
19670                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
19671                    }
19672    
19673                    if (!getDB().isSupportsInlineDistinct()) {
19674                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19675                    }
19676    
19677                    if (orderByComparator != null) {
19678                            if (getDB().isSupportsInlineDistinct()) {
19679                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19680                                            orderByComparator, true);
19681                            }
19682                            else {
19683                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
19684                                            orderByComparator, true);
19685                            }
19686                    }
19687                    else {
19688                            if (getDB().isSupportsInlineDistinct()) {
19689                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19690                            }
19691                            else {
19692                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19693                            }
19694                    }
19695    
19696                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19697                                    JournalArticle.class.getName(),
19698                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19699    
19700                    Session session = null;
19701    
19702                    try {
19703                            session = openSession();
19704    
19705                            SQLQuery q = session.createSQLQuery(sql);
19706    
19707                            if (getDB().isSupportsInlineDistinct()) {
19708                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19709                            }
19710                            else {
19711                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19712                            }
19713    
19714                            QueryPos qPos = QueryPos.getInstance(q);
19715    
19716                            qPos.add(groupId);
19717    
19718                            qPos.add(classNameId);
19719    
19720                            if (bindLayoutUuid) {
19721                                    qPos.add(layoutUuid);
19722                            }
19723    
19724                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19725                                    end);
19726                    }
19727                    catch (Exception e) {
19728                            throw processException(e);
19729                    }
19730                    finally {
19731                            closeSession(session);
19732                    }
19733            }
19734    
19735            /**
19736             * 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;.
19737             *
19738             * @param id the primary key of the current journal article
19739             * @param groupId the group ID
19740             * @param classNameId the class name ID
19741             * @param layoutUuid the layout uuid
19742             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19743             * @return the previous, current, and next journal article
19744             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19745             * @throws SystemException if a system exception occurred
19746             */
19747            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
19748                    long groupId, long classNameId, String layoutUuid,
19749                    OrderByComparator orderByComparator)
19750                    throws NoSuchArticleException, SystemException {
19751                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19752                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
19753                                    layoutUuid, orderByComparator);
19754                    }
19755    
19756                    JournalArticle journalArticle = findByPrimaryKey(id);
19757    
19758                    Session session = null;
19759    
19760                    try {
19761                            session = openSession();
19762    
19763                            JournalArticle[] array = new JournalArticleImpl[3];
19764    
19765                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
19766                                            groupId, classNameId, layoutUuid, orderByComparator, true);
19767    
19768                            array[1] = journalArticle;
19769    
19770                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
19771                                            groupId, classNameId, layoutUuid, orderByComparator, false);
19772    
19773                            return array;
19774                    }
19775                    catch (Exception e) {
19776                            throw processException(e);
19777                    }
19778                    finally {
19779                            closeSession(session);
19780                    }
19781            }
19782    
19783            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
19784                    JournalArticle journalArticle, long groupId, long classNameId,
19785                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
19786                    StringBundler query = null;
19787    
19788                    if (orderByComparator != null) {
19789                            query = new StringBundler(6 +
19790                                            (orderByComparator.getOrderByFields().length * 6));
19791                    }
19792                    else {
19793                            query = new StringBundler(3);
19794                    }
19795    
19796                    if (getDB().isSupportsInlineDistinct()) {
19797                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19798                    }
19799                    else {
19800                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19801                    }
19802    
19803                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
19804    
19805                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
19806    
19807                    boolean bindLayoutUuid = false;
19808    
19809                    if (layoutUuid == null) {
19810                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
19811                    }
19812                    else if (layoutUuid.equals(StringPool.BLANK)) {
19813                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
19814                    }
19815                    else {
19816                            bindLayoutUuid = true;
19817    
19818                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
19819                    }
19820    
19821                    if (!getDB().isSupportsInlineDistinct()) {
19822                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19823                    }
19824    
19825                    if (orderByComparator != null) {
19826                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19827    
19828                            if (orderByConditionFields.length > 0) {
19829                                    query.append(WHERE_AND);
19830                            }
19831    
19832                            for (int i = 0; i < orderByConditionFields.length; i++) {
19833                                    if (getDB().isSupportsInlineDistinct()) {
19834                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19835                                    }
19836                                    else {
19837                                            query.append(_ORDER_BY_ENTITY_TABLE);
19838                                    }
19839    
19840                                    query.append(orderByConditionFields[i]);
19841    
19842                                    if ((i + 1) < orderByConditionFields.length) {
19843                                            if (orderByComparator.isAscending() ^ previous) {
19844                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19845                                            }
19846                                            else {
19847                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19848                                            }
19849                                    }
19850                                    else {
19851                                            if (orderByComparator.isAscending() ^ previous) {
19852                                                    query.append(WHERE_GREATER_THAN);
19853                                            }
19854                                            else {
19855                                                    query.append(WHERE_LESSER_THAN);
19856                                            }
19857                                    }
19858                            }
19859    
19860                            query.append(ORDER_BY_CLAUSE);
19861    
19862                            String[] orderByFields = orderByComparator.getOrderByFields();
19863    
19864                            for (int i = 0; i < orderByFields.length; i++) {
19865                                    if (getDB().isSupportsInlineDistinct()) {
19866                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19867                                    }
19868                                    else {
19869                                            query.append(_ORDER_BY_ENTITY_TABLE);
19870                                    }
19871    
19872                                    query.append(orderByFields[i]);
19873    
19874                                    if ((i + 1) < orderByFields.length) {
19875                                            if (orderByComparator.isAscending() ^ previous) {
19876                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19877                                            }
19878                                            else {
19879                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19880                                            }
19881                                    }
19882                                    else {
19883                                            if (orderByComparator.isAscending() ^ previous) {
19884                                                    query.append(ORDER_BY_ASC);
19885                                            }
19886                                            else {
19887                                                    query.append(ORDER_BY_DESC);
19888                                            }
19889                                    }
19890                            }
19891                    }
19892                    else {
19893                            if (getDB().isSupportsInlineDistinct()) {
19894                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19895                            }
19896                            else {
19897                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19898                            }
19899                    }
19900    
19901                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19902                                    JournalArticle.class.getName(),
19903                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19904    
19905                    SQLQuery q = session.createSQLQuery(sql);
19906    
19907                    q.setFirstResult(0);
19908                    q.setMaxResults(2);
19909    
19910                    if (getDB().isSupportsInlineDistinct()) {
19911                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19912                    }
19913                    else {
19914                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19915                    }
19916    
19917                    QueryPos qPos = QueryPos.getInstance(q);
19918    
19919                    qPos.add(groupId);
19920    
19921                    qPos.add(classNameId);
19922    
19923                    if (bindLayoutUuid) {
19924                            qPos.add(layoutUuid);
19925                    }
19926    
19927                    if (orderByComparator != null) {
19928                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19929    
19930                            for (Object value : values) {
19931                                    qPos.add(value);
19932                            }
19933                    }
19934    
19935                    List<JournalArticle> list = q.list();
19936    
19937                    if (list.size() == 2) {
19938                            return list.get(1);
19939                    }
19940                    else {
19941                            return null;
19942                    }
19943            }
19944    
19945            /**
19946             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
19947             *
19948             * @param groupId the group ID
19949             * @param classNameId the class name ID
19950             * @param layoutUuid the layout uuid
19951             * @throws SystemException if a system exception occurred
19952             */
19953            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
19954                    throws SystemException {
19955                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
19956                                    layoutUuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19957                            remove(journalArticle);
19958                    }
19959            }
19960    
19961            /**
19962             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
19963             *
19964             * @param groupId the group ID
19965             * @param classNameId the class name ID
19966             * @param layoutUuid the layout uuid
19967             * @return the number of matching journal articles
19968             * @throws SystemException if a system exception occurred
19969             */
19970            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
19971                    throws SystemException {
19972                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
19973    
19974                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
19975    
19976                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19977                                    this);
19978    
19979                    if (count == null) {
19980                            StringBundler query = new StringBundler(4);
19981    
19982                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19983    
19984                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
19985    
19986                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
19987    
19988                            boolean bindLayoutUuid = false;
19989    
19990                            if (layoutUuid == null) {
19991                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
19992                            }
19993                            else if (layoutUuid.equals(StringPool.BLANK)) {
19994                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
19995                            }
19996                            else {
19997                                    bindLayoutUuid = true;
19998    
19999                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
20000                            }
20001    
20002                            String sql = query.toString();
20003    
20004                            Session session = null;
20005    
20006                            try {
20007                                    session = openSession();
20008    
20009                                    Query q = session.createQuery(sql);
20010    
20011                                    QueryPos qPos = QueryPos.getInstance(q);
20012    
20013                                    qPos.add(groupId);
20014    
20015                                    qPos.add(classNameId);
20016    
20017                                    if (bindLayoutUuid) {
20018                                            qPos.add(layoutUuid);
20019                                    }
20020    
20021                                    count = (Long)q.uniqueResult();
20022    
20023                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20024                            }
20025                            catch (Exception e) {
20026                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20027    
20028                                    throw processException(e);
20029                            }
20030                            finally {
20031                                    closeSession(session);
20032                            }
20033                    }
20034    
20035                    return count.intValue();
20036            }
20037    
20038            /**
20039             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
20040             *
20041             * @param groupId the group ID
20042             * @param classNameId the class name ID
20043             * @param layoutUuid the layout uuid
20044             * @return the number of matching journal articles that the user has permission to view
20045             * @throws SystemException if a system exception occurred
20046             */
20047            public int filterCountByG_C_L(long groupId, long classNameId,
20048                    String layoutUuid) throws SystemException {
20049                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20050                            return countByG_C_L(groupId, classNameId, layoutUuid);
20051                    }
20052    
20053                    StringBundler query = new StringBundler(4);
20054    
20055                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20056    
20057                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
20058    
20059                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
20060    
20061                    boolean bindLayoutUuid = false;
20062    
20063                    if (layoutUuid == null) {
20064                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
20065                    }
20066                    else if (layoutUuid.equals(StringPool.BLANK)) {
20067                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
20068                    }
20069                    else {
20070                            bindLayoutUuid = true;
20071    
20072                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
20073                    }
20074    
20075                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20076                                    JournalArticle.class.getName(),
20077                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20078    
20079                    Session session = null;
20080    
20081                    try {
20082                            session = openSession();
20083    
20084                            SQLQuery q = session.createSQLQuery(sql);
20085    
20086                            q.addScalar(COUNT_COLUMN_NAME,
20087                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20088    
20089                            QueryPos qPos = QueryPos.getInstance(q);
20090    
20091                            qPos.add(groupId);
20092    
20093                            qPos.add(classNameId);
20094    
20095                            if (bindLayoutUuid) {
20096                                    qPos.add(layoutUuid);
20097                            }
20098    
20099                            Long count = (Long)q.uniqueResult();
20100    
20101                            return count.intValue();
20102                    }
20103                    catch (Exception e) {
20104                            throw processException(e);
20105                    }
20106                    finally {
20107                            closeSession(session);
20108                    }
20109            }
20110    
20111            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
20112            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
20113            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
20114            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
20115            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
20116            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20117                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20118                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
20119                            "findByG_U_C",
20120                            new String[] {
20121                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
20122                                    
20123                            Integer.class.getName(), Integer.class.getName(),
20124                                    OrderByComparator.class.getName()
20125                            });
20126            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20127                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20128                            JournalArticleImpl.class,
20129                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C",
20130                            new String[] {
20131                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20132                            },
20133                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
20134                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
20135                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
20136                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
20137                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
20138            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20139                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20140                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C",
20141                            new String[] {
20142                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20143                            });
20144    
20145            /**
20146             * Returns all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20147             *
20148             * @param groupId the group ID
20149             * @param userId the user ID
20150             * @param classNameId the class name ID
20151             * @return the matching journal articles
20152             * @throws SystemException if a system exception occurred
20153             */
20154            public List<JournalArticle> findByG_U_C(long groupId, long userId,
20155                    long classNameId) throws SystemException {
20156                    return findByG_U_C(groupId, userId, classNameId, QueryUtil.ALL_POS,
20157                            QueryUtil.ALL_POS, null);
20158            }
20159    
20160            /**
20161             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20162             *
20163             * <p>
20164             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20165             * </p>
20166             *
20167             * @param groupId the group ID
20168             * @param userId the user ID
20169             * @param classNameId the class name ID
20170             * @param start the lower bound of the range of journal articles
20171             * @param end the upper bound of the range of journal articles (not inclusive)
20172             * @return the range of matching journal articles
20173             * @throws SystemException if a system exception occurred
20174             */
20175            public List<JournalArticle> findByG_U_C(long groupId, long userId,
20176                    long classNameId, int start, int end) throws SystemException {
20177                    return findByG_U_C(groupId, userId, classNameId, start, end, null);
20178            }
20179    
20180            /**
20181             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20182             *
20183             * <p>
20184             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20185             * </p>
20186             *
20187             * @param groupId the group ID
20188             * @param userId the user ID
20189             * @param classNameId the class name ID
20190             * @param start the lower bound of the range of journal articles
20191             * @param end the upper bound of the range of journal articles (not inclusive)
20192             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20193             * @return the ordered range of matching journal articles
20194             * @throws SystemException if a system exception occurred
20195             */
20196            public List<JournalArticle> findByG_U_C(long groupId, long userId,
20197                    long classNameId, int start, int end,
20198                    OrderByComparator orderByComparator) throws SystemException {
20199                    boolean pagination = true;
20200                    FinderPath finderPath = null;
20201                    Object[] finderArgs = null;
20202    
20203                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20204                                    (orderByComparator == null)) {
20205                            pagination = false;
20206                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C;
20207                            finderArgs = new Object[] { groupId, userId, classNameId };
20208                    }
20209                    else {
20210                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C;
20211                            finderArgs = new Object[] {
20212                                            groupId, userId, classNameId,
20213                                            
20214                                            start, end, orderByComparator
20215                                    };
20216                    }
20217    
20218                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
20219                                    finderArgs, this);
20220    
20221                    if ((list != null) && !list.isEmpty()) {
20222                            for (JournalArticle journalArticle : list) {
20223                                    if ((groupId != journalArticle.getGroupId()) ||
20224                                                    (userId != journalArticle.getUserId()) ||
20225                                                    (classNameId != journalArticle.getClassNameId())) {
20226                                            list = null;
20227    
20228                                            break;
20229                                    }
20230                            }
20231                    }
20232    
20233                    if (list == null) {
20234                            StringBundler query = null;
20235    
20236                            if (orderByComparator != null) {
20237                                    query = new StringBundler(5 +
20238                                                    (orderByComparator.getOrderByFields().length * 3));
20239                            }
20240                            else {
20241                                    query = new StringBundler(5);
20242                            }
20243    
20244                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20245    
20246                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20247    
20248                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20249    
20250                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20251    
20252                            if (orderByComparator != null) {
20253                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20254                                            orderByComparator);
20255                            }
20256                            else
20257                             if (pagination) {
20258                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20259                            }
20260    
20261                            String sql = query.toString();
20262    
20263                            Session session = null;
20264    
20265                            try {
20266                                    session = openSession();
20267    
20268                                    Query q = session.createQuery(sql);
20269    
20270                                    QueryPos qPos = QueryPos.getInstance(q);
20271    
20272                                    qPos.add(groupId);
20273    
20274                                    qPos.add(userId);
20275    
20276                                    qPos.add(classNameId);
20277    
20278                                    if (!pagination) {
20279                                            list = (List<JournalArticle>)QueryUtil.list(q,
20280                                                            getDialect(), start, end, false);
20281    
20282                                            Collections.sort(list);
20283    
20284                                            list = new UnmodifiableList<JournalArticle>(list);
20285                                    }
20286                                    else {
20287                                            list = (List<JournalArticle>)QueryUtil.list(q,
20288                                                            getDialect(), start, end);
20289                                    }
20290    
20291                                    cacheResult(list);
20292    
20293                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
20294                            }
20295                            catch (Exception e) {
20296                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20297    
20298                                    throw processException(e);
20299                            }
20300                            finally {
20301                                    closeSession(session);
20302                            }
20303                    }
20304    
20305                    return list;
20306            }
20307    
20308            /**
20309             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20310             *
20311             * @param groupId the group ID
20312             * @param userId the user ID
20313             * @param classNameId the class name ID
20314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20315             * @return the first matching journal article
20316             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20317             * @throws SystemException if a system exception occurred
20318             */
20319            public JournalArticle findByG_U_C_First(long groupId, long userId,
20320                    long classNameId, OrderByComparator orderByComparator)
20321                    throws NoSuchArticleException, SystemException {
20322                    JournalArticle journalArticle = fetchByG_U_C_First(groupId, userId,
20323                                    classNameId, orderByComparator);
20324    
20325                    if (journalArticle != null) {
20326                            return journalArticle;
20327                    }
20328    
20329                    StringBundler msg = new StringBundler(8);
20330    
20331                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20332    
20333                    msg.append("groupId=");
20334                    msg.append(groupId);
20335    
20336                    msg.append(", userId=");
20337                    msg.append(userId);
20338    
20339                    msg.append(", classNameId=");
20340                    msg.append(classNameId);
20341    
20342                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20343    
20344                    throw new NoSuchArticleException(msg.toString());
20345            }
20346    
20347            /**
20348             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20349             *
20350             * @param groupId the group ID
20351             * @param userId the user ID
20352             * @param classNameId the class name ID
20353             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20354             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
20355             * @throws SystemException if a system exception occurred
20356             */
20357            public JournalArticle fetchByG_U_C_First(long groupId, long userId,
20358                    long classNameId, OrderByComparator orderByComparator)
20359                    throws SystemException {
20360                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
20361                                    0, 1, orderByComparator);
20362    
20363                    if (!list.isEmpty()) {
20364                            return list.get(0);
20365                    }
20366    
20367                    return null;
20368            }
20369    
20370            /**
20371             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20372             *
20373             * @param groupId the group ID
20374             * @param userId the user ID
20375             * @param classNameId the class name ID
20376             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20377             * @return the last matching journal article
20378             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
20379             * @throws SystemException if a system exception occurred
20380             */
20381            public JournalArticle findByG_U_C_Last(long groupId, long userId,
20382                    long classNameId, OrderByComparator orderByComparator)
20383                    throws NoSuchArticleException, SystemException {
20384                    JournalArticle journalArticle = fetchByG_U_C_Last(groupId, userId,
20385                                    classNameId, orderByComparator);
20386    
20387                    if (journalArticle != null) {
20388                            return journalArticle;
20389                    }
20390    
20391                    StringBundler msg = new StringBundler(8);
20392    
20393                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
20394    
20395                    msg.append("groupId=");
20396                    msg.append(groupId);
20397    
20398                    msg.append(", userId=");
20399                    msg.append(userId);
20400    
20401                    msg.append(", classNameId=");
20402                    msg.append(classNameId);
20403    
20404                    msg.append(StringPool.CLOSE_CURLY_BRACE);
20405    
20406                    throw new NoSuchArticleException(msg.toString());
20407            }
20408    
20409            /**
20410             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20411             *
20412             * @param groupId the group ID
20413             * @param userId the user ID
20414             * @param classNameId the class name ID
20415             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20416             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
20417             * @throws SystemException if a system exception occurred
20418             */
20419            public JournalArticle fetchByG_U_C_Last(long groupId, long userId,
20420                    long classNameId, OrderByComparator orderByComparator)
20421                    throws SystemException {
20422                    int count = countByG_U_C(groupId, userId, classNameId);
20423    
20424                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
20425                                    count - 1, count, orderByComparator);
20426    
20427                    if (!list.isEmpty()) {
20428                            return list.get(0);
20429                    }
20430    
20431                    return null;
20432            }
20433    
20434            /**
20435             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20436             *
20437             * @param id the primary key of the current journal article
20438             * @param groupId the group ID
20439             * @param userId the user ID
20440             * @param classNameId the class name ID
20441             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20442             * @return the previous, current, and next journal article
20443             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20444             * @throws SystemException if a system exception occurred
20445             */
20446            public JournalArticle[] findByG_U_C_PrevAndNext(long id, long groupId,
20447                    long userId, long classNameId, OrderByComparator orderByComparator)
20448                    throws NoSuchArticleException, SystemException {
20449                    JournalArticle journalArticle = findByPrimaryKey(id);
20450    
20451                    Session session = null;
20452    
20453                    try {
20454                            session = openSession();
20455    
20456                            JournalArticle[] array = new JournalArticleImpl[3];
20457    
20458                            array[0] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
20459                                            userId, classNameId, orderByComparator, true);
20460    
20461                            array[1] = journalArticle;
20462    
20463                            array[2] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
20464                                            userId, classNameId, orderByComparator, false);
20465    
20466                            return array;
20467                    }
20468                    catch (Exception e) {
20469                            throw processException(e);
20470                    }
20471                    finally {
20472                            closeSession(session);
20473                    }
20474            }
20475    
20476            protected JournalArticle getByG_U_C_PrevAndNext(Session session,
20477                    JournalArticle journalArticle, long groupId, long userId,
20478                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
20479                    StringBundler query = null;
20480    
20481                    if (orderByComparator != null) {
20482                            query = new StringBundler(6 +
20483                                            (orderByComparator.getOrderByFields().length * 6));
20484                    }
20485                    else {
20486                            query = new StringBundler(3);
20487                    }
20488    
20489                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20490    
20491                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20492    
20493                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20494    
20495                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20496    
20497                    if (orderByComparator != null) {
20498                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20499    
20500                            if (orderByConditionFields.length > 0) {
20501                                    query.append(WHERE_AND);
20502                            }
20503    
20504                            for (int i = 0; i < orderByConditionFields.length; i++) {
20505                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20506                                    query.append(orderByConditionFields[i]);
20507    
20508                                    if ((i + 1) < orderByConditionFields.length) {
20509                                            if (orderByComparator.isAscending() ^ previous) {
20510                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20511                                            }
20512                                            else {
20513                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20514                                            }
20515                                    }
20516                                    else {
20517                                            if (orderByComparator.isAscending() ^ previous) {
20518                                                    query.append(WHERE_GREATER_THAN);
20519                                            }
20520                                            else {
20521                                                    query.append(WHERE_LESSER_THAN);
20522                                            }
20523                                    }
20524                            }
20525    
20526                            query.append(ORDER_BY_CLAUSE);
20527    
20528                            String[] orderByFields = orderByComparator.getOrderByFields();
20529    
20530                            for (int i = 0; i < orderByFields.length; i++) {
20531                                    query.append(_ORDER_BY_ENTITY_ALIAS);
20532                                    query.append(orderByFields[i]);
20533    
20534                                    if ((i + 1) < orderByFields.length) {
20535                                            if (orderByComparator.isAscending() ^ previous) {
20536                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20537                                            }
20538                                            else {
20539                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20540                                            }
20541                                    }
20542                                    else {
20543                                            if (orderByComparator.isAscending() ^ previous) {
20544                                                    query.append(ORDER_BY_ASC);
20545                                            }
20546                                            else {
20547                                                    query.append(ORDER_BY_DESC);
20548                                            }
20549                                    }
20550                            }
20551                    }
20552                    else {
20553                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20554                    }
20555    
20556                    String sql = query.toString();
20557    
20558                    Query q = session.createQuery(sql);
20559    
20560                    q.setFirstResult(0);
20561                    q.setMaxResults(2);
20562    
20563                    QueryPos qPos = QueryPos.getInstance(q);
20564    
20565                    qPos.add(groupId);
20566    
20567                    qPos.add(userId);
20568    
20569                    qPos.add(classNameId);
20570    
20571                    if (orderByComparator != null) {
20572                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20573    
20574                            for (Object value : values) {
20575                                    qPos.add(value);
20576                            }
20577                    }
20578    
20579                    List<JournalArticle> list = q.list();
20580    
20581                    if (list.size() == 2) {
20582                            return list.get(1);
20583                    }
20584                    else {
20585                            return null;
20586                    }
20587            }
20588    
20589            /**
20590             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20591             *
20592             * @param groupId the group ID
20593             * @param userId the user ID
20594             * @param classNameId the class name ID
20595             * @return the matching journal articles that the user has permission to view
20596             * @throws SystemException if a system exception occurred
20597             */
20598            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
20599                    long classNameId) throws SystemException {
20600                    return filterFindByG_U_C(groupId, userId, classNameId,
20601                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20602            }
20603    
20604            /**
20605             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20606             *
20607             * <p>
20608             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20609             * </p>
20610             *
20611             * @param groupId the group ID
20612             * @param userId the user ID
20613             * @param classNameId the class name ID
20614             * @param start the lower bound of the range of journal articles
20615             * @param end the upper bound of the range of journal articles (not inclusive)
20616             * @return the range of matching journal articles that the user has permission to view
20617             * @throws SystemException if a system exception occurred
20618             */
20619            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
20620                    long classNameId, int start, int end) throws SystemException {
20621                    return filterFindByG_U_C(groupId, userId, classNameId, start, end, null);
20622            }
20623    
20624            /**
20625             * 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;.
20626             *
20627             * <p>
20628             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20629             * </p>
20630             *
20631             * @param groupId the group ID
20632             * @param userId the user ID
20633             * @param classNameId the class name ID
20634             * @param start the lower bound of the range of journal articles
20635             * @param end the upper bound of the range of journal articles (not inclusive)
20636             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20637             * @return the ordered range of matching journal articles that the user has permission to view
20638             * @throws SystemException if a system exception occurred
20639             */
20640            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
20641                    long classNameId, int start, int end,
20642                    OrderByComparator orderByComparator) throws SystemException {
20643                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20644                            return findByG_U_C(groupId, userId, classNameId, start, end,
20645                                    orderByComparator);
20646                    }
20647    
20648                    StringBundler query = null;
20649    
20650                    if (orderByComparator != null) {
20651                            query = new StringBundler(5 +
20652                                            (orderByComparator.getOrderByFields().length * 3));
20653                    }
20654                    else {
20655                            query = new StringBundler(5);
20656                    }
20657    
20658                    if (getDB().isSupportsInlineDistinct()) {
20659                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20660                    }
20661                    else {
20662                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20663                    }
20664    
20665                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20666    
20667                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20668    
20669                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20670    
20671                    if (!getDB().isSupportsInlineDistinct()) {
20672                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20673                    }
20674    
20675                    if (orderByComparator != null) {
20676                            if (getDB().isSupportsInlineDistinct()) {
20677                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20678                                            orderByComparator, true);
20679                            }
20680                            else {
20681                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20682                                            orderByComparator, true);
20683                            }
20684                    }
20685                    else {
20686                            if (getDB().isSupportsInlineDistinct()) {
20687                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20688                            }
20689                            else {
20690                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20691                            }
20692                    }
20693    
20694                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20695                                    JournalArticle.class.getName(),
20696                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20697    
20698                    Session session = null;
20699    
20700                    try {
20701                            session = openSession();
20702    
20703                            SQLQuery q = session.createSQLQuery(sql);
20704    
20705                            if (getDB().isSupportsInlineDistinct()) {
20706                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20707                            }
20708                            else {
20709                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20710                            }
20711    
20712                            QueryPos qPos = QueryPos.getInstance(q);
20713    
20714                            qPos.add(groupId);
20715    
20716                            qPos.add(userId);
20717    
20718                            qPos.add(classNameId);
20719    
20720                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20721                                    end);
20722                    }
20723                    catch (Exception e) {
20724                            throw processException(e);
20725                    }
20726                    finally {
20727                            closeSession(session);
20728                    }
20729            }
20730    
20731            /**
20732             * 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;.
20733             *
20734             * @param id the primary key of the current journal article
20735             * @param groupId the group ID
20736             * @param userId the user ID
20737             * @param classNameId the class name ID
20738             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20739             * @return the previous, current, and next journal article
20740             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
20741             * @throws SystemException if a system exception occurred
20742             */
20743            public JournalArticle[] filterFindByG_U_C_PrevAndNext(long id,
20744                    long groupId, long userId, long classNameId,
20745                    OrderByComparator orderByComparator)
20746                    throws NoSuchArticleException, SystemException {
20747                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20748                            return findByG_U_C_PrevAndNext(id, groupId, userId, classNameId,
20749                                    orderByComparator);
20750                    }
20751    
20752                    JournalArticle journalArticle = findByPrimaryKey(id);
20753    
20754                    Session session = null;
20755    
20756                    try {
20757                            session = openSession();
20758    
20759                            JournalArticle[] array = new JournalArticleImpl[3];
20760    
20761                            array[0] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
20762                                            groupId, userId, classNameId, orderByComparator, true);
20763    
20764                            array[1] = journalArticle;
20765    
20766                            array[2] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
20767                                            groupId, userId, classNameId, orderByComparator, false);
20768    
20769                            return array;
20770                    }
20771                    catch (Exception e) {
20772                            throw processException(e);
20773                    }
20774                    finally {
20775                            closeSession(session);
20776                    }
20777            }
20778    
20779            protected JournalArticle filterGetByG_U_C_PrevAndNext(Session session,
20780                    JournalArticle journalArticle, long groupId, long userId,
20781                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
20782                    StringBundler query = null;
20783    
20784                    if (orderByComparator != null) {
20785                            query = new StringBundler(6 +
20786                                            (orderByComparator.getOrderByFields().length * 6));
20787                    }
20788                    else {
20789                            query = new StringBundler(3);
20790                    }
20791    
20792                    if (getDB().isSupportsInlineDistinct()) {
20793                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20794                    }
20795                    else {
20796                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20797                    }
20798    
20799                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20800    
20801                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20802    
20803                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20804    
20805                    if (!getDB().isSupportsInlineDistinct()) {
20806                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20807                    }
20808    
20809                    if (orderByComparator != null) {
20810                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20811    
20812                            if (orderByConditionFields.length > 0) {
20813                                    query.append(WHERE_AND);
20814                            }
20815    
20816                            for (int i = 0; i < orderByConditionFields.length; i++) {
20817                                    if (getDB().isSupportsInlineDistinct()) {
20818                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20819                                    }
20820                                    else {
20821                                            query.append(_ORDER_BY_ENTITY_TABLE);
20822                                    }
20823    
20824                                    query.append(orderByConditionFields[i]);
20825    
20826                                    if ((i + 1) < orderByConditionFields.length) {
20827                                            if (orderByComparator.isAscending() ^ previous) {
20828                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20829                                            }
20830                                            else {
20831                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20832                                            }
20833                                    }
20834                                    else {
20835                                            if (orderByComparator.isAscending() ^ previous) {
20836                                                    query.append(WHERE_GREATER_THAN);
20837                                            }
20838                                            else {
20839                                                    query.append(WHERE_LESSER_THAN);
20840                                            }
20841                                    }
20842                            }
20843    
20844                            query.append(ORDER_BY_CLAUSE);
20845    
20846                            String[] orderByFields = orderByComparator.getOrderByFields();
20847    
20848                            for (int i = 0; i < orderByFields.length; i++) {
20849                                    if (getDB().isSupportsInlineDistinct()) {
20850                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20851                                    }
20852                                    else {
20853                                            query.append(_ORDER_BY_ENTITY_TABLE);
20854                                    }
20855    
20856                                    query.append(orderByFields[i]);
20857    
20858                                    if ((i + 1) < orderByFields.length) {
20859                                            if (orderByComparator.isAscending() ^ previous) {
20860                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20861                                            }
20862                                            else {
20863                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20864                                            }
20865                                    }
20866                                    else {
20867                                            if (orderByComparator.isAscending() ^ previous) {
20868                                                    query.append(ORDER_BY_ASC);
20869                                            }
20870                                            else {
20871                                                    query.append(ORDER_BY_DESC);
20872                                            }
20873                                    }
20874                            }
20875                    }
20876                    else {
20877                            if (getDB().isSupportsInlineDistinct()) {
20878                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20879                            }
20880                            else {
20881                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20882                            }
20883                    }
20884    
20885                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20886                                    JournalArticle.class.getName(),
20887                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20888    
20889                    SQLQuery q = session.createSQLQuery(sql);
20890    
20891                    q.setFirstResult(0);
20892                    q.setMaxResults(2);
20893    
20894                    if (getDB().isSupportsInlineDistinct()) {
20895                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20896                    }
20897                    else {
20898                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20899                    }
20900    
20901                    QueryPos qPos = QueryPos.getInstance(q);
20902    
20903                    qPos.add(groupId);
20904    
20905                    qPos.add(userId);
20906    
20907                    qPos.add(classNameId);
20908    
20909                    if (orderByComparator != null) {
20910                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20911    
20912                            for (Object value : values) {
20913                                    qPos.add(value);
20914                            }
20915                    }
20916    
20917                    List<JournalArticle> list = q.list();
20918    
20919                    if (list.size() == 2) {
20920                            return list.get(1);
20921                    }
20922                    else {
20923                            return null;
20924                    }
20925            }
20926    
20927            /**
20928             * Removes all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63; from the database.
20929             *
20930             * @param groupId the group ID
20931             * @param userId the user ID
20932             * @param classNameId the class name ID
20933             * @throws SystemException if a system exception occurred
20934             */
20935            public void removeByG_U_C(long groupId, long userId, long classNameId)
20936                    throws SystemException {
20937                    for (JournalArticle journalArticle : findByG_U_C(groupId, userId,
20938                                    classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
20939                            remove(journalArticle);
20940                    }
20941            }
20942    
20943            /**
20944             * Returns the number of journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
20945             *
20946             * @param groupId the group ID
20947             * @param userId the user ID
20948             * @param classNameId the class name ID
20949             * @return the number of matching journal articles
20950             * @throws SystemException if a system exception occurred
20951             */
20952            public int countByG_U_C(long groupId, long userId, long classNameId)
20953                    throws SystemException {
20954                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C;
20955    
20956                    Object[] finderArgs = new Object[] { groupId, userId, classNameId };
20957    
20958                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
20959                                    this);
20960    
20961                    if (count == null) {
20962                            StringBundler query = new StringBundler(4);
20963    
20964                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20965    
20966                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
20967    
20968                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
20969    
20970                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
20971    
20972                            String sql = query.toString();
20973    
20974                            Session session = null;
20975    
20976                            try {
20977                                    session = openSession();
20978    
20979                                    Query q = session.createQuery(sql);
20980    
20981                                    QueryPos qPos = QueryPos.getInstance(q);
20982    
20983                                    qPos.add(groupId);
20984    
20985                                    qPos.add(userId);
20986    
20987                                    qPos.add(classNameId);
20988    
20989                                    count = (Long)q.uniqueResult();
20990    
20991                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20992                            }
20993                            catch (Exception e) {
20994                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20995    
20996                                    throw processException(e);
20997                            }
20998                            finally {
20999                                    closeSession(session);
21000                            }
21001                    }
21002    
21003                    return count.intValue();
21004            }
21005    
21006            /**
21007             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
21008             *
21009             * @param groupId the group ID
21010             * @param userId the user ID
21011             * @param classNameId the class name ID
21012             * @return the number of matching journal articles that the user has permission to view
21013             * @throws SystemException if a system exception occurred
21014             */
21015            public int filterCountByG_U_C(long groupId, long userId, long classNameId)
21016                    throws SystemException {
21017                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21018                            return countByG_U_C(groupId, userId, classNameId);
21019                    }
21020    
21021                    StringBundler query = new StringBundler(4);
21022    
21023                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21024    
21025                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
21026    
21027                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
21028    
21029                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
21030    
21031                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21032                                    JournalArticle.class.getName(),
21033                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21034    
21035                    Session session = null;
21036    
21037                    try {
21038                            session = openSession();
21039    
21040                            SQLQuery q = session.createSQLQuery(sql);
21041    
21042                            q.addScalar(COUNT_COLUMN_NAME,
21043                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21044    
21045                            QueryPos qPos = QueryPos.getInstance(q);
21046    
21047                            qPos.add(groupId);
21048    
21049                            qPos.add(userId);
21050    
21051                            qPos.add(classNameId);
21052    
21053                            Long count = (Long)q.uniqueResult();
21054    
21055                            return count.intValue();
21056                    }
21057                    catch (Exception e) {
21058                            throw processException(e);
21059                    }
21060                    finally {
21061                            closeSession(session);
21062                    }
21063            }
21064    
21065            private static final String _FINDER_COLUMN_G_U_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
21066            private static final String _FINDER_COLUMN_G_U_C_USERID_2 = "journalArticle.userId = ? AND ";
21067            private static final String _FINDER_COLUMN_G_U_C_CLASSNAMEID_2 = "journalArticle.classNameId = ?";
21068            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21069                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21070                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
21071                            new String[] {
21072                                    Long.class.getName(), String.class.getName(),
21073                                    Double.class.getName()
21074                            },
21075                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
21076                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
21077                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
21078            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21079                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21080                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
21081                            new String[] {
21082                                    Long.class.getName(), String.class.getName(),
21083                                    Double.class.getName()
21084                            });
21085    
21086            /**
21087             * 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.
21088             *
21089             * @param groupId the group ID
21090             * @param articleId the article ID
21091             * @param version the version
21092             * @return the matching journal article
21093             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21094             * @throws SystemException if a system exception occurred
21095             */
21096            public JournalArticle findByG_A_V(long groupId, String articleId,
21097                    double version) throws NoSuchArticleException, SystemException {
21098                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
21099    
21100                    if (journalArticle == null) {
21101                            StringBundler msg = new StringBundler(8);
21102    
21103                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21104    
21105                            msg.append("groupId=");
21106                            msg.append(groupId);
21107    
21108                            msg.append(", articleId=");
21109                            msg.append(articleId);
21110    
21111                            msg.append(", version=");
21112                            msg.append(version);
21113    
21114                            msg.append(StringPool.CLOSE_CURLY_BRACE);
21115    
21116                            if (_log.isWarnEnabled()) {
21117                                    _log.warn(msg.toString());
21118                            }
21119    
21120                            throw new NoSuchArticleException(msg.toString());
21121                    }
21122    
21123                    return journalArticle;
21124            }
21125    
21126            /**
21127             * 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.
21128             *
21129             * @param groupId the group ID
21130             * @param articleId the article ID
21131             * @param version the version
21132             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
21133             * @throws SystemException if a system exception occurred
21134             */
21135            public JournalArticle fetchByG_A_V(long groupId, String articleId,
21136                    double version) throws SystemException {
21137                    return fetchByG_A_V(groupId, articleId, version, true);
21138            }
21139    
21140            /**
21141             * 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.
21142             *
21143             * @param groupId the group ID
21144             * @param articleId the article ID
21145             * @param version the version
21146             * @param retrieveFromCache whether to use the finder cache
21147             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
21148             * @throws SystemException if a system exception occurred
21149             */
21150            public JournalArticle fetchByG_A_V(long groupId, String articleId,
21151                    double version, boolean retrieveFromCache) throws SystemException {
21152                    Object[] finderArgs = new Object[] { groupId, articleId, version };
21153    
21154                    Object result = null;
21155    
21156                    if (retrieveFromCache) {
21157                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
21158                                            finderArgs, this);
21159                    }
21160    
21161                    if (result instanceof JournalArticle) {
21162                            JournalArticle journalArticle = (JournalArticle)result;
21163    
21164                            if ((groupId != journalArticle.getGroupId()) ||
21165                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
21166                                            (version != journalArticle.getVersion())) {
21167                                    result = null;
21168                            }
21169                    }
21170    
21171                    if (result == null) {
21172                            StringBundler query = new StringBundler(5);
21173    
21174                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21175    
21176                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
21177    
21178                            boolean bindArticleId = false;
21179    
21180                            if (articleId == null) {
21181                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
21182                            }
21183                            else if (articleId.equals(StringPool.BLANK)) {
21184                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
21185                            }
21186                            else {
21187                                    bindArticleId = true;
21188    
21189                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
21190                            }
21191    
21192                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
21193    
21194                            String sql = query.toString();
21195    
21196                            Session session = null;
21197    
21198                            try {
21199                                    session = openSession();
21200    
21201                                    Query q = session.createQuery(sql);
21202    
21203                                    QueryPos qPos = QueryPos.getInstance(q);
21204    
21205                                    qPos.add(groupId);
21206    
21207                                    if (bindArticleId) {
21208                                            qPos.add(articleId);
21209                                    }
21210    
21211                                    qPos.add(version);
21212    
21213                                    List<JournalArticle> list = q.list();
21214    
21215                                    if (list.isEmpty()) {
21216                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
21217                                                    finderArgs, list);
21218                                    }
21219                                    else {
21220                                            JournalArticle journalArticle = list.get(0);
21221    
21222                                            result = journalArticle;
21223    
21224                                            cacheResult(journalArticle);
21225    
21226                                            if ((journalArticle.getGroupId() != groupId) ||
21227                                                            (journalArticle.getArticleId() == null) ||
21228                                                            !journalArticle.getArticleId().equals(articleId) ||
21229                                                            (journalArticle.getVersion() != version)) {
21230                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
21231                                                            finderArgs, journalArticle);
21232                                            }
21233                                    }
21234                            }
21235                            catch (Exception e) {
21236                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
21237                                            finderArgs);
21238    
21239                                    throw processException(e);
21240                            }
21241                            finally {
21242                                    closeSession(session);
21243                            }
21244                    }
21245    
21246                    if (result instanceof List<?>) {
21247                            return null;
21248                    }
21249                    else {
21250                            return (JournalArticle)result;
21251                    }
21252            }
21253    
21254            /**
21255             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
21256             *
21257             * @param groupId the group ID
21258             * @param articleId the article ID
21259             * @param version the version
21260             * @return the journal article that was removed
21261             * @throws SystemException if a system exception occurred
21262             */
21263            public JournalArticle removeByG_A_V(long groupId, String articleId,
21264                    double version) throws NoSuchArticleException, SystemException {
21265                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
21266    
21267                    return remove(journalArticle);
21268            }
21269    
21270            /**
21271             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
21272             *
21273             * @param groupId the group ID
21274             * @param articleId the article ID
21275             * @param version the version
21276             * @return the number of matching journal articles
21277             * @throws SystemException if a system exception occurred
21278             */
21279            public int countByG_A_V(long groupId, String articleId, double version)
21280                    throws SystemException {
21281                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_V;
21282    
21283                    Object[] finderArgs = new Object[] { groupId, articleId, version };
21284    
21285                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21286                                    this);
21287    
21288                    if (count == null) {
21289                            StringBundler query = new StringBundler(4);
21290    
21291                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21292    
21293                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
21294    
21295                            boolean bindArticleId = false;
21296    
21297                            if (articleId == null) {
21298                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
21299                            }
21300                            else if (articleId.equals(StringPool.BLANK)) {
21301                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
21302                            }
21303                            else {
21304                                    bindArticleId = true;
21305    
21306                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
21307                            }
21308    
21309                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
21310    
21311                            String sql = query.toString();
21312    
21313                            Session session = null;
21314    
21315                            try {
21316                                    session = openSession();
21317    
21318                                    Query q = session.createQuery(sql);
21319    
21320                                    QueryPos qPos = QueryPos.getInstance(q);
21321    
21322                                    qPos.add(groupId);
21323    
21324                                    if (bindArticleId) {
21325                                            qPos.add(articleId);
21326                                    }
21327    
21328                                    qPos.add(version);
21329    
21330                                    count = (Long)q.uniqueResult();
21331    
21332                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21333                            }
21334                            catch (Exception e) {
21335                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21336    
21337                                    throw processException(e);
21338                            }
21339                            finally {
21340                                    closeSession(session);
21341                            }
21342                    }
21343    
21344                    return count.intValue();
21345            }
21346    
21347            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
21348            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
21349            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
21350            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
21351            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
21352            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21353                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21354                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
21355                            "findByG_A_ST",
21356                            new String[] {
21357                                    Long.class.getName(), String.class.getName(),
21358                                    Integer.class.getName(),
21359                                    
21360                            Integer.class.getName(), Integer.class.getName(),
21361                                    OrderByComparator.class.getName()
21362                            });
21363            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
21364                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21365                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21366                            JournalArticleImpl.class,
21367                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
21368                            new String[] {
21369                                    Long.class.getName(), String.class.getName(),
21370                                    Integer.class.getName()
21371                            },
21372                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
21373                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
21374                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
21375                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
21376            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21377                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21378                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
21379                            new String[] {
21380                                    Long.class.getName(), String.class.getName(),
21381                                    Integer.class.getName()
21382                            });
21383            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21384                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21385                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
21386                            new String[] {
21387                                    Long.class.getName(), String.class.getName(),
21388                                    Integer.class.getName()
21389                            });
21390    
21391            /**
21392             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
21393             *
21394             * @param groupId the group ID
21395             * @param articleId the article ID
21396             * @param status the status
21397             * @return the matching journal articles
21398             * @throws SystemException if a system exception occurred
21399             */
21400            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
21401                    int status) throws SystemException {
21402                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
21403                            QueryUtil.ALL_POS, null);
21404            }
21405    
21406            /**
21407             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
21408             *
21409             * <p>
21410             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21411             * </p>
21412             *
21413             * @param groupId the group ID
21414             * @param articleId the article ID
21415             * @param status the status
21416             * @param start the lower bound of the range of journal articles
21417             * @param end the upper bound of the range of journal articles (not inclusive)
21418             * @return the range of matching journal articles
21419             * @throws SystemException if a system exception occurred
21420             */
21421            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
21422                    int status, int start, int end) throws SystemException {
21423                    return findByG_A_ST(groupId, articleId, status, start, end, null);
21424            }
21425    
21426            /**
21427             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
21428             *
21429             * <p>
21430             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21431             * </p>
21432             *
21433             * @param groupId the group ID
21434             * @param articleId the article ID
21435             * @param status the status
21436             * @param start the lower bound of the range of journal articles
21437             * @param end the upper bound of the range of journal articles (not inclusive)
21438             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21439             * @return the ordered range of matching journal articles
21440             * @throws SystemException if a system exception occurred
21441             */
21442            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
21443                    int status, int start, int end, OrderByComparator orderByComparator)
21444                    throws SystemException {
21445                    boolean pagination = true;
21446                    FinderPath finderPath = null;
21447                    Object[] finderArgs = null;
21448    
21449                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
21450                                    (orderByComparator == null)) {
21451                            pagination = false;
21452                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
21453                            finderArgs = new Object[] { groupId, articleId, status };
21454                    }
21455                    else {
21456                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
21457                            finderArgs = new Object[] {
21458                                            groupId, articleId, status,
21459                                            
21460                                            start, end, orderByComparator
21461                                    };
21462                    }
21463    
21464                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
21465                                    finderArgs, this);
21466    
21467                    if ((list != null) && !list.isEmpty()) {
21468                            for (JournalArticle journalArticle : list) {
21469                                    if ((groupId != journalArticle.getGroupId()) ||
21470                                                    !Validator.equals(articleId,
21471                                                            journalArticle.getArticleId()) ||
21472                                                    (status != journalArticle.getStatus())) {
21473                                            list = null;
21474    
21475                                            break;
21476                                    }
21477                            }
21478                    }
21479    
21480                    if (list == null) {
21481                            StringBundler query = null;
21482    
21483                            if (orderByComparator != null) {
21484                                    query = new StringBundler(5 +
21485                                                    (orderByComparator.getOrderByFields().length * 3));
21486                            }
21487                            else {
21488                                    query = new StringBundler(5);
21489                            }
21490    
21491                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21492    
21493                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
21494    
21495                            boolean bindArticleId = false;
21496    
21497                            if (articleId == null) {
21498                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
21499                            }
21500                            else if (articleId.equals(StringPool.BLANK)) {
21501                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
21502                            }
21503                            else {
21504                                    bindArticleId = true;
21505    
21506                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
21507                            }
21508    
21509                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
21510    
21511                            if (orderByComparator != null) {
21512                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21513                                            orderByComparator);
21514                            }
21515                            else
21516                             if (pagination) {
21517                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21518                            }
21519    
21520                            String sql = query.toString();
21521    
21522                            Session session = null;
21523    
21524                            try {
21525                                    session = openSession();
21526    
21527                                    Query q = session.createQuery(sql);
21528    
21529                                    QueryPos qPos = QueryPos.getInstance(q);
21530    
21531                                    qPos.add(groupId);
21532    
21533                                    if (bindArticleId) {
21534                                            qPos.add(articleId);
21535                                    }
21536    
21537                                    qPos.add(status);
21538    
21539                                    if (!pagination) {
21540                                            list = (List<JournalArticle>)QueryUtil.list(q,
21541                                                            getDialect(), start, end, false);
21542    
21543                                            Collections.sort(list);
21544    
21545                                            list = new UnmodifiableList<JournalArticle>(list);
21546                                    }
21547                                    else {
21548                                            list = (List<JournalArticle>)QueryUtil.list(q,
21549                                                            getDialect(), start, end);
21550                                    }
21551    
21552                                    cacheResult(list);
21553    
21554                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
21555                            }
21556                            catch (Exception e) {
21557                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21558    
21559                                    throw processException(e);
21560                            }
21561                            finally {
21562                                    closeSession(session);
21563                            }
21564                    }
21565    
21566                    return list;
21567            }
21568    
21569            /**
21570             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
21571             *
21572             * @param groupId the group ID
21573             * @param articleId the article ID
21574             * @param status the status
21575             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21576             * @return the first matching journal article
21577             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21578             * @throws SystemException if a system exception occurred
21579             */
21580            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
21581                    int status, OrderByComparator orderByComparator)
21582                    throws NoSuchArticleException, SystemException {
21583                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
21584                                    status, orderByComparator);
21585    
21586                    if (journalArticle != null) {
21587                            return journalArticle;
21588                    }
21589    
21590                    StringBundler msg = new StringBundler(8);
21591    
21592                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21593    
21594                    msg.append("groupId=");
21595                    msg.append(groupId);
21596    
21597                    msg.append(", articleId=");
21598                    msg.append(articleId);
21599    
21600                    msg.append(", status=");
21601                    msg.append(status);
21602    
21603                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21604    
21605                    throw new NoSuchArticleException(msg.toString());
21606            }
21607    
21608            /**
21609             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
21610             *
21611             * @param groupId the group ID
21612             * @param articleId the article ID
21613             * @param status the status
21614             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21615             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
21616             * @throws SystemException if a system exception occurred
21617             */
21618            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
21619                    int status, OrderByComparator orderByComparator)
21620                    throws SystemException {
21621                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
21622                                    1, orderByComparator);
21623    
21624                    if (!list.isEmpty()) {
21625                            return list.get(0);
21626                    }
21627    
21628                    return null;
21629            }
21630    
21631            /**
21632             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
21633             *
21634             * @param groupId the group ID
21635             * @param articleId the article ID
21636             * @param status the status
21637             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21638             * @return the last matching journal article
21639             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
21640             * @throws SystemException if a system exception occurred
21641             */
21642            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
21643                    int status, OrderByComparator orderByComparator)
21644                    throws NoSuchArticleException, SystemException {
21645                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
21646                                    status, orderByComparator);
21647    
21648                    if (journalArticle != null) {
21649                            return journalArticle;
21650                    }
21651    
21652                    StringBundler msg = new StringBundler(8);
21653    
21654                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21655    
21656                    msg.append("groupId=");
21657                    msg.append(groupId);
21658    
21659                    msg.append(", articleId=");
21660                    msg.append(articleId);
21661    
21662                    msg.append(", status=");
21663                    msg.append(status);
21664    
21665                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21666    
21667                    throw new NoSuchArticleException(msg.toString());
21668            }
21669    
21670            /**
21671             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
21672             *
21673             * @param groupId the group ID
21674             * @param articleId the article ID
21675             * @param status the status
21676             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21677             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
21678             * @throws SystemException if a system exception occurred
21679             */
21680            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
21681                    int status, OrderByComparator orderByComparator)
21682                    throws SystemException {
21683                    int count = countByG_A_ST(groupId, articleId, status);
21684    
21685                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
21686                                    count - 1, count, orderByComparator);
21687    
21688                    if (!list.isEmpty()) {
21689                            return list.get(0);
21690                    }
21691    
21692                    return null;
21693            }
21694    
21695            /**
21696             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
21697             *
21698             * @param id the primary key of the current journal article
21699             * @param groupId the group ID
21700             * @param articleId the article ID
21701             * @param status the status
21702             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21703             * @return the previous, current, and next journal article
21704             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
21705             * @throws SystemException if a system exception occurred
21706             */
21707            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
21708                    String articleId, int status, OrderByComparator orderByComparator)
21709                    throws NoSuchArticleException, SystemException {
21710                    JournalArticle journalArticle = findByPrimaryKey(id);
21711    
21712                    Session session = null;
21713    
21714                    try {
21715                            session = openSession();
21716    
21717                            JournalArticle[] array = new JournalArticleImpl[3];
21718    
21719                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
21720                                            groupId, articleId, status, orderByComparator, true);
21721    
21722                            array[1] = journalArticle;
21723    
21724                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
21725                                            groupId, articleId, status, orderByComparator, false);
21726    
21727                            return array;
21728                    }
21729                    catch (Exception e) {
21730                            throw processException(e);
21731                    }
21732                    finally {
21733                            closeSession(session);
21734                    }
21735            }
21736    
21737            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
21738                    JournalArticle journalArticle, long groupId, String articleId,
21739                    int status, OrderByComparator orderByComparator, boolean previous) {
21740                    StringBundler query = null;
21741    
21742                    if (orderByComparator != null) {
21743                            query = new StringBundler(6 +
21744                                            (orderByComparator.getOrderByFields().length * 6));
21745                    }
21746                    else {
21747                            query = new StringBundler(3);
21748                    }
21749    
21750                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21751    
21752                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
21753    
21754                    boolean bindArticleId = false;
21755    
21756                    if (articleId == null) {
21757                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
21758                    }
21759                    else if (articleId.equals(StringPool.BLANK)) {
21760                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
21761                    }
21762                    else {
21763                            bindArticleId = true;
21764    
21765                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
21766                    }
21767    
21768                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
21769    
21770                    if (orderByComparator != null) {
21771                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21772    
21773                            if (orderByConditionFields.length > 0) {
21774                                    query.append(WHERE_AND);
21775                            }
21776    
21777                            for (int i = 0; i < orderByConditionFields.length; i++) {
21778                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21779                                    query.append(orderByConditionFields[i]);
21780    
21781                                    if ((i + 1) < orderByConditionFields.length) {
21782                                            if (orderByComparator.isAscending() ^ previous) {
21783                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21784                                            }
21785                                            else {
21786                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21787                                            }
21788                                    }
21789                                    else {
21790                                            if (orderByComparator.isAscending() ^ previous) {
21791                                                    query.append(WHERE_GREATER_THAN);
21792                                            }
21793                                            else {
21794                                                    query.append(WHERE_LESSER_THAN);
21795                                            }
21796                                    }
21797                            }
21798    
21799                            query.append(ORDER_BY_CLAUSE);
21800    
21801                            String[] orderByFields = orderByComparator.getOrderByFields();
21802    
21803                            for (int i = 0; i < orderByFields.length; i++) {
21804                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21805                                    query.append(orderByFields[i]);
21806    
21807                                    if ((i + 1) < orderByFields.length) {
21808                                            if (orderByComparator.isAscending() ^ previous) {
21809                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21810                                            }
21811                                            else {
21812                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21813                                            }
21814                                    }
21815                                    else {
21816                                            if (orderByComparator.isAscending() ^ previous) {
21817                                                    query.append(ORDER_BY_ASC);
21818                                            }
21819                                            else {
21820                                                    query.append(ORDER_BY_DESC);
21821                                            }
21822                                    }
21823                            }
21824                    }
21825                    else {
21826                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21827                    }
21828    
21829                    String sql = query.toString();
21830    
21831                    Query q = session.createQuery(sql);
21832    
21833                    q.setFirstResult(0);
21834                    q.setMaxResults(2);
21835    
21836                    QueryPos qPos = QueryPos.getInstance(q);
21837    
21838                    qPos.add(groupId);
21839    
21840                    if (bindArticleId) {
21841                            qPos.add(articleId);
21842                    }
21843    
21844                    qPos.add(status);
21845    
21846                    if (orderByComparator != null) {
21847                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21848    
21849                            for (Object value : values) {
21850                                    qPos.add(value);
21851                            }
21852                    }
21853    
21854                    List<JournalArticle> list = q.list();
21855    
21856                    if (list.size() == 2) {
21857                            return list.get(1);
21858                    }
21859                    else {
21860                            return null;
21861                    }
21862            }
21863    
21864            /**
21865             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
21866             *
21867             * @param groupId the group ID
21868             * @param articleId the article ID
21869             * @param status the status
21870             * @return the matching journal articles that the user has permission to view
21871             * @throws SystemException if a system exception occurred
21872             */
21873            public List<JournalArticle> filterFindByG_A_ST(long groupId,
21874                    String articleId, int status) throws SystemException {
21875                    return filterFindByG_A_ST(groupId, articleId, status,
21876                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21877            }
21878    
21879            /**
21880             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
21881             *
21882             * <p>
21883             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21884             * </p>
21885             *
21886             * @param groupId the group ID
21887             * @param articleId the article ID
21888             * @param status the status
21889             * @param start the lower bound of the range of journal articles
21890             * @param end the upper bound of the range of journal articles (not inclusive)
21891             * @return the range of matching journal articles that the user has permission to view
21892             * @throws SystemException if a system exception occurred
21893             */
21894            public List<JournalArticle> filterFindByG_A_ST(long groupId,
21895                    String articleId, int status, int start, int end)
21896                    throws SystemException {
21897                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
21898            }
21899    
21900            /**
21901             * 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;.
21902             *
21903             * <p>
21904             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21905             * </p>
21906             *
21907             * @param groupId the group ID
21908             * @param articleId the article ID
21909             * @param status the status
21910             * @param start the lower bound of the range of journal articles
21911             * @param end the upper bound of the range of journal articles (not inclusive)
21912             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21913             * @return the ordered range of matching journal articles that the user has permission to view
21914             * @throws SystemException if a system exception occurred
21915             */
21916            public List<JournalArticle> filterFindByG_A_ST(long groupId,
21917                    String articleId, int status, int start, int end,
21918                    OrderByComparator orderByComparator) throws SystemException {
21919                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21920                            return findByG_A_ST(groupId, articleId, status, start, end,
21921                                    orderByComparator);
21922                    }
21923    
21924                    StringBundler query = null;
21925    
21926                    if (orderByComparator != null) {
21927                            query = new StringBundler(5 +
21928                                            (orderByComparator.getOrderByFields().length * 3));
21929                    }
21930                    else {
21931                            query = new StringBundler(5);
21932                    }
21933    
21934                    if (getDB().isSupportsInlineDistinct()) {
21935                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21936                    }
21937                    else {
21938                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21939                    }
21940    
21941                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
21942    
21943                    boolean bindArticleId = false;
21944    
21945                    if (articleId == null) {
21946                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
21947                    }
21948                    else if (articleId.equals(StringPool.BLANK)) {
21949                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
21950                    }
21951                    else {
21952                            bindArticleId = true;
21953    
21954                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
21955                    }
21956    
21957                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
21958    
21959                    if (!getDB().isSupportsInlineDistinct()) {
21960                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21961                    }
21962    
21963                    if (orderByComparator != null) {
21964                            if (getDB().isSupportsInlineDistinct()) {
21965                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21966                                            orderByComparator, true);
21967                            }
21968                            else {
21969                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
21970                                            orderByComparator, true);
21971                            }
21972                    }
21973                    else {
21974                            if (getDB().isSupportsInlineDistinct()) {
21975                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21976                            }
21977                            else {
21978                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21979                            }
21980                    }
21981    
21982                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21983                                    JournalArticle.class.getName(),
21984                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21985    
21986                    Session session = null;
21987    
21988                    try {
21989                            session = openSession();
21990    
21991                            SQLQuery q = session.createSQLQuery(sql);
21992    
21993                            if (getDB().isSupportsInlineDistinct()) {
21994                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21995                            }
21996                            else {
21997                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21998                            }
21999    
22000                            QueryPos qPos = QueryPos.getInstance(q);
22001    
22002                            qPos.add(groupId);
22003    
22004                            if (bindArticleId) {
22005                                    qPos.add(articleId);
22006                            }
22007    
22008                            qPos.add(status);
22009    
22010                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22011                                    end);
22012                    }
22013                    catch (Exception e) {
22014                            throw processException(e);
22015                    }
22016                    finally {
22017                            closeSession(session);
22018                    }
22019            }
22020    
22021            /**
22022             * 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;.
22023             *
22024             * @param id the primary key of the current journal article
22025             * @param groupId the group ID
22026             * @param articleId the article ID
22027             * @param status the status
22028             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22029             * @return the previous, current, and next journal article
22030             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
22031             * @throws SystemException if a system exception occurred
22032             */
22033            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
22034                    long groupId, String articleId, int status,
22035                    OrderByComparator orderByComparator)
22036                    throws NoSuchArticleException, SystemException {
22037                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22038                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
22039                                    orderByComparator);
22040                    }
22041    
22042                    JournalArticle journalArticle = findByPrimaryKey(id);
22043    
22044                    Session session = null;
22045    
22046                    try {
22047                            session = openSession();
22048    
22049                            JournalArticle[] array = new JournalArticleImpl[3];
22050    
22051                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
22052                                            groupId, articleId, status, orderByComparator, true);
22053    
22054                            array[1] = journalArticle;
22055    
22056                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
22057                                            groupId, articleId, status, orderByComparator, false);
22058    
22059                            return array;
22060                    }
22061                    catch (Exception e) {
22062                            throw processException(e);
22063                    }
22064                    finally {
22065                            closeSession(session);
22066                    }
22067            }
22068    
22069            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
22070                    JournalArticle journalArticle, long groupId, String articleId,
22071                    int status, OrderByComparator orderByComparator, boolean previous) {
22072                    StringBundler query = null;
22073    
22074                    if (orderByComparator != null) {
22075                            query = new StringBundler(6 +
22076                                            (orderByComparator.getOrderByFields().length * 6));
22077                    }
22078                    else {
22079                            query = new StringBundler(3);
22080                    }
22081    
22082                    if (getDB().isSupportsInlineDistinct()) {
22083                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22084                    }
22085                    else {
22086                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22087                    }
22088    
22089                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
22090    
22091                    boolean bindArticleId = false;
22092    
22093                    if (articleId == null) {
22094                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
22095                    }
22096                    else if (articleId.equals(StringPool.BLANK)) {
22097                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
22098                    }
22099                    else {
22100                            bindArticleId = true;
22101    
22102                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
22103                    }
22104    
22105                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
22106    
22107                    if (!getDB().isSupportsInlineDistinct()) {
22108                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22109                    }
22110    
22111                    if (orderByComparator != null) {
22112                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22113    
22114                            if (orderByConditionFields.length > 0) {
22115                                    query.append(WHERE_AND);
22116                            }
22117    
22118                            for (int i = 0; i < orderByConditionFields.length; i++) {
22119                                    if (getDB().isSupportsInlineDistinct()) {
22120                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22121                                    }
22122                                    else {
22123                                            query.append(_ORDER_BY_ENTITY_TABLE);
22124                                    }
22125    
22126                                    query.append(orderByConditionFields[i]);
22127    
22128                                    if ((i + 1) < orderByConditionFields.length) {
22129                                            if (orderByComparator.isAscending() ^ previous) {
22130                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22131                                            }
22132                                            else {
22133                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22134                                            }
22135                                    }
22136                                    else {
22137                                            if (orderByComparator.isAscending() ^ previous) {
22138                                                    query.append(WHERE_GREATER_THAN);
22139                                            }
22140                                            else {
22141                                                    query.append(WHERE_LESSER_THAN);
22142                                            }
22143                                    }
22144                            }
22145    
22146                            query.append(ORDER_BY_CLAUSE);
22147    
22148                            String[] orderByFields = orderByComparator.getOrderByFields();
22149    
22150                            for (int i = 0; i < orderByFields.length; i++) {
22151                                    if (getDB().isSupportsInlineDistinct()) {
22152                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22153                                    }
22154                                    else {
22155                                            query.append(_ORDER_BY_ENTITY_TABLE);
22156                                    }
22157    
22158                                    query.append(orderByFields[i]);
22159    
22160                                    if ((i + 1) < orderByFields.length) {
22161                                            if (orderByComparator.isAscending() ^ previous) {
22162                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22163                                            }
22164                                            else {
22165                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22166                                            }
22167                                    }
22168                                    else {
22169                                            if (orderByComparator.isAscending() ^ previous) {
22170                                                    query.append(ORDER_BY_ASC);
22171                                            }
22172                                            else {
22173                                                    query.append(ORDER_BY_DESC);
22174                                            }
22175                                    }
22176                            }
22177                    }
22178                    else {
22179                            if (getDB().isSupportsInlineDistinct()) {
22180                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22181                            }
22182                            else {
22183                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22184                            }
22185                    }
22186    
22187                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22188                                    JournalArticle.class.getName(),
22189                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22190    
22191                    SQLQuery q = session.createSQLQuery(sql);
22192    
22193                    q.setFirstResult(0);
22194                    q.setMaxResults(2);
22195    
22196                    if (getDB().isSupportsInlineDistinct()) {
22197                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22198                    }
22199                    else {
22200                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22201                    }
22202    
22203                    QueryPos qPos = QueryPos.getInstance(q);
22204    
22205                    qPos.add(groupId);
22206    
22207                    if (bindArticleId) {
22208                            qPos.add(articleId);
22209                    }
22210    
22211                    qPos.add(status);
22212    
22213                    if (orderByComparator != null) {
22214                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22215    
22216                            for (Object value : values) {
22217                                    qPos.add(value);
22218                            }
22219                    }
22220    
22221                    List<JournalArticle> list = q.list();
22222    
22223                    if (list.size() == 2) {
22224                            return list.get(1);
22225                    }
22226                    else {
22227                            return null;
22228                    }
22229            }
22230    
22231            /**
22232             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
22233             *
22234             * @param groupId the group ID
22235             * @param articleId the article ID
22236             * @param statuses the statuses
22237             * @return the matching journal articles that the user has permission to view
22238             * @throws SystemException if a system exception occurred
22239             */
22240            public List<JournalArticle> filterFindByG_A_ST(long groupId,
22241                    String articleId, int[] statuses) throws SystemException {
22242                    return filterFindByG_A_ST(groupId, articleId, statuses,
22243                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
22244            }
22245    
22246            /**
22247             * 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;.
22248             *
22249             * <p>
22250             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22251             * </p>
22252             *
22253             * @param groupId the group ID
22254             * @param articleId the article ID
22255             * @param statuses the statuses
22256             * @param start the lower bound of the range of journal articles
22257             * @param end the upper bound of the range of journal articles (not inclusive)
22258             * @return the range of matching journal articles that the user has permission to view
22259             * @throws SystemException if a system exception occurred
22260             */
22261            public List<JournalArticle> filterFindByG_A_ST(long groupId,
22262                    String articleId, int[] statuses, int start, int end)
22263                    throws SystemException {
22264                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
22265            }
22266    
22267            /**
22268             * 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;.
22269             *
22270             * <p>
22271             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22272             * </p>
22273             *
22274             * @param groupId the group ID
22275             * @param articleId the article ID
22276             * @param statuses the statuses
22277             * @param start the lower bound of the range of journal articles
22278             * @param end the upper bound of the range of journal articles (not inclusive)
22279             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22280             * @return the ordered range of matching journal articles that the user has permission to view
22281             * @throws SystemException if a system exception occurred
22282             */
22283            public List<JournalArticle> filterFindByG_A_ST(long groupId,
22284                    String articleId, int[] statuses, int start, int end,
22285                    OrderByComparator orderByComparator) throws SystemException {
22286                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22287                            return findByG_A_ST(groupId, articleId, statuses, start, end,
22288                                    orderByComparator);
22289                    }
22290    
22291                    StringBundler query = new StringBundler();
22292    
22293                    if (getDB().isSupportsInlineDistinct()) {
22294                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22295                    }
22296                    else {
22297                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22298                    }
22299    
22300                    boolean conjunctionable = false;
22301    
22302                    if (conjunctionable) {
22303                            query.append(WHERE_AND);
22304                    }
22305    
22306                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
22307    
22308                    conjunctionable = true;
22309    
22310                    if (conjunctionable) {
22311                            query.append(WHERE_AND);
22312                    }
22313    
22314                    if (articleId == null) {
22315                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
22316                    }
22317                    else if (articleId.equals(StringPool.BLANK)) {
22318                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
22319                    }
22320                    else {
22321                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
22322                    }
22323    
22324                    conjunctionable = true;
22325    
22326                    if ((statuses == null) || (statuses.length > 0)) {
22327                            if (conjunctionable) {
22328                                    query.append(WHERE_AND);
22329                            }
22330    
22331                            query.append(StringPool.OPEN_PARENTHESIS);
22332    
22333                            for (int i = 0; i < statuses.length; i++) {
22334                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
22335    
22336                                    if ((i + 1) < statuses.length) {
22337                                            query.append(WHERE_OR);
22338                                    }
22339                            }
22340    
22341                            query.append(StringPool.CLOSE_PARENTHESIS);
22342    
22343                            conjunctionable = true;
22344                    }
22345    
22346                    if (!getDB().isSupportsInlineDistinct()) {
22347                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22348                    }
22349    
22350                    if (orderByComparator != null) {
22351                            if (getDB().isSupportsInlineDistinct()) {
22352                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22353                                            orderByComparator, true);
22354                            }
22355                            else {
22356                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
22357                                            orderByComparator, true);
22358                            }
22359                    }
22360                    else {
22361                            if (getDB().isSupportsInlineDistinct()) {
22362                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22363                            }
22364                            else {
22365                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22366                            }
22367                    }
22368    
22369                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22370                                    JournalArticle.class.getName(),
22371                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22372    
22373                    Session session = null;
22374    
22375                    try {
22376                            session = openSession();
22377    
22378                            SQLQuery q = session.createSQLQuery(sql);
22379    
22380                            if (getDB().isSupportsInlineDistinct()) {
22381                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22382                            }
22383                            else {
22384                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22385                            }
22386    
22387                            QueryPos qPos = QueryPos.getInstance(q);
22388    
22389                            qPos.add(groupId);
22390    
22391                            if (articleId != null) {
22392                                    qPos.add(articleId);
22393                            }
22394    
22395                            if (statuses != null) {
22396                                    qPos.add(statuses);
22397                            }
22398    
22399                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22400                                    end);
22401                    }
22402                    catch (Exception e) {
22403                            throw processException(e);
22404                    }
22405                    finally {
22406                            closeSession(session);
22407                    }
22408            }
22409    
22410            /**
22411             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
22412             *
22413             * <p>
22414             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22415             * </p>
22416             *
22417             * @param groupId the group ID
22418             * @param articleId the article ID
22419             * @param statuses the statuses
22420             * @return the matching journal articles
22421             * @throws SystemException if a system exception occurred
22422             */
22423            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
22424                    int[] statuses) throws SystemException {
22425                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
22426                            QueryUtil.ALL_POS, null);
22427            }
22428    
22429            /**
22430             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
22431             *
22432             * <p>
22433             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22434             * </p>
22435             *
22436             * @param groupId the group ID
22437             * @param articleId the article ID
22438             * @param statuses the statuses
22439             * @param start the lower bound of the range of journal articles
22440             * @param end the upper bound of the range of journal articles (not inclusive)
22441             * @return the range of matching journal articles
22442             * @throws SystemException if a system exception occurred
22443             */
22444            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
22445                    int[] statuses, int start, int end) throws SystemException {
22446                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
22447            }
22448    
22449            /**
22450             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
22451             *
22452             * <p>
22453             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22454             * </p>
22455             *
22456             * @param groupId the group ID
22457             * @param articleId the article ID
22458             * @param statuses the statuses
22459             * @param start the lower bound of the range of journal articles
22460             * @param end the upper bound of the range of journal articles (not inclusive)
22461             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22462             * @return the ordered range of matching journal articles
22463             * @throws SystemException if a system exception occurred
22464             */
22465            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
22466                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
22467                    throws SystemException {
22468                    if ((statuses != null) && (statuses.length == 1)) {
22469                            return findByG_A_ST(groupId, articleId, statuses[0], start, end,
22470                                    orderByComparator);
22471                    }
22472    
22473                    boolean pagination = true;
22474                    Object[] finderArgs = null;
22475    
22476                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22477                                    (orderByComparator == null)) {
22478                            pagination = false;
22479                            finderArgs = new Object[] {
22480                                            groupId, articleId, StringUtil.merge(statuses)
22481                                    };
22482                    }
22483                    else {
22484                            finderArgs = new Object[] {
22485                                            groupId, articleId, StringUtil.merge(statuses),
22486                                            
22487                                            start, end, orderByComparator
22488                                    };
22489                    }
22490    
22491                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
22492                                    finderArgs, this);
22493    
22494                    if ((list != null) && !list.isEmpty()) {
22495                            for (JournalArticle journalArticle : list) {
22496                                    if ((groupId != journalArticle.getGroupId()) ||
22497                                                    !Validator.equals(articleId,
22498                                                            journalArticle.getArticleId()) ||
22499                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
22500                                            list = null;
22501    
22502                                            break;
22503                                    }
22504                            }
22505                    }
22506    
22507                    if (list == null) {
22508                            StringBundler query = new StringBundler();
22509    
22510                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22511    
22512                            boolean conjunctionable = false;
22513    
22514                            if (conjunctionable) {
22515                                    query.append(WHERE_AND);
22516                            }
22517    
22518                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
22519    
22520                            conjunctionable = true;
22521    
22522                            if (conjunctionable) {
22523                                    query.append(WHERE_AND);
22524                            }
22525    
22526                            if (articleId == null) {
22527                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
22528                            }
22529                            else if (articleId.equals(StringPool.BLANK)) {
22530                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
22531                            }
22532                            else {
22533                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
22534                            }
22535    
22536                            conjunctionable = true;
22537    
22538                            if ((statuses == null) || (statuses.length > 0)) {
22539                                    if (conjunctionable) {
22540                                            query.append(WHERE_AND);
22541                                    }
22542    
22543                                    query.append(StringPool.OPEN_PARENTHESIS);
22544    
22545                                    for (int i = 0; i < statuses.length; i++) {
22546                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
22547    
22548                                            if ((i + 1) < statuses.length) {
22549                                                    query.append(WHERE_OR);
22550                                            }
22551                                    }
22552    
22553                                    query.append(StringPool.CLOSE_PARENTHESIS);
22554    
22555                                    conjunctionable = true;
22556                            }
22557    
22558                            if (orderByComparator != null) {
22559                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22560                                            orderByComparator);
22561                            }
22562                            else
22563                             if (pagination) {
22564                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22565                            }
22566    
22567                            String sql = query.toString();
22568    
22569                            Session session = null;
22570    
22571                            try {
22572                                    session = openSession();
22573    
22574                                    Query q = session.createQuery(sql);
22575    
22576                                    QueryPos qPos = QueryPos.getInstance(q);
22577    
22578                                    qPos.add(groupId);
22579    
22580                                    if (articleId != null) {
22581                                            qPos.add(articleId);
22582                                    }
22583    
22584                                    if (statuses != null) {
22585                                            qPos.add(statuses);
22586                                    }
22587    
22588                                    if (!pagination) {
22589                                            list = (List<JournalArticle>)QueryUtil.list(q,
22590                                                            getDialect(), start, end, false);
22591    
22592                                            Collections.sort(list);
22593    
22594                                            list = new UnmodifiableList<JournalArticle>(list);
22595                                    }
22596                                    else {
22597                                            list = (List<JournalArticle>)QueryUtil.list(q,
22598                                                            getDialect(), start, end);
22599                                    }
22600    
22601                                    cacheResult(list);
22602    
22603                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
22604                                            finderArgs, list);
22605                            }
22606                            catch (Exception e) {
22607                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
22608                                            finderArgs);
22609    
22610                                    throw processException(e);
22611                            }
22612                            finally {
22613                                    closeSession(session);
22614                            }
22615                    }
22616    
22617                    return list;
22618            }
22619    
22620            /**
22621             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
22622             *
22623             * @param groupId the group ID
22624             * @param articleId the article ID
22625             * @param status the status
22626             * @throws SystemException if a system exception occurred
22627             */
22628            public void removeByG_A_ST(long groupId, String articleId, int status)
22629                    throws SystemException {
22630                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
22631                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
22632                            remove(journalArticle);
22633                    }
22634            }
22635    
22636            /**
22637             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
22638             *
22639             * @param groupId the group ID
22640             * @param articleId the article ID
22641             * @param status the status
22642             * @return the number of matching journal articles
22643             * @throws SystemException if a system exception occurred
22644             */
22645            public int countByG_A_ST(long groupId, String articleId, int status)
22646                    throws SystemException {
22647                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_ST;
22648    
22649                    Object[] finderArgs = new Object[] { groupId, articleId, status };
22650    
22651                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22652                                    this);
22653    
22654                    if (count == null) {
22655                            StringBundler query = new StringBundler(4);
22656    
22657                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22658    
22659                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
22660    
22661                            boolean bindArticleId = false;
22662    
22663                            if (articleId == null) {
22664                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
22665                            }
22666                            else if (articleId.equals(StringPool.BLANK)) {
22667                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
22668                            }
22669                            else {
22670                                    bindArticleId = true;
22671    
22672                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
22673                            }
22674    
22675                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
22676    
22677                            String sql = query.toString();
22678    
22679                            Session session = null;
22680    
22681                            try {
22682                                    session = openSession();
22683    
22684                                    Query q = session.createQuery(sql);
22685    
22686                                    QueryPos qPos = QueryPos.getInstance(q);
22687    
22688                                    qPos.add(groupId);
22689    
22690                                    if (bindArticleId) {
22691                                            qPos.add(articleId);
22692                                    }
22693    
22694                                    qPos.add(status);
22695    
22696                                    count = (Long)q.uniqueResult();
22697    
22698                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22699                            }
22700                            catch (Exception e) {
22701                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22702    
22703                                    throw processException(e);
22704                            }
22705                            finally {
22706                                    closeSession(session);
22707                            }
22708                    }
22709    
22710                    return count.intValue();
22711            }
22712    
22713            /**
22714             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
22715             *
22716             * @param groupId the group ID
22717             * @param articleId the article ID
22718             * @param statuses the statuses
22719             * @return the number of matching journal articles
22720             * @throws SystemException if a system exception occurred
22721             */
22722            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
22723                    throws SystemException {
22724                    Object[] finderArgs = new Object[] {
22725                                    groupId, articleId, StringUtil.merge(statuses)
22726                            };
22727    
22728                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
22729                                    finderArgs, this);
22730    
22731                    if (count == null) {
22732                            StringBundler query = new StringBundler();
22733    
22734                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22735    
22736                            boolean conjunctionable = false;
22737    
22738                            if (conjunctionable) {
22739                                    query.append(WHERE_AND);
22740                            }
22741    
22742                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
22743    
22744                            conjunctionable = true;
22745    
22746                            if (conjunctionable) {
22747                                    query.append(WHERE_AND);
22748                            }
22749    
22750                            if (articleId == null) {
22751                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
22752                            }
22753                            else if (articleId.equals(StringPool.BLANK)) {
22754                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
22755                            }
22756                            else {
22757                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
22758                            }
22759    
22760                            conjunctionable = true;
22761    
22762                            if ((statuses == null) || (statuses.length > 0)) {
22763                                    if (conjunctionable) {
22764                                            query.append(WHERE_AND);
22765                                    }
22766    
22767                                    query.append(StringPool.OPEN_PARENTHESIS);
22768    
22769                                    for (int i = 0; i < statuses.length; i++) {
22770                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
22771    
22772                                            if ((i + 1) < statuses.length) {
22773                                                    query.append(WHERE_OR);
22774                                            }
22775                                    }
22776    
22777                                    query.append(StringPool.CLOSE_PARENTHESIS);
22778    
22779                                    conjunctionable = true;
22780                            }
22781    
22782                            String sql = query.toString();
22783    
22784                            Session session = null;
22785    
22786                            try {
22787                                    session = openSession();
22788    
22789                                    Query q = session.createQuery(sql);
22790    
22791                                    QueryPos qPos = QueryPos.getInstance(q);
22792    
22793                                    qPos.add(groupId);
22794    
22795                                    if (articleId != null) {
22796                                            qPos.add(articleId);
22797                                    }
22798    
22799                                    if (statuses != null) {
22800                                            qPos.add(statuses);
22801                                    }
22802    
22803                                    count = (Long)q.uniqueResult();
22804    
22805                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
22806                                            finderArgs, count);
22807                            }
22808                            catch (Exception e) {
22809                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
22810                                            finderArgs);
22811    
22812                                    throw processException(e);
22813                            }
22814                            finally {
22815                                    closeSession(session);
22816                            }
22817                    }
22818    
22819                    return count.intValue();
22820            }
22821    
22822            /**
22823             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
22824             *
22825             * @param groupId the group ID
22826             * @param articleId the article ID
22827             * @param status the status
22828             * @return the number of matching journal articles that the user has permission to view
22829             * @throws SystemException if a system exception occurred
22830             */
22831            public int filterCountByG_A_ST(long groupId, String articleId, int status)
22832                    throws SystemException {
22833                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22834                            return countByG_A_ST(groupId, articleId, status);
22835                    }
22836    
22837                    StringBundler query = new StringBundler(4);
22838    
22839                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22840    
22841                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
22842    
22843                    boolean bindArticleId = false;
22844    
22845                    if (articleId == null) {
22846                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
22847                    }
22848                    else if (articleId.equals(StringPool.BLANK)) {
22849                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
22850                    }
22851                    else {
22852                            bindArticleId = true;
22853    
22854                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
22855                    }
22856    
22857                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
22858    
22859                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22860                                    JournalArticle.class.getName(),
22861                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22862    
22863                    Session session = null;
22864    
22865                    try {
22866                            session = openSession();
22867    
22868                            SQLQuery q = session.createSQLQuery(sql);
22869    
22870                            q.addScalar(COUNT_COLUMN_NAME,
22871                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22872    
22873                            QueryPos qPos = QueryPos.getInstance(q);
22874    
22875                            qPos.add(groupId);
22876    
22877                            if (bindArticleId) {
22878                                    qPos.add(articleId);
22879                            }
22880    
22881                            qPos.add(status);
22882    
22883                            Long count = (Long)q.uniqueResult();
22884    
22885                            return count.intValue();
22886                    }
22887                    catch (Exception e) {
22888                            throw processException(e);
22889                    }
22890                    finally {
22891                            closeSession(session);
22892                    }
22893            }
22894    
22895            /**
22896             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
22897             *
22898             * @param groupId the group ID
22899             * @param articleId the article ID
22900             * @param statuses the statuses
22901             * @return the number of matching journal articles that the user has permission to view
22902             * @throws SystemException if a system exception occurred
22903             */
22904            public int filterCountByG_A_ST(long groupId, String articleId,
22905                    int[] statuses) throws SystemException {
22906                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22907                            return countByG_A_ST(groupId, articleId, statuses);
22908                    }
22909    
22910                    StringBundler query = new StringBundler();
22911    
22912                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22913    
22914                    boolean conjunctionable = false;
22915    
22916                    if (conjunctionable) {
22917                            query.append(WHERE_AND);
22918                    }
22919    
22920                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
22921    
22922                    conjunctionable = true;
22923    
22924                    if (conjunctionable) {
22925                            query.append(WHERE_AND);
22926                    }
22927    
22928                    if (articleId == null) {
22929                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
22930                    }
22931                    else if (articleId.equals(StringPool.BLANK)) {
22932                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
22933                    }
22934                    else {
22935                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
22936                    }
22937    
22938                    conjunctionable = true;
22939    
22940                    if ((statuses == null) || (statuses.length > 0)) {
22941                            if (conjunctionable) {
22942                                    query.append(WHERE_AND);
22943                            }
22944    
22945                            query.append(StringPool.OPEN_PARENTHESIS);
22946    
22947                            for (int i = 0; i < statuses.length; i++) {
22948                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
22949    
22950                                    if ((i + 1) < statuses.length) {
22951                                            query.append(WHERE_OR);
22952                                    }
22953                            }
22954    
22955                            query.append(StringPool.CLOSE_PARENTHESIS);
22956    
22957                            conjunctionable = true;
22958                    }
22959    
22960                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22961                                    JournalArticle.class.getName(),
22962                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22963    
22964                    Session session = null;
22965    
22966                    try {
22967                            session = openSession();
22968    
22969                            SQLQuery q = session.createSQLQuery(sql);
22970    
22971                            q.addScalar(COUNT_COLUMN_NAME,
22972                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22973    
22974                            QueryPos qPos = QueryPos.getInstance(q);
22975    
22976                            qPos.add(groupId);
22977    
22978                            if (articleId != null) {
22979                                    qPos.add(articleId);
22980                            }
22981    
22982                            if (statuses != null) {
22983                                    qPos.add(statuses);
22984                            }
22985    
22986                            Long count = (Long)q.uniqueResult();
22987    
22988                            return count.intValue();
22989                    }
22990                    catch (Exception e) {
22991                            throw processException(e);
22992                    }
22993                    finally {
22994                            closeSession(session);
22995                    }
22996            }
22997    
22998            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
22999            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
23000                    removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
23001            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
23002            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
23003            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
23004            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
23005                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
23006            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
23007                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
23008            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
23009                    removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
23010            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
23011            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
23012                    removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
23013            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23014                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23015                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
23016                            "findByG_UT_ST",
23017                            new String[] {
23018                                    Long.class.getName(), String.class.getName(),
23019                                    Integer.class.getName(),
23020                                    
23021                            Integer.class.getName(), Integer.class.getName(),
23022                                    OrderByComparator.class.getName()
23023                            });
23024            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
23025                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23026                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23027                            JournalArticleImpl.class,
23028                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
23029                            new String[] {
23030                                    Long.class.getName(), String.class.getName(),
23031                                    Integer.class.getName()
23032                            },
23033                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
23034                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
23035                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
23036                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
23037                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
23038            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23039                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23040                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
23041                            new String[] {
23042                                    Long.class.getName(), String.class.getName(),
23043                                    Integer.class.getName()
23044                            });
23045    
23046            /**
23047             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23048             *
23049             * @param groupId the group ID
23050             * @param urlTitle the url title
23051             * @param status the status
23052             * @return the matching journal articles
23053             * @throws SystemException if a system exception occurred
23054             */
23055            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
23056                    int status) throws SystemException {
23057                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
23058                            QueryUtil.ALL_POS, null);
23059            }
23060    
23061            /**
23062             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23063             *
23064             * <p>
23065             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23066             * </p>
23067             *
23068             * @param groupId the group ID
23069             * @param urlTitle the url title
23070             * @param status the status
23071             * @param start the lower bound of the range of journal articles
23072             * @param end the upper bound of the range of journal articles (not inclusive)
23073             * @return the range of matching journal articles
23074             * @throws SystemException if a system exception occurred
23075             */
23076            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
23077                    int status, int start, int end) throws SystemException {
23078                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
23079            }
23080    
23081            /**
23082             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23083             *
23084             * <p>
23085             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23086             * </p>
23087             *
23088             * @param groupId the group ID
23089             * @param urlTitle the url title
23090             * @param status the status
23091             * @param start the lower bound of the range of journal articles
23092             * @param end the upper bound of the range of journal articles (not inclusive)
23093             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23094             * @return the ordered range of matching journal articles
23095             * @throws SystemException if a system exception occurred
23096             */
23097            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
23098                    int status, int start, int end, OrderByComparator orderByComparator)
23099                    throws SystemException {
23100                    boolean pagination = true;
23101                    FinderPath finderPath = null;
23102                    Object[] finderArgs = null;
23103    
23104                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23105                                    (orderByComparator == null)) {
23106                            pagination = false;
23107                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
23108                            finderArgs = new Object[] { groupId, urlTitle, status };
23109                    }
23110                    else {
23111                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
23112                            finderArgs = new Object[] {
23113                                            groupId, urlTitle, status,
23114                                            
23115                                            start, end, orderByComparator
23116                                    };
23117                    }
23118    
23119                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
23120                                    finderArgs, this);
23121    
23122                    if ((list != null) && !list.isEmpty()) {
23123                            for (JournalArticle journalArticle : list) {
23124                                    if ((groupId != journalArticle.getGroupId()) ||
23125                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
23126                                                    (status != journalArticle.getStatus())) {
23127                                            list = null;
23128    
23129                                            break;
23130                                    }
23131                            }
23132                    }
23133    
23134                    if (list == null) {
23135                            StringBundler query = null;
23136    
23137                            if (orderByComparator != null) {
23138                                    query = new StringBundler(5 +
23139                                                    (orderByComparator.getOrderByFields().length * 3));
23140                            }
23141                            else {
23142                                    query = new StringBundler(5);
23143                            }
23144    
23145                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23146    
23147                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23148    
23149                            boolean bindUrlTitle = false;
23150    
23151                            if (urlTitle == null) {
23152                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23153                            }
23154                            else if (urlTitle.equals(StringPool.BLANK)) {
23155                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23156                            }
23157                            else {
23158                                    bindUrlTitle = true;
23159    
23160                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23161                            }
23162    
23163                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23164    
23165                            if (orderByComparator != null) {
23166                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23167                                            orderByComparator);
23168                            }
23169                            else
23170                             if (pagination) {
23171                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23172                            }
23173    
23174                            String sql = query.toString();
23175    
23176                            Session session = null;
23177    
23178                            try {
23179                                    session = openSession();
23180    
23181                                    Query q = session.createQuery(sql);
23182    
23183                                    QueryPos qPos = QueryPos.getInstance(q);
23184    
23185                                    qPos.add(groupId);
23186    
23187                                    if (bindUrlTitle) {
23188                                            qPos.add(urlTitle);
23189                                    }
23190    
23191                                    qPos.add(status);
23192    
23193                                    if (!pagination) {
23194                                            list = (List<JournalArticle>)QueryUtil.list(q,
23195                                                            getDialect(), start, end, false);
23196    
23197                                            Collections.sort(list);
23198    
23199                                            list = new UnmodifiableList<JournalArticle>(list);
23200                                    }
23201                                    else {
23202                                            list = (List<JournalArticle>)QueryUtil.list(q,
23203                                                            getDialect(), start, end);
23204                                    }
23205    
23206                                    cacheResult(list);
23207    
23208                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
23209                            }
23210                            catch (Exception e) {
23211                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23212    
23213                                    throw processException(e);
23214                            }
23215                            finally {
23216                                    closeSession(session);
23217                            }
23218                    }
23219    
23220                    return list;
23221            }
23222    
23223            /**
23224             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23225             *
23226             * @param groupId the group ID
23227             * @param urlTitle the url title
23228             * @param status the status
23229             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23230             * @return the first matching journal article
23231             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23232             * @throws SystemException if a system exception occurred
23233             */
23234            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
23235                    int status, OrderByComparator orderByComparator)
23236                    throws NoSuchArticleException, SystemException {
23237                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
23238                                    status, orderByComparator);
23239    
23240                    if (journalArticle != null) {
23241                            return journalArticle;
23242                    }
23243    
23244                    StringBundler msg = new StringBundler(8);
23245    
23246                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23247    
23248                    msg.append("groupId=");
23249                    msg.append(groupId);
23250    
23251                    msg.append(", urlTitle=");
23252                    msg.append(urlTitle);
23253    
23254                    msg.append(", status=");
23255                    msg.append(status);
23256    
23257                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23258    
23259                    throw new NoSuchArticleException(msg.toString());
23260            }
23261    
23262            /**
23263             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23264             *
23265             * @param groupId the group ID
23266             * @param urlTitle the url title
23267             * @param status the status
23268             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23269             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
23270             * @throws SystemException if a system exception occurred
23271             */
23272            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
23273                    int status, OrderByComparator orderByComparator)
23274                    throws SystemException {
23275                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
23276                                    1, orderByComparator);
23277    
23278                    if (!list.isEmpty()) {
23279                            return list.get(0);
23280                    }
23281    
23282                    return null;
23283            }
23284    
23285            /**
23286             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23287             *
23288             * @param groupId the group ID
23289             * @param urlTitle the url title
23290             * @param status the status
23291             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23292             * @return the last matching journal article
23293             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
23294             * @throws SystemException if a system exception occurred
23295             */
23296            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
23297                    int status, OrderByComparator orderByComparator)
23298                    throws NoSuchArticleException, SystemException {
23299                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
23300                                    status, orderByComparator);
23301    
23302                    if (journalArticle != null) {
23303                            return journalArticle;
23304                    }
23305    
23306                    StringBundler msg = new StringBundler(8);
23307    
23308                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23309    
23310                    msg.append("groupId=");
23311                    msg.append(groupId);
23312    
23313                    msg.append(", urlTitle=");
23314                    msg.append(urlTitle);
23315    
23316                    msg.append(", status=");
23317                    msg.append(status);
23318    
23319                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23320    
23321                    throw new NoSuchArticleException(msg.toString());
23322            }
23323    
23324            /**
23325             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23326             *
23327             * @param groupId the group ID
23328             * @param urlTitle the url title
23329             * @param status the status
23330             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23331             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
23332             * @throws SystemException if a system exception occurred
23333             */
23334            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
23335                    int status, OrderByComparator orderByComparator)
23336                    throws SystemException {
23337                    int count = countByG_UT_ST(groupId, urlTitle, status);
23338    
23339                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
23340                                    count - 1, count, orderByComparator);
23341    
23342                    if (!list.isEmpty()) {
23343                            return list.get(0);
23344                    }
23345    
23346                    return null;
23347            }
23348    
23349            /**
23350             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23351             *
23352             * @param id the primary key of the current journal article
23353             * @param groupId the group ID
23354             * @param urlTitle the url title
23355             * @param status the status
23356             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23357             * @return the previous, current, and next journal article
23358             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23359             * @throws SystemException if a system exception occurred
23360             */
23361            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
23362                    String urlTitle, int status, OrderByComparator orderByComparator)
23363                    throws NoSuchArticleException, SystemException {
23364                    JournalArticle journalArticle = findByPrimaryKey(id);
23365    
23366                    Session session = null;
23367    
23368                    try {
23369                            session = openSession();
23370    
23371                            JournalArticle[] array = new JournalArticleImpl[3];
23372    
23373                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
23374                                            groupId, urlTitle, status, orderByComparator, true);
23375    
23376                            array[1] = journalArticle;
23377    
23378                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
23379                                            groupId, urlTitle, status, orderByComparator, false);
23380    
23381                            return array;
23382                    }
23383                    catch (Exception e) {
23384                            throw processException(e);
23385                    }
23386                    finally {
23387                            closeSession(session);
23388                    }
23389            }
23390    
23391            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
23392                    JournalArticle journalArticle, long groupId, String urlTitle,
23393                    int status, OrderByComparator orderByComparator, boolean previous) {
23394                    StringBundler query = null;
23395    
23396                    if (orderByComparator != null) {
23397                            query = new StringBundler(6 +
23398                                            (orderByComparator.getOrderByFields().length * 6));
23399                    }
23400                    else {
23401                            query = new StringBundler(3);
23402                    }
23403    
23404                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23405    
23406                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23407    
23408                    boolean bindUrlTitle = false;
23409    
23410                    if (urlTitle == null) {
23411                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23412                    }
23413                    else if (urlTitle.equals(StringPool.BLANK)) {
23414                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23415                    }
23416                    else {
23417                            bindUrlTitle = true;
23418    
23419                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23420                    }
23421    
23422                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23423    
23424                    if (orderByComparator != null) {
23425                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23426    
23427                            if (orderByConditionFields.length > 0) {
23428                                    query.append(WHERE_AND);
23429                            }
23430    
23431                            for (int i = 0; i < orderByConditionFields.length; i++) {
23432                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23433                                    query.append(orderByConditionFields[i]);
23434    
23435                                    if ((i + 1) < orderByConditionFields.length) {
23436                                            if (orderByComparator.isAscending() ^ previous) {
23437                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23438                                            }
23439                                            else {
23440                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23441                                            }
23442                                    }
23443                                    else {
23444                                            if (orderByComparator.isAscending() ^ previous) {
23445                                                    query.append(WHERE_GREATER_THAN);
23446                                            }
23447                                            else {
23448                                                    query.append(WHERE_LESSER_THAN);
23449                                            }
23450                                    }
23451                            }
23452    
23453                            query.append(ORDER_BY_CLAUSE);
23454    
23455                            String[] orderByFields = orderByComparator.getOrderByFields();
23456    
23457                            for (int i = 0; i < orderByFields.length; i++) {
23458                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23459                                    query.append(orderByFields[i]);
23460    
23461                                    if ((i + 1) < orderByFields.length) {
23462                                            if (orderByComparator.isAscending() ^ previous) {
23463                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23464                                            }
23465                                            else {
23466                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23467                                            }
23468                                    }
23469                                    else {
23470                                            if (orderByComparator.isAscending() ^ previous) {
23471                                                    query.append(ORDER_BY_ASC);
23472                                            }
23473                                            else {
23474                                                    query.append(ORDER_BY_DESC);
23475                                            }
23476                                    }
23477                            }
23478                    }
23479                    else {
23480                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23481                    }
23482    
23483                    String sql = query.toString();
23484    
23485                    Query q = session.createQuery(sql);
23486    
23487                    q.setFirstResult(0);
23488                    q.setMaxResults(2);
23489    
23490                    QueryPos qPos = QueryPos.getInstance(q);
23491    
23492                    qPos.add(groupId);
23493    
23494                    if (bindUrlTitle) {
23495                            qPos.add(urlTitle);
23496                    }
23497    
23498                    qPos.add(status);
23499    
23500                    if (orderByComparator != null) {
23501                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23502    
23503                            for (Object value : values) {
23504                                    qPos.add(value);
23505                            }
23506                    }
23507    
23508                    List<JournalArticle> list = q.list();
23509    
23510                    if (list.size() == 2) {
23511                            return list.get(1);
23512                    }
23513                    else {
23514                            return null;
23515                    }
23516            }
23517    
23518            /**
23519             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23520             *
23521             * @param groupId the group ID
23522             * @param urlTitle the url title
23523             * @param status the status
23524             * @return the matching journal articles that the user has permission to view
23525             * @throws SystemException if a system exception occurred
23526             */
23527            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
23528                    String urlTitle, int status) throws SystemException {
23529                    return filterFindByG_UT_ST(groupId, urlTitle, status,
23530                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
23531            }
23532    
23533            /**
23534             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23535             *
23536             * <p>
23537             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23538             * </p>
23539             *
23540             * @param groupId the group ID
23541             * @param urlTitle the url title
23542             * @param status the status
23543             * @param start the lower bound of the range of journal articles
23544             * @param end the upper bound of the range of journal articles (not inclusive)
23545             * @return the range of matching journal articles that the user has permission to view
23546             * @throws SystemException if a system exception occurred
23547             */
23548            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
23549                    String urlTitle, int status, int start, int end)
23550                    throws SystemException {
23551                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
23552            }
23553    
23554            /**
23555             * 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;.
23556             *
23557             * <p>
23558             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23559             * </p>
23560             *
23561             * @param groupId the group ID
23562             * @param urlTitle the url title
23563             * @param status the status
23564             * @param start the lower bound of the range of journal articles
23565             * @param end the upper bound of the range of journal articles (not inclusive)
23566             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23567             * @return the ordered range of matching journal articles that the user has permission to view
23568             * @throws SystemException if a system exception occurred
23569             */
23570            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
23571                    String urlTitle, int status, int start, int end,
23572                    OrderByComparator orderByComparator) throws SystemException {
23573                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23574                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
23575                                    orderByComparator);
23576                    }
23577    
23578                    StringBundler query = null;
23579    
23580                    if (orderByComparator != null) {
23581                            query = new StringBundler(5 +
23582                                            (orderByComparator.getOrderByFields().length * 3));
23583                    }
23584                    else {
23585                            query = new StringBundler(5);
23586                    }
23587    
23588                    if (getDB().isSupportsInlineDistinct()) {
23589                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23590                    }
23591                    else {
23592                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23593                    }
23594    
23595                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23596    
23597                    boolean bindUrlTitle = false;
23598    
23599                    if (urlTitle == null) {
23600                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23601                    }
23602                    else if (urlTitle.equals(StringPool.BLANK)) {
23603                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23604                    }
23605                    else {
23606                            bindUrlTitle = true;
23607    
23608                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23609                    }
23610    
23611                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23612    
23613                    if (!getDB().isSupportsInlineDistinct()) {
23614                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23615                    }
23616    
23617                    if (orderByComparator != null) {
23618                            if (getDB().isSupportsInlineDistinct()) {
23619                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23620                                            orderByComparator, true);
23621                            }
23622                            else {
23623                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
23624                                            orderByComparator, true);
23625                            }
23626                    }
23627                    else {
23628                            if (getDB().isSupportsInlineDistinct()) {
23629                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23630                            }
23631                            else {
23632                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23633                            }
23634                    }
23635    
23636                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23637                                    JournalArticle.class.getName(),
23638                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23639    
23640                    Session session = null;
23641    
23642                    try {
23643                            session = openSession();
23644    
23645                            SQLQuery q = session.createSQLQuery(sql);
23646    
23647                            if (getDB().isSupportsInlineDistinct()) {
23648                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23649                            }
23650                            else {
23651                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23652                            }
23653    
23654                            QueryPos qPos = QueryPos.getInstance(q);
23655    
23656                            qPos.add(groupId);
23657    
23658                            if (bindUrlTitle) {
23659                                    qPos.add(urlTitle);
23660                            }
23661    
23662                            qPos.add(status);
23663    
23664                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
23665                                    end);
23666                    }
23667                    catch (Exception e) {
23668                            throw processException(e);
23669                    }
23670                    finally {
23671                            closeSession(session);
23672                    }
23673            }
23674    
23675            /**
23676             * 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;.
23677             *
23678             * @param id the primary key of the current journal article
23679             * @param groupId the group ID
23680             * @param urlTitle the url title
23681             * @param status the status
23682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23683             * @return the previous, current, and next journal article
23684             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
23685             * @throws SystemException if a system exception occurred
23686             */
23687            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
23688                    long groupId, String urlTitle, int status,
23689                    OrderByComparator orderByComparator)
23690                    throws NoSuchArticleException, SystemException {
23691                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23692                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
23693                                    orderByComparator);
23694                    }
23695    
23696                    JournalArticle journalArticle = findByPrimaryKey(id);
23697    
23698                    Session session = null;
23699    
23700                    try {
23701                            session = openSession();
23702    
23703                            JournalArticle[] array = new JournalArticleImpl[3];
23704    
23705                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
23706                                            groupId, urlTitle, status, orderByComparator, true);
23707    
23708                            array[1] = journalArticle;
23709    
23710                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
23711                                            groupId, urlTitle, status, orderByComparator, false);
23712    
23713                            return array;
23714                    }
23715                    catch (Exception e) {
23716                            throw processException(e);
23717                    }
23718                    finally {
23719                            closeSession(session);
23720                    }
23721            }
23722    
23723            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
23724                    JournalArticle journalArticle, long groupId, String urlTitle,
23725                    int status, OrderByComparator orderByComparator, boolean previous) {
23726                    StringBundler query = null;
23727    
23728                    if (orderByComparator != null) {
23729                            query = new StringBundler(6 +
23730                                            (orderByComparator.getOrderByFields().length * 6));
23731                    }
23732                    else {
23733                            query = new StringBundler(3);
23734                    }
23735    
23736                    if (getDB().isSupportsInlineDistinct()) {
23737                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23738                    }
23739                    else {
23740                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23741                    }
23742    
23743                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23744    
23745                    boolean bindUrlTitle = false;
23746    
23747                    if (urlTitle == null) {
23748                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23749                    }
23750                    else if (urlTitle.equals(StringPool.BLANK)) {
23751                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23752                    }
23753                    else {
23754                            bindUrlTitle = true;
23755    
23756                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23757                    }
23758    
23759                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23760    
23761                    if (!getDB().isSupportsInlineDistinct()) {
23762                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23763                    }
23764    
23765                    if (orderByComparator != null) {
23766                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23767    
23768                            if (orderByConditionFields.length > 0) {
23769                                    query.append(WHERE_AND);
23770                            }
23771    
23772                            for (int i = 0; i < orderByConditionFields.length; i++) {
23773                                    if (getDB().isSupportsInlineDistinct()) {
23774                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23775                                    }
23776                                    else {
23777                                            query.append(_ORDER_BY_ENTITY_TABLE);
23778                                    }
23779    
23780                                    query.append(orderByConditionFields[i]);
23781    
23782                                    if ((i + 1) < orderByConditionFields.length) {
23783                                            if (orderByComparator.isAscending() ^ previous) {
23784                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23785                                            }
23786                                            else {
23787                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23788                                            }
23789                                    }
23790                                    else {
23791                                            if (orderByComparator.isAscending() ^ previous) {
23792                                                    query.append(WHERE_GREATER_THAN);
23793                                            }
23794                                            else {
23795                                                    query.append(WHERE_LESSER_THAN);
23796                                            }
23797                                    }
23798                            }
23799    
23800                            query.append(ORDER_BY_CLAUSE);
23801    
23802                            String[] orderByFields = orderByComparator.getOrderByFields();
23803    
23804                            for (int i = 0; i < orderByFields.length; i++) {
23805                                    if (getDB().isSupportsInlineDistinct()) {
23806                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23807                                    }
23808                                    else {
23809                                            query.append(_ORDER_BY_ENTITY_TABLE);
23810                                    }
23811    
23812                                    query.append(orderByFields[i]);
23813    
23814                                    if ((i + 1) < orderByFields.length) {
23815                                            if (orderByComparator.isAscending() ^ previous) {
23816                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23817                                            }
23818                                            else {
23819                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23820                                            }
23821                                    }
23822                                    else {
23823                                            if (orderByComparator.isAscending() ^ previous) {
23824                                                    query.append(ORDER_BY_ASC);
23825                                            }
23826                                            else {
23827                                                    query.append(ORDER_BY_DESC);
23828                                            }
23829                                    }
23830                            }
23831                    }
23832                    else {
23833                            if (getDB().isSupportsInlineDistinct()) {
23834                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23835                            }
23836                            else {
23837                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23838                            }
23839                    }
23840    
23841                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23842                                    JournalArticle.class.getName(),
23843                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23844    
23845                    SQLQuery q = session.createSQLQuery(sql);
23846    
23847                    q.setFirstResult(0);
23848                    q.setMaxResults(2);
23849    
23850                    if (getDB().isSupportsInlineDistinct()) {
23851                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23852                    }
23853                    else {
23854                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23855                    }
23856    
23857                    QueryPos qPos = QueryPos.getInstance(q);
23858    
23859                    qPos.add(groupId);
23860    
23861                    if (bindUrlTitle) {
23862                            qPos.add(urlTitle);
23863                    }
23864    
23865                    qPos.add(status);
23866    
23867                    if (orderByComparator != null) {
23868                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23869    
23870                            for (Object value : values) {
23871                                    qPos.add(value);
23872                            }
23873                    }
23874    
23875                    List<JournalArticle> list = q.list();
23876    
23877                    if (list.size() == 2) {
23878                            return list.get(1);
23879                    }
23880                    else {
23881                            return null;
23882                    }
23883            }
23884    
23885            /**
23886             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
23887             *
23888             * @param groupId the group ID
23889             * @param urlTitle the url title
23890             * @param status the status
23891             * @throws SystemException if a system exception occurred
23892             */
23893            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
23894                    throws SystemException {
23895                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
23896                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
23897                            remove(journalArticle);
23898                    }
23899            }
23900    
23901            /**
23902             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23903             *
23904             * @param groupId the group ID
23905             * @param urlTitle the url title
23906             * @param status the status
23907             * @return the number of matching journal articles
23908             * @throws SystemException if a system exception occurred
23909             */
23910            public int countByG_UT_ST(long groupId, String urlTitle, int status)
23911                    throws SystemException {
23912                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT_ST;
23913    
23914                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
23915    
23916                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
23917                                    this);
23918    
23919                    if (count == null) {
23920                            StringBundler query = new StringBundler(4);
23921    
23922                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23923    
23924                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23925    
23926                            boolean bindUrlTitle = false;
23927    
23928                            if (urlTitle == null) {
23929                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23930                            }
23931                            else if (urlTitle.equals(StringPool.BLANK)) {
23932                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23933                            }
23934                            else {
23935                                    bindUrlTitle = true;
23936    
23937                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23938                            }
23939    
23940                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23941    
23942                            String sql = query.toString();
23943    
23944                            Session session = null;
23945    
23946                            try {
23947                                    session = openSession();
23948    
23949                                    Query q = session.createQuery(sql);
23950    
23951                                    QueryPos qPos = QueryPos.getInstance(q);
23952    
23953                                    qPos.add(groupId);
23954    
23955                                    if (bindUrlTitle) {
23956                                            qPos.add(urlTitle);
23957                                    }
23958    
23959                                    qPos.add(status);
23960    
23961                                    count = (Long)q.uniqueResult();
23962    
23963                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23964                            }
23965                            catch (Exception e) {
23966                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23967    
23968                                    throw processException(e);
23969                            }
23970                            finally {
23971                                    closeSession(session);
23972                            }
23973                    }
23974    
23975                    return count.intValue();
23976            }
23977    
23978            /**
23979             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23980             *
23981             * @param groupId the group ID
23982             * @param urlTitle the url title
23983             * @param status the status
23984             * @return the number of matching journal articles that the user has permission to view
23985             * @throws SystemException if a system exception occurred
23986             */
23987            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
23988                    throws SystemException {
23989                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23990                            return countByG_UT_ST(groupId, urlTitle, status);
23991                    }
23992    
23993                    StringBundler query = new StringBundler(4);
23994    
23995                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23996    
23997                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23998    
23999                    boolean bindUrlTitle = false;
24000    
24001                    if (urlTitle == null) {
24002                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
24003                    }
24004                    else if (urlTitle.equals(StringPool.BLANK)) {
24005                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
24006                    }
24007                    else {
24008                            bindUrlTitle = true;
24009    
24010                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
24011                    }
24012    
24013                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
24014    
24015                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24016                                    JournalArticle.class.getName(),
24017                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24018    
24019                    Session session = null;
24020    
24021                    try {
24022                            session = openSession();
24023    
24024                            SQLQuery q = session.createSQLQuery(sql);
24025    
24026                            q.addScalar(COUNT_COLUMN_NAME,
24027                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
24028    
24029                            QueryPos qPos = QueryPos.getInstance(q);
24030    
24031                            qPos.add(groupId);
24032    
24033                            if (bindUrlTitle) {
24034                                    qPos.add(urlTitle);
24035                            }
24036    
24037                            qPos.add(status);
24038    
24039                            Long count = (Long)q.uniqueResult();
24040    
24041                            return count.intValue();
24042                    }
24043                    catch (Exception e) {
24044                            throw processException(e);
24045                    }
24046                    finally {
24047                            closeSession(session);
24048                    }
24049            }
24050    
24051            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
24052            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
24053            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
24054            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '') AND ";
24055            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
24056            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24057                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24058                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
24059                            "findByC_V_ST",
24060                            new String[] {
24061                                    Long.class.getName(), Double.class.getName(),
24062                                    Integer.class.getName(),
24063                                    
24064                            Integer.class.getName(), Integer.class.getName(),
24065                                    OrderByComparator.class.getName()
24066                            });
24067            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
24068                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24069                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24070                            JournalArticleImpl.class,
24071                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
24072                            new String[] {
24073                                    Long.class.getName(), Double.class.getName(),
24074                                    Integer.class.getName()
24075                            },
24076                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
24077                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
24078                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
24079                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
24080            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24081                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24082                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
24083                            new String[] {
24084                                    Long.class.getName(), Double.class.getName(),
24085                                    Integer.class.getName()
24086                            });
24087    
24088            /**
24089             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
24090             *
24091             * @param companyId the company ID
24092             * @param version the version
24093             * @param status the status
24094             * @return the matching journal articles
24095             * @throws SystemException if a system exception occurred
24096             */
24097            public List<JournalArticle> findByC_V_ST(long companyId, double version,
24098                    int status) throws SystemException {
24099                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
24100                            QueryUtil.ALL_POS, null);
24101            }
24102    
24103            /**
24104             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
24105             *
24106             * <p>
24107             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24108             * </p>
24109             *
24110             * @param companyId the company ID
24111             * @param version the version
24112             * @param status the status
24113             * @param start the lower bound of the range of journal articles
24114             * @param end the upper bound of the range of journal articles (not inclusive)
24115             * @return the range of matching journal articles
24116             * @throws SystemException if a system exception occurred
24117             */
24118            public List<JournalArticle> findByC_V_ST(long companyId, double version,
24119                    int status, int start, int end) throws SystemException {
24120                    return findByC_V_ST(companyId, version, status, start, end, null);
24121            }
24122    
24123            /**
24124             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
24125             *
24126             * <p>
24127             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24128             * </p>
24129             *
24130             * @param companyId the company ID
24131             * @param version the version
24132             * @param status the status
24133             * @param start the lower bound of the range of journal articles
24134             * @param end the upper bound of the range of journal articles (not inclusive)
24135             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24136             * @return the ordered range of matching journal articles
24137             * @throws SystemException if a system exception occurred
24138             */
24139            public List<JournalArticle> findByC_V_ST(long companyId, double version,
24140                    int status, int start, int end, OrderByComparator orderByComparator)
24141                    throws SystemException {
24142                    boolean pagination = true;
24143                    FinderPath finderPath = null;
24144                    Object[] finderArgs = null;
24145    
24146                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
24147                                    (orderByComparator == null)) {
24148                            pagination = false;
24149                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
24150                            finderArgs = new Object[] { companyId, version, status };
24151                    }
24152                    else {
24153                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
24154                            finderArgs = new Object[] {
24155                                            companyId, version, status,
24156                                            
24157                                            start, end, orderByComparator
24158                                    };
24159                    }
24160    
24161                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
24162                                    finderArgs, this);
24163    
24164                    if ((list != null) && !list.isEmpty()) {
24165                            for (JournalArticle journalArticle : list) {
24166                                    if ((companyId != journalArticle.getCompanyId()) ||
24167                                                    (version != journalArticle.getVersion()) ||
24168                                                    (status != journalArticle.getStatus())) {
24169                                            list = null;
24170    
24171                                            break;
24172                                    }
24173                            }
24174                    }
24175    
24176                    if (list == null) {
24177                            StringBundler query = null;
24178    
24179                            if (orderByComparator != null) {
24180                                    query = new StringBundler(5 +
24181                                                    (orderByComparator.getOrderByFields().length * 3));
24182                            }
24183                            else {
24184                                    query = new StringBundler(5);
24185                            }
24186    
24187                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24188    
24189                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
24190    
24191                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
24192    
24193                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
24194    
24195                            if (orderByComparator != null) {
24196                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24197                                            orderByComparator);
24198                            }
24199                            else
24200                             if (pagination) {
24201                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24202                            }
24203    
24204                            String sql = query.toString();
24205    
24206                            Session session = null;
24207    
24208                            try {
24209                                    session = openSession();
24210    
24211                                    Query q = session.createQuery(sql);
24212    
24213                                    QueryPos qPos = QueryPos.getInstance(q);
24214    
24215                                    qPos.add(companyId);
24216    
24217                                    qPos.add(version);
24218    
24219                                    qPos.add(status);
24220    
24221                                    if (!pagination) {
24222                                            list = (List<JournalArticle>)QueryUtil.list(q,
24223                                                            getDialect(), start, end, false);
24224    
24225                                            Collections.sort(list);
24226    
24227                                            list = new UnmodifiableList<JournalArticle>(list);
24228                                    }
24229                                    else {
24230                                            list = (List<JournalArticle>)QueryUtil.list(q,
24231                                                            getDialect(), start, end);
24232                                    }
24233    
24234                                    cacheResult(list);
24235    
24236                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
24237                            }
24238                            catch (Exception e) {
24239                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24240    
24241                                    throw processException(e);
24242                            }
24243                            finally {
24244                                    closeSession(session);
24245                            }
24246                    }
24247    
24248                    return list;
24249            }
24250    
24251            /**
24252             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
24253             *
24254             * @param companyId the company ID
24255             * @param version the version
24256             * @param status the status
24257             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24258             * @return the first matching journal article
24259             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24260             * @throws SystemException if a system exception occurred
24261             */
24262            public JournalArticle findByC_V_ST_First(long companyId, double version,
24263                    int status, OrderByComparator orderByComparator)
24264                    throws NoSuchArticleException, SystemException {
24265                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
24266                                    status, orderByComparator);
24267    
24268                    if (journalArticle != null) {
24269                            return journalArticle;
24270                    }
24271    
24272                    StringBundler msg = new StringBundler(8);
24273    
24274                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24275    
24276                    msg.append("companyId=");
24277                    msg.append(companyId);
24278    
24279                    msg.append(", version=");
24280                    msg.append(version);
24281    
24282                    msg.append(", status=");
24283                    msg.append(status);
24284    
24285                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24286    
24287                    throw new NoSuchArticleException(msg.toString());
24288            }
24289    
24290            /**
24291             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
24292             *
24293             * @param companyId the company ID
24294             * @param version the version
24295             * @param status the status
24296             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24297             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
24298             * @throws SystemException if a system exception occurred
24299             */
24300            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
24301                    int status, OrderByComparator orderByComparator)
24302                    throws SystemException {
24303                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
24304                                    1, orderByComparator);
24305    
24306                    if (!list.isEmpty()) {
24307                            return list.get(0);
24308                    }
24309    
24310                    return null;
24311            }
24312    
24313            /**
24314             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
24315             *
24316             * @param companyId the company ID
24317             * @param version the version
24318             * @param status the status
24319             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24320             * @return the last matching journal article
24321             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
24322             * @throws SystemException if a system exception occurred
24323             */
24324            public JournalArticle findByC_V_ST_Last(long companyId, double version,
24325                    int status, OrderByComparator orderByComparator)
24326                    throws NoSuchArticleException, SystemException {
24327                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
24328                                    status, orderByComparator);
24329    
24330                    if (journalArticle != null) {
24331                            return journalArticle;
24332                    }
24333    
24334                    StringBundler msg = new StringBundler(8);
24335    
24336                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24337    
24338                    msg.append("companyId=");
24339                    msg.append(companyId);
24340    
24341                    msg.append(", version=");
24342                    msg.append(version);
24343    
24344                    msg.append(", status=");
24345                    msg.append(status);
24346    
24347                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24348    
24349                    throw new NoSuchArticleException(msg.toString());
24350            }
24351    
24352            /**
24353             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
24354             *
24355             * @param companyId the company ID
24356             * @param version the version
24357             * @param status the status
24358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24359             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
24360             * @throws SystemException if a system exception occurred
24361             */
24362            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
24363                    int status, OrderByComparator orderByComparator)
24364                    throws SystemException {
24365                    int count = countByC_V_ST(companyId, version, status);
24366    
24367                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
24368                                    count - 1, count, orderByComparator);
24369    
24370                    if (!list.isEmpty()) {
24371                            return list.get(0);
24372                    }
24373    
24374                    return null;
24375            }
24376    
24377            /**
24378             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
24379             *
24380             * @param id the primary key of the current journal article
24381             * @param companyId the company ID
24382             * @param version the version
24383             * @param status the status
24384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24385             * @return the previous, current, and next journal article
24386             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24387             * @throws SystemException if a system exception occurred
24388             */
24389            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
24390                    double version, int status, OrderByComparator orderByComparator)
24391                    throws NoSuchArticleException, SystemException {
24392                    JournalArticle journalArticle = findByPrimaryKey(id);
24393    
24394                    Session session = null;
24395    
24396                    try {
24397                            session = openSession();
24398    
24399                            JournalArticle[] array = new JournalArticleImpl[3];
24400    
24401                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
24402                                            companyId, version, status, orderByComparator, true);
24403    
24404                            array[1] = journalArticle;
24405    
24406                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
24407                                            companyId, version, status, orderByComparator, false);
24408    
24409                            return array;
24410                    }
24411                    catch (Exception e) {
24412                            throw processException(e);
24413                    }
24414                    finally {
24415                            closeSession(session);
24416                    }
24417            }
24418    
24419            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
24420                    JournalArticle journalArticle, long companyId, double version,
24421                    int status, OrderByComparator orderByComparator, boolean previous) {
24422                    StringBundler query = null;
24423    
24424                    if (orderByComparator != null) {
24425                            query = new StringBundler(6 +
24426                                            (orderByComparator.getOrderByFields().length * 6));
24427                    }
24428                    else {
24429                            query = new StringBundler(3);
24430                    }
24431    
24432                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24433    
24434                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
24435    
24436                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
24437    
24438                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
24439    
24440                    if (orderByComparator != null) {
24441                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24442    
24443                            if (orderByConditionFields.length > 0) {
24444                                    query.append(WHERE_AND);
24445                            }
24446    
24447                            for (int i = 0; i < orderByConditionFields.length; i++) {
24448                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24449                                    query.append(orderByConditionFields[i]);
24450    
24451                                    if ((i + 1) < orderByConditionFields.length) {
24452                                            if (orderByComparator.isAscending() ^ previous) {
24453                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24454                                            }
24455                                            else {
24456                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24457                                            }
24458                                    }
24459                                    else {
24460                                            if (orderByComparator.isAscending() ^ previous) {
24461                                                    query.append(WHERE_GREATER_THAN);
24462                                            }
24463                                            else {
24464                                                    query.append(WHERE_LESSER_THAN);
24465                                            }
24466                                    }
24467                            }
24468    
24469                            query.append(ORDER_BY_CLAUSE);
24470    
24471                            String[] orderByFields = orderByComparator.getOrderByFields();
24472    
24473                            for (int i = 0; i < orderByFields.length; i++) {
24474                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24475                                    query.append(orderByFields[i]);
24476    
24477                                    if ((i + 1) < orderByFields.length) {
24478                                            if (orderByComparator.isAscending() ^ previous) {
24479                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24480                                            }
24481                                            else {
24482                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24483                                            }
24484                                    }
24485                                    else {
24486                                            if (orderByComparator.isAscending() ^ previous) {
24487                                                    query.append(ORDER_BY_ASC);
24488                                            }
24489                                            else {
24490                                                    query.append(ORDER_BY_DESC);
24491                                            }
24492                                    }
24493                            }
24494                    }
24495                    else {
24496                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24497                    }
24498    
24499                    String sql = query.toString();
24500    
24501                    Query q = session.createQuery(sql);
24502    
24503                    q.setFirstResult(0);
24504                    q.setMaxResults(2);
24505    
24506                    QueryPos qPos = QueryPos.getInstance(q);
24507    
24508                    qPos.add(companyId);
24509    
24510                    qPos.add(version);
24511    
24512                    qPos.add(status);
24513    
24514                    if (orderByComparator != null) {
24515                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24516    
24517                            for (Object value : values) {
24518                                    qPos.add(value);
24519                            }
24520                    }
24521    
24522                    List<JournalArticle> list = q.list();
24523    
24524                    if (list.size() == 2) {
24525                            return list.get(1);
24526                    }
24527                    else {
24528                            return null;
24529                    }
24530            }
24531    
24532            /**
24533             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
24534             *
24535             * @param companyId the company ID
24536             * @param version the version
24537             * @param status the status
24538             * @throws SystemException if a system exception occurred
24539             */
24540            public void removeByC_V_ST(long companyId, double version, int status)
24541                    throws SystemException {
24542                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
24543                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
24544                            remove(journalArticle);
24545                    }
24546            }
24547    
24548            /**
24549             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
24550             *
24551             * @param companyId the company ID
24552             * @param version the version
24553             * @param status the status
24554             * @return the number of matching journal articles
24555             * @throws SystemException if a system exception occurred
24556             */
24557            public int countByC_V_ST(long companyId, double version, int status)
24558                    throws SystemException {
24559                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V_ST;
24560    
24561                    Object[] finderArgs = new Object[] { companyId, version, status };
24562    
24563                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24564                                    this);
24565    
24566                    if (count == null) {
24567                            StringBundler query = new StringBundler(4);
24568    
24569                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24570    
24571                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
24572    
24573                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
24574    
24575                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
24576    
24577                            String sql = query.toString();
24578    
24579                            Session session = null;
24580    
24581                            try {
24582                                    session = openSession();
24583    
24584                                    Query q = session.createQuery(sql);
24585    
24586                                    QueryPos qPos = QueryPos.getInstance(q);
24587    
24588                                    qPos.add(companyId);
24589    
24590                                    qPos.add(version);
24591    
24592                                    qPos.add(status);
24593    
24594                                    count = (Long)q.uniqueResult();
24595    
24596                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24597                            }
24598                            catch (Exception e) {
24599                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24600    
24601                                    throw processException(e);
24602                            }
24603                            finally {
24604                                    closeSession(session);
24605                            }
24606                    }
24607    
24608                    return count.intValue();
24609            }
24610    
24611            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
24612            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
24613            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
24614    
24615            /**
24616             * Caches the journal article in the entity cache if it is enabled.
24617             *
24618             * @param journalArticle the journal article
24619             */
24620            public void cacheResult(JournalArticle journalArticle) {
24621                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24622                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
24623                            journalArticle);
24624    
24625                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
24626                            new Object[] { journalArticle.getUuid(), journalArticle.getGroupId() },
24627                            journalArticle);
24628    
24629                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
24630                            new Object[] {
24631                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
24632                                    journalArticle.getStructureId()
24633                            }, journalArticle);
24634    
24635                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
24636                            new Object[] {
24637                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
24638                                    journalArticle.getVersion()
24639                            }, journalArticle);
24640    
24641                    journalArticle.resetOriginalValues();
24642            }
24643    
24644            /**
24645             * Caches the journal articles in the entity cache if it is enabled.
24646             *
24647             * @param journalArticles the journal articles
24648             */
24649            public void cacheResult(List<JournalArticle> journalArticles) {
24650                    for (JournalArticle journalArticle : journalArticles) {
24651                            if (EntityCacheUtil.getResult(
24652                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24653                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
24654                                    cacheResult(journalArticle);
24655                            }
24656                            else {
24657                                    journalArticle.resetOriginalValues();
24658                            }
24659                    }
24660            }
24661    
24662            /**
24663             * Clears the cache for all journal articles.
24664             *
24665             * <p>
24666             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
24667             * </p>
24668             */
24669            @Override
24670            public void clearCache() {
24671                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
24672                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
24673                    }
24674    
24675                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
24676    
24677                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
24678                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
24679                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
24680            }
24681    
24682            /**
24683             * Clears the cache for the journal article.
24684             *
24685             * <p>
24686             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
24687             * </p>
24688             */
24689            @Override
24690            public void clearCache(JournalArticle journalArticle) {
24691                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24692                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
24693    
24694                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
24695                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
24696    
24697                    clearUniqueFindersCache(journalArticle);
24698            }
24699    
24700            @Override
24701            public void clearCache(List<JournalArticle> journalArticles) {
24702                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
24703                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
24704    
24705                    for (JournalArticle journalArticle : journalArticles) {
24706                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24707                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
24708    
24709                            clearUniqueFindersCache(journalArticle);
24710                    }
24711            }
24712    
24713            protected void cacheUniqueFindersCache(JournalArticle journalArticle) {
24714                    if (journalArticle.isNew()) {
24715                            Object[] args = new Object[] {
24716                                            journalArticle.getUuid(), journalArticle.getGroupId()
24717                                    };
24718    
24719                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
24720                                    Long.valueOf(1));
24721                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
24722                                    journalArticle);
24723    
24724                            args = new Object[] {
24725                                            journalArticle.getGroupId(), journalArticle.getClassNameId(),
24726                                            journalArticle.getStructureId()
24727                                    };
24728    
24729                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
24730                                    Long.valueOf(1));
24731                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
24732                                    journalArticle);
24733    
24734                            args = new Object[] {
24735                                            journalArticle.getGroupId(), journalArticle.getArticleId(),
24736                                            journalArticle.getVersion()
24737                                    };
24738    
24739                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
24740                                    Long.valueOf(1));
24741                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
24742                                    journalArticle);
24743                    }
24744                    else {
24745                            JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
24746    
24747                            if ((journalArticleModelImpl.getColumnBitmask() &
24748                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
24749                                    Object[] args = new Object[] {
24750                                                    journalArticle.getUuid(), journalArticle.getGroupId()
24751                                            };
24752    
24753                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
24754                                            Long.valueOf(1));
24755                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
24756                                            journalArticle);
24757                            }
24758    
24759                            if ((journalArticleModelImpl.getColumnBitmask() &
24760                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
24761                                    Object[] args = new Object[] {
24762                                                    journalArticle.getGroupId(),
24763                                                    journalArticle.getClassNameId(),
24764                                                    journalArticle.getStructureId()
24765                                            };
24766    
24767                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S, args,
24768                                            Long.valueOf(1));
24769                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S, args,
24770                                            journalArticle);
24771                            }
24772    
24773                            if ((journalArticleModelImpl.getColumnBitmask() &
24774                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
24775                                    Object[] args = new Object[] {
24776                                                    journalArticle.getGroupId(),
24777                                                    journalArticle.getArticleId(),
24778                                                    journalArticle.getVersion()
24779                                            };
24780    
24781                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
24782                                            Long.valueOf(1));
24783                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
24784                                            journalArticle);
24785                            }
24786                    }
24787            }
24788    
24789            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
24790                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
24791    
24792                    Object[] args = new Object[] {
24793                                    journalArticle.getUuid(), journalArticle.getGroupId()
24794                            };
24795    
24796                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
24797                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
24798    
24799                    if ((journalArticleModelImpl.getColumnBitmask() &
24800                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
24801                            args = new Object[] {
24802                                            journalArticleModelImpl.getOriginalUuid(),
24803                                            journalArticleModelImpl.getOriginalGroupId()
24804                                    };
24805    
24806                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
24807                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
24808                    }
24809    
24810                    args = new Object[] {
24811                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
24812                                    journalArticle.getStructureId()
24813                            };
24814    
24815                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
24816                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
24817    
24818                    if ((journalArticleModelImpl.getColumnBitmask() &
24819                                    FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
24820                            args = new Object[] {
24821                                            journalArticleModelImpl.getOriginalGroupId(),
24822                                            journalArticleModelImpl.getOriginalClassNameId(),
24823                                            journalArticleModelImpl.getOriginalStructureId()
24824                                    };
24825    
24826                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
24827                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
24828                    }
24829    
24830                    args = new Object[] {
24831                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
24832                                    journalArticle.getVersion()
24833                            };
24834    
24835                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
24836                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
24837    
24838                    if ((journalArticleModelImpl.getColumnBitmask() &
24839                                    FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
24840                            args = new Object[] {
24841                                            journalArticleModelImpl.getOriginalGroupId(),
24842                                            journalArticleModelImpl.getOriginalArticleId(),
24843                                            journalArticleModelImpl.getOriginalVersion()
24844                                    };
24845    
24846                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
24847                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
24848                    }
24849            }
24850    
24851            /**
24852             * Creates a new journal article with the primary key. Does not add the journal article to the database.
24853             *
24854             * @param id the primary key for the new journal article
24855             * @return the new journal article
24856             */
24857            public JournalArticle create(long id) {
24858                    JournalArticle journalArticle = new JournalArticleImpl();
24859    
24860                    journalArticle.setNew(true);
24861                    journalArticle.setPrimaryKey(id);
24862    
24863                    String uuid = PortalUUIDUtil.generate();
24864    
24865                    journalArticle.setUuid(uuid);
24866    
24867                    return journalArticle;
24868            }
24869    
24870            /**
24871             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
24872             *
24873             * @param id the primary key of the journal article
24874             * @return the journal article that was removed
24875             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24876             * @throws SystemException if a system exception occurred
24877             */
24878            public JournalArticle remove(long id)
24879                    throws NoSuchArticleException, SystemException {
24880                    return remove((Serializable)id);
24881            }
24882    
24883            /**
24884             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
24885             *
24886             * @param primaryKey the primary key of the journal article
24887             * @return the journal article that was removed
24888             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
24889             * @throws SystemException if a system exception occurred
24890             */
24891            @Override
24892            public JournalArticle remove(Serializable primaryKey)
24893                    throws NoSuchArticleException, SystemException {
24894                    Session session = null;
24895    
24896                    try {
24897                            session = openSession();
24898    
24899                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
24900                                            primaryKey);
24901    
24902                            if (journalArticle == null) {
24903                                    if (_log.isWarnEnabled()) {
24904                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
24905                                    }
24906    
24907                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
24908                                            primaryKey);
24909                            }
24910    
24911                            return remove(journalArticle);
24912                    }
24913                    catch (NoSuchArticleException nsee) {
24914                            throw nsee;
24915                    }
24916                    catch (Exception e) {
24917                            throw processException(e);
24918                    }
24919                    finally {
24920                            closeSession(session);
24921                    }
24922            }
24923    
24924            @Override
24925            protected JournalArticle removeImpl(JournalArticle journalArticle)
24926                    throws SystemException {
24927                    journalArticle = toUnwrappedModel(journalArticle);
24928    
24929                    Session session = null;
24930    
24931                    try {
24932                            session = openSession();
24933    
24934                            if (!session.contains(journalArticle)) {
24935                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
24936                                                    journalArticle.getPrimaryKeyObj());
24937                            }
24938    
24939                            if (journalArticle != null) {
24940                                    session.delete(journalArticle);
24941                            }
24942                    }
24943                    catch (Exception e) {
24944                            throw processException(e);
24945                    }
24946                    finally {
24947                            closeSession(session);
24948                    }
24949    
24950                    if (journalArticle != null) {
24951                            clearCache(journalArticle);
24952                    }
24953    
24954                    return journalArticle;
24955            }
24956    
24957            @Override
24958            public JournalArticle updateImpl(
24959                    com.liferay.portlet.journal.model.JournalArticle journalArticle)
24960                    throws SystemException {
24961                    journalArticle = toUnwrappedModel(journalArticle);
24962    
24963                    boolean isNew = journalArticle.isNew();
24964    
24965                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
24966    
24967                    if (Validator.isNull(journalArticle.getUuid())) {
24968                            String uuid = PortalUUIDUtil.generate();
24969    
24970                            journalArticle.setUuid(uuid);
24971                    }
24972    
24973                    Session session = null;
24974    
24975                    try {
24976                            session = openSession();
24977    
24978                            if (journalArticle.isNew()) {
24979                                    session.save(journalArticle);
24980    
24981                                    journalArticle.setNew(false);
24982                            }
24983                            else {
24984                                    session.merge(journalArticle);
24985                            }
24986                    }
24987                    catch (Exception e) {
24988                            throw processException(e);
24989                    }
24990                    finally {
24991                            closeSession(session);
24992                    }
24993    
24994                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
24995    
24996                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
24997                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
24998                    }
24999    
25000                    else {
25001                            if ((journalArticleModelImpl.getColumnBitmask() &
25002                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
25003                                    Object[] args = new Object[] {
25004                                                    journalArticleModelImpl.getOriginalUuid()
25005                                            };
25006    
25007                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
25008                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
25009                                            args);
25010    
25011                                    args = new Object[] { journalArticleModelImpl.getUuid() };
25012    
25013                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
25014                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
25015                                            args);
25016                            }
25017    
25018                            if ((journalArticleModelImpl.getColumnBitmask() &
25019                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
25020                                    Object[] args = new Object[] {
25021                                                    journalArticleModelImpl.getOriginalUuid(),
25022                                                    journalArticleModelImpl.getOriginalCompanyId()
25023                                            };
25024    
25025                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
25026                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
25027                                            args);
25028    
25029                                    args = new Object[] {
25030                                                    journalArticleModelImpl.getUuid(),
25031                                                    journalArticleModelImpl.getCompanyId()
25032                                            };
25033    
25034                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
25035                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
25036                                            args);
25037                            }
25038    
25039                            if ((journalArticleModelImpl.getColumnBitmask() &
25040                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
25041                                    Object[] args = new Object[] {
25042                                                    journalArticleModelImpl.getOriginalResourcePrimKey()
25043                                            };
25044    
25045                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
25046                                            args);
25047                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
25048                                            args);
25049    
25050                                    args = new Object[] { journalArticleModelImpl.getResourcePrimKey() };
25051    
25052                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
25053                                            args);
25054                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
25055                                            args);
25056                            }
25057    
25058                            if ((journalArticleModelImpl.getColumnBitmask() &
25059                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
25060                                    Object[] args = new Object[] {
25061                                                    journalArticleModelImpl.getOriginalGroupId()
25062                                            };
25063    
25064                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
25065                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
25066                                            args);
25067    
25068                                    args = new Object[] { journalArticleModelImpl.getGroupId() };
25069    
25070                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
25071                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
25072                                            args);
25073                            }
25074    
25075                            if ((journalArticleModelImpl.getColumnBitmask() &
25076                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
25077                                    Object[] args = new Object[] {
25078                                                    journalArticleModelImpl.getOriginalCompanyId()
25079                                            };
25080    
25081                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
25082                                            args);
25083                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
25084                                            args);
25085    
25086                                    args = new Object[] { journalArticleModelImpl.getCompanyId() };
25087    
25088                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
25089                                            args);
25090                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
25091                                            args);
25092                            }
25093    
25094                            if ((journalArticleModelImpl.getColumnBitmask() &
25095                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
25096                                    Object[] args = new Object[] {
25097                                                    journalArticleModelImpl.getOriginalStructureId()
25098                                            };
25099    
25100                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
25101                                            args);
25102                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
25103                                            args);
25104    
25105                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
25106    
25107                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
25108                                            args);
25109                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
25110                                            args);
25111                            }
25112    
25113                            if ((journalArticleModelImpl.getColumnBitmask() &
25114                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
25115                                    Object[] args = new Object[] {
25116                                                    journalArticleModelImpl.getOriginalTemplateId()
25117                                            };
25118    
25119                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
25120                                            args);
25121                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
25122                                            args);
25123    
25124                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
25125    
25126                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
25127                                            args);
25128                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
25129                                            args);
25130                            }
25131    
25132                            if ((journalArticleModelImpl.getColumnBitmask() &
25133                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
25134                                    Object[] args = new Object[] {
25135                                                    journalArticleModelImpl.getOriginalLayoutUuid()
25136                                            };
25137    
25138                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
25139                                            args);
25140                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
25141                                            args);
25142    
25143                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
25144    
25145                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
25146                                            args);
25147                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
25148                                            args);
25149                            }
25150    
25151                            if ((journalArticleModelImpl.getColumnBitmask() &
25152                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
25153                                    Object[] args = new Object[] {
25154                                                    journalArticleModelImpl.getOriginalSmallImageId()
25155                                            };
25156    
25157                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
25158                                            args);
25159                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
25160                                            args);
25161    
25162                                    args = new Object[] { journalArticleModelImpl.getSmallImageId() };
25163    
25164                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
25165                                            args);
25166                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
25167                                            args);
25168                            }
25169    
25170                            if ((journalArticleModelImpl.getColumnBitmask() &
25171                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
25172                                    Object[] args = new Object[] {
25173                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
25174                                                    journalArticleModelImpl.getOriginalStatus()
25175                                            };
25176    
25177                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
25178                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
25179                                            args);
25180    
25181                                    args = new Object[] {
25182                                                    journalArticleModelImpl.getResourcePrimKey(),
25183                                                    journalArticleModelImpl.getStatus()
25184                                            };
25185    
25186                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
25187                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
25188                                            args);
25189                            }
25190    
25191                            if ((journalArticleModelImpl.getColumnBitmask() &
25192                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
25193                                    Object[] args = new Object[] {
25194                                                    journalArticleModelImpl.getOriginalGroupId(),
25195                                                    journalArticleModelImpl.getOriginalUserId()
25196                                            };
25197    
25198                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
25199                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
25200                                            args);
25201    
25202                                    args = new Object[] {
25203                                                    journalArticleModelImpl.getGroupId(),
25204                                                    journalArticleModelImpl.getUserId()
25205                                            };
25206    
25207                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
25208                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
25209                                            args);
25210                            }
25211    
25212                            if ((journalArticleModelImpl.getColumnBitmask() &
25213                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
25214                                    Object[] args = new Object[] {
25215                                                    journalArticleModelImpl.getOriginalGroupId(),
25216                                                    journalArticleModelImpl.getOriginalFolderId()
25217                                            };
25218    
25219                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
25220                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
25221                                            args);
25222    
25223                                    args = new Object[] {
25224                                                    journalArticleModelImpl.getGroupId(),
25225                                                    journalArticleModelImpl.getFolderId()
25226                                            };
25227    
25228                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
25229                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
25230                                            args);
25231                            }
25232    
25233                            if ((journalArticleModelImpl.getColumnBitmask() &
25234                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
25235                                    Object[] args = new Object[] {
25236                                                    journalArticleModelImpl.getOriginalGroupId(),
25237                                                    journalArticleModelImpl.getOriginalArticleId()
25238                                            };
25239    
25240                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
25241                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
25242                                            args);
25243    
25244                                    args = new Object[] {
25245                                                    journalArticleModelImpl.getGroupId(),
25246                                                    journalArticleModelImpl.getArticleId()
25247                                            };
25248    
25249                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
25250                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
25251                                            args);
25252                            }
25253    
25254                            if ((journalArticleModelImpl.getColumnBitmask() &
25255                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
25256                                    Object[] args = new Object[] {
25257                                                    journalArticleModelImpl.getOriginalGroupId(),
25258                                                    journalArticleModelImpl.getOriginalUrlTitle()
25259                                            };
25260    
25261                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
25262                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
25263                                            args);
25264    
25265                                    args = new Object[] {
25266                                                    journalArticleModelImpl.getGroupId(),
25267                                                    journalArticleModelImpl.getUrlTitle()
25268                                            };
25269    
25270                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
25271                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
25272                                            args);
25273                            }
25274    
25275                            if ((journalArticleModelImpl.getColumnBitmask() &
25276                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
25277                                    Object[] args = new Object[] {
25278                                                    journalArticleModelImpl.getOriginalGroupId(),
25279                                                    journalArticleModelImpl.getOriginalStructureId()
25280                                            };
25281    
25282                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
25283                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
25284                                            args);
25285    
25286                                    args = new Object[] {
25287                                                    journalArticleModelImpl.getGroupId(),
25288                                                    journalArticleModelImpl.getStructureId()
25289                                            };
25290    
25291                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
25292                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
25293                                            args);
25294                            }
25295    
25296                            if ((journalArticleModelImpl.getColumnBitmask() &
25297                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
25298                                    Object[] args = new Object[] {
25299                                                    journalArticleModelImpl.getOriginalGroupId(),
25300                                                    journalArticleModelImpl.getOriginalTemplateId()
25301                                            };
25302    
25303                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
25304                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
25305                                            args);
25306    
25307                                    args = new Object[] {
25308                                                    journalArticleModelImpl.getGroupId(),
25309                                                    journalArticleModelImpl.getTemplateId()
25310                                            };
25311    
25312                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
25313                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
25314                                            args);
25315                            }
25316    
25317                            if ((journalArticleModelImpl.getColumnBitmask() &
25318                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
25319                                    Object[] args = new Object[] {
25320                                                    journalArticleModelImpl.getOriginalGroupId(),
25321                                                    journalArticleModelImpl.getOriginalLayoutUuid()
25322                                            };
25323    
25324                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
25325                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
25326                                            args);
25327    
25328                                    args = new Object[] {
25329                                                    journalArticleModelImpl.getGroupId(),
25330                                                    journalArticleModelImpl.getLayoutUuid()
25331                                            };
25332    
25333                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
25334                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
25335                                            args);
25336                            }
25337    
25338                            if ((journalArticleModelImpl.getColumnBitmask() &
25339                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
25340                                    Object[] args = new Object[] {
25341                                                    journalArticleModelImpl.getOriginalGroupId(),
25342                                                    journalArticleModelImpl.getOriginalStatus()
25343                                            };
25344    
25345                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
25346                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
25347                                            args);
25348    
25349                                    args = new Object[] {
25350                                                    journalArticleModelImpl.getGroupId(),
25351                                                    journalArticleModelImpl.getStatus()
25352                                            };
25353    
25354                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
25355                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
25356                                            args);
25357                            }
25358    
25359                            if ((journalArticleModelImpl.getColumnBitmask() &
25360                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
25361                                    Object[] args = new Object[] {
25362                                                    journalArticleModelImpl.getOriginalCompanyId(),
25363                                                    journalArticleModelImpl.getOriginalVersion()
25364                                            };
25365    
25366                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
25367                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
25368                                            args);
25369    
25370                                    args = new Object[] {
25371                                                    journalArticleModelImpl.getCompanyId(),
25372                                                    journalArticleModelImpl.getVersion()
25373                                            };
25374    
25375                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
25376                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
25377                                            args);
25378                            }
25379    
25380                            if ((journalArticleModelImpl.getColumnBitmask() &
25381                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
25382                                    Object[] args = new Object[] {
25383                                                    journalArticleModelImpl.getOriginalCompanyId(),
25384                                                    journalArticleModelImpl.getOriginalStatus()
25385                                            };
25386    
25387                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
25388                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
25389                                            args);
25390    
25391                                    args = new Object[] {
25392                                                    journalArticleModelImpl.getCompanyId(),
25393                                                    journalArticleModelImpl.getStatus()
25394                                            };
25395    
25396                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
25397                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
25398                                            args);
25399                            }
25400    
25401                            if ((journalArticleModelImpl.getColumnBitmask() &
25402                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
25403                                    Object[] args = new Object[] {
25404                                                    journalArticleModelImpl.getOriginalGroupId(),
25405                                                    journalArticleModelImpl.getOriginalFolderId(),
25406                                                    journalArticleModelImpl.getOriginalStatus()
25407                                            };
25408    
25409                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
25410                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
25411                                            args);
25412    
25413                                    args = new Object[] {
25414                                                    journalArticleModelImpl.getGroupId(),
25415                                                    journalArticleModelImpl.getFolderId(),
25416                                                    journalArticleModelImpl.getStatus()
25417                                            };
25418    
25419                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
25420                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
25421                                            args);
25422                            }
25423    
25424                            if ((journalArticleModelImpl.getColumnBitmask() &
25425                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
25426                                    Object[] args = new Object[] {
25427                                                    journalArticleModelImpl.getOriginalGroupId(),
25428                                                    journalArticleModelImpl.getOriginalClassNameId(),
25429                                                    journalArticleModelImpl.getOriginalClassPK()
25430                                            };
25431    
25432                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
25433                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
25434                                            args);
25435    
25436                                    args = new Object[] {
25437                                                    journalArticleModelImpl.getGroupId(),
25438                                                    journalArticleModelImpl.getClassNameId(),
25439                                                    journalArticleModelImpl.getClassPK()
25440                                            };
25441    
25442                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
25443                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
25444                                            args);
25445                            }
25446    
25447                            if ((journalArticleModelImpl.getColumnBitmask() &
25448                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
25449                                    Object[] args = new Object[] {
25450                                                    journalArticleModelImpl.getOriginalGroupId(),
25451                                                    journalArticleModelImpl.getOriginalClassNameId(),
25452                                                    journalArticleModelImpl.getOriginalTemplateId()
25453                                            };
25454    
25455                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
25456                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
25457                                            args);
25458    
25459                                    args = new Object[] {
25460                                                    journalArticleModelImpl.getGroupId(),
25461                                                    journalArticleModelImpl.getClassNameId(),
25462                                                    journalArticleModelImpl.getTemplateId()
25463                                            };
25464    
25465                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
25466                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
25467                                            args);
25468                            }
25469    
25470                            if ((journalArticleModelImpl.getColumnBitmask() &
25471                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
25472                                    Object[] args = new Object[] {
25473                                                    journalArticleModelImpl.getOriginalGroupId(),
25474                                                    journalArticleModelImpl.getOriginalClassNameId(),
25475                                                    journalArticleModelImpl.getOriginalLayoutUuid()
25476                                            };
25477    
25478                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
25479                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
25480                                            args);
25481    
25482                                    args = new Object[] {
25483                                                    journalArticleModelImpl.getGroupId(),
25484                                                    journalArticleModelImpl.getClassNameId(),
25485                                                    journalArticleModelImpl.getLayoutUuid()
25486                                            };
25487    
25488                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
25489                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
25490                                            args);
25491                            }
25492    
25493                            if ((journalArticleModelImpl.getColumnBitmask() &
25494                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C.getColumnBitmask()) != 0) {
25495                                    Object[] args = new Object[] {
25496                                                    journalArticleModelImpl.getOriginalGroupId(),
25497                                                    journalArticleModelImpl.getOriginalUserId(),
25498                                                    journalArticleModelImpl.getOriginalClassNameId()
25499                                            };
25500    
25501                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
25502                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
25503                                            args);
25504    
25505                                    args = new Object[] {
25506                                                    journalArticleModelImpl.getGroupId(),
25507                                                    journalArticleModelImpl.getUserId(),
25508                                                    journalArticleModelImpl.getClassNameId()
25509                                            };
25510    
25511                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
25512                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
25513                                            args);
25514                            }
25515    
25516                            if ((journalArticleModelImpl.getColumnBitmask() &
25517                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
25518                                    Object[] args = new Object[] {
25519                                                    journalArticleModelImpl.getOriginalGroupId(),
25520                                                    journalArticleModelImpl.getOriginalArticleId(),
25521                                                    journalArticleModelImpl.getOriginalStatus()
25522                                            };
25523    
25524                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
25525                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
25526                                            args);
25527    
25528                                    args = new Object[] {
25529                                                    journalArticleModelImpl.getGroupId(),
25530                                                    journalArticleModelImpl.getArticleId(),
25531                                                    journalArticleModelImpl.getStatus()
25532                                            };
25533    
25534                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
25535                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
25536                                            args);
25537                            }
25538    
25539                            if ((journalArticleModelImpl.getColumnBitmask() &
25540                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
25541                                    Object[] args = new Object[] {
25542                                                    journalArticleModelImpl.getOriginalGroupId(),
25543                                                    journalArticleModelImpl.getOriginalUrlTitle(),
25544                                                    journalArticleModelImpl.getOriginalStatus()
25545                                            };
25546    
25547                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
25548                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
25549                                            args);
25550    
25551                                    args = new Object[] {
25552                                                    journalArticleModelImpl.getGroupId(),
25553                                                    journalArticleModelImpl.getUrlTitle(),
25554                                                    journalArticleModelImpl.getStatus()
25555                                            };
25556    
25557                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
25558                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
25559                                            args);
25560                            }
25561    
25562                            if ((journalArticleModelImpl.getColumnBitmask() &
25563                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
25564                                    Object[] args = new Object[] {
25565                                                    journalArticleModelImpl.getOriginalCompanyId(),
25566                                                    journalArticleModelImpl.getOriginalVersion(),
25567                                                    journalArticleModelImpl.getOriginalStatus()
25568                                            };
25569    
25570                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
25571                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
25572                                            args);
25573    
25574                                    args = new Object[] {
25575                                                    journalArticleModelImpl.getCompanyId(),
25576                                                    journalArticleModelImpl.getVersion(),
25577                                                    journalArticleModelImpl.getStatus()
25578                                            };
25579    
25580                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
25581                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
25582                                            args);
25583                            }
25584                    }
25585    
25586                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25587                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
25588                            journalArticle);
25589    
25590                    clearUniqueFindersCache(journalArticle);
25591                    cacheUniqueFindersCache(journalArticle);
25592    
25593                    return journalArticle;
25594            }
25595    
25596            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
25597                    if (journalArticle instanceof JournalArticleImpl) {
25598                            return journalArticle;
25599                    }
25600    
25601                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
25602    
25603                    journalArticleImpl.setNew(journalArticle.isNew());
25604                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
25605    
25606                    journalArticleImpl.setUuid(journalArticle.getUuid());
25607                    journalArticleImpl.setId(journalArticle.getId());
25608                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
25609                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
25610                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
25611                    journalArticleImpl.setUserId(journalArticle.getUserId());
25612                    journalArticleImpl.setUserName(journalArticle.getUserName());
25613                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
25614                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
25615                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
25616                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
25617                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
25618                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
25619                    journalArticleImpl.setVersion(journalArticle.getVersion());
25620                    journalArticleImpl.setTitle(journalArticle.getTitle());
25621                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
25622                    journalArticleImpl.setDescription(journalArticle.getDescription());
25623                    journalArticleImpl.setContent(journalArticle.getContent());
25624                    journalArticleImpl.setType(journalArticle.getType());
25625                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
25626                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
25627                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
25628                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
25629                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
25630                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
25631                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
25632                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
25633                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
25634                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
25635                    journalArticleImpl.setStatus(journalArticle.getStatus());
25636                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
25637                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
25638                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
25639    
25640                    return journalArticleImpl;
25641            }
25642    
25643            /**
25644             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
25645             *
25646             * @param primaryKey the primary key of the journal article
25647             * @return the journal article
25648             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25649             * @throws SystemException if a system exception occurred
25650             */
25651            @Override
25652            public JournalArticle findByPrimaryKey(Serializable primaryKey)
25653                    throws NoSuchArticleException, SystemException {
25654                    JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
25655    
25656                    if (journalArticle == null) {
25657                            if (_log.isWarnEnabled()) {
25658                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
25659                            }
25660    
25661                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
25662                                    primaryKey);
25663                    }
25664    
25665                    return journalArticle;
25666            }
25667    
25668            /**
25669             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
25670             *
25671             * @param id the primary key of the journal article
25672             * @return the journal article
25673             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
25674             * @throws SystemException if a system exception occurred
25675             */
25676            public JournalArticle findByPrimaryKey(long id)
25677                    throws NoSuchArticleException, SystemException {
25678                    return findByPrimaryKey((Serializable)id);
25679            }
25680    
25681            /**
25682             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
25683             *
25684             * @param primaryKey the primary key of the journal article
25685             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
25686             * @throws SystemException if a system exception occurred
25687             */
25688            @Override
25689            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
25690                    throws SystemException {
25691                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25692                                    JournalArticleImpl.class, primaryKey);
25693    
25694                    if (journalArticle == _nullJournalArticle) {
25695                            return null;
25696                    }
25697    
25698                    if (journalArticle == null) {
25699                            Session session = null;
25700    
25701                            try {
25702                                    session = openSession();
25703    
25704                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
25705                                                    primaryKey);
25706    
25707                                    if (journalArticle != null) {
25708                                            cacheResult(journalArticle);
25709                                    }
25710                                    else {
25711                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25712                                                    JournalArticleImpl.class, primaryKey,
25713                                                    _nullJournalArticle);
25714                                    }
25715                            }
25716                            catch (Exception e) {
25717                                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
25718                                            JournalArticleImpl.class, primaryKey);
25719    
25720                                    throw processException(e);
25721                            }
25722                            finally {
25723                                    closeSession(session);
25724                            }
25725                    }
25726    
25727                    return journalArticle;
25728            }
25729    
25730            /**
25731             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
25732             *
25733             * @param id the primary key of the journal article
25734             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
25735             * @throws SystemException if a system exception occurred
25736             */
25737            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
25738                    return fetchByPrimaryKey((Serializable)id);
25739            }
25740    
25741            /**
25742             * Returns all the journal articles.
25743             *
25744             * @return the journal articles
25745             * @throws SystemException if a system exception occurred
25746             */
25747            public List<JournalArticle> findAll() throws SystemException {
25748                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
25749            }
25750    
25751            /**
25752             * Returns a range of all the journal articles.
25753             *
25754             * <p>
25755             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25756             * </p>
25757             *
25758             * @param start the lower bound of the range of journal articles
25759             * @param end the upper bound of the range of journal articles (not inclusive)
25760             * @return the range of journal articles
25761             * @throws SystemException if a system exception occurred
25762             */
25763            public List<JournalArticle> findAll(int start, int end)
25764                    throws SystemException {
25765                    return findAll(start, end, null);
25766            }
25767    
25768            /**
25769             * Returns an ordered range of all the journal articles.
25770             *
25771             * <p>
25772             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.journal.model.impl.JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25773             * </p>
25774             *
25775             * @param start the lower bound of the range of journal articles
25776             * @param end the upper bound of the range of journal articles (not inclusive)
25777             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25778             * @return the ordered range of journal articles
25779             * @throws SystemException if a system exception occurred
25780             */
25781            public List<JournalArticle> findAll(int start, int end,
25782                    OrderByComparator orderByComparator) throws SystemException {
25783                    boolean pagination = true;
25784                    FinderPath finderPath = null;
25785                    Object[] finderArgs = null;
25786    
25787                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
25788                                    (orderByComparator == null)) {
25789                            pagination = false;
25790                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
25791                            finderArgs = FINDER_ARGS_EMPTY;
25792                    }
25793                    else {
25794                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
25795                            finderArgs = new Object[] { start, end, orderByComparator };
25796                    }
25797    
25798                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
25799                                    finderArgs, this);
25800    
25801                    if (list == null) {
25802                            StringBundler query = null;
25803                            String sql = null;
25804    
25805                            if (orderByComparator != null) {
25806                                    query = new StringBundler(2 +
25807                                                    (orderByComparator.getOrderByFields().length * 3));
25808    
25809                                    query.append(_SQL_SELECT_JOURNALARTICLE);
25810    
25811                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25812                                            orderByComparator);
25813    
25814                                    sql = query.toString();
25815                            }
25816                            else {
25817                                    sql = _SQL_SELECT_JOURNALARTICLE;
25818    
25819                                    if (pagination) {
25820                                            sql = sql.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
25821                                    }
25822                            }
25823    
25824                            Session session = null;
25825    
25826                            try {
25827                                    session = openSession();
25828    
25829                                    Query q = session.createQuery(sql);
25830    
25831                                    if (!pagination) {
25832                                            list = (List<JournalArticle>)QueryUtil.list(q,
25833                                                            getDialect(), start, end, false);
25834    
25835                                            Collections.sort(list);
25836    
25837                                            list = new UnmodifiableList<JournalArticle>(list);
25838                                    }
25839                                    else {
25840                                            list = (List<JournalArticle>)QueryUtil.list(q,
25841                                                            getDialect(), start, end);
25842                                    }
25843    
25844                                    cacheResult(list);
25845    
25846                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
25847                            }
25848                            catch (Exception e) {
25849                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25850    
25851                                    throw processException(e);
25852                            }
25853                            finally {
25854                                    closeSession(session);
25855                            }
25856                    }
25857    
25858                    return list;
25859            }
25860    
25861            /**
25862             * Removes all the journal articles from the database.
25863             *
25864             * @throws SystemException if a system exception occurred
25865             */
25866            public void removeAll() throws SystemException {
25867                    for (JournalArticle journalArticle : findAll()) {
25868                            remove(journalArticle);
25869                    }
25870            }
25871    
25872            /**
25873             * Returns the number of journal articles.
25874             *
25875             * @return the number of journal articles
25876             * @throws SystemException if a system exception occurred
25877             */
25878            public int countAll() throws SystemException {
25879                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
25880                                    FINDER_ARGS_EMPTY, this);
25881    
25882                    if (count == null) {
25883                            Session session = null;
25884    
25885                            try {
25886                                    session = openSession();
25887    
25888                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
25889    
25890                                    count = (Long)q.uniqueResult();
25891    
25892                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
25893                                            FINDER_ARGS_EMPTY, count);
25894                            }
25895                            catch (Exception e) {
25896                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
25897                                            FINDER_ARGS_EMPTY);
25898    
25899                                    throw processException(e);
25900                            }
25901                            finally {
25902                                    closeSession(session);
25903                            }
25904                    }
25905    
25906                    return count.intValue();
25907            }
25908    
25909            @Override
25910            protected Set<String> getBadColumnNames() {
25911                    return _badColumnNames;
25912            }
25913    
25914            /**
25915             * Initializes the journal article persistence.
25916             */
25917            public void afterPropertiesSet() {
25918                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
25919                                            com.liferay.portal.util.PropsUtil.get(
25920                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
25921    
25922                    if (listenerClassNames.length > 0) {
25923                            try {
25924                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
25925    
25926                                    for (String listenerClassName : listenerClassNames) {
25927                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
25928                                                            getClassLoader(), listenerClassName));
25929                                    }
25930    
25931                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
25932                            }
25933                            catch (Exception e) {
25934                                    _log.error(e);
25935                            }
25936                    }
25937            }
25938    
25939            public void destroy() {
25940                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
25941                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
25942                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
25943                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
25944            }
25945    
25946            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
25947            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
25948            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
25949            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
25950            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
25951            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
25952            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
25953                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
25954            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
25955                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
25956            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
25957            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
25958            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
25959            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
25960            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
25961            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
25962            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
25963            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
25964            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
25965            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
25966                                    "uuid", "id", "type"
25967                            });
25968            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
25969                            @Override
25970                            public Object clone() {
25971                                    return this;
25972                            }
25973    
25974                            @Override
25975                            public CacheModel<JournalArticle> toCacheModel() {
25976                                    return _nullJournalArticleCacheModel;
25977                            }
25978                    };
25979    
25980            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
25981                            public JournalArticle toEntityModel() {
25982                                    return _nullJournalArticle;
25983                            }
25984                    };
25985    }