001    /**
002     * Copyright (c) 2000-present 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.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.SQLQuery;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.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.OrderByComparator;
031    import com.liferay.portal.kernel.util.SetUtil;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.StringUtil;
035    import com.liferay.portal.kernel.util.Validator;
036    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
039    import com.liferay.portal.service.ServiceContext;
040    import com.liferay.portal.service.ServiceContextThreadLocal;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import com.liferay.portlet.journal.NoSuchArticleException;
044    import com.liferay.portlet.journal.model.JournalArticle;
045    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
046    import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
047    import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
048    
049    import java.io.Serializable;
050    
051    import java.sql.Timestamp;
052    
053    import java.util.Collections;
054    import java.util.Date;
055    import java.util.HashMap;
056    import java.util.HashSet;
057    import java.util.Iterator;
058    import java.util.List;
059    import java.util.Map;
060    import java.util.Set;
061    
062    /**
063     * The persistence implementation for the journal article service.
064     *
065     * <p>
066     * Caching information and settings can be found in <code>portal.properties</code>
067     * </p>
068     *
069     * @author Brian Wing Shun Chan
070     * @see JournalArticlePersistence
071     * @see com.liferay.portlet.journal.service.persistence.JournalArticleUtil
072     * @generated
073     */
074    @ProviderType
075    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
076            implements JournalArticlePersistence {
077            /*
078             * NOTE FOR DEVELOPERS:
079             *
080             * 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.
081             */
082            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
083            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084                    ".List1";
085            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086                    ".List2";
087            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
088                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
089                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
090                            "findAll", new String[0]);
091            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
092                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
093                            JournalArticleImpl.class,
094                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
095            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
096                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
098            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
099                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
100                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
101                            "findByUuid",
102                            new String[] {
103                                    String.class.getName(),
104                                    
105                            Integer.class.getName(), Integer.class.getName(),
106                                    OrderByComparator.class.getName()
107                            });
108            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
109                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
110                            JournalArticleImpl.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
112                            new String[] { String.class.getName() },
113                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
114                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
115                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
116            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
117                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
118                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
119                            new String[] { String.class.getName() });
120    
121            /**
122             * Returns all the journal articles where uuid = &#63;.
123             *
124             * @param uuid the uuid
125             * @return the matching journal articles
126             */
127            @Override
128            public List<JournalArticle> findByUuid(String uuid) {
129                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
130            }
131    
132            /**
133             * Returns a range of all the journal articles where uuid = &#63;.
134             *
135             * <p>
136             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
137             * </p>
138             *
139             * @param uuid the uuid
140             * @param start the lower bound of the range of journal articles
141             * @param end the upper bound of the range of journal articles (not inclusive)
142             * @return the range of matching journal articles
143             */
144            @Override
145            public List<JournalArticle> findByUuid(String uuid, int start, int end) {
146                    return findByUuid(uuid, start, end, null);
147            }
148    
149            /**
150             * Returns an ordered range of all the journal articles where uuid = &#63;.
151             *
152             * <p>
153             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
154             * </p>
155             *
156             * @param uuid the uuid
157             * @param start the lower bound of the range of journal articles
158             * @param end the upper bound of the range of journal articles (not inclusive)
159             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
160             * @return the ordered range of matching journal articles
161             */
162            @Override
163            public List<JournalArticle> findByUuid(String uuid, int start, int end,
164                    OrderByComparator<JournalArticle> orderByComparator) {
165                    boolean pagination = true;
166                    FinderPath finderPath = null;
167                    Object[] finderArgs = null;
168    
169                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
170                                    (orderByComparator == null)) {
171                            pagination = false;
172                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
173                            finderArgs = new Object[] { uuid };
174                    }
175                    else {
176                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
177                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
178                    }
179    
180                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
181                                    finderArgs, this);
182    
183                    if ((list != null) && !list.isEmpty()) {
184                            for (JournalArticle journalArticle : list) {
185                                    if (!Validator.equals(uuid, journalArticle.getUuid())) {
186                                            list = null;
187    
188                                            break;
189                                    }
190                            }
191                    }
192    
193                    if (list == null) {
194                            StringBundler query = null;
195    
196                            if (orderByComparator != null) {
197                                    query = new StringBundler(3 +
198                                                    (orderByComparator.getOrderByFields().length * 3));
199                            }
200                            else {
201                                    query = new StringBundler(3);
202                            }
203    
204                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
205    
206                            boolean bindUuid = false;
207    
208                            if (uuid == null) {
209                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
210                            }
211                            else if (uuid.equals(StringPool.BLANK)) {
212                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
213                            }
214                            else {
215                                    bindUuid = true;
216    
217                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
218                            }
219    
220                            if (orderByComparator != null) {
221                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
222                                            orderByComparator);
223                            }
224                            else
225                             if (pagination) {
226                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
227                            }
228    
229                            String sql = query.toString();
230    
231                            Session session = null;
232    
233                            try {
234                                    session = openSession();
235    
236                                    Query q = session.createQuery(sql);
237    
238                                    QueryPos qPos = QueryPos.getInstance(q);
239    
240                                    if (bindUuid) {
241                                            qPos.add(uuid);
242                                    }
243    
244                                    if (!pagination) {
245                                            list = (List<JournalArticle>)QueryUtil.list(q,
246                                                            getDialect(), start, end, false);
247    
248                                            Collections.sort(list);
249    
250                                            list = Collections.unmodifiableList(list);
251                                    }
252                                    else {
253                                            list = (List<JournalArticle>)QueryUtil.list(q,
254                                                            getDialect(), start, end);
255                                    }
256    
257                                    cacheResult(list);
258    
259                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
260                            }
261                            catch (Exception e) {
262                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
263    
264                                    throw processException(e);
265                            }
266                            finally {
267                                    closeSession(session);
268                            }
269                    }
270    
271                    return list;
272            }
273    
274            /**
275             * Returns the first journal article in the ordered set where uuid = &#63;.
276             *
277             * @param uuid the uuid
278             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
279             * @return the first matching journal article
280             * @throws NoSuchArticleException if a matching journal article could not be found
281             */
282            @Override
283            public JournalArticle findByUuid_First(String uuid,
284                    OrderByComparator<JournalArticle> orderByComparator)
285                    throws NoSuchArticleException {
286                    JournalArticle journalArticle = fetchByUuid_First(uuid,
287                                    orderByComparator);
288    
289                    if (journalArticle != null) {
290                            return journalArticle;
291                    }
292    
293                    StringBundler msg = new StringBundler(4);
294    
295                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
296    
297                    msg.append("uuid=");
298                    msg.append(uuid);
299    
300                    msg.append(StringPool.CLOSE_CURLY_BRACE);
301    
302                    throw new NoSuchArticleException(msg.toString());
303            }
304    
305            /**
306             * Returns the first journal article in the ordered set where uuid = &#63;.
307             *
308             * @param uuid the uuid
309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
310             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
311             */
312            @Override
313            public JournalArticle fetchByUuid_First(String uuid,
314                    OrderByComparator<JournalArticle> orderByComparator) {
315                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
316    
317                    if (!list.isEmpty()) {
318                            return list.get(0);
319                    }
320    
321                    return null;
322            }
323    
324            /**
325             * Returns the last journal article in the ordered set where uuid = &#63;.
326             *
327             * @param uuid the uuid
328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
329             * @return the last matching journal article
330             * @throws NoSuchArticleException if a matching journal article could not be found
331             */
332            @Override
333            public JournalArticle findByUuid_Last(String uuid,
334                    OrderByComparator<JournalArticle> orderByComparator)
335                    throws NoSuchArticleException {
336                    JournalArticle journalArticle = fetchByUuid_Last(uuid, orderByComparator);
337    
338                    if (journalArticle != null) {
339                            return journalArticle;
340                    }
341    
342                    StringBundler msg = new StringBundler(4);
343    
344                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
345    
346                    msg.append("uuid=");
347                    msg.append(uuid);
348    
349                    msg.append(StringPool.CLOSE_CURLY_BRACE);
350    
351                    throw new NoSuchArticleException(msg.toString());
352            }
353    
354            /**
355             * Returns the last journal article in the ordered set where uuid = &#63;.
356             *
357             * @param uuid the uuid
358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
359             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
360             */
361            @Override
362            public JournalArticle fetchByUuid_Last(String uuid,
363                    OrderByComparator<JournalArticle> orderByComparator) {
364                    int count = countByUuid(uuid);
365    
366                    if (count == 0) {
367                            return null;
368                    }
369    
370                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
371                                    orderByComparator);
372    
373                    if (!list.isEmpty()) {
374                            return list.get(0);
375                    }
376    
377                    return null;
378            }
379    
380            /**
381             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
382             *
383             * @param id the primary key of the current journal article
384             * @param uuid the uuid
385             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
386             * @return the previous, current, and next journal article
387             * @throws NoSuchArticleException if a journal article with the primary key could not be found
388             */
389            @Override
390            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
391                    OrderByComparator<JournalArticle> orderByComparator)
392                    throws NoSuchArticleException {
393                    JournalArticle journalArticle = findByPrimaryKey(id);
394    
395                    Session session = null;
396    
397                    try {
398                            session = openSession();
399    
400                            JournalArticle[] array = new JournalArticleImpl[3];
401    
402                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
403                                            orderByComparator, true);
404    
405                            array[1] = journalArticle;
406    
407                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
408                                            orderByComparator, false);
409    
410                            return array;
411                    }
412                    catch (Exception e) {
413                            throw processException(e);
414                    }
415                    finally {
416                            closeSession(session);
417                    }
418            }
419    
420            protected JournalArticle getByUuid_PrevAndNext(Session session,
421                    JournalArticle journalArticle, String uuid,
422                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
423                    StringBundler query = null;
424    
425                    if (orderByComparator != null) {
426                            query = new StringBundler(6 +
427                                            (orderByComparator.getOrderByFields().length * 6));
428                    }
429                    else {
430                            query = new StringBundler(3);
431                    }
432    
433                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
434    
435                    boolean bindUuid = false;
436    
437                    if (uuid == null) {
438                            query.append(_FINDER_COLUMN_UUID_UUID_1);
439                    }
440                    else if (uuid.equals(StringPool.BLANK)) {
441                            query.append(_FINDER_COLUMN_UUID_UUID_3);
442                    }
443                    else {
444                            bindUuid = true;
445    
446                            query.append(_FINDER_COLUMN_UUID_UUID_2);
447                    }
448    
449                    if (orderByComparator != null) {
450                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
451    
452                            if (orderByConditionFields.length > 0) {
453                                    query.append(WHERE_AND);
454                            }
455    
456                            for (int i = 0; i < orderByConditionFields.length; i++) {
457                                    query.append(_ORDER_BY_ENTITY_ALIAS);
458                                    query.append(orderByConditionFields[i]);
459    
460                                    if ((i + 1) < orderByConditionFields.length) {
461                                            if (orderByComparator.isAscending() ^ previous) {
462                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
463                                            }
464                                            else {
465                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
466                                            }
467                                    }
468                                    else {
469                                            if (orderByComparator.isAscending() ^ previous) {
470                                                    query.append(WHERE_GREATER_THAN);
471                                            }
472                                            else {
473                                                    query.append(WHERE_LESSER_THAN);
474                                            }
475                                    }
476                            }
477    
478                            query.append(ORDER_BY_CLAUSE);
479    
480                            String[] orderByFields = orderByComparator.getOrderByFields();
481    
482                            for (int i = 0; i < orderByFields.length; i++) {
483                                    query.append(_ORDER_BY_ENTITY_ALIAS);
484                                    query.append(orderByFields[i]);
485    
486                                    if ((i + 1) < orderByFields.length) {
487                                            if (orderByComparator.isAscending() ^ previous) {
488                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
489                                            }
490                                            else {
491                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
492                                            }
493                                    }
494                                    else {
495                                            if (orderByComparator.isAscending() ^ previous) {
496                                                    query.append(ORDER_BY_ASC);
497                                            }
498                                            else {
499                                                    query.append(ORDER_BY_DESC);
500                                            }
501                                    }
502                            }
503                    }
504                    else {
505                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
506                    }
507    
508                    String sql = query.toString();
509    
510                    Query q = session.createQuery(sql);
511    
512                    q.setFirstResult(0);
513                    q.setMaxResults(2);
514    
515                    QueryPos qPos = QueryPos.getInstance(q);
516    
517                    if (bindUuid) {
518                            qPos.add(uuid);
519                    }
520    
521                    if (orderByComparator != null) {
522                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
523    
524                            for (Object value : values) {
525                                    qPos.add(value);
526                            }
527                    }
528    
529                    List<JournalArticle> list = q.list();
530    
531                    if (list.size() == 2) {
532                            return list.get(1);
533                    }
534                    else {
535                            return null;
536                    }
537            }
538    
539            /**
540             * Removes all the journal articles where uuid = &#63; from the database.
541             *
542             * @param uuid the uuid
543             */
544            @Override
545            public void removeByUuid(String uuid) {
546                    for (JournalArticle journalArticle : findByUuid(uuid,
547                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
548                            remove(journalArticle);
549                    }
550            }
551    
552            /**
553             * Returns the number of journal articles where uuid = &#63;.
554             *
555             * @param uuid the uuid
556             * @return the number of matching journal articles
557             */
558            @Override
559            public int countByUuid(String uuid) {
560                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
561    
562                    Object[] finderArgs = new Object[] { uuid };
563    
564                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
565                                    this);
566    
567                    if (count == null) {
568                            StringBundler query = new StringBundler(2);
569    
570                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
571    
572                            boolean bindUuid = false;
573    
574                            if (uuid == null) {
575                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
576                            }
577                            else if (uuid.equals(StringPool.BLANK)) {
578                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
579                            }
580                            else {
581                                    bindUuid = true;
582    
583                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
584                            }
585    
586                            String sql = query.toString();
587    
588                            Session session = null;
589    
590                            try {
591                                    session = openSession();
592    
593                                    Query q = session.createQuery(sql);
594    
595                                    QueryPos qPos = QueryPos.getInstance(q);
596    
597                                    if (bindUuid) {
598                                            qPos.add(uuid);
599                                    }
600    
601                                    count = (Long)q.uniqueResult();
602    
603                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
604                            }
605                            catch (Exception e) {
606                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
607    
608                                    throw processException(e);
609                            }
610                            finally {
611                                    closeSession(session);
612                            }
613                    }
614    
615                    return count.intValue();
616            }
617    
618            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
619            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
620            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '')";
621            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
622                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
623                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
624                            "fetchByUUID_G",
625                            new String[] { String.class.getName(), Long.class.getName() },
626                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
627                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
628            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
629                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
630                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
631                            new String[] { String.class.getName(), Long.class.getName() });
632    
633            /**
634             * Returns the journal article where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchArticleException} if it could not be found.
635             *
636             * @param uuid the uuid
637             * @param groupId the group ID
638             * @return the matching journal article
639             * @throws NoSuchArticleException if a matching journal article could not be found
640             */
641            @Override
642            public JournalArticle findByUUID_G(String uuid, long groupId)
643                    throws NoSuchArticleException {
644                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
645    
646                    if (journalArticle == null) {
647                            StringBundler msg = new StringBundler(6);
648    
649                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
650    
651                            msg.append("uuid=");
652                            msg.append(uuid);
653    
654                            msg.append(", groupId=");
655                            msg.append(groupId);
656    
657                            msg.append(StringPool.CLOSE_CURLY_BRACE);
658    
659                            if (_log.isWarnEnabled()) {
660                                    _log.warn(msg.toString());
661                            }
662    
663                            throw new NoSuchArticleException(msg.toString());
664                    }
665    
666                    return journalArticle;
667            }
668    
669            /**
670             * 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.
671             *
672             * @param uuid the uuid
673             * @param groupId the group ID
674             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
675             */
676            @Override
677            public JournalArticle fetchByUUID_G(String uuid, long groupId) {
678                    return fetchByUUID_G(uuid, groupId, true);
679            }
680    
681            /**
682             * 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.
683             *
684             * @param uuid the uuid
685             * @param groupId the group ID
686             * @param retrieveFromCache whether to use the finder cache
687             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
688             */
689            @Override
690            public JournalArticle fetchByUUID_G(String uuid, long groupId,
691                    boolean retrieveFromCache) {
692                    Object[] finderArgs = new Object[] { uuid, groupId };
693    
694                    Object result = null;
695    
696                    if (retrieveFromCache) {
697                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
698                                            finderArgs, this);
699                    }
700    
701                    if (result instanceof JournalArticle) {
702                            JournalArticle journalArticle = (JournalArticle)result;
703    
704                            if (!Validator.equals(uuid, journalArticle.getUuid()) ||
705                                            (groupId != journalArticle.getGroupId())) {
706                                    result = null;
707                            }
708                    }
709    
710                    if (result == null) {
711                            StringBundler query = new StringBundler(4);
712    
713                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
714    
715                            boolean bindUuid = false;
716    
717                            if (uuid == null) {
718                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
719                            }
720                            else if (uuid.equals(StringPool.BLANK)) {
721                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
722                            }
723                            else {
724                                    bindUuid = true;
725    
726                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
727                            }
728    
729                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
730    
731                            String sql = query.toString();
732    
733                            Session session = null;
734    
735                            try {
736                                    session = openSession();
737    
738                                    Query q = session.createQuery(sql);
739    
740                                    QueryPos qPos = QueryPos.getInstance(q);
741    
742                                    if (bindUuid) {
743                                            qPos.add(uuid);
744                                    }
745    
746                                    qPos.add(groupId);
747    
748                                    List<JournalArticle> list = q.list();
749    
750                                    if (list.isEmpty()) {
751                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
752                                                    finderArgs, list);
753                                    }
754                                    else {
755                                            JournalArticle journalArticle = list.get(0);
756    
757                                            result = journalArticle;
758    
759                                            cacheResult(journalArticle);
760    
761                                            if ((journalArticle.getUuid() == null) ||
762                                                            !journalArticle.getUuid().equals(uuid) ||
763                                                            (journalArticle.getGroupId() != groupId)) {
764                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
765                                                            finderArgs, journalArticle);
766                                            }
767                                    }
768                            }
769                            catch (Exception e) {
770                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
771                                            finderArgs);
772    
773                                    throw processException(e);
774                            }
775                            finally {
776                                    closeSession(session);
777                            }
778                    }
779    
780                    if (result instanceof List<?>) {
781                            return null;
782                    }
783                    else {
784                            return (JournalArticle)result;
785                    }
786            }
787    
788            /**
789             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
790             *
791             * @param uuid the uuid
792             * @param groupId the group ID
793             * @return the journal article that was removed
794             */
795            @Override
796            public JournalArticle removeByUUID_G(String uuid, long groupId)
797                    throws NoSuchArticleException {
798                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
799    
800                    return remove(journalArticle);
801            }
802    
803            /**
804             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
805             *
806             * @param uuid the uuid
807             * @param groupId the group ID
808             * @return the number of matching journal articles
809             */
810            @Override
811            public int countByUUID_G(String uuid, long groupId) {
812                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
813    
814                    Object[] finderArgs = new Object[] { uuid, groupId };
815    
816                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
817                                    this);
818    
819                    if (count == null) {
820                            StringBundler query = new StringBundler(3);
821    
822                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
823    
824                            boolean bindUuid = false;
825    
826                            if (uuid == null) {
827                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
828                            }
829                            else if (uuid.equals(StringPool.BLANK)) {
830                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
831                            }
832                            else {
833                                    bindUuid = true;
834    
835                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
836                            }
837    
838                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
839    
840                            String sql = query.toString();
841    
842                            Session session = null;
843    
844                            try {
845                                    session = openSession();
846    
847                                    Query q = session.createQuery(sql);
848    
849                                    QueryPos qPos = QueryPos.getInstance(q);
850    
851                                    if (bindUuid) {
852                                            qPos.add(uuid);
853                                    }
854    
855                                    qPos.add(groupId);
856    
857                                    count = (Long)q.uniqueResult();
858    
859                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
860                            }
861                            catch (Exception e) {
862                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
863    
864                                    throw processException(e);
865                            }
866                            finally {
867                                    closeSession(session);
868                            }
869                    }
870    
871                    return count.intValue();
872            }
873    
874            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
875            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
876            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
877            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
878            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
879                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
880                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
881                            "findByUuid_C",
882                            new String[] {
883                                    String.class.getName(), Long.class.getName(),
884                                    
885                            Integer.class.getName(), Integer.class.getName(),
886                                    OrderByComparator.class.getName()
887                            });
888            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
889                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
890                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
891                            JournalArticleImpl.class,
892                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
893                            new String[] { String.class.getName(), Long.class.getName() },
894                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
895                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
896                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
897                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
898            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
899                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
900                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
901                            new String[] { String.class.getName(), Long.class.getName() });
902    
903            /**
904             * Returns all the journal articles where uuid = &#63; and companyId = &#63;.
905             *
906             * @param uuid the uuid
907             * @param companyId the company ID
908             * @return the matching journal articles
909             */
910            @Override
911            public List<JournalArticle> findByUuid_C(String uuid, long companyId) {
912                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
913                            QueryUtil.ALL_POS, null);
914            }
915    
916            /**
917             * Returns a range of all the journal articles where uuid = &#63; and companyId = &#63;.
918             *
919             * <p>
920             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
921             * </p>
922             *
923             * @param uuid the uuid
924             * @param companyId the company ID
925             * @param start the lower bound of the range of journal articles
926             * @param end the upper bound of the range of journal articles (not inclusive)
927             * @return the range of matching journal articles
928             */
929            @Override
930            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
931                    int start, int end) {
932                    return findByUuid_C(uuid, companyId, start, end, null);
933            }
934    
935            /**
936             * Returns an ordered range of all the journal articles where uuid = &#63; and companyId = &#63;.
937             *
938             * <p>
939             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
940             * </p>
941             *
942             * @param uuid the uuid
943             * @param companyId the company ID
944             * @param start the lower bound of the range of journal articles
945             * @param end the upper bound of the range of journal articles (not inclusive)
946             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
947             * @return the ordered range of matching journal articles
948             */
949            @Override
950            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
951                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
952                    boolean pagination = true;
953                    FinderPath finderPath = null;
954                    Object[] finderArgs = null;
955    
956                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
957                                    (orderByComparator == null)) {
958                            pagination = false;
959                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
960                            finderArgs = new Object[] { uuid, companyId };
961                    }
962                    else {
963                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
964                            finderArgs = new Object[] {
965                                            uuid, companyId,
966                                            
967                                            start, end, orderByComparator
968                                    };
969                    }
970    
971                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
972                                    finderArgs, this);
973    
974                    if ((list != null) && !list.isEmpty()) {
975                            for (JournalArticle journalArticle : list) {
976                                    if (!Validator.equals(uuid, journalArticle.getUuid()) ||
977                                                    (companyId != journalArticle.getCompanyId())) {
978                                            list = null;
979    
980                                            break;
981                                    }
982                            }
983                    }
984    
985                    if (list == null) {
986                            StringBundler query = null;
987    
988                            if (orderByComparator != null) {
989                                    query = new StringBundler(4 +
990                                                    (orderByComparator.getOrderByFields().length * 3));
991                            }
992                            else {
993                                    query = new StringBundler(4);
994                            }
995    
996                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
997    
998                            boolean bindUuid = false;
999    
1000                            if (uuid == null) {
1001                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1002                            }
1003                            else if (uuid.equals(StringPool.BLANK)) {
1004                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1005                            }
1006                            else {
1007                                    bindUuid = true;
1008    
1009                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1010                            }
1011    
1012                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1013    
1014                            if (orderByComparator != null) {
1015                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1016                                            orderByComparator);
1017                            }
1018                            else
1019                             if (pagination) {
1020                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1021                            }
1022    
1023                            String sql = query.toString();
1024    
1025                            Session session = null;
1026    
1027                            try {
1028                                    session = openSession();
1029    
1030                                    Query q = session.createQuery(sql);
1031    
1032                                    QueryPos qPos = QueryPos.getInstance(q);
1033    
1034                                    if (bindUuid) {
1035                                            qPos.add(uuid);
1036                                    }
1037    
1038                                    qPos.add(companyId);
1039    
1040                                    if (!pagination) {
1041                                            list = (List<JournalArticle>)QueryUtil.list(q,
1042                                                            getDialect(), start, end, false);
1043    
1044                                            Collections.sort(list);
1045    
1046                                            list = Collections.unmodifiableList(list);
1047                                    }
1048                                    else {
1049                                            list = (List<JournalArticle>)QueryUtil.list(q,
1050                                                            getDialect(), start, end);
1051                                    }
1052    
1053                                    cacheResult(list);
1054    
1055                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1056                            }
1057                            catch (Exception e) {
1058                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1059    
1060                                    throw processException(e);
1061                            }
1062                            finally {
1063                                    closeSession(session);
1064                            }
1065                    }
1066    
1067                    return list;
1068            }
1069    
1070            /**
1071             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1072             *
1073             * @param uuid the uuid
1074             * @param companyId the company ID
1075             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1076             * @return the first matching journal article
1077             * @throws NoSuchArticleException if a matching journal article could not be found
1078             */
1079            @Override
1080            public JournalArticle findByUuid_C_First(String uuid, long companyId,
1081                    OrderByComparator<JournalArticle> orderByComparator)
1082                    throws NoSuchArticleException {
1083                    JournalArticle journalArticle = fetchByUuid_C_First(uuid, companyId,
1084                                    orderByComparator);
1085    
1086                    if (journalArticle != null) {
1087                            return journalArticle;
1088                    }
1089    
1090                    StringBundler msg = new StringBundler(6);
1091    
1092                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1093    
1094                    msg.append("uuid=");
1095                    msg.append(uuid);
1096    
1097                    msg.append(", companyId=");
1098                    msg.append(companyId);
1099    
1100                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1101    
1102                    throw new NoSuchArticleException(msg.toString());
1103            }
1104    
1105            /**
1106             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1107             *
1108             * @param uuid the uuid
1109             * @param companyId the company ID
1110             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1111             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1112             */
1113            @Override
1114            public JournalArticle fetchByUuid_C_First(String uuid, long companyId,
1115                    OrderByComparator<JournalArticle> orderByComparator) {
1116                    List<JournalArticle> list = findByUuid_C(uuid, companyId, 0, 1,
1117                                    orderByComparator);
1118    
1119                    if (!list.isEmpty()) {
1120                            return list.get(0);
1121                    }
1122    
1123                    return null;
1124            }
1125    
1126            /**
1127             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1128             *
1129             * @param uuid the uuid
1130             * @param companyId the company ID
1131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1132             * @return the last matching journal article
1133             * @throws NoSuchArticleException if a matching journal article could not be found
1134             */
1135            @Override
1136            public JournalArticle findByUuid_C_Last(String uuid, long companyId,
1137                    OrderByComparator<JournalArticle> orderByComparator)
1138                    throws NoSuchArticleException {
1139                    JournalArticle journalArticle = fetchByUuid_C_Last(uuid, companyId,
1140                                    orderByComparator);
1141    
1142                    if (journalArticle != null) {
1143                            return journalArticle;
1144                    }
1145    
1146                    StringBundler msg = new StringBundler(6);
1147    
1148                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1149    
1150                    msg.append("uuid=");
1151                    msg.append(uuid);
1152    
1153                    msg.append(", companyId=");
1154                    msg.append(companyId);
1155    
1156                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1157    
1158                    throw new NoSuchArticleException(msg.toString());
1159            }
1160    
1161            /**
1162             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1163             *
1164             * @param uuid the uuid
1165             * @param companyId the company ID
1166             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1167             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1168             */
1169            @Override
1170            public JournalArticle fetchByUuid_C_Last(String uuid, long companyId,
1171                    OrderByComparator<JournalArticle> orderByComparator) {
1172                    int count = countByUuid_C(uuid, companyId);
1173    
1174                    if (count == 0) {
1175                            return null;
1176                    }
1177    
1178                    List<JournalArticle> list = findByUuid_C(uuid, companyId, count - 1,
1179                                    count, orderByComparator);
1180    
1181                    if (!list.isEmpty()) {
1182                            return list.get(0);
1183                    }
1184    
1185                    return null;
1186            }
1187    
1188            /**
1189             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63; and companyId = &#63;.
1190             *
1191             * @param id the primary key of the current journal article
1192             * @param uuid the uuid
1193             * @param companyId the company ID
1194             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1195             * @return the previous, current, and next journal article
1196             * @throws NoSuchArticleException if a journal article with the primary key could not be found
1197             */
1198            @Override
1199            public JournalArticle[] findByUuid_C_PrevAndNext(long id, String uuid,
1200                    long companyId, OrderByComparator<JournalArticle> orderByComparator)
1201                    throws NoSuchArticleException {
1202                    JournalArticle journalArticle = findByPrimaryKey(id);
1203    
1204                    Session session = null;
1205    
1206                    try {
1207                            session = openSession();
1208    
1209                            JournalArticle[] array = new JournalArticleImpl[3];
1210    
1211                            array[0] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1212                                            companyId, orderByComparator, true);
1213    
1214                            array[1] = journalArticle;
1215    
1216                            array[2] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
1217                                            companyId, orderByComparator, false);
1218    
1219                            return array;
1220                    }
1221                    catch (Exception e) {
1222                            throw processException(e);
1223                    }
1224                    finally {
1225                            closeSession(session);
1226                    }
1227            }
1228    
1229            protected JournalArticle getByUuid_C_PrevAndNext(Session session,
1230                    JournalArticle journalArticle, String uuid, long companyId,
1231                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
1232                    StringBundler query = null;
1233    
1234                    if (orderByComparator != null) {
1235                            query = new StringBundler(6 +
1236                                            (orderByComparator.getOrderByFields().length * 6));
1237                    }
1238                    else {
1239                            query = new StringBundler(3);
1240                    }
1241    
1242                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1243    
1244                    boolean bindUuid = false;
1245    
1246                    if (uuid == null) {
1247                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1248                    }
1249                    else if (uuid.equals(StringPool.BLANK)) {
1250                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1251                    }
1252                    else {
1253                            bindUuid = true;
1254    
1255                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1256                    }
1257    
1258                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1259    
1260                    if (orderByComparator != null) {
1261                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1262    
1263                            if (orderByConditionFields.length > 0) {
1264                                    query.append(WHERE_AND);
1265                            }
1266    
1267                            for (int i = 0; i < orderByConditionFields.length; i++) {
1268                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1269                                    query.append(orderByConditionFields[i]);
1270    
1271                                    if ((i + 1) < orderByConditionFields.length) {
1272                                            if (orderByComparator.isAscending() ^ previous) {
1273                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1274                                            }
1275                                            else {
1276                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1277                                            }
1278                                    }
1279                                    else {
1280                                            if (orderByComparator.isAscending() ^ previous) {
1281                                                    query.append(WHERE_GREATER_THAN);
1282                                            }
1283                                            else {
1284                                                    query.append(WHERE_LESSER_THAN);
1285                                            }
1286                                    }
1287                            }
1288    
1289                            query.append(ORDER_BY_CLAUSE);
1290    
1291                            String[] orderByFields = orderByComparator.getOrderByFields();
1292    
1293                            for (int i = 0; i < orderByFields.length; i++) {
1294                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1295                                    query.append(orderByFields[i]);
1296    
1297                                    if ((i + 1) < orderByFields.length) {
1298                                            if (orderByComparator.isAscending() ^ previous) {
1299                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1300                                            }
1301                                            else {
1302                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1303                                            }
1304                                    }
1305                                    else {
1306                                            if (orderByComparator.isAscending() ^ previous) {
1307                                                    query.append(ORDER_BY_ASC);
1308                                            }
1309                                            else {
1310                                                    query.append(ORDER_BY_DESC);
1311                                            }
1312                                    }
1313                            }
1314                    }
1315                    else {
1316                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1317                    }
1318    
1319                    String sql = query.toString();
1320    
1321                    Query q = session.createQuery(sql);
1322    
1323                    q.setFirstResult(0);
1324                    q.setMaxResults(2);
1325    
1326                    QueryPos qPos = QueryPos.getInstance(q);
1327    
1328                    if (bindUuid) {
1329                            qPos.add(uuid);
1330                    }
1331    
1332                    qPos.add(companyId);
1333    
1334                    if (orderByComparator != null) {
1335                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1336    
1337                            for (Object value : values) {
1338                                    qPos.add(value);
1339                            }
1340                    }
1341    
1342                    List<JournalArticle> list = q.list();
1343    
1344                    if (list.size() == 2) {
1345                            return list.get(1);
1346                    }
1347                    else {
1348                            return null;
1349                    }
1350            }
1351    
1352            /**
1353             * Removes all the journal articles where uuid = &#63; and companyId = &#63; from the database.
1354             *
1355             * @param uuid the uuid
1356             * @param companyId the company ID
1357             */
1358            @Override
1359            public void removeByUuid_C(String uuid, long companyId) {
1360                    for (JournalArticle journalArticle : findByUuid_C(uuid, companyId,
1361                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1362                            remove(journalArticle);
1363                    }
1364            }
1365    
1366            /**
1367             * Returns the number of journal articles where uuid = &#63; and companyId = &#63;.
1368             *
1369             * @param uuid the uuid
1370             * @param companyId the company ID
1371             * @return the number of matching journal articles
1372             */
1373            @Override
1374            public int countByUuid_C(String uuid, long companyId) {
1375                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1376    
1377                    Object[] finderArgs = new Object[] { uuid, companyId };
1378    
1379                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1380                                    this);
1381    
1382                    if (count == null) {
1383                            StringBundler query = new StringBundler(3);
1384    
1385                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1386    
1387                            boolean bindUuid = false;
1388    
1389                            if (uuid == null) {
1390                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1391                            }
1392                            else if (uuid.equals(StringPool.BLANK)) {
1393                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1394                            }
1395                            else {
1396                                    bindUuid = true;
1397    
1398                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1399                            }
1400    
1401                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1402    
1403                            String sql = query.toString();
1404    
1405                            Session session = null;
1406    
1407                            try {
1408                                    session = openSession();
1409    
1410                                    Query q = session.createQuery(sql);
1411    
1412                                    QueryPos qPos = QueryPos.getInstance(q);
1413    
1414                                    if (bindUuid) {
1415                                            qPos.add(uuid);
1416                                    }
1417    
1418                                    qPos.add(companyId);
1419    
1420                                    count = (Long)q.uniqueResult();
1421    
1422                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1423                            }
1424                            catch (Exception e) {
1425                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1426    
1427                                    throw processException(e);
1428                            }
1429                            finally {
1430                                    closeSession(session);
1431                            }
1432                    }
1433    
1434                    return count.intValue();
1435            }
1436    
1437            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalArticle.uuid IS NULL AND ";
1438            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalArticle.uuid = ? AND ";
1439            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = '') AND ";
1440            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalArticle.companyId = ?";
1441            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1442                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1443                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1444                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1445                            "findByResourcePrimKey",
1446                            new String[] {
1447                                    Long.class.getName(),
1448                                    
1449                            Integer.class.getName(), Integer.class.getName(),
1450                                    OrderByComparator.class.getName()
1451                            });
1452            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
1453                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1454                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1455                            JournalArticleImpl.class,
1456                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
1457                            new String[] { Long.class.getName() },
1458                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
1459                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1460                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1461            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1462                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1463                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1464                            "countByResourcePrimKey", new String[] { Long.class.getName() });
1465    
1466            /**
1467             * Returns all the journal articles where resourcePrimKey = &#63;.
1468             *
1469             * @param resourcePrimKey the resource prim key
1470             * @return the matching journal articles
1471             */
1472            @Override
1473            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey) {
1474                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
1475                            QueryUtil.ALL_POS, null);
1476            }
1477    
1478            /**
1479             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
1480             *
1481             * <p>
1482             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1483             * </p>
1484             *
1485             * @param resourcePrimKey the resource prim key
1486             * @param start the lower bound of the range of journal articles
1487             * @param end the upper bound of the range of journal articles (not inclusive)
1488             * @return the range of matching journal articles
1489             */
1490            @Override
1491            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1492                    int start, int end) {
1493                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
1494            }
1495    
1496            /**
1497             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
1498             *
1499             * <p>
1500             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1501             * </p>
1502             *
1503             * @param resourcePrimKey the resource prim key
1504             * @param start the lower bound of the range of journal articles
1505             * @param end the upper bound of the range of journal articles (not inclusive)
1506             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1507             * @return the ordered range of matching journal articles
1508             */
1509            @Override
1510            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1511                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
1512                    boolean pagination = true;
1513                    FinderPath finderPath = null;
1514                    Object[] finderArgs = null;
1515    
1516                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1517                                    (orderByComparator == null)) {
1518                            pagination = false;
1519                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1520                            finderArgs = new Object[] { resourcePrimKey };
1521                    }
1522                    else {
1523                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
1524                            finderArgs = new Object[] {
1525                                            resourcePrimKey,
1526                                            
1527                                            start, end, orderByComparator
1528                                    };
1529                    }
1530    
1531                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1532                                    finderArgs, this);
1533    
1534                    if ((list != null) && !list.isEmpty()) {
1535                            for (JournalArticle journalArticle : list) {
1536                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey())) {
1537                                            list = null;
1538    
1539                                            break;
1540                                    }
1541                            }
1542                    }
1543    
1544                    if (list == null) {
1545                            StringBundler query = null;
1546    
1547                            if (orderByComparator != null) {
1548                                    query = new StringBundler(3 +
1549                                                    (orderByComparator.getOrderByFields().length * 3));
1550                            }
1551                            else {
1552                                    query = new StringBundler(3);
1553                            }
1554    
1555                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1556    
1557                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1558    
1559                            if (orderByComparator != null) {
1560                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1561                                            orderByComparator);
1562                            }
1563                            else
1564                             if (pagination) {
1565                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1566                            }
1567    
1568                            String sql = query.toString();
1569    
1570                            Session session = null;
1571    
1572                            try {
1573                                    session = openSession();
1574    
1575                                    Query q = session.createQuery(sql);
1576    
1577                                    QueryPos qPos = QueryPos.getInstance(q);
1578    
1579                                    qPos.add(resourcePrimKey);
1580    
1581                                    if (!pagination) {
1582                                            list = (List<JournalArticle>)QueryUtil.list(q,
1583                                                            getDialect(), start, end, false);
1584    
1585                                            Collections.sort(list);
1586    
1587                                            list = Collections.unmodifiableList(list);
1588                                    }
1589                                    else {
1590                                            list = (List<JournalArticle>)QueryUtil.list(q,
1591                                                            getDialect(), start, end);
1592                                    }
1593    
1594                                    cacheResult(list);
1595    
1596                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1597                            }
1598                            catch (Exception e) {
1599                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1600    
1601                                    throw processException(e);
1602                            }
1603                            finally {
1604                                    closeSession(session);
1605                            }
1606                    }
1607    
1608                    return list;
1609            }
1610    
1611            /**
1612             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1613             *
1614             * @param resourcePrimKey the resource prim key
1615             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1616             * @return the first matching journal article
1617             * @throws NoSuchArticleException if a matching journal article could not be found
1618             */
1619            @Override
1620            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
1621                    OrderByComparator<JournalArticle> orderByComparator)
1622                    throws NoSuchArticleException {
1623                    JournalArticle journalArticle = fetchByResourcePrimKey_First(resourcePrimKey,
1624                                    orderByComparator);
1625    
1626                    if (journalArticle != null) {
1627                            return journalArticle;
1628                    }
1629    
1630                    StringBundler msg = new StringBundler(4);
1631    
1632                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1633    
1634                    msg.append("resourcePrimKey=");
1635                    msg.append(resourcePrimKey);
1636    
1637                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1638    
1639                    throw new NoSuchArticleException(msg.toString());
1640            }
1641    
1642            /**
1643             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
1644             *
1645             * @param resourcePrimKey the resource prim key
1646             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1647             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1648             */
1649            @Override
1650            public JournalArticle fetchByResourcePrimKey_First(long resourcePrimKey,
1651                    OrderByComparator<JournalArticle> orderByComparator) {
1652                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
1653                                    1, orderByComparator);
1654    
1655                    if (!list.isEmpty()) {
1656                            return list.get(0);
1657                    }
1658    
1659                    return null;
1660            }
1661    
1662            /**
1663             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1664             *
1665             * @param resourcePrimKey the resource prim key
1666             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1667             * @return the last matching journal article
1668             * @throws NoSuchArticleException if a matching journal article could not be found
1669             */
1670            @Override
1671            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
1672                    OrderByComparator<JournalArticle> orderByComparator)
1673                    throws NoSuchArticleException {
1674                    JournalArticle journalArticle = fetchByResourcePrimKey_Last(resourcePrimKey,
1675                                    orderByComparator);
1676    
1677                    if (journalArticle != null) {
1678                            return journalArticle;
1679                    }
1680    
1681                    StringBundler msg = new StringBundler(4);
1682    
1683                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1684    
1685                    msg.append("resourcePrimKey=");
1686                    msg.append(resourcePrimKey);
1687    
1688                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1689    
1690                    throw new NoSuchArticleException(msg.toString());
1691            }
1692    
1693            /**
1694             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
1695             *
1696             * @param resourcePrimKey the resource prim key
1697             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1698             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1699             */
1700            @Override
1701            public JournalArticle fetchByResourcePrimKey_Last(long resourcePrimKey,
1702                    OrderByComparator<JournalArticle> orderByComparator) {
1703                    int count = countByResourcePrimKey(resourcePrimKey);
1704    
1705                    if (count == 0) {
1706                            return null;
1707                    }
1708    
1709                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
1710                                    count - 1, count, orderByComparator);
1711    
1712                    if (!list.isEmpty()) {
1713                            return list.get(0);
1714                    }
1715    
1716                    return null;
1717            }
1718    
1719            /**
1720             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
1721             *
1722             * @param id the primary key of the current journal article
1723             * @param resourcePrimKey the resource prim key
1724             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1725             * @return the previous, current, and next journal article
1726             * @throws NoSuchArticleException if a journal article with the primary key could not be found
1727             */
1728            @Override
1729            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
1730                    long resourcePrimKey,
1731                    OrderByComparator<JournalArticle> orderByComparator)
1732                    throws NoSuchArticleException {
1733                    JournalArticle journalArticle = findByPrimaryKey(id);
1734    
1735                    Session session = null;
1736    
1737                    try {
1738                            session = openSession();
1739    
1740                            JournalArticle[] array = new JournalArticleImpl[3];
1741    
1742                            array[0] = getByResourcePrimKey_PrevAndNext(session,
1743                                            journalArticle, resourcePrimKey, orderByComparator, true);
1744    
1745                            array[1] = journalArticle;
1746    
1747                            array[2] = getByResourcePrimKey_PrevAndNext(session,
1748                                            journalArticle, resourcePrimKey, orderByComparator, false);
1749    
1750                            return array;
1751                    }
1752                    catch (Exception e) {
1753                            throw processException(e);
1754                    }
1755                    finally {
1756                            closeSession(session);
1757                    }
1758            }
1759    
1760            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
1761                    JournalArticle journalArticle, long resourcePrimKey,
1762                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
1763                    StringBundler query = null;
1764    
1765                    if (orderByComparator != null) {
1766                            query = new StringBundler(6 +
1767                                            (orderByComparator.getOrderByFields().length * 6));
1768                    }
1769                    else {
1770                            query = new StringBundler(3);
1771                    }
1772    
1773                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1774    
1775                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1776    
1777                    if (orderByComparator != null) {
1778                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1779    
1780                            if (orderByConditionFields.length > 0) {
1781                                    query.append(WHERE_AND);
1782                            }
1783    
1784                            for (int i = 0; i < orderByConditionFields.length; i++) {
1785                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1786                                    query.append(orderByConditionFields[i]);
1787    
1788                                    if ((i + 1) < orderByConditionFields.length) {
1789                                            if (orderByComparator.isAscending() ^ previous) {
1790                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1791                                            }
1792                                            else {
1793                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1794                                            }
1795                                    }
1796                                    else {
1797                                            if (orderByComparator.isAscending() ^ previous) {
1798                                                    query.append(WHERE_GREATER_THAN);
1799                                            }
1800                                            else {
1801                                                    query.append(WHERE_LESSER_THAN);
1802                                            }
1803                                    }
1804                            }
1805    
1806                            query.append(ORDER_BY_CLAUSE);
1807    
1808                            String[] orderByFields = orderByComparator.getOrderByFields();
1809    
1810                            for (int i = 0; i < orderByFields.length; i++) {
1811                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1812                                    query.append(orderByFields[i]);
1813    
1814                                    if ((i + 1) < orderByFields.length) {
1815                                            if (orderByComparator.isAscending() ^ previous) {
1816                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1817                                            }
1818                                            else {
1819                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1820                                            }
1821                                    }
1822                                    else {
1823                                            if (orderByComparator.isAscending() ^ previous) {
1824                                                    query.append(ORDER_BY_ASC);
1825                                            }
1826                                            else {
1827                                                    query.append(ORDER_BY_DESC);
1828                                            }
1829                                    }
1830                            }
1831                    }
1832                    else {
1833                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1834                    }
1835    
1836                    String sql = query.toString();
1837    
1838                    Query q = session.createQuery(sql);
1839    
1840                    q.setFirstResult(0);
1841                    q.setMaxResults(2);
1842    
1843                    QueryPos qPos = QueryPos.getInstance(q);
1844    
1845                    qPos.add(resourcePrimKey);
1846    
1847                    if (orderByComparator != null) {
1848                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1849    
1850                            for (Object value : values) {
1851                                    qPos.add(value);
1852                            }
1853                    }
1854    
1855                    List<JournalArticle> list = q.list();
1856    
1857                    if (list.size() == 2) {
1858                            return list.get(1);
1859                    }
1860                    else {
1861                            return null;
1862                    }
1863            }
1864    
1865            /**
1866             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
1867             *
1868             * @param resourcePrimKey the resource prim key
1869             */
1870            @Override
1871            public void removeByResourcePrimKey(long resourcePrimKey) {
1872                    for (JournalArticle journalArticle : findByResourcePrimKey(
1873                                    resourcePrimKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1874                            remove(journalArticle);
1875                    }
1876            }
1877    
1878            /**
1879             * Returns the number of journal articles where resourcePrimKey = &#63;.
1880             *
1881             * @param resourcePrimKey the resource prim key
1882             * @return the number of matching journal articles
1883             */
1884            @Override
1885            public int countByResourcePrimKey(long resourcePrimKey) {
1886                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY;
1887    
1888                    Object[] finderArgs = new Object[] { resourcePrimKey };
1889    
1890                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1891                                    this);
1892    
1893                    if (count == null) {
1894                            StringBundler query = new StringBundler(2);
1895    
1896                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
1897    
1898                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1899    
1900                            String sql = query.toString();
1901    
1902                            Session session = null;
1903    
1904                            try {
1905                                    session = openSession();
1906    
1907                                    Query q = session.createQuery(sql);
1908    
1909                                    QueryPos qPos = QueryPos.getInstance(q);
1910    
1911                                    qPos.add(resourcePrimKey);
1912    
1913                                    count = (Long)q.uniqueResult();
1914    
1915                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1916                            }
1917                            catch (Exception e) {
1918                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1919    
1920                                    throw processException(e);
1921                            }
1922                            finally {
1923                                    closeSession(session);
1924                            }
1925                    }
1926    
1927                    return count.intValue();
1928            }
1929    
1930            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
1931                    "journalArticle.resourcePrimKey = ?";
1932            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1933                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1934                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1935                            "findByGroupId",
1936                            new String[] {
1937                                    Long.class.getName(),
1938                                    
1939                            Integer.class.getName(), Integer.class.getName(),
1940                                    OrderByComparator.class.getName()
1941                            });
1942            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1943                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1944                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
1945                            JournalArticleImpl.class,
1946                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1947                            new String[] { Long.class.getName() },
1948                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
1949                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
1950                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
1951            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1952                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
1953                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1954                            new String[] { Long.class.getName() });
1955    
1956            /**
1957             * Returns all the journal articles where groupId = &#63;.
1958             *
1959             * @param groupId the group ID
1960             * @return the matching journal articles
1961             */
1962            @Override
1963            public List<JournalArticle> findByGroupId(long groupId) {
1964                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1965            }
1966    
1967            /**
1968             * Returns a range of all the journal articles where groupId = &#63;.
1969             *
1970             * <p>
1971             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1972             * </p>
1973             *
1974             * @param groupId the group ID
1975             * @param start the lower bound of the range of journal articles
1976             * @param end the upper bound of the range of journal articles (not inclusive)
1977             * @return the range of matching journal articles
1978             */
1979            @Override
1980            public List<JournalArticle> findByGroupId(long groupId, int start, int end) {
1981                    return findByGroupId(groupId, start, end, null);
1982            }
1983    
1984            /**
1985             * Returns an ordered range of all the journal articles where groupId = &#63;.
1986             *
1987             * <p>
1988             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1989             * </p>
1990             *
1991             * @param groupId the group ID
1992             * @param start the lower bound of the range of journal articles
1993             * @param end the upper bound of the range of journal articles (not inclusive)
1994             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1995             * @return the ordered range of matching journal articles
1996             */
1997            @Override
1998            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
1999                    OrderByComparator<JournalArticle> orderByComparator) {
2000                    boolean pagination = true;
2001                    FinderPath finderPath = null;
2002                    Object[] finderArgs = null;
2003    
2004                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2005                                    (orderByComparator == null)) {
2006                            pagination = false;
2007                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2008                            finderArgs = new Object[] { groupId };
2009                    }
2010                    else {
2011                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2012                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2013                    }
2014    
2015                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2016                                    finderArgs, this);
2017    
2018                    if ((list != null) && !list.isEmpty()) {
2019                            for (JournalArticle journalArticle : list) {
2020                                    if ((groupId != journalArticle.getGroupId())) {
2021                                            list = null;
2022    
2023                                            break;
2024                                    }
2025                            }
2026                    }
2027    
2028                    if (list == null) {
2029                            StringBundler query = null;
2030    
2031                            if (orderByComparator != null) {
2032                                    query = new StringBundler(3 +
2033                                                    (orderByComparator.getOrderByFields().length * 3));
2034                            }
2035                            else {
2036                                    query = new StringBundler(3);
2037                            }
2038    
2039                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2040    
2041                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2042    
2043                            if (orderByComparator != null) {
2044                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2045                                            orderByComparator);
2046                            }
2047                            else
2048                             if (pagination) {
2049                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2050                            }
2051    
2052                            String sql = query.toString();
2053    
2054                            Session session = null;
2055    
2056                            try {
2057                                    session = openSession();
2058    
2059                                    Query q = session.createQuery(sql);
2060    
2061                                    QueryPos qPos = QueryPos.getInstance(q);
2062    
2063                                    qPos.add(groupId);
2064    
2065                                    if (!pagination) {
2066                                            list = (List<JournalArticle>)QueryUtil.list(q,
2067                                                            getDialect(), start, end, false);
2068    
2069                                            Collections.sort(list);
2070    
2071                                            list = Collections.unmodifiableList(list);
2072                                    }
2073                                    else {
2074                                            list = (List<JournalArticle>)QueryUtil.list(q,
2075                                                            getDialect(), start, end);
2076                                    }
2077    
2078                                    cacheResult(list);
2079    
2080                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2081                            }
2082                            catch (Exception e) {
2083                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2084    
2085                                    throw processException(e);
2086                            }
2087                            finally {
2088                                    closeSession(session);
2089                            }
2090                    }
2091    
2092                    return list;
2093            }
2094    
2095            /**
2096             * Returns the first journal article in the ordered set where groupId = &#63;.
2097             *
2098             * @param groupId the group ID
2099             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2100             * @return the first matching journal article
2101             * @throws NoSuchArticleException if a matching journal article could not be found
2102             */
2103            @Override
2104            public JournalArticle findByGroupId_First(long groupId,
2105                    OrderByComparator<JournalArticle> orderByComparator)
2106                    throws NoSuchArticleException {
2107                    JournalArticle journalArticle = fetchByGroupId_First(groupId,
2108                                    orderByComparator);
2109    
2110                    if (journalArticle != null) {
2111                            return journalArticle;
2112                    }
2113    
2114                    StringBundler msg = new StringBundler(4);
2115    
2116                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2117    
2118                    msg.append("groupId=");
2119                    msg.append(groupId);
2120    
2121                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2122    
2123                    throw new NoSuchArticleException(msg.toString());
2124            }
2125    
2126            /**
2127             * Returns the first journal article in the ordered set where groupId = &#63;.
2128             *
2129             * @param groupId the group ID
2130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2131             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2132             */
2133            @Override
2134            public JournalArticle fetchByGroupId_First(long groupId,
2135                    OrderByComparator<JournalArticle> orderByComparator) {
2136                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2137                                    orderByComparator);
2138    
2139                    if (!list.isEmpty()) {
2140                            return list.get(0);
2141                    }
2142    
2143                    return null;
2144            }
2145    
2146            /**
2147             * Returns the last journal article in the ordered set where groupId = &#63;.
2148             *
2149             * @param groupId the group ID
2150             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2151             * @return the last matching journal article
2152             * @throws NoSuchArticleException if a matching journal article could not be found
2153             */
2154            @Override
2155            public JournalArticle findByGroupId_Last(long groupId,
2156                    OrderByComparator<JournalArticle> orderByComparator)
2157                    throws NoSuchArticleException {
2158                    JournalArticle journalArticle = fetchByGroupId_Last(groupId,
2159                                    orderByComparator);
2160    
2161                    if (journalArticle != null) {
2162                            return journalArticle;
2163                    }
2164    
2165                    StringBundler msg = new StringBundler(4);
2166    
2167                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2168    
2169                    msg.append("groupId=");
2170                    msg.append(groupId);
2171    
2172                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2173    
2174                    throw new NoSuchArticleException(msg.toString());
2175            }
2176    
2177            /**
2178             * Returns the last journal article in the ordered set where groupId = &#63;.
2179             *
2180             * @param groupId the group ID
2181             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2182             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2183             */
2184            @Override
2185            public JournalArticle fetchByGroupId_Last(long groupId,
2186                    OrderByComparator<JournalArticle> orderByComparator) {
2187                    int count = countByGroupId(groupId);
2188    
2189                    if (count == 0) {
2190                            return null;
2191                    }
2192    
2193                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2194                                    orderByComparator);
2195    
2196                    if (!list.isEmpty()) {
2197                            return list.get(0);
2198                    }
2199    
2200                    return null;
2201            }
2202    
2203            /**
2204             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2205             *
2206             * @param id the primary key of the current journal article
2207             * @param groupId the group ID
2208             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2209             * @return the previous, current, and next journal article
2210             * @throws NoSuchArticleException if a journal article with the primary key could not be found
2211             */
2212            @Override
2213            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2214                    OrderByComparator<JournalArticle> orderByComparator)
2215                    throws NoSuchArticleException {
2216                    JournalArticle journalArticle = findByPrimaryKey(id);
2217    
2218                    Session session = null;
2219    
2220                    try {
2221                            session = openSession();
2222    
2223                            JournalArticle[] array = new JournalArticleImpl[3];
2224    
2225                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2226                                            groupId, orderByComparator, true);
2227    
2228                            array[1] = journalArticle;
2229    
2230                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2231                                            groupId, orderByComparator, false);
2232    
2233                            return array;
2234                    }
2235                    catch (Exception e) {
2236                            throw processException(e);
2237                    }
2238                    finally {
2239                            closeSession(session);
2240                    }
2241            }
2242    
2243            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2244                    JournalArticle journalArticle, long groupId,
2245                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
2246                    StringBundler query = null;
2247    
2248                    if (orderByComparator != null) {
2249                            query = new StringBundler(6 +
2250                                            (orderByComparator.getOrderByFields().length * 6));
2251                    }
2252                    else {
2253                            query = new StringBundler(3);
2254                    }
2255    
2256                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2257    
2258                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2259    
2260                    if (orderByComparator != null) {
2261                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2262    
2263                            if (orderByConditionFields.length > 0) {
2264                                    query.append(WHERE_AND);
2265                            }
2266    
2267                            for (int i = 0; i < orderByConditionFields.length; i++) {
2268                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2269                                    query.append(orderByConditionFields[i]);
2270    
2271                                    if ((i + 1) < orderByConditionFields.length) {
2272                                            if (orderByComparator.isAscending() ^ previous) {
2273                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2274                                            }
2275                                            else {
2276                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2277                                            }
2278                                    }
2279                                    else {
2280                                            if (orderByComparator.isAscending() ^ previous) {
2281                                                    query.append(WHERE_GREATER_THAN);
2282                                            }
2283                                            else {
2284                                                    query.append(WHERE_LESSER_THAN);
2285                                            }
2286                                    }
2287                            }
2288    
2289                            query.append(ORDER_BY_CLAUSE);
2290    
2291                            String[] orderByFields = orderByComparator.getOrderByFields();
2292    
2293                            for (int i = 0; i < orderByFields.length; i++) {
2294                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2295                                    query.append(orderByFields[i]);
2296    
2297                                    if ((i + 1) < orderByFields.length) {
2298                                            if (orderByComparator.isAscending() ^ previous) {
2299                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2300                                            }
2301                                            else {
2302                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2303                                            }
2304                                    }
2305                                    else {
2306                                            if (orderByComparator.isAscending() ^ previous) {
2307                                                    query.append(ORDER_BY_ASC);
2308                                            }
2309                                            else {
2310                                                    query.append(ORDER_BY_DESC);
2311                                            }
2312                                    }
2313                            }
2314                    }
2315                    else {
2316                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2317                    }
2318    
2319                    String sql = query.toString();
2320    
2321                    Query q = session.createQuery(sql);
2322    
2323                    q.setFirstResult(0);
2324                    q.setMaxResults(2);
2325    
2326                    QueryPos qPos = QueryPos.getInstance(q);
2327    
2328                    qPos.add(groupId);
2329    
2330                    if (orderByComparator != null) {
2331                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2332    
2333                            for (Object value : values) {
2334                                    qPos.add(value);
2335                            }
2336                    }
2337    
2338                    List<JournalArticle> list = q.list();
2339    
2340                    if (list.size() == 2) {
2341                            return list.get(1);
2342                    }
2343                    else {
2344                            return null;
2345                    }
2346            }
2347    
2348            /**
2349             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2350             *
2351             * @param groupId the group ID
2352             * @return the matching journal articles that the user has permission to view
2353             */
2354            @Override
2355            public List<JournalArticle> filterFindByGroupId(long groupId) {
2356                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2357                            QueryUtil.ALL_POS, null);
2358            }
2359    
2360            /**
2361             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
2362             *
2363             * <p>
2364             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2365             * </p>
2366             *
2367             * @param groupId the group ID
2368             * @param start the lower bound of the range of journal articles
2369             * @param end the upper bound of the range of journal articles (not inclusive)
2370             * @return the range of matching journal articles that the user has permission to view
2371             */
2372            @Override
2373            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2374                    int end) {
2375                    return filterFindByGroupId(groupId, start, end, null);
2376            }
2377    
2378            /**
2379             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
2380             *
2381             * <p>
2382             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2383             * </p>
2384             *
2385             * @param groupId the group ID
2386             * @param start the lower bound of the range of journal articles
2387             * @param end the upper bound of the range of journal articles (not inclusive)
2388             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2389             * @return the ordered range of matching journal articles that the user has permission to view
2390             */
2391            @Override
2392            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2393                    int end, OrderByComparator<JournalArticle> orderByComparator) {
2394                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2395                            return findByGroupId(groupId, start, end, orderByComparator);
2396                    }
2397    
2398                    StringBundler query = null;
2399    
2400                    if (orderByComparator != null) {
2401                            query = new StringBundler(3 +
2402                                            (orderByComparator.getOrderByFields().length * 3));
2403                    }
2404                    else {
2405                            query = new StringBundler(3);
2406                    }
2407    
2408                    if (getDB().isSupportsInlineDistinct()) {
2409                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2410                    }
2411                    else {
2412                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2413                    }
2414    
2415                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2416    
2417                    if (!getDB().isSupportsInlineDistinct()) {
2418                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2419                    }
2420    
2421                    if (orderByComparator != null) {
2422                            if (getDB().isSupportsInlineDistinct()) {
2423                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2424                                            orderByComparator, true);
2425                            }
2426                            else {
2427                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2428                                            orderByComparator, true);
2429                            }
2430                    }
2431                    else {
2432                            if (getDB().isSupportsInlineDistinct()) {
2433                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2434                            }
2435                            else {
2436                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2437                            }
2438                    }
2439    
2440                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2441                                    JournalArticle.class.getName(),
2442                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2443    
2444                    Session session = null;
2445    
2446                    try {
2447                            session = openSession();
2448    
2449                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2450    
2451                            if (getDB().isSupportsInlineDistinct()) {
2452                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2453                            }
2454                            else {
2455                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2456                            }
2457    
2458                            QueryPos qPos = QueryPos.getInstance(q);
2459    
2460                            qPos.add(groupId);
2461    
2462                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
2463                                    end);
2464                    }
2465                    catch (Exception e) {
2466                            throw processException(e);
2467                    }
2468                    finally {
2469                            closeSession(session);
2470                    }
2471            }
2472    
2473            /**
2474             * 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;.
2475             *
2476             * @param id the primary key of the current journal article
2477             * @param groupId the group ID
2478             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2479             * @return the previous, current, and next journal article
2480             * @throws NoSuchArticleException if a journal article with the primary key could not be found
2481             */
2482            @Override
2483            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
2484                    long groupId, OrderByComparator<JournalArticle> orderByComparator)
2485                    throws NoSuchArticleException {
2486                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2487                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
2488                    }
2489    
2490                    JournalArticle journalArticle = findByPrimaryKey(id);
2491    
2492                    Session session = null;
2493    
2494                    try {
2495                            session = openSession();
2496    
2497                            JournalArticle[] array = new JournalArticleImpl[3];
2498    
2499                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2500                                            groupId, orderByComparator, true);
2501    
2502                            array[1] = journalArticle;
2503    
2504                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2505                                            groupId, orderByComparator, false);
2506    
2507                            return array;
2508                    }
2509                    catch (Exception e) {
2510                            throw processException(e);
2511                    }
2512                    finally {
2513                            closeSession(session);
2514                    }
2515            }
2516    
2517            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
2518                    JournalArticle journalArticle, long groupId,
2519                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
2520                    StringBundler query = null;
2521    
2522                    if (orderByComparator != null) {
2523                            query = new StringBundler(6 +
2524                                            (orderByComparator.getOrderByFields().length * 6));
2525                    }
2526                    else {
2527                            query = new StringBundler(3);
2528                    }
2529    
2530                    if (getDB().isSupportsInlineDistinct()) {
2531                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2532                    }
2533                    else {
2534                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2535                    }
2536    
2537                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2538    
2539                    if (!getDB().isSupportsInlineDistinct()) {
2540                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2541                    }
2542    
2543                    if (orderByComparator != null) {
2544                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2545    
2546                            if (orderByConditionFields.length > 0) {
2547                                    query.append(WHERE_AND);
2548                            }
2549    
2550                            for (int i = 0; i < orderByConditionFields.length; i++) {
2551                                    if (getDB().isSupportsInlineDistinct()) {
2552                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2553                                    }
2554                                    else {
2555                                            query.append(_ORDER_BY_ENTITY_TABLE);
2556                                    }
2557    
2558                                    query.append(orderByConditionFields[i]);
2559    
2560                                    if ((i + 1) < orderByConditionFields.length) {
2561                                            if (orderByComparator.isAscending() ^ previous) {
2562                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2563                                            }
2564                                            else {
2565                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2566                                            }
2567                                    }
2568                                    else {
2569                                            if (orderByComparator.isAscending() ^ previous) {
2570                                                    query.append(WHERE_GREATER_THAN);
2571                                            }
2572                                            else {
2573                                                    query.append(WHERE_LESSER_THAN);
2574                                            }
2575                                    }
2576                            }
2577    
2578                            query.append(ORDER_BY_CLAUSE);
2579    
2580                            String[] orderByFields = orderByComparator.getOrderByFields();
2581    
2582                            for (int i = 0; i < orderByFields.length; i++) {
2583                                    if (getDB().isSupportsInlineDistinct()) {
2584                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2585                                    }
2586                                    else {
2587                                            query.append(_ORDER_BY_ENTITY_TABLE);
2588                                    }
2589    
2590                                    query.append(orderByFields[i]);
2591    
2592                                    if ((i + 1) < orderByFields.length) {
2593                                            if (orderByComparator.isAscending() ^ previous) {
2594                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2595                                            }
2596                                            else {
2597                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2598                                            }
2599                                    }
2600                                    else {
2601                                            if (orderByComparator.isAscending() ^ previous) {
2602                                                    query.append(ORDER_BY_ASC);
2603                                            }
2604                                            else {
2605                                                    query.append(ORDER_BY_DESC);
2606                                            }
2607                                    }
2608                            }
2609                    }
2610                    else {
2611                            if (getDB().isSupportsInlineDistinct()) {
2612                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2613                            }
2614                            else {
2615                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2616                            }
2617                    }
2618    
2619                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2620                                    JournalArticle.class.getName(),
2621                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2622    
2623                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2624    
2625                    q.setFirstResult(0);
2626                    q.setMaxResults(2);
2627    
2628                    if (getDB().isSupportsInlineDistinct()) {
2629                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2630                    }
2631                    else {
2632                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2633                    }
2634    
2635                    QueryPos qPos = QueryPos.getInstance(q);
2636    
2637                    qPos.add(groupId);
2638    
2639                    if (orderByComparator != null) {
2640                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2641    
2642                            for (Object value : values) {
2643                                    qPos.add(value);
2644                            }
2645                    }
2646    
2647                    List<JournalArticle> list = q.list();
2648    
2649                    if (list.size() == 2) {
2650                            return list.get(1);
2651                    }
2652                    else {
2653                            return null;
2654                    }
2655            }
2656    
2657            /**
2658             * Removes all the journal articles where groupId = &#63; from the database.
2659             *
2660             * @param groupId the group ID
2661             */
2662            @Override
2663            public void removeByGroupId(long groupId) {
2664                    for (JournalArticle journalArticle : findByGroupId(groupId,
2665                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2666                            remove(journalArticle);
2667                    }
2668            }
2669    
2670            /**
2671             * Returns the number of journal articles where groupId = &#63;.
2672             *
2673             * @param groupId the group ID
2674             * @return the number of matching journal articles
2675             */
2676            @Override
2677            public int countByGroupId(long groupId) {
2678                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2679    
2680                    Object[] finderArgs = new Object[] { groupId };
2681    
2682                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2683                                    this);
2684    
2685                    if (count == null) {
2686                            StringBundler query = new StringBundler(2);
2687    
2688                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
2689    
2690                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2691    
2692                            String sql = query.toString();
2693    
2694                            Session session = null;
2695    
2696                            try {
2697                                    session = openSession();
2698    
2699                                    Query q = session.createQuery(sql);
2700    
2701                                    QueryPos qPos = QueryPos.getInstance(q);
2702    
2703                                    qPos.add(groupId);
2704    
2705                                    count = (Long)q.uniqueResult();
2706    
2707                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2708                            }
2709                            catch (Exception e) {
2710                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2711    
2712                                    throw processException(e);
2713                            }
2714                            finally {
2715                                    closeSession(session);
2716                            }
2717                    }
2718    
2719                    return count.intValue();
2720            }
2721    
2722            /**
2723             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
2724             *
2725             * @param groupId the group ID
2726             * @return the number of matching journal articles that the user has permission to view
2727             */
2728            @Override
2729            public int filterCountByGroupId(long groupId) {
2730                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2731                            return countByGroupId(groupId);
2732                    }
2733    
2734                    StringBundler query = new StringBundler(2);
2735    
2736                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
2737    
2738                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2739    
2740                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2741                                    JournalArticle.class.getName(),
2742                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2743    
2744                    Session session = null;
2745    
2746                    try {
2747                            session = openSession();
2748    
2749                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2750    
2751                            q.addScalar(COUNT_COLUMN_NAME,
2752                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2753    
2754                            QueryPos qPos = QueryPos.getInstance(q);
2755    
2756                            qPos.add(groupId);
2757    
2758                            Long count = (Long)q.uniqueResult();
2759    
2760                            return count.intValue();
2761                    }
2762                    catch (Exception e) {
2763                            throw processException(e);
2764                    }
2765                    finally {
2766                            closeSession(session);
2767                    }
2768            }
2769    
2770            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
2771            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2772                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2773                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2774                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2775                            "findByCompanyId",
2776                            new String[] {
2777                                    Long.class.getName(),
2778                                    
2779                            Integer.class.getName(), Integer.class.getName(),
2780                                    OrderByComparator.class.getName()
2781                            });
2782            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2783                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2784                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
2785                            JournalArticleImpl.class,
2786                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2787                            new String[] { Long.class.getName() },
2788                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
2789                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
2790                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
2791            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
2792                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
2793                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2794                            new String[] { Long.class.getName() });
2795    
2796            /**
2797             * Returns all the journal articles where companyId = &#63;.
2798             *
2799             * @param companyId the company ID
2800             * @return the matching journal articles
2801             */
2802            @Override
2803            public List<JournalArticle> findByCompanyId(long companyId) {
2804                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2805                            null);
2806            }
2807    
2808            /**
2809             * Returns a range of all the journal articles where companyId = &#63;.
2810             *
2811             * <p>
2812             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2813             * </p>
2814             *
2815             * @param companyId the company ID
2816             * @param start the lower bound of the range of journal articles
2817             * @param end the upper bound of the range of journal articles (not inclusive)
2818             * @return the range of matching journal articles
2819             */
2820            @Override
2821            public List<JournalArticle> findByCompanyId(long companyId, int start,
2822                    int end) {
2823                    return findByCompanyId(companyId, start, end, null);
2824            }
2825    
2826            /**
2827             * Returns an ordered range of all the journal articles where companyId = &#63;.
2828             *
2829             * <p>
2830             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2831             * </p>
2832             *
2833             * @param companyId the company ID
2834             * @param start the lower bound of the range of journal articles
2835             * @param end the upper bound of the range of journal articles (not inclusive)
2836             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2837             * @return the ordered range of matching journal articles
2838             */
2839            @Override
2840            public List<JournalArticle> findByCompanyId(long companyId, int start,
2841                    int end, OrderByComparator<JournalArticle> orderByComparator) {
2842                    boolean pagination = true;
2843                    FinderPath finderPath = null;
2844                    Object[] finderArgs = null;
2845    
2846                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2847                                    (orderByComparator == null)) {
2848                            pagination = false;
2849                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2850                            finderArgs = new Object[] { companyId };
2851                    }
2852                    else {
2853                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2854                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2855                    }
2856    
2857                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2858                                    finderArgs, this);
2859    
2860                    if ((list != null) && !list.isEmpty()) {
2861                            for (JournalArticle journalArticle : list) {
2862                                    if ((companyId != journalArticle.getCompanyId())) {
2863                                            list = null;
2864    
2865                                            break;
2866                                    }
2867                            }
2868                    }
2869    
2870                    if (list == null) {
2871                            StringBundler query = null;
2872    
2873                            if (orderByComparator != null) {
2874                                    query = new StringBundler(3 +
2875                                                    (orderByComparator.getOrderByFields().length * 3));
2876                            }
2877                            else {
2878                                    query = new StringBundler(3);
2879                            }
2880    
2881                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2882    
2883                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2884    
2885                            if (orderByComparator != null) {
2886                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2887                                            orderByComparator);
2888                            }
2889                            else
2890                             if (pagination) {
2891                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2892                            }
2893    
2894                            String sql = query.toString();
2895    
2896                            Session session = null;
2897    
2898                            try {
2899                                    session = openSession();
2900    
2901                                    Query q = session.createQuery(sql);
2902    
2903                                    QueryPos qPos = QueryPos.getInstance(q);
2904    
2905                                    qPos.add(companyId);
2906    
2907                                    if (!pagination) {
2908                                            list = (List<JournalArticle>)QueryUtil.list(q,
2909                                                            getDialect(), start, end, false);
2910    
2911                                            Collections.sort(list);
2912    
2913                                            list = Collections.unmodifiableList(list);
2914                                    }
2915                                    else {
2916                                            list = (List<JournalArticle>)QueryUtil.list(q,
2917                                                            getDialect(), start, end);
2918                                    }
2919    
2920                                    cacheResult(list);
2921    
2922                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2923                            }
2924                            catch (Exception e) {
2925                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2926    
2927                                    throw processException(e);
2928                            }
2929                            finally {
2930                                    closeSession(session);
2931                            }
2932                    }
2933    
2934                    return list;
2935            }
2936    
2937            /**
2938             * Returns the first journal article in the ordered set where companyId = &#63;.
2939             *
2940             * @param companyId the company ID
2941             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2942             * @return the first matching journal article
2943             * @throws NoSuchArticleException if a matching journal article could not be found
2944             */
2945            @Override
2946            public JournalArticle findByCompanyId_First(long companyId,
2947                    OrderByComparator<JournalArticle> orderByComparator)
2948                    throws NoSuchArticleException {
2949                    JournalArticle journalArticle = fetchByCompanyId_First(companyId,
2950                                    orderByComparator);
2951    
2952                    if (journalArticle != null) {
2953                            return journalArticle;
2954                    }
2955    
2956                    StringBundler msg = new StringBundler(4);
2957    
2958                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2959    
2960                    msg.append("companyId=");
2961                    msg.append(companyId);
2962    
2963                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2964    
2965                    throw new NoSuchArticleException(msg.toString());
2966            }
2967    
2968            /**
2969             * Returns the first journal article in the ordered set where companyId = &#63;.
2970             *
2971             * @param companyId the company ID
2972             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2973             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2974             */
2975            @Override
2976            public JournalArticle fetchByCompanyId_First(long companyId,
2977                    OrderByComparator<JournalArticle> orderByComparator) {
2978                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
2979                                    orderByComparator);
2980    
2981                    if (!list.isEmpty()) {
2982                            return list.get(0);
2983                    }
2984    
2985                    return null;
2986            }
2987    
2988            /**
2989             * Returns the last journal article in the ordered set where companyId = &#63;.
2990             *
2991             * @param companyId the company ID
2992             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2993             * @return the last matching journal article
2994             * @throws NoSuchArticleException if a matching journal article could not be found
2995             */
2996            @Override
2997            public JournalArticle findByCompanyId_Last(long companyId,
2998                    OrderByComparator<JournalArticle> orderByComparator)
2999                    throws NoSuchArticleException {
3000                    JournalArticle journalArticle = fetchByCompanyId_Last(companyId,
3001                                    orderByComparator);
3002    
3003                    if (journalArticle != null) {
3004                            return journalArticle;
3005                    }
3006    
3007                    StringBundler msg = new StringBundler(4);
3008    
3009                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3010    
3011                    msg.append("companyId=");
3012                    msg.append(companyId);
3013    
3014                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3015    
3016                    throw new NoSuchArticleException(msg.toString());
3017            }
3018    
3019            /**
3020             * Returns the last journal article in the ordered set where companyId = &#63;.
3021             *
3022             * @param companyId the company ID
3023             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3024             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3025             */
3026            @Override
3027            public JournalArticle fetchByCompanyId_Last(long companyId,
3028                    OrderByComparator<JournalArticle> orderByComparator) {
3029                    int count = countByCompanyId(companyId);
3030    
3031                    if (count == 0) {
3032                            return null;
3033                    }
3034    
3035                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3036                                    count, orderByComparator);
3037    
3038                    if (!list.isEmpty()) {
3039                            return list.get(0);
3040                    }
3041    
3042                    return null;
3043            }
3044    
3045            /**
3046             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3047             *
3048             * @param id the primary key of the current journal article
3049             * @param companyId the company ID
3050             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3051             * @return the previous, current, and next journal article
3052             * @throws NoSuchArticleException if a journal article with the primary key could not be found
3053             */
3054            @Override
3055            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3056                    long companyId, OrderByComparator<JournalArticle> orderByComparator)
3057                    throws NoSuchArticleException {
3058                    JournalArticle journalArticle = findByPrimaryKey(id);
3059    
3060                    Session session = null;
3061    
3062                    try {
3063                            session = openSession();
3064    
3065                            JournalArticle[] array = new JournalArticleImpl[3];
3066    
3067                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3068                                            companyId, orderByComparator, true);
3069    
3070                            array[1] = journalArticle;
3071    
3072                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3073                                            companyId, orderByComparator, false);
3074    
3075                            return array;
3076                    }
3077                    catch (Exception e) {
3078                            throw processException(e);
3079                    }
3080                    finally {
3081                            closeSession(session);
3082                    }
3083            }
3084    
3085            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3086                    JournalArticle journalArticle, long companyId,
3087                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
3088                    StringBundler query = null;
3089    
3090                    if (orderByComparator != null) {
3091                            query = new StringBundler(6 +
3092                                            (orderByComparator.getOrderByFields().length * 6));
3093                    }
3094                    else {
3095                            query = new StringBundler(3);
3096                    }
3097    
3098                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3099    
3100                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3101    
3102                    if (orderByComparator != null) {
3103                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3104    
3105                            if (orderByConditionFields.length > 0) {
3106                                    query.append(WHERE_AND);
3107                            }
3108    
3109                            for (int i = 0; i < orderByConditionFields.length; i++) {
3110                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3111                                    query.append(orderByConditionFields[i]);
3112    
3113                                    if ((i + 1) < orderByConditionFields.length) {
3114                                            if (orderByComparator.isAscending() ^ previous) {
3115                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3116                                            }
3117                                            else {
3118                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3119                                            }
3120                                    }
3121                                    else {
3122                                            if (orderByComparator.isAscending() ^ previous) {
3123                                                    query.append(WHERE_GREATER_THAN);
3124                                            }
3125                                            else {
3126                                                    query.append(WHERE_LESSER_THAN);
3127                                            }
3128                                    }
3129                            }
3130    
3131                            query.append(ORDER_BY_CLAUSE);
3132    
3133                            String[] orderByFields = orderByComparator.getOrderByFields();
3134    
3135                            for (int i = 0; i < orderByFields.length; i++) {
3136                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3137                                    query.append(orderByFields[i]);
3138    
3139                                    if ((i + 1) < orderByFields.length) {
3140                                            if (orderByComparator.isAscending() ^ previous) {
3141                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3142                                            }
3143                                            else {
3144                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3145                                            }
3146                                    }
3147                                    else {
3148                                            if (orderByComparator.isAscending() ^ previous) {
3149                                                    query.append(ORDER_BY_ASC);
3150                                            }
3151                                            else {
3152                                                    query.append(ORDER_BY_DESC);
3153                                            }
3154                                    }
3155                            }
3156                    }
3157                    else {
3158                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3159                    }
3160    
3161                    String sql = query.toString();
3162    
3163                    Query q = session.createQuery(sql);
3164    
3165                    q.setFirstResult(0);
3166                    q.setMaxResults(2);
3167    
3168                    QueryPos qPos = QueryPos.getInstance(q);
3169    
3170                    qPos.add(companyId);
3171    
3172                    if (orderByComparator != null) {
3173                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3174    
3175                            for (Object value : values) {
3176                                    qPos.add(value);
3177                            }
3178                    }
3179    
3180                    List<JournalArticle> list = q.list();
3181    
3182                    if (list.size() == 2) {
3183                            return list.get(1);
3184                    }
3185                    else {
3186                            return null;
3187                    }
3188            }
3189    
3190            /**
3191             * Removes all the journal articles where companyId = &#63; from the database.
3192             *
3193             * @param companyId the company ID
3194             */
3195            @Override
3196            public void removeByCompanyId(long companyId) {
3197                    for (JournalArticle journalArticle : findByCompanyId(companyId,
3198                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3199                            remove(journalArticle);
3200                    }
3201            }
3202    
3203            /**
3204             * Returns the number of journal articles where companyId = &#63;.
3205             *
3206             * @param companyId the company ID
3207             * @return the number of matching journal articles
3208             */
3209            @Override
3210            public int countByCompanyId(long companyId) {
3211                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
3212    
3213                    Object[] finderArgs = new Object[] { companyId };
3214    
3215                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3216                                    this);
3217    
3218                    if (count == null) {
3219                            StringBundler query = new StringBundler(2);
3220    
3221                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3222    
3223                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3224    
3225                            String sql = query.toString();
3226    
3227                            Session session = null;
3228    
3229                            try {
3230                                    session = openSession();
3231    
3232                                    Query q = session.createQuery(sql);
3233    
3234                                    QueryPos qPos = QueryPos.getInstance(q);
3235    
3236                                    qPos.add(companyId);
3237    
3238                                    count = (Long)q.uniqueResult();
3239    
3240                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3241                            }
3242                            catch (Exception e) {
3243                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3244    
3245                                    throw processException(e);
3246                            }
3247                            finally {
3248                                    closeSession(session);
3249                            }
3250                    }
3251    
3252                    return count.intValue();
3253            }
3254    
3255            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
3256            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_DDMSTRUCTUREKEY =
3257                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3258                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3259                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3260                            "findByDDMStructureKey",
3261                            new String[] {
3262                                    String.class.getName(),
3263                                    
3264                            Integer.class.getName(), Integer.class.getName(),
3265                                    OrderByComparator.class.getName()
3266                            });
3267            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DDMSTRUCTUREKEY =
3268                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3269                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
3270                            JournalArticleImpl.class,
3271                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByDDMStructureKey",
3272                            new String[] { String.class.getName() },
3273                            JournalArticleModelImpl.DDMSTRUCTUREKEY_COLUMN_BITMASK |
3274                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
3275                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
3276            public static final FinderPath FINDER_PATH_COUNT_BY_DDMSTRUCTUREKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3277                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3278                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
3279                            "countByDDMStructureKey", new String[] { String.class.getName() });
3280            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_DDMSTRUCTUREKEY =
3281                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
3282                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
3283                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByDDMStructureKey",
3284                            new String[] { String.class.getName() });
3285    
3286            /**
3287             * Returns all the journal articles where DDMStructureKey = &#63;.
3288             *
3289             * @param DDMStructureKey the d d m structure key
3290             * @return the matching journal articles
3291             */
3292            @Override
3293            public List<JournalArticle> findByDDMStructureKey(String DDMStructureKey) {
3294                    return findByDDMStructureKey(DDMStructureKey, QueryUtil.ALL_POS,
3295                            QueryUtil.ALL_POS, null);
3296            }
3297    
3298            /**
3299             * Returns a range of all the journal articles where DDMStructureKey = &#63;.
3300             *
3301             * <p>
3302             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3303             * </p>
3304             *
3305             * @param DDMStructureKey the d d m structure key
3306             * @param start the lower bound of the range of journal articles
3307             * @param end the upper bound of the range of journal articles (not inclusive)
3308             * @return the range of matching journal articles
3309             */
3310            @Override
3311            public List<JournalArticle> findByDDMStructureKey(String DDMStructureKey,
3312                    int start, int end) {
3313                    return findByDDMStructureKey(DDMStructureKey, start, end, null);
3314            }
3315    
3316            /**
3317             * Returns an ordered range of all the journal articles where DDMStructureKey = &#63;.
3318             *
3319             * <p>
3320             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3321             * </p>
3322             *
3323             * @param DDMStructureKey the d d m structure key
3324             * @param start the lower bound of the range of journal articles
3325             * @param end the upper bound of the range of journal articles (not inclusive)
3326             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3327             * @return the ordered range of matching journal articles
3328             */
3329            @Override
3330            public List<JournalArticle> findByDDMStructureKey(String DDMStructureKey,
3331                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
3332                    boolean pagination = true;
3333                    FinderPath finderPath = null;
3334                    Object[] finderArgs = null;
3335    
3336                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3337                                    (orderByComparator == null)) {
3338                            pagination = false;
3339                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DDMSTRUCTUREKEY;
3340                            finderArgs = new Object[] { DDMStructureKey };
3341                    }
3342                    else {
3343                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_DDMSTRUCTUREKEY;
3344                            finderArgs = new Object[] {
3345                                            DDMStructureKey,
3346                                            
3347                                            start, end, orderByComparator
3348                                    };
3349                    }
3350    
3351                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3352                                    finderArgs, this);
3353    
3354                    if ((list != null) && !list.isEmpty()) {
3355                            for (JournalArticle journalArticle : list) {
3356                                    if (!Validator.equals(DDMStructureKey,
3357                                                            journalArticle.getDDMStructureKey())) {
3358                                            list = null;
3359    
3360                                            break;
3361                                    }
3362                            }
3363                    }
3364    
3365                    if (list == null) {
3366                            StringBundler query = null;
3367    
3368                            if (orderByComparator != null) {
3369                                    query = new StringBundler(3 +
3370                                                    (orderByComparator.getOrderByFields().length * 3));
3371                            }
3372                            else {
3373                                    query = new StringBundler(3);
3374                            }
3375    
3376                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3377    
3378                            boolean bindDDMStructureKey = false;
3379    
3380                            if (DDMStructureKey == null) {
3381                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_1);
3382                            }
3383                            else if (DDMStructureKey.equals(StringPool.BLANK)) {
3384                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_3);
3385                            }
3386                            else {
3387                                    bindDDMStructureKey = true;
3388    
3389                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_2);
3390                            }
3391    
3392                            if (orderByComparator != null) {
3393                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3394                                            orderByComparator);
3395                            }
3396                            else
3397                             if (pagination) {
3398                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3399                            }
3400    
3401                            String sql = query.toString();
3402    
3403                            Session session = null;
3404    
3405                            try {
3406                                    session = openSession();
3407    
3408                                    Query q = session.createQuery(sql);
3409    
3410                                    QueryPos qPos = QueryPos.getInstance(q);
3411    
3412                                    if (bindDDMStructureKey) {
3413                                            qPos.add(DDMStructureKey);
3414                                    }
3415    
3416                                    if (!pagination) {
3417                                            list = (List<JournalArticle>)QueryUtil.list(q,
3418                                                            getDialect(), start, end, false);
3419    
3420                                            Collections.sort(list);
3421    
3422                                            list = Collections.unmodifiableList(list);
3423                                    }
3424                                    else {
3425                                            list = (List<JournalArticle>)QueryUtil.list(q,
3426                                                            getDialect(), start, end);
3427                                    }
3428    
3429                                    cacheResult(list);
3430    
3431                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3432                            }
3433                            catch (Exception e) {
3434                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3435    
3436                                    throw processException(e);
3437                            }
3438                            finally {
3439                                    closeSession(session);
3440                            }
3441                    }
3442    
3443                    return list;
3444            }
3445    
3446            /**
3447             * Returns the first journal article in the ordered set where DDMStructureKey = &#63;.
3448             *
3449             * @param DDMStructureKey the d d m structure key
3450             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3451             * @return the first matching journal article
3452             * @throws NoSuchArticleException if a matching journal article could not be found
3453             */
3454            @Override
3455            public JournalArticle findByDDMStructureKey_First(String DDMStructureKey,
3456                    OrderByComparator<JournalArticle> orderByComparator)
3457                    throws NoSuchArticleException {
3458                    JournalArticle journalArticle = fetchByDDMStructureKey_First(DDMStructureKey,
3459                                    orderByComparator);
3460    
3461                    if (journalArticle != null) {
3462                            return journalArticle;
3463                    }
3464    
3465                    StringBundler msg = new StringBundler(4);
3466    
3467                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3468    
3469                    msg.append("DDMStructureKey=");
3470                    msg.append(DDMStructureKey);
3471    
3472                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3473    
3474                    throw new NoSuchArticleException(msg.toString());
3475            }
3476    
3477            /**
3478             * Returns the first journal article in the ordered set where DDMStructureKey = &#63;.
3479             *
3480             * @param DDMStructureKey the d d m structure key
3481             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3482             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3483             */
3484            @Override
3485            public JournalArticle fetchByDDMStructureKey_First(String DDMStructureKey,
3486                    OrderByComparator<JournalArticle> orderByComparator) {
3487                    List<JournalArticle> list = findByDDMStructureKey(DDMStructureKey, 0,
3488                                    1, orderByComparator);
3489    
3490                    if (!list.isEmpty()) {
3491                            return list.get(0);
3492                    }
3493    
3494                    return null;
3495            }
3496    
3497            /**
3498             * Returns the last journal article in the ordered set where DDMStructureKey = &#63;.
3499             *
3500             * @param DDMStructureKey the d d m structure key
3501             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3502             * @return the last matching journal article
3503             * @throws NoSuchArticleException if a matching journal article could not be found
3504             */
3505            @Override
3506            public JournalArticle findByDDMStructureKey_Last(String DDMStructureKey,
3507                    OrderByComparator<JournalArticle> orderByComparator)
3508                    throws NoSuchArticleException {
3509                    JournalArticle journalArticle = fetchByDDMStructureKey_Last(DDMStructureKey,
3510                                    orderByComparator);
3511    
3512                    if (journalArticle != null) {
3513                            return journalArticle;
3514                    }
3515    
3516                    StringBundler msg = new StringBundler(4);
3517    
3518                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3519    
3520                    msg.append("DDMStructureKey=");
3521                    msg.append(DDMStructureKey);
3522    
3523                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3524    
3525                    throw new NoSuchArticleException(msg.toString());
3526            }
3527    
3528            /**
3529             * Returns the last journal article in the ordered set where DDMStructureKey = &#63;.
3530             *
3531             * @param DDMStructureKey the d d m structure key
3532             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3533             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3534             */
3535            @Override
3536            public JournalArticle fetchByDDMStructureKey_Last(String DDMStructureKey,
3537                    OrderByComparator<JournalArticle> orderByComparator) {
3538                    int count = countByDDMStructureKey(DDMStructureKey);
3539    
3540                    if (count == 0) {
3541                            return null;
3542                    }
3543    
3544                    List<JournalArticle> list = findByDDMStructureKey(DDMStructureKey,
3545                                    count - 1, count, orderByComparator);
3546    
3547                    if (!list.isEmpty()) {
3548                            return list.get(0);
3549                    }
3550    
3551                    return null;
3552            }
3553    
3554            /**
3555             * Returns the journal articles before and after the current journal article in the ordered set where DDMStructureKey = &#63;.
3556             *
3557             * @param id the primary key of the current journal article
3558             * @param DDMStructureKey the d d m structure key
3559             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3560             * @return the previous, current, and next journal article
3561             * @throws NoSuchArticleException if a journal article with the primary key could not be found
3562             */
3563            @Override
3564            public JournalArticle[] findByDDMStructureKey_PrevAndNext(long id,
3565                    String DDMStructureKey,
3566                    OrderByComparator<JournalArticle> orderByComparator)
3567                    throws NoSuchArticleException {
3568                    JournalArticle journalArticle = findByPrimaryKey(id);
3569    
3570                    Session session = null;
3571    
3572                    try {
3573                            session = openSession();
3574    
3575                            JournalArticle[] array = new JournalArticleImpl[3];
3576    
3577                            array[0] = getByDDMStructureKey_PrevAndNext(session,
3578                                            journalArticle, DDMStructureKey, orderByComparator, true);
3579    
3580                            array[1] = journalArticle;
3581    
3582                            array[2] = getByDDMStructureKey_PrevAndNext(session,
3583                                            journalArticle, DDMStructureKey, orderByComparator, false);
3584    
3585                            return array;
3586                    }
3587                    catch (Exception e) {
3588                            throw processException(e);
3589                    }
3590                    finally {
3591                            closeSession(session);
3592                    }
3593            }
3594    
3595            protected JournalArticle getByDDMStructureKey_PrevAndNext(Session session,
3596                    JournalArticle journalArticle, String DDMStructureKey,
3597                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
3598                    StringBundler query = null;
3599    
3600                    if (orderByComparator != null) {
3601                            query = new StringBundler(6 +
3602                                            (orderByComparator.getOrderByFields().length * 6));
3603                    }
3604                    else {
3605                            query = new StringBundler(3);
3606                    }
3607    
3608                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3609    
3610                    boolean bindDDMStructureKey = false;
3611    
3612                    if (DDMStructureKey == null) {
3613                            query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_1);
3614                    }
3615                    else if (DDMStructureKey.equals(StringPool.BLANK)) {
3616                            query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_3);
3617                    }
3618                    else {
3619                            bindDDMStructureKey = true;
3620    
3621                            query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_2);
3622                    }
3623    
3624                    if (orderByComparator != null) {
3625                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3626    
3627                            if (orderByConditionFields.length > 0) {
3628                                    query.append(WHERE_AND);
3629                            }
3630    
3631                            for (int i = 0; i < orderByConditionFields.length; i++) {
3632                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3633                                    query.append(orderByConditionFields[i]);
3634    
3635                                    if ((i + 1) < orderByConditionFields.length) {
3636                                            if (orderByComparator.isAscending() ^ previous) {
3637                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3638                                            }
3639                                            else {
3640                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3641                                            }
3642                                    }
3643                                    else {
3644                                            if (orderByComparator.isAscending() ^ previous) {
3645                                                    query.append(WHERE_GREATER_THAN);
3646                                            }
3647                                            else {
3648                                                    query.append(WHERE_LESSER_THAN);
3649                                            }
3650                                    }
3651                            }
3652    
3653                            query.append(ORDER_BY_CLAUSE);
3654    
3655                            String[] orderByFields = orderByComparator.getOrderByFields();
3656    
3657                            for (int i = 0; i < orderByFields.length; i++) {
3658                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3659                                    query.append(orderByFields[i]);
3660    
3661                                    if ((i + 1) < orderByFields.length) {
3662                                            if (orderByComparator.isAscending() ^ previous) {
3663                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3664                                            }
3665                                            else {
3666                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3667                                            }
3668                                    }
3669                                    else {
3670                                            if (orderByComparator.isAscending() ^ previous) {
3671                                                    query.append(ORDER_BY_ASC);
3672                                            }
3673                                            else {
3674                                                    query.append(ORDER_BY_DESC);
3675                                            }
3676                                    }
3677                            }
3678                    }
3679                    else {
3680                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3681                    }
3682    
3683                    String sql = query.toString();
3684    
3685                    Query q = session.createQuery(sql);
3686    
3687                    q.setFirstResult(0);
3688                    q.setMaxResults(2);
3689    
3690                    QueryPos qPos = QueryPos.getInstance(q);
3691    
3692                    if (bindDDMStructureKey) {
3693                            qPos.add(DDMStructureKey);
3694                    }
3695    
3696                    if (orderByComparator != null) {
3697                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3698    
3699                            for (Object value : values) {
3700                                    qPos.add(value);
3701                            }
3702                    }
3703    
3704                    List<JournalArticle> list = q.list();
3705    
3706                    if (list.size() == 2) {
3707                            return list.get(1);
3708                    }
3709                    else {
3710                            return null;
3711                    }
3712            }
3713    
3714            /**
3715             * Returns all the journal articles where DDMStructureKey = any &#63;.
3716             *
3717             * <p>
3718             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3719             * </p>
3720             *
3721             * @param DDMStructureKeies the d d m structure keies
3722             * @return the matching journal articles
3723             */
3724            @Override
3725            public List<JournalArticle> findByDDMStructureKey(
3726                    String[] DDMStructureKeies) {
3727                    return findByDDMStructureKey(DDMStructureKeies, QueryUtil.ALL_POS,
3728                            QueryUtil.ALL_POS, null);
3729            }
3730    
3731            /**
3732             * Returns a range of all the journal articles where DDMStructureKey = 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query 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 DDMStructureKeies the d d m structure keies
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             * @return the range of matching journal articles
3742             */
3743            @Override
3744            public List<JournalArticle> findByDDMStructureKey(
3745                    String[] DDMStructureKeies, int start, int end) {
3746                    return findByDDMStructureKey(DDMStructureKeies, start, end, null);
3747            }
3748    
3749            /**
3750             * Returns an ordered range of all the journal articles where DDMStructureKey = any &#63;.
3751             *
3752             * <p>
3753             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3754             * </p>
3755             *
3756             * @param DDMStructureKeies the d d m structure keies
3757             * @param start the lower bound of the range of journal articles
3758             * @param end the upper bound of the range of journal articles (not inclusive)
3759             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3760             * @return the ordered range of matching journal articles
3761             */
3762            @Override
3763            public List<JournalArticle> findByDDMStructureKey(
3764                    String[] DDMStructureKeies, int start, int end,
3765                    OrderByComparator<JournalArticle> orderByComparator) {
3766                    if (DDMStructureKeies == null) {
3767                            DDMStructureKeies = new String[0];
3768                    }
3769                    else {
3770                            DDMStructureKeies = ArrayUtil.distinct(DDMStructureKeies,
3771                                            NULL_SAFE_STRING_COMPARATOR);
3772                    }
3773    
3774                    if (DDMStructureKeies.length == 1) {
3775                            return findByDDMStructureKey(DDMStructureKeies[0], start, end,
3776                                    orderByComparator);
3777                    }
3778    
3779                    boolean pagination = true;
3780                    Object[] finderArgs = null;
3781    
3782                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3783                                    (orderByComparator == null)) {
3784                            pagination = false;
3785                            finderArgs = new Object[] { StringUtil.merge(DDMStructureKeies) };
3786                    }
3787                    else {
3788                            finderArgs = new Object[] {
3789                                            StringUtil.merge(DDMStructureKeies),
3790                                            
3791                                            start, end, orderByComparator
3792                                    };
3793                    }
3794    
3795                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_DDMSTRUCTUREKEY,
3796                                    finderArgs, this);
3797    
3798                    if ((list != null) && !list.isEmpty()) {
3799                            for (JournalArticle journalArticle : list) {
3800                                    if (!ArrayUtil.contains(DDMStructureKeies,
3801                                                            journalArticle.getDDMStructureKey())) {
3802                                            list = null;
3803    
3804                                            break;
3805                                    }
3806                            }
3807                    }
3808    
3809                    if (list == null) {
3810                            StringBundler query = new StringBundler();
3811    
3812                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3813    
3814                            if (DDMStructureKeies.length > 0) {
3815                                    query.append(StringPool.OPEN_PARENTHESIS);
3816    
3817                                    for (int i = 0; i < DDMStructureKeies.length; i++) {
3818                                            String DDMStructureKey = DDMStructureKeies[i];
3819    
3820                                            if (DDMStructureKey == null) {
3821                                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_1);
3822                                            }
3823                                            else if (DDMStructureKey.equals(StringPool.BLANK)) {
3824                                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_3);
3825                                            }
3826                                            else {
3827                                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_2);
3828                                            }
3829    
3830                                            if ((i + 1) < DDMStructureKeies.length) {
3831                                                    query.append(WHERE_OR);
3832                                            }
3833                                    }
3834    
3835                                    query.append(StringPool.CLOSE_PARENTHESIS);
3836                            }
3837    
3838                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
3839                                                    1)), query.index() - 1);
3840    
3841                            if (orderByComparator != null) {
3842                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3843                                            orderByComparator);
3844                            }
3845                            else
3846                             if (pagination) {
3847                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3848                            }
3849    
3850                            String sql = query.toString();
3851    
3852                            Session session = null;
3853    
3854                            try {
3855                                    session = openSession();
3856    
3857                                    Query q = session.createQuery(sql);
3858    
3859                                    QueryPos qPos = QueryPos.getInstance(q);
3860    
3861                                    for (String DDMStructureKey : DDMStructureKeies) {
3862                                            if ((DDMStructureKey != null) &&
3863                                                            !DDMStructureKey.isEmpty()) {
3864                                                    qPos.add(DDMStructureKey);
3865                                            }
3866                                    }
3867    
3868                                    if (!pagination) {
3869                                            list = (List<JournalArticle>)QueryUtil.list(q,
3870                                                            getDialect(), start, end, false);
3871    
3872                                            Collections.sort(list);
3873    
3874                                            list = Collections.unmodifiableList(list);
3875                                    }
3876                                    else {
3877                                            list = (List<JournalArticle>)QueryUtil.list(q,
3878                                                            getDialect(), start, end);
3879                                    }
3880    
3881                                    cacheResult(list);
3882    
3883                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_DDMSTRUCTUREKEY,
3884                                            finderArgs, list);
3885                            }
3886                            catch (Exception e) {
3887                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_DDMSTRUCTUREKEY,
3888                                            finderArgs);
3889    
3890                                    throw processException(e);
3891                            }
3892                            finally {
3893                                    closeSession(session);
3894                            }
3895                    }
3896    
3897                    return list;
3898            }
3899    
3900            /**
3901             * Removes all the journal articles where DDMStructureKey = &#63; from the database.
3902             *
3903             * @param DDMStructureKey the d d m structure key
3904             */
3905            @Override
3906            public void removeByDDMStructureKey(String DDMStructureKey) {
3907                    for (JournalArticle journalArticle : findByDDMStructureKey(
3908                                    DDMStructureKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3909                            remove(journalArticle);
3910                    }
3911            }
3912    
3913            /**
3914             * Returns the number of journal articles where DDMStructureKey = &#63;.
3915             *
3916             * @param DDMStructureKey the d d m structure key
3917             * @return the number of matching journal articles
3918             */
3919            @Override
3920            public int countByDDMStructureKey(String DDMStructureKey) {
3921                    FinderPath finderPath = FINDER_PATH_COUNT_BY_DDMSTRUCTUREKEY;
3922    
3923                    Object[] finderArgs = new Object[] { DDMStructureKey };
3924    
3925                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3926                                    this);
3927    
3928                    if (count == null) {
3929                            StringBundler query = new StringBundler(2);
3930    
3931                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
3932    
3933                            boolean bindDDMStructureKey = false;
3934    
3935                            if (DDMStructureKey == null) {
3936                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_1);
3937                            }
3938                            else if (DDMStructureKey.equals(StringPool.BLANK)) {
3939                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_3);
3940                            }
3941                            else {
3942                                    bindDDMStructureKey = true;
3943    
3944                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_2);
3945                            }
3946    
3947                            String sql = query.toString();
3948    
3949                            Session session = null;
3950    
3951                            try {
3952                                    session = openSession();
3953    
3954                                    Query q = session.createQuery(sql);
3955    
3956                                    QueryPos qPos = QueryPos.getInstance(q);
3957    
3958                                    if (bindDDMStructureKey) {
3959                                            qPos.add(DDMStructureKey);
3960                                    }
3961    
3962                                    count = (Long)q.uniqueResult();
3963    
3964                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3965                            }
3966                            catch (Exception e) {
3967                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3968    
3969                                    throw processException(e);
3970                            }
3971                            finally {
3972                                    closeSession(session);
3973                            }
3974                    }
3975    
3976                    return count.intValue();
3977            }
3978    
3979            /**
3980             * Returns the number of journal articles where DDMStructureKey = any &#63;.
3981             *
3982             * @param DDMStructureKeies the d d m structure keies
3983             * @return the number of matching journal articles
3984             */
3985            @Override
3986            public int countByDDMStructureKey(String[] DDMStructureKeies) {
3987                    if (DDMStructureKeies == null) {
3988                            DDMStructureKeies = new String[0];
3989                    }
3990                    else {
3991                            DDMStructureKeies = ArrayUtil.distinct(DDMStructureKeies,
3992                                            NULL_SAFE_STRING_COMPARATOR);
3993                    }
3994    
3995                    Object[] finderArgs = new Object[] { StringUtil.merge(DDMStructureKeies) };
3996    
3997                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_DDMSTRUCTUREKEY,
3998                                    finderArgs, this);
3999    
4000                    if (count == null) {
4001                            StringBundler query = new StringBundler();
4002    
4003                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4004    
4005                            if (DDMStructureKeies.length > 0) {
4006                                    query.append(StringPool.OPEN_PARENTHESIS);
4007    
4008                                    for (int i = 0; i < DDMStructureKeies.length; i++) {
4009                                            String DDMStructureKey = DDMStructureKeies[i];
4010    
4011                                            if (DDMStructureKey == null) {
4012                                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_1);
4013                                            }
4014                                            else if (DDMStructureKey.equals(StringPool.BLANK)) {
4015                                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_3);
4016                                            }
4017                                            else {
4018                                                    query.append(_FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_2);
4019                                            }
4020    
4021                                            if ((i + 1) < DDMStructureKeies.length) {
4022                                                    query.append(WHERE_OR);
4023                                            }
4024                                    }
4025    
4026                                    query.append(StringPool.CLOSE_PARENTHESIS);
4027                            }
4028    
4029                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
4030                                                    1)), query.index() - 1);
4031    
4032                            String sql = query.toString();
4033    
4034                            Session session = null;
4035    
4036                            try {
4037                                    session = openSession();
4038    
4039                                    Query q = session.createQuery(sql);
4040    
4041                                    QueryPos qPos = QueryPos.getInstance(q);
4042    
4043                                    for (String DDMStructureKey : DDMStructureKeies) {
4044                                            if ((DDMStructureKey != null) &&
4045                                                            !DDMStructureKey.isEmpty()) {
4046                                                    qPos.add(DDMStructureKey);
4047                                            }
4048                                    }
4049    
4050                                    count = (Long)q.uniqueResult();
4051    
4052                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_DDMSTRUCTUREKEY,
4053                                            finderArgs, count);
4054                            }
4055                            catch (Exception e) {
4056                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_DDMSTRUCTUREKEY,
4057                                            finderArgs);
4058    
4059                                    throw processException(e);
4060                            }
4061                            finally {
4062                                    closeSession(session);
4063                            }
4064                    }
4065    
4066                    return count.intValue();
4067            }
4068    
4069            private static final String _FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_1 =
4070                    "journalArticle.DDMStructureKey IS NULL";
4071            private static final String _FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_2 =
4072                    "journalArticle.DDMStructureKey = ?";
4073            private static final String _FINDER_COLUMN_DDMSTRUCTUREKEY_DDMSTRUCTUREKEY_3 =
4074                    "(journalArticle.DDMStructureKey IS NULL OR journalArticle.DDMStructureKey = '')";
4075            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_DDMTEMPLATEKEY =
4076                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4077                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4078                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4079                            "findByDDMTemplateKey",
4080                            new String[] {
4081                                    String.class.getName(),
4082                                    
4083                            Integer.class.getName(), Integer.class.getName(),
4084                                    OrderByComparator.class.getName()
4085                            });
4086            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DDMTEMPLATEKEY =
4087                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4088                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4089                            JournalArticleImpl.class,
4090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByDDMTemplateKey",
4091                            new String[] { String.class.getName() },
4092                            JournalArticleModelImpl.DDMTEMPLATEKEY_COLUMN_BITMASK |
4093                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4094                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4095            public static final FinderPath FINDER_PATH_COUNT_BY_DDMTEMPLATEKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4096                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByDDMTemplateKey",
4098                            new String[] { String.class.getName() });
4099    
4100            /**
4101             * Returns all the journal articles where DDMTemplateKey = &#63;.
4102             *
4103             * @param DDMTemplateKey the d d m template key
4104             * @return the matching journal articles
4105             */
4106            @Override
4107            public List<JournalArticle> findByDDMTemplateKey(String DDMTemplateKey) {
4108                    return findByDDMTemplateKey(DDMTemplateKey, QueryUtil.ALL_POS,
4109                            QueryUtil.ALL_POS, null);
4110            }
4111    
4112            /**
4113             * Returns a range of all the journal articles where DDMTemplateKey = &#63;.
4114             *
4115             * <p>
4116             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4117             * </p>
4118             *
4119             * @param DDMTemplateKey the d d m template key
4120             * @param start the lower bound of the range of journal articles
4121             * @param end the upper bound of the range of journal articles (not inclusive)
4122             * @return the range of matching journal articles
4123             */
4124            @Override
4125            public List<JournalArticle> findByDDMTemplateKey(String DDMTemplateKey,
4126                    int start, int end) {
4127                    return findByDDMTemplateKey(DDMTemplateKey, start, end, null);
4128            }
4129    
4130            /**
4131             * Returns an ordered range of all the journal articles where DDMTemplateKey = &#63;.
4132             *
4133             * <p>
4134             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4135             * </p>
4136             *
4137             * @param DDMTemplateKey the d d m template key
4138             * @param start the lower bound of the range of journal articles
4139             * @param end the upper bound of the range of journal articles (not inclusive)
4140             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4141             * @return the ordered range of matching journal articles
4142             */
4143            @Override
4144            public List<JournalArticle> findByDDMTemplateKey(String DDMTemplateKey,
4145                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
4146                    boolean pagination = true;
4147                    FinderPath finderPath = null;
4148                    Object[] finderArgs = null;
4149    
4150                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4151                                    (orderByComparator == null)) {
4152                            pagination = false;
4153                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DDMTEMPLATEKEY;
4154                            finderArgs = new Object[] { DDMTemplateKey };
4155                    }
4156                    else {
4157                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_DDMTEMPLATEKEY;
4158                            finderArgs = new Object[] {
4159                                            DDMTemplateKey,
4160                                            
4161                                            start, end, orderByComparator
4162                                    };
4163                    }
4164    
4165                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4166                                    finderArgs, this);
4167    
4168                    if ((list != null) && !list.isEmpty()) {
4169                            for (JournalArticle journalArticle : list) {
4170                                    if (!Validator.equals(DDMTemplateKey,
4171                                                            journalArticle.getDDMTemplateKey())) {
4172                                            list = null;
4173    
4174                                            break;
4175                                    }
4176                            }
4177                    }
4178    
4179                    if (list == null) {
4180                            StringBundler query = null;
4181    
4182                            if (orderByComparator != null) {
4183                                    query = new StringBundler(3 +
4184                                                    (orderByComparator.getOrderByFields().length * 3));
4185                            }
4186                            else {
4187                                    query = new StringBundler(3);
4188                            }
4189    
4190                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4191    
4192                            boolean bindDDMTemplateKey = false;
4193    
4194                            if (DDMTemplateKey == null) {
4195                                    query.append(_FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_1);
4196                            }
4197                            else if (DDMTemplateKey.equals(StringPool.BLANK)) {
4198                                    query.append(_FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_3);
4199                            }
4200                            else {
4201                                    bindDDMTemplateKey = true;
4202    
4203                                    query.append(_FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_2);
4204                            }
4205    
4206                            if (orderByComparator != null) {
4207                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4208                                            orderByComparator);
4209                            }
4210                            else
4211                             if (pagination) {
4212                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4213                            }
4214    
4215                            String sql = query.toString();
4216    
4217                            Session session = null;
4218    
4219                            try {
4220                                    session = openSession();
4221    
4222                                    Query q = session.createQuery(sql);
4223    
4224                                    QueryPos qPos = QueryPos.getInstance(q);
4225    
4226                                    if (bindDDMTemplateKey) {
4227                                            qPos.add(DDMTemplateKey);
4228                                    }
4229    
4230                                    if (!pagination) {
4231                                            list = (List<JournalArticle>)QueryUtil.list(q,
4232                                                            getDialect(), start, end, false);
4233    
4234                                            Collections.sort(list);
4235    
4236                                            list = Collections.unmodifiableList(list);
4237                                    }
4238                                    else {
4239                                            list = (List<JournalArticle>)QueryUtil.list(q,
4240                                                            getDialect(), start, end);
4241                                    }
4242    
4243                                    cacheResult(list);
4244    
4245                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4246                            }
4247                            catch (Exception e) {
4248                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4249    
4250                                    throw processException(e);
4251                            }
4252                            finally {
4253                                    closeSession(session);
4254                            }
4255                    }
4256    
4257                    return list;
4258            }
4259    
4260            /**
4261             * Returns the first journal article in the ordered set where DDMTemplateKey = &#63;.
4262             *
4263             * @param DDMTemplateKey the d d m template key
4264             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4265             * @return the first matching journal article
4266             * @throws NoSuchArticleException if a matching journal article could not be found
4267             */
4268            @Override
4269            public JournalArticle findByDDMTemplateKey_First(String DDMTemplateKey,
4270                    OrderByComparator<JournalArticle> orderByComparator)
4271                    throws NoSuchArticleException {
4272                    JournalArticle journalArticle = fetchByDDMTemplateKey_First(DDMTemplateKey,
4273                                    orderByComparator);
4274    
4275                    if (journalArticle != null) {
4276                            return journalArticle;
4277                    }
4278    
4279                    StringBundler msg = new StringBundler(4);
4280    
4281                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4282    
4283                    msg.append("DDMTemplateKey=");
4284                    msg.append(DDMTemplateKey);
4285    
4286                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4287    
4288                    throw new NoSuchArticleException(msg.toString());
4289            }
4290    
4291            /**
4292             * Returns the first journal article in the ordered set where DDMTemplateKey = &#63;.
4293             *
4294             * @param DDMTemplateKey the d d m template key
4295             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4296             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4297             */
4298            @Override
4299            public JournalArticle fetchByDDMTemplateKey_First(String DDMTemplateKey,
4300                    OrderByComparator<JournalArticle> orderByComparator) {
4301                    List<JournalArticle> list = findByDDMTemplateKey(DDMTemplateKey, 0, 1,
4302                                    orderByComparator);
4303    
4304                    if (!list.isEmpty()) {
4305                            return list.get(0);
4306                    }
4307    
4308                    return null;
4309            }
4310    
4311            /**
4312             * Returns the last journal article in the ordered set where DDMTemplateKey = &#63;.
4313             *
4314             * @param DDMTemplateKey the d d m template key
4315             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4316             * @return the last matching journal article
4317             * @throws NoSuchArticleException if a matching journal article could not be found
4318             */
4319            @Override
4320            public JournalArticle findByDDMTemplateKey_Last(String DDMTemplateKey,
4321                    OrderByComparator<JournalArticle> orderByComparator)
4322                    throws NoSuchArticleException {
4323                    JournalArticle journalArticle = fetchByDDMTemplateKey_Last(DDMTemplateKey,
4324                                    orderByComparator);
4325    
4326                    if (journalArticle != null) {
4327                            return journalArticle;
4328                    }
4329    
4330                    StringBundler msg = new StringBundler(4);
4331    
4332                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4333    
4334                    msg.append("DDMTemplateKey=");
4335                    msg.append(DDMTemplateKey);
4336    
4337                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4338    
4339                    throw new NoSuchArticleException(msg.toString());
4340            }
4341    
4342            /**
4343             * Returns the last journal article in the ordered set where DDMTemplateKey = &#63;.
4344             *
4345             * @param DDMTemplateKey the d d m template key
4346             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4347             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4348             */
4349            @Override
4350            public JournalArticle fetchByDDMTemplateKey_Last(String DDMTemplateKey,
4351                    OrderByComparator<JournalArticle> orderByComparator) {
4352                    int count = countByDDMTemplateKey(DDMTemplateKey);
4353    
4354                    if (count == 0) {
4355                            return null;
4356                    }
4357    
4358                    List<JournalArticle> list = findByDDMTemplateKey(DDMTemplateKey,
4359                                    count - 1, count, orderByComparator);
4360    
4361                    if (!list.isEmpty()) {
4362                            return list.get(0);
4363                    }
4364    
4365                    return null;
4366            }
4367    
4368            /**
4369             * Returns the journal articles before and after the current journal article in the ordered set where DDMTemplateKey = &#63;.
4370             *
4371             * @param id the primary key of the current journal article
4372             * @param DDMTemplateKey the d d m template key
4373             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4374             * @return the previous, current, and next journal article
4375             * @throws NoSuchArticleException if a journal article with the primary key could not be found
4376             */
4377            @Override
4378            public JournalArticle[] findByDDMTemplateKey_PrevAndNext(long id,
4379                    String DDMTemplateKey,
4380                    OrderByComparator<JournalArticle> orderByComparator)
4381                    throws NoSuchArticleException {
4382                    JournalArticle journalArticle = findByPrimaryKey(id);
4383    
4384                    Session session = null;
4385    
4386                    try {
4387                            session = openSession();
4388    
4389                            JournalArticle[] array = new JournalArticleImpl[3];
4390    
4391                            array[0] = getByDDMTemplateKey_PrevAndNext(session, journalArticle,
4392                                            DDMTemplateKey, orderByComparator, true);
4393    
4394                            array[1] = journalArticle;
4395    
4396                            array[2] = getByDDMTemplateKey_PrevAndNext(session, journalArticle,
4397                                            DDMTemplateKey, orderByComparator, false);
4398    
4399                            return array;
4400                    }
4401                    catch (Exception e) {
4402                            throw processException(e);
4403                    }
4404                    finally {
4405                            closeSession(session);
4406                    }
4407            }
4408    
4409            protected JournalArticle getByDDMTemplateKey_PrevAndNext(Session session,
4410                    JournalArticle journalArticle, String DDMTemplateKey,
4411                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
4412                    StringBundler query = null;
4413    
4414                    if (orderByComparator != null) {
4415                            query = new StringBundler(6 +
4416                                            (orderByComparator.getOrderByFields().length * 6));
4417                    }
4418                    else {
4419                            query = new StringBundler(3);
4420                    }
4421    
4422                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4423    
4424                    boolean bindDDMTemplateKey = false;
4425    
4426                    if (DDMTemplateKey == null) {
4427                            query.append(_FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_1);
4428                    }
4429                    else if (DDMTemplateKey.equals(StringPool.BLANK)) {
4430                            query.append(_FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_3);
4431                    }
4432                    else {
4433                            bindDDMTemplateKey = true;
4434    
4435                            query.append(_FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_2);
4436                    }
4437    
4438                    if (orderByComparator != null) {
4439                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4440    
4441                            if (orderByConditionFields.length > 0) {
4442                                    query.append(WHERE_AND);
4443                            }
4444    
4445                            for (int i = 0; i < orderByConditionFields.length; i++) {
4446                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4447                                    query.append(orderByConditionFields[i]);
4448    
4449                                    if ((i + 1) < orderByConditionFields.length) {
4450                                            if (orderByComparator.isAscending() ^ previous) {
4451                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4452                                            }
4453                                            else {
4454                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4455                                            }
4456                                    }
4457                                    else {
4458                                            if (orderByComparator.isAscending() ^ previous) {
4459                                                    query.append(WHERE_GREATER_THAN);
4460                                            }
4461                                            else {
4462                                                    query.append(WHERE_LESSER_THAN);
4463                                            }
4464                                    }
4465                            }
4466    
4467                            query.append(ORDER_BY_CLAUSE);
4468    
4469                            String[] orderByFields = orderByComparator.getOrderByFields();
4470    
4471                            for (int i = 0; i < orderByFields.length; i++) {
4472                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4473                                    query.append(orderByFields[i]);
4474    
4475                                    if ((i + 1) < orderByFields.length) {
4476                                            if (orderByComparator.isAscending() ^ previous) {
4477                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4478                                            }
4479                                            else {
4480                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4481                                            }
4482                                    }
4483                                    else {
4484                                            if (orderByComparator.isAscending() ^ previous) {
4485                                                    query.append(ORDER_BY_ASC);
4486                                            }
4487                                            else {
4488                                                    query.append(ORDER_BY_DESC);
4489                                            }
4490                                    }
4491                            }
4492                    }
4493                    else {
4494                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4495                    }
4496    
4497                    String sql = query.toString();
4498    
4499                    Query q = session.createQuery(sql);
4500    
4501                    q.setFirstResult(0);
4502                    q.setMaxResults(2);
4503    
4504                    QueryPos qPos = QueryPos.getInstance(q);
4505    
4506                    if (bindDDMTemplateKey) {
4507                            qPos.add(DDMTemplateKey);
4508                    }
4509    
4510                    if (orderByComparator != null) {
4511                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4512    
4513                            for (Object value : values) {
4514                                    qPos.add(value);
4515                            }
4516                    }
4517    
4518                    List<JournalArticle> list = q.list();
4519    
4520                    if (list.size() == 2) {
4521                            return list.get(1);
4522                    }
4523                    else {
4524                            return null;
4525                    }
4526            }
4527    
4528            /**
4529             * Removes all the journal articles where DDMTemplateKey = &#63; from the database.
4530             *
4531             * @param DDMTemplateKey the d d m template key
4532             */
4533            @Override
4534            public void removeByDDMTemplateKey(String DDMTemplateKey) {
4535                    for (JournalArticle journalArticle : findByDDMTemplateKey(
4536                                    DDMTemplateKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4537                            remove(journalArticle);
4538                    }
4539            }
4540    
4541            /**
4542             * Returns the number of journal articles where DDMTemplateKey = &#63;.
4543             *
4544             * @param DDMTemplateKey the d d m template key
4545             * @return the number of matching journal articles
4546             */
4547            @Override
4548            public int countByDDMTemplateKey(String DDMTemplateKey) {
4549                    FinderPath finderPath = FINDER_PATH_COUNT_BY_DDMTEMPLATEKEY;
4550    
4551                    Object[] finderArgs = new Object[] { DDMTemplateKey };
4552    
4553                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4554                                    this);
4555    
4556                    if (count == null) {
4557                            StringBundler query = new StringBundler(2);
4558    
4559                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
4560    
4561                            boolean bindDDMTemplateKey = false;
4562    
4563                            if (DDMTemplateKey == null) {
4564                                    query.append(_FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_1);
4565                            }
4566                            else if (DDMTemplateKey.equals(StringPool.BLANK)) {
4567                                    query.append(_FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_3);
4568                            }
4569                            else {
4570                                    bindDDMTemplateKey = true;
4571    
4572                                    query.append(_FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_2);
4573                            }
4574    
4575                            String sql = query.toString();
4576    
4577                            Session session = null;
4578    
4579                            try {
4580                                    session = openSession();
4581    
4582                                    Query q = session.createQuery(sql);
4583    
4584                                    QueryPos qPos = QueryPos.getInstance(q);
4585    
4586                                    if (bindDDMTemplateKey) {
4587                                            qPos.add(DDMTemplateKey);
4588                                    }
4589    
4590                                    count = (Long)q.uniqueResult();
4591    
4592                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4593                            }
4594                            catch (Exception e) {
4595                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4596    
4597                                    throw processException(e);
4598                            }
4599                            finally {
4600                                    closeSession(session);
4601                            }
4602                    }
4603    
4604                    return count.intValue();
4605            }
4606    
4607            private static final String _FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_1 = "journalArticle.DDMTemplateKey IS NULL";
4608            private static final String _FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_2 = "journalArticle.DDMTemplateKey = ?";
4609            private static final String _FINDER_COLUMN_DDMTEMPLATEKEY_DDMTEMPLATEKEY_3 = "(journalArticle.DDMTemplateKey IS NULL OR journalArticle.DDMTemplateKey = '')";
4610            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
4611                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4612                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4613                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4614                            "findByLayoutUuid",
4615                            new String[] {
4616                                    String.class.getName(),
4617                                    
4618                            Integer.class.getName(), Integer.class.getName(),
4619                                    OrderByComparator.class.getName()
4620                            });
4621            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
4622                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4623                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
4624                            JournalArticleImpl.class,
4625                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
4626                            new String[] { String.class.getName() },
4627                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
4628                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
4629                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
4630            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
4631                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
4632                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
4633                            new String[] { String.class.getName() });
4634    
4635            /**
4636             * Returns all the journal articles where layoutUuid = &#63;.
4637             *
4638             * @param layoutUuid the layout uuid
4639             * @return the matching journal articles
4640             */
4641            @Override
4642            public List<JournalArticle> findByLayoutUuid(String layoutUuid) {
4643                    return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
4644                            QueryUtil.ALL_POS, null);
4645            }
4646    
4647            /**
4648             * Returns a range of all the journal articles where layoutUuid = &#63;.
4649             *
4650             * <p>
4651             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4652             * </p>
4653             *
4654             * @param layoutUuid the layout uuid
4655             * @param start the lower bound of the range of journal articles
4656             * @param end the upper bound of the range of journal articles (not inclusive)
4657             * @return the range of matching journal articles
4658             */
4659            @Override
4660            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4661                    int end) {
4662                    return findByLayoutUuid(layoutUuid, start, end, null);
4663            }
4664    
4665            /**
4666             * Returns an ordered range of all the journal articles where layoutUuid = &#63;.
4667             *
4668             * <p>
4669             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4670             * </p>
4671             *
4672             * @param layoutUuid the layout uuid
4673             * @param start the lower bound of the range of journal articles
4674             * @param end the upper bound of the range of journal articles (not inclusive)
4675             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4676             * @return the ordered range of matching journal articles
4677             */
4678            @Override
4679            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
4680                    int end, OrderByComparator<JournalArticle> orderByComparator) {
4681                    boolean pagination = true;
4682                    FinderPath finderPath = null;
4683                    Object[] finderArgs = null;
4684    
4685                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4686                                    (orderByComparator == null)) {
4687                            pagination = false;
4688                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
4689                            finderArgs = new Object[] { layoutUuid };
4690                    }
4691                    else {
4692                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
4693                            finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
4694                    }
4695    
4696                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4697                                    finderArgs, this);
4698    
4699                    if ((list != null) && !list.isEmpty()) {
4700                            for (JournalArticle journalArticle : list) {
4701                                    if (!Validator.equals(layoutUuid, journalArticle.getLayoutUuid())) {
4702                                            list = null;
4703    
4704                                            break;
4705                                    }
4706                            }
4707                    }
4708    
4709                    if (list == null) {
4710                            StringBundler query = null;
4711    
4712                            if (orderByComparator != null) {
4713                                    query = new StringBundler(3 +
4714                                                    (orderByComparator.getOrderByFields().length * 3));
4715                            }
4716                            else {
4717                                    query = new StringBundler(3);
4718                            }
4719    
4720                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4721    
4722                            boolean bindLayoutUuid = false;
4723    
4724                            if (layoutUuid == null) {
4725                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4726                            }
4727                            else if (layoutUuid.equals(StringPool.BLANK)) {
4728                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4729                            }
4730                            else {
4731                                    bindLayoutUuid = true;
4732    
4733                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4734                            }
4735    
4736                            if (orderByComparator != null) {
4737                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4738                                            orderByComparator);
4739                            }
4740                            else
4741                             if (pagination) {
4742                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4743                            }
4744    
4745                            String sql = query.toString();
4746    
4747                            Session session = null;
4748    
4749                            try {
4750                                    session = openSession();
4751    
4752                                    Query q = session.createQuery(sql);
4753    
4754                                    QueryPos qPos = QueryPos.getInstance(q);
4755    
4756                                    if (bindLayoutUuid) {
4757                                            qPos.add(layoutUuid);
4758                                    }
4759    
4760                                    if (!pagination) {
4761                                            list = (List<JournalArticle>)QueryUtil.list(q,
4762                                                            getDialect(), start, end, false);
4763    
4764                                            Collections.sort(list);
4765    
4766                                            list = Collections.unmodifiableList(list);
4767                                    }
4768                                    else {
4769                                            list = (List<JournalArticle>)QueryUtil.list(q,
4770                                                            getDialect(), start, end);
4771                                    }
4772    
4773                                    cacheResult(list);
4774    
4775                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4776                            }
4777                            catch (Exception e) {
4778                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4779    
4780                                    throw processException(e);
4781                            }
4782                            finally {
4783                                    closeSession(session);
4784                            }
4785                    }
4786    
4787                    return list;
4788            }
4789    
4790            /**
4791             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4792             *
4793             * @param layoutUuid the layout uuid
4794             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4795             * @return the first matching journal article
4796             * @throws NoSuchArticleException if a matching journal article could not be found
4797             */
4798            @Override
4799            public JournalArticle findByLayoutUuid_First(String layoutUuid,
4800                    OrderByComparator<JournalArticle> orderByComparator)
4801                    throws NoSuchArticleException {
4802                    JournalArticle journalArticle = fetchByLayoutUuid_First(layoutUuid,
4803                                    orderByComparator);
4804    
4805                    if (journalArticle != null) {
4806                            return journalArticle;
4807                    }
4808    
4809                    StringBundler msg = new StringBundler(4);
4810    
4811                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4812    
4813                    msg.append("layoutUuid=");
4814                    msg.append(layoutUuid);
4815    
4816                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4817    
4818                    throw new NoSuchArticleException(msg.toString());
4819            }
4820    
4821            /**
4822             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
4823             *
4824             * @param layoutUuid the layout uuid
4825             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4826             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4827             */
4828            @Override
4829            public JournalArticle fetchByLayoutUuid_First(String layoutUuid,
4830                    OrderByComparator<JournalArticle> orderByComparator) {
4831                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, 0, 1,
4832                                    orderByComparator);
4833    
4834                    if (!list.isEmpty()) {
4835                            return list.get(0);
4836                    }
4837    
4838                    return null;
4839            }
4840    
4841            /**
4842             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4843             *
4844             * @param layoutUuid the layout uuid
4845             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4846             * @return the last matching journal article
4847             * @throws NoSuchArticleException if a matching journal article could not be found
4848             */
4849            @Override
4850            public JournalArticle findByLayoutUuid_Last(String layoutUuid,
4851                    OrderByComparator<JournalArticle> orderByComparator)
4852                    throws NoSuchArticleException {
4853                    JournalArticle journalArticle = fetchByLayoutUuid_Last(layoutUuid,
4854                                    orderByComparator);
4855    
4856                    if (journalArticle != null) {
4857                            return journalArticle;
4858                    }
4859    
4860                    StringBundler msg = new StringBundler(4);
4861    
4862                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4863    
4864                    msg.append("layoutUuid=");
4865                    msg.append(layoutUuid);
4866    
4867                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4868    
4869                    throw new NoSuchArticleException(msg.toString());
4870            }
4871    
4872            /**
4873             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
4874             *
4875             * @param layoutUuid the layout uuid
4876             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4877             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4878             */
4879            @Override
4880            public JournalArticle fetchByLayoutUuid_Last(String layoutUuid,
4881                    OrderByComparator<JournalArticle> orderByComparator) {
4882                    int count = countByLayoutUuid(layoutUuid);
4883    
4884                    if (count == 0) {
4885                            return null;
4886                    }
4887    
4888                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, count - 1,
4889                                    count, orderByComparator);
4890    
4891                    if (!list.isEmpty()) {
4892                            return list.get(0);
4893                    }
4894    
4895                    return null;
4896            }
4897    
4898            /**
4899             * Returns the journal articles before and after the current journal article in the ordered set where layoutUuid = &#63;.
4900             *
4901             * @param id the primary key of the current journal article
4902             * @param layoutUuid the layout uuid
4903             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4904             * @return the previous, current, and next journal article
4905             * @throws NoSuchArticleException if a journal article with the primary key could not be found
4906             */
4907            @Override
4908            public JournalArticle[] findByLayoutUuid_PrevAndNext(long id,
4909                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator)
4910                    throws NoSuchArticleException {
4911                    JournalArticle journalArticle = findByPrimaryKey(id);
4912    
4913                    Session session = null;
4914    
4915                    try {
4916                            session = openSession();
4917    
4918                            JournalArticle[] array = new JournalArticleImpl[3];
4919    
4920                            array[0] = getByLayoutUuid_PrevAndNext(session, journalArticle,
4921                                            layoutUuid, orderByComparator, true);
4922    
4923                            array[1] = journalArticle;
4924    
4925                            array[2] = getByLayoutUuid_PrevAndNext(session, journalArticle,
4926                                            layoutUuid, orderByComparator, false);
4927    
4928                            return array;
4929                    }
4930                    catch (Exception e) {
4931                            throw processException(e);
4932                    }
4933                    finally {
4934                            closeSession(session);
4935                    }
4936            }
4937    
4938            protected JournalArticle getByLayoutUuid_PrevAndNext(Session session,
4939                    JournalArticle journalArticle, String layoutUuid,
4940                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
4941                    StringBundler query = null;
4942    
4943                    if (orderByComparator != null) {
4944                            query = new StringBundler(6 +
4945                                            (orderByComparator.getOrderByFields().length * 6));
4946                    }
4947                    else {
4948                            query = new StringBundler(3);
4949                    }
4950    
4951                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4952    
4953                    boolean bindLayoutUuid = false;
4954    
4955                    if (layoutUuid == null) {
4956                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
4957                    }
4958                    else if (layoutUuid.equals(StringPool.BLANK)) {
4959                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
4960                    }
4961                    else {
4962                            bindLayoutUuid = true;
4963    
4964                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
4965                    }
4966    
4967                    if (orderByComparator != null) {
4968                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4969    
4970                            if (orderByConditionFields.length > 0) {
4971                                    query.append(WHERE_AND);
4972                            }
4973    
4974                            for (int i = 0; i < orderByConditionFields.length; i++) {
4975                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4976                                    query.append(orderByConditionFields[i]);
4977    
4978                                    if ((i + 1) < orderByConditionFields.length) {
4979                                            if (orderByComparator.isAscending() ^ previous) {
4980                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4981                                            }
4982                                            else {
4983                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4984                                            }
4985                                    }
4986                                    else {
4987                                            if (orderByComparator.isAscending() ^ previous) {
4988                                                    query.append(WHERE_GREATER_THAN);
4989                                            }
4990                                            else {
4991                                                    query.append(WHERE_LESSER_THAN);
4992                                            }
4993                                    }
4994                            }
4995    
4996                            query.append(ORDER_BY_CLAUSE);
4997    
4998                            String[] orderByFields = orderByComparator.getOrderByFields();
4999    
5000                            for (int i = 0; i < orderByFields.length; i++) {
5001                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5002                                    query.append(orderByFields[i]);
5003    
5004                                    if ((i + 1) < orderByFields.length) {
5005                                            if (orderByComparator.isAscending() ^ previous) {
5006                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5007                                            }
5008                                            else {
5009                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5010                                            }
5011                                    }
5012                                    else {
5013                                            if (orderByComparator.isAscending() ^ previous) {
5014                                                    query.append(ORDER_BY_ASC);
5015                                            }
5016                                            else {
5017                                                    query.append(ORDER_BY_DESC);
5018                                            }
5019                                    }
5020                            }
5021                    }
5022                    else {
5023                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5024                    }
5025    
5026                    String sql = query.toString();
5027    
5028                    Query q = session.createQuery(sql);
5029    
5030                    q.setFirstResult(0);
5031                    q.setMaxResults(2);
5032    
5033                    QueryPos qPos = QueryPos.getInstance(q);
5034    
5035                    if (bindLayoutUuid) {
5036                            qPos.add(layoutUuid);
5037                    }
5038    
5039                    if (orderByComparator != null) {
5040                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5041    
5042                            for (Object value : values) {
5043                                    qPos.add(value);
5044                            }
5045                    }
5046    
5047                    List<JournalArticle> list = q.list();
5048    
5049                    if (list.size() == 2) {
5050                            return list.get(1);
5051                    }
5052                    else {
5053                            return null;
5054                    }
5055            }
5056    
5057            /**
5058             * Removes all the journal articles where layoutUuid = &#63; from the database.
5059             *
5060             * @param layoutUuid the layout uuid
5061             */
5062            @Override
5063            public void removeByLayoutUuid(String layoutUuid) {
5064                    for (JournalArticle journalArticle : findByLayoutUuid(layoutUuid,
5065                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5066                            remove(journalArticle);
5067                    }
5068            }
5069    
5070            /**
5071             * Returns the number of journal articles where layoutUuid = &#63;.
5072             *
5073             * @param layoutUuid the layout uuid
5074             * @return the number of matching journal articles
5075             */
5076            @Override
5077            public int countByLayoutUuid(String layoutUuid) {
5078                    FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
5079    
5080                    Object[] finderArgs = new Object[] { layoutUuid };
5081    
5082                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5083                                    this);
5084    
5085                    if (count == null) {
5086                            StringBundler query = new StringBundler(2);
5087    
5088                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5089    
5090                            boolean bindLayoutUuid = false;
5091    
5092                            if (layoutUuid == null) {
5093                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5094                            }
5095                            else if (layoutUuid.equals(StringPool.BLANK)) {
5096                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5097                            }
5098                            else {
5099                                    bindLayoutUuid = true;
5100    
5101                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5102                            }
5103    
5104                            String sql = query.toString();
5105    
5106                            Session session = null;
5107    
5108                            try {
5109                                    session = openSession();
5110    
5111                                    Query q = session.createQuery(sql);
5112    
5113                                    QueryPos qPos = QueryPos.getInstance(q);
5114    
5115                                    if (bindLayoutUuid) {
5116                                            qPos.add(layoutUuid);
5117                                    }
5118    
5119                                    count = (Long)q.uniqueResult();
5120    
5121                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5122                            }
5123                            catch (Exception e) {
5124                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5125    
5126                                    throw processException(e);
5127                            }
5128                            finally {
5129                                    closeSession(session);
5130                            }
5131                    }
5132    
5133                    return count.intValue();
5134            }
5135    
5136            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
5137            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
5138            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
5139            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
5140                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5141                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5142                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5143                            "findBySmallImageId",
5144                            new String[] {
5145                                    Long.class.getName(),
5146                                    
5147                            Integer.class.getName(), Integer.class.getName(),
5148                                    OrderByComparator.class.getName()
5149                            });
5150            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
5151                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5152                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5153                            JournalArticleImpl.class,
5154                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
5155                            new String[] { Long.class.getName() },
5156                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK |
5157                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5158                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5159            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5160                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5161                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
5162                            new String[] { Long.class.getName() });
5163    
5164            /**
5165             * Returns all the journal articles where smallImageId = &#63;.
5166             *
5167             * @param smallImageId the small image ID
5168             * @return the matching journal articles
5169             */
5170            @Override
5171            public List<JournalArticle> findBySmallImageId(long smallImageId) {
5172                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
5173                            QueryUtil.ALL_POS, null);
5174            }
5175    
5176            /**
5177             * Returns a range of all the journal articles where smallImageId = &#63;.
5178             *
5179             * <p>
5180             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5181             * </p>
5182             *
5183             * @param smallImageId the small image ID
5184             * @param start the lower bound of the range of journal articles
5185             * @param end the upper bound of the range of journal articles (not inclusive)
5186             * @return the range of matching journal articles
5187             */
5188            @Override
5189            public List<JournalArticle> findBySmallImageId(long smallImageId,
5190                    int start, int end) {
5191                    return findBySmallImageId(smallImageId, start, end, null);
5192            }
5193    
5194            /**
5195             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
5196             *
5197             * <p>
5198             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5199             * </p>
5200             *
5201             * @param smallImageId the small image ID
5202             * @param start the lower bound of the range of journal articles
5203             * @param end the upper bound of the range of journal articles (not inclusive)
5204             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5205             * @return the ordered range of matching journal articles
5206             */
5207            @Override
5208            public List<JournalArticle> findBySmallImageId(long smallImageId,
5209                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
5210                    boolean pagination = true;
5211                    FinderPath finderPath = null;
5212                    Object[] finderArgs = null;
5213    
5214                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5215                                    (orderByComparator == null)) {
5216                            pagination = false;
5217                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
5218                            finderArgs = new Object[] { smallImageId };
5219                    }
5220                    else {
5221                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
5222                            finderArgs = new Object[] {
5223                                            smallImageId,
5224                                            
5225                                            start, end, orderByComparator
5226                                    };
5227                    }
5228    
5229                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5230                                    finderArgs, this);
5231    
5232                    if ((list != null) && !list.isEmpty()) {
5233                            for (JournalArticle journalArticle : list) {
5234                                    if ((smallImageId != journalArticle.getSmallImageId())) {
5235                                            list = null;
5236    
5237                                            break;
5238                                    }
5239                            }
5240                    }
5241    
5242                    if (list == null) {
5243                            StringBundler query = null;
5244    
5245                            if (orderByComparator != null) {
5246                                    query = new StringBundler(3 +
5247                                                    (orderByComparator.getOrderByFields().length * 3));
5248                            }
5249                            else {
5250                                    query = new StringBundler(3);
5251                            }
5252    
5253                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5254    
5255                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5256    
5257                            if (orderByComparator != null) {
5258                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5259                                            orderByComparator);
5260                            }
5261                            else
5262                             if (pagination) {
5263                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5264                            }
5265    
5266                            String sql = query.toString();
5267    
5268                            Session session = null;
5269    
5270                            try {
5271                                    session = openSession();
5272    
5273                                    Query q = session.createQuery(sql);
5274    
5275                                    QueryPos qPos = QueryPos.getInstance(q);
5276    
5277                                    qPos.add(smallImageId);
5278    
5279                                    if (!pagination) {
5280                                            list = (List<JournalArticle>)QueryUtil.list(q,
5281                                                            getDialect(), start, end, false);
5282    
5283                                            Collections.sort(list);
5284    
5285                                            list = Collections.unmodifiableList(list);
5286                                    }
5287                                    else {
5288                                            list = (List<JournalArticle>)QueryUtil.list(q,
5289                                                            getDialect(), start, end);
5290                                    }
5291    
5292                                    cacheResult(list);
5293    
5294                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5295                            }
5296                            catch (Exception e) {
5297                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5298    
5299                                    throw processException(e);
5300                            }
5301                            finally {
5302                                    closeSession(session);
5303                            }
5304                    }
5305    
5306                    return list;
5307            }
5308    
5309            /**
5310             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5311             *
5312             * @param smallImageId the small image ID
5313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5314             * @return the first matching journal article
5315             * @throws NoSuchArticleException if a matching journal article could not be found
5316             */
5317            @Override
5318            public JournalArticle findBySmallImageId_First(long smallImageId,
5319                    OrderByComparator<JournalArticle> orderByComparator)
5320                    throws NoSuchArticleException {
5321                    JournalArticle journalArticle = fetchBySmallImageId_First(smallImageId,
5322                                    orderByComparator);
5323    
5324                    if (journalArticle != null) {
5325                            return journalArticle;
5326                    }
5327    
5328                    StringBundler msg = new StringBundler(4);
5329    
5330                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5331    
5332                    msg.append("smallImageId=");
5333                    msg.append(smallImageId);
5334    
5335                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5336    
5337                    throw new NoSuchArticleException(msg.toString());
5338            }
5339    
5340            /**
5341             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5342             *
5343             * @param smallImageId the small image ID
5344             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5345             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5346             */
5347            @Override
5348            public JournalArticle fetchBySmallImageId_First(long smallImageId,
5349                    OrderByComparator<JournalArticle> orderByComparator) {
5350                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
5351                                    orderByComparator);
5352    
5353                    if (!list.isEmpty()) {
5354                            return list.get(0);
5355                    }
5356    
5357                    return null;
5358            }
5359    
5360            /**
5361             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5362             *
5363             * @param smallImageId the small image ID
5364             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5365             * @return the last matching journal article
5366             * @throws NoSuchArticleException if a matching journal article could not be found
5367             */
5368            @Override
5369            public JournalArticle findBySmallImageId_Last(long smallImageId,
5370                    OrderByComparator<JournalArticle> orderByComparator)
5371                    throws NoSuchArticleException {
5372                    JournalArticle journalArticle = fetchBySmallImageId_Last(smallImageId,
5373                                    orderByComparator);
5374    
5375                    if (journalArticle != null) {
5376                            return journalArticle;
5377                    }
5378    
5379                    StringBundler msg = new StringBundler(4);
5380    
5381                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5382    
5383                    msg.append("smallImageId=");
5384                    msg.append(smallImageId);
5385    
5386                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5387    
5388                    throw new NoSuchArticleException(msg.toString());
5389            }
5390    
5391            /**
5392             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5393             *
5394             * @param smallImageId the small image ID
5395             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5396             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5397             */
5398            @Override
5399            public JournalArticle fetchBySmallImageId_Last(long smallImageId,
5400                    OrderByComparator<JournalArticle> orderByComparator) {
5401                    int count = countBySmallImageId(smallImageId);
5402    
5403                    if (count == 0) {
5404                            return null;
5405                    }
5406    
5407                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
5408                                    count, orderByComparator);
5409    
5410                    if (!list.isEmpty()) {
5411                            return list.get(0);
5412                    }
5413    
5414                    return null;
5415            }
5416    
5417            /**
5418             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
5419             *
5420             * @param id the primary key of the current journal article
5421             * @param smallImageId the small image ID
5422             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5423             * @return the previous, current, and next journal article
5424             * @throws NoSuchArticleException if a journal article with the primary key could not be found
5425             */
5426            @Override
5427            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
5428                    long smallImageId, OrderByComparator<JournalArticle> orderByComparator)
5429                    throws NoSuchArticleException {
5430                    JournalArticle journalArticle = findByPrimaryKey(id);
5431    
5432                    Session session = null;
5433    
5434                    try {
5435                            session = openSession();
5436    
5437                            JournalArticle[] array = new JournalArticleImpl[3];
5438    
5439                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
5440                                            smallImageId, orderByComparator, true);
5441    
5442                            array[1] = journalArticle;
5443    
5444                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
5445                                            smallImageId, orderByComparator, false);
5446    
5447                            return array;
5448                    }
5449                    catch (Exception e) {
5450                            throw processException(e);
5451                    }
5452                    finally {
5453                            closeSession(session);
5454                    }
5455            }
5456    
5457            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
5458                    JournalArticle journalArticle, long smallImageId,
5459                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
5460                    StringBundler query = null;
5461    
5462                    if (orderByComparator != null) {
5463                            query = new StringBundler(6 +
5464                                            (orderByComparator.getOrderByFields().length * 6));
5465                    }
5466                    else {
5467                            query = new StringBundler(3);
5468                    }
5469    
5470                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5471    
5472                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5473    
5474                    if (orderByComparator != null) {
5475                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5476    
5477                            if (orderByConditionFields.length > 0) {
5478                                    query.append(WHERE_AND);
5479                            }
5480    
5481                            for (int i = 0; i < orderByConditionFields.length; i++) {
5482                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5483                                    query.append(orderByConditionFields[i]);
5484    
5485                                    if ((i + 1) < orderByConditionFields.length) {
5486                                            if (orderByComparator.isAscending() ^ previous) {
5487                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5488                                            }
5489                                            else {
5490                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5491                                            }
5492                                    }
5493                                    else {
5494                                            if (orderByComparator.isAscending() ^ previous) {
5495                                                    query.append(WHERE_GREATER_THAN);
5496                                            }
5497                                            else {
5498                                                    query.append(WHERE_LESSER_THAN);
5499                                            }
5500                                    }
5501                            }
5502    
5503                            query.append(ORDER_BY_CLAUSE);
5504    
5505                            String[] orderByFields = orderByComparator.getOrderByFields();
5506    
5507                            for (int i = 0; i < orderByFields.length; i++) {
5508                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5509                                    query.append(orderByFields[i]);
5510    
5511                                    if ((i + 1) < orderByFields.length) {
5512                                            if (orderByComparator.isAscending() ^ previous) {
5513                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5514                                            }
5515                                            else {
5516                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5517                                            }
5518                                    }
5519                                    else {
5520                                            if (orderByComparator.isAscending() ^ previous) {
5521                                                    query.append(ORDER_BY_ASC);
5522                                            }
5523                                            else {
5524                                                    query.append(ORDER_BY_DESC);
5525                                            }
5526                                    }
5527                            }
5528                    }
5529                    else {
5530                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5531                    }
5532    
5533                    String sql = query.toString();
5534    
5535                    Query q = session.createQuery(sql);
5536    
5537                    q.setFirstResult(0);
5538                    q.setMaxResults(2);
5539    
5540                    QueryPos qPos = QueryPos.getInstance(q);
5541    
5542                    qPos.add(smallImageId);
5543    
5544                    if (orderByComparator != null) {
5545                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5546    
5547                            for (Object value : values) {
5548                                    qPos.add(value);
5549                            }
5550                    }
5551    
5552                    List<JournalArticle> list = q.list();
5553    
5554                    if (list.size() == 2) {
5555                            return list.get(1);
5556                    }
5557                    else {
5558                            return null;
5559                    }
5560            }
5561    
5562            /**
5563             * Removes all the journal articles where smallImageId = &#63; from the database.
5564             *
5565             * @param smallImageId the small image ID
5566             */
5567            @Override
5568            public void removeBySmallImageId(long smallImageId) {
5569                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId,
5570                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5571                            remove(journalArticle);
5572                    }
5573            }
5574    
5575            /**
5576             * Returns the number of journal articles where smallImageId = &#63;.
5577             *
5578             * @param smallImageId the small image ID
5579             * @return the number of matching journal articles
5580             */
5581            @Override
5582            public int countBySmallImageId(long smallImageId) {
5583                    FinderPath finderPath = FINDER_PATH_COUNT_BY_SMALLIMAGEID;
5584    
5585                    Object[] finderArgs = new Object[] { smallImageId };
5586    
5587                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5588                                    this);
5589    
5590                    if (count == null) {
5591                            StringBundler query = new StringBundler(2);
5592    
5593                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
5594    
5595                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5596    
5597                            String sql = query.toString();
5598    
5599                            Session session = null;
5600    
5601                            try {
5602                                    session = openSession();
5603    
5604                                    Query q = session.createQuery(sql);
5605    
5606                                    QueryPos qPos = QueryPos.getInstance(q);
5607    
5608                                    qPos.add(smallImageId);
5609    
5610                                    count = (Long)q.uniqueResult();
5611    
5612                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5613                            }
5614                            catch (Exception e) {
5615                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5616    
5617                                    throw processException(e);
5618                            }
5619                            finally {
5620                                    closeSession(session);
5621                            }
5622                    }
5623    
5624                    return count.intValue();
5625            }
5626    
5627            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
5628            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5629                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5630                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5631                            "findByR_I",
5632                            new String[] {
5633                                    Long.class.getName(), Boolean.class.getName(),
5634                                    
5635                            Integer.class.getName(), Integer.class.getName(),
5636                                    OrderByComparator.class.getName()
5637                            });
5638            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5639                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
5640                            JournalArticleImpl.class,
5641                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I",
5642                            new String[] { Long.class.getName(), Boolean.class.getName() },
5643                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
5644                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
5645                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
5646                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
5647            public static final FinderPath FINDER_PATH_COUNT_BY_R_I = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
5648                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
5649                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I",
5650                            new String[] { Long.class.getName(), Boolean.class.getName() });
5651    
5652            /**
5653             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5654             *
5655             * @param resourcePrimKey the resource prim key
5656             * @param indexable the indexable
5657             * @return the matching journal articles
5658             */
5659            @Override
5660            public List<JournalArticle> findByR_I(long resourcePrimKey,
5661                    boolean indexable) {
5662                    return findByR_I(resourcePrimKey, indexable, QueryUtil.ALL_POS,
5663                            QueryUtil.ALL_POS, null);
5664            }
5665    
5666            /**
5667             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5668             *
5669             * <p>
5670             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5671             * </p>
5672             *
5673             * @param resourcePrimKey the resource prim key
5674             * @param indexable the indexable
5675             * @param start the lower bound of the range of journal articles
5676             * @param end the upper bound of the range of journal articles (not inclusive)
5677             * @return the range of matching journal articles
5678             */
5679            @Override
5680            public List<JournalArticle> findByR_I(long resourcePrimKey,
5681                    boolean indexable, int start, int end) {
5682                    return findByR_I(resourcePrimKey, indexable, start, end, null);
5683            }
5684    
5685            /**
5686             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63;.
5687             *
5688             * <p>
5689             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5690             * </p>
5691             *
5692             * @param resourcePrimKey the resource prim key
5693             * @param indexable the indexable
5694             * @param start the lower bound of the range of journal articles
5695             * @param end the upper bound of the range of journal articles (not inclusive)
5696             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5697             * @return the ordered range of matching journal articles
5698             */
5699            @Override
5700            public List<JournalArticle> findByR_I(long resourcePrimKey,
5701                    boolean indexable, int start, int end,
5702                    OrderByComparator<JournalArticle> orderByComparator) {
5703                    boolean pagination = true;
5704                    FinderPath finderPath = null;
5705                    Object[] finderArgs = null;
5706    
5707                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5708                                    (orderByComparator == null)) {
5709                            pagination = false;
5710                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I;
5711                            finderArgs = new Object[] { resourcePrimKey, indexable };
5712                    }
5713                    else {
5714                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I;
5715                            finderArgs = new Object[] {
5716                                            resourcePrimKey, indexable,
5717                                            
5718                                            start, end, orderByComparator
5719                                    };
5720                    }
5721    
5722                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5723                                    finderArgs, this);
5724    
5725                    if ((list != null) && !list.isEmpty()) {
5726                            for (JournalArticle journalArticle : list) {
5727                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
5728                                                    (indexable != journalArticle.getIndexable())) {
5729                                            list = null;
5730    
5731                                            break;
5732                                    }
5733                            }
5734                    }
5735    
5736                    if (list == null) {
5737                            StringBundler query = null;
5738    
5739                            if (orderByComparator != null) {
5740                                    query = new StringBundler(4 +
5741                                                    (orderByComparator.getOrderByFields().length * 3));
5742                            }
5743                            else {
5744                                    query = new StringBundler(4);
5745                            }
5746    
5747                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5748    
5749                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
5750    
5751                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
5752    
5753                            if (orderByComparator != null) {
5754                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5755                                            orderByComparator);
5756                            }
5757                            else
5758                             if (pagination) {
5759                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5760                            }
5761    
5762                            String sql = query.toString();
5763    
5764                            Session session = null;
5765    
5766                            try {
5767                                    session = openSession();
5768    
5769                                    Query q = session.createQuery(sql);
5770    
5771                                    QueryPos qPos = QueryPos.getInstance(q);
5772    
5773                                    qPos.add(resourcePrimKey);
5774    
5775                                    qPos.add(indexable);
5776    
5777                                    if (!pagination) {
5778                                            list = (List<JournalArticle>)QueryUtil.list(q,
5779                                                            getDialect(), start, end, false);
5780    
5781                                            Collections.sort(list);
5782    
5783                                            list = Collections.unmodifiableList(list);
5784                                    }
5785                                    else {
5786                                            list = (List<JournalArticle>)QueryUtil.list(q,
5787                                                            getDialect(), start, end);
5788                                    }
5789    
5790                                    cacheResult(list);
5791    
5792                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5793                            }
5794                            catch (Exception e) {
5795                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5796    
5797                                    throw processException(e);
5798                            }
5799                            finally {
5800                                    closeSession(session);
5801                            }
5802                    }
5803    
5804                    return list;
5805            }
5806    
5807            /**
5808             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5809             *
5810             * @param resourcePrimKey the resource prim key
5811             * @param indexable the indexable
5812             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5813             * @return the first matching journal article
5814             * @throws NoSuchArticleException if a matching journal article could not be found
5815             */
5816            @Override
5817            public JournalArticle findByR_I_First(long resourcePrimKey,
5818                    boolean indexable, OrderByComparator<JournalArticle> orderByComparator)
5819                    throws NoSuchArticleException {
5820                    JournalArticle journalArticle = fetchByR_I_First(resourcePrimKey,
5821                                    indexable, orderByComparator);
5822    
5823                    if (journalArticle != null) {
5824                            return journalArticle;
5825                    }
5826    
5827                    StringBundler msg = new StringBundler(6);
5828    
5829                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5830    
5831                    msg.append("resourcePrimKey=");
5832                    msg.append(resourcePrimKey);
5833    
5834                    msg.append(", indexable=");
5835                    msg.append(indexable);
5836    
5837                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5838    
5839                    throw new NoSuchArticleException(msg.toString());
5840            }
5841    
5842            /**
5843             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5844             *
5845             * @param resourcePrimKey the resource prim key
5846             * @param indexable the indexable
5847             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5848             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5849             */
5850            @Override
5851            public JournalArticle fetchByR_I_First(long resourcePrimKey,
5852                    boolean indexable, OrderByComparator<JournalArticle> orderByComparator) {
5853                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable, 0, 1,
5854                                    orderByComparator);
5855    
5856                    if (!list.isEmpty()) {
5857                            return list.get(0);
5858                    }
5859    
5860                    return null;
5861            }
5862    
5863            /**
5864             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5865             *
5866             * @param resourcePrimKey the resource prim key
5867             * @param indexable the indexable
5868             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5869             * @return the last matching journal article
5870             * @throws NoSuchArticleException if a matching journal article could not be found
5871             */
5872            @Override
5873            public JournalArticle findByR_I_Last(long resourcePrimKey,
5874                    boolean indexable, OrderByComparator<JournalArticle> orderByComparator)
5875                    throws NoSuchArticleException {
5876                    JournalArticle journalArticle = fetchByR_I_Last(resourcePrimKey,
5877                                    indexable, orderByComparator);
5878    
5879                    if (journalArticle != null) {
5880                            return journalArticle;
5881                    }
5882    
5883                    StringBundler msg = new StringBundler(6);
5884    
5885                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5886    
5887                    msg.append("resourcePrimKey=");
5888                    msg.append(resourcePrimKey);
5889    
5890                    msg.append(", indexable=");
5891                    msg.append(indexable);
5892    
5893                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5894    
5895                    throw new NoSuchArticleException(msg.toString());
5896            }
5897    
5898            /**
5899             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5900             *
5901             * @param resourcePrimKey the resource prim key
5902             * @param indexable the indexable
5903             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5904             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5905             */
5906            @Override
5907            public JournalArticle fetchByR_I_Last(long resourcePrimKey,
5908                    boolean indexable, OrderByComparator<JournalArticle> orderByComparator) {
5909                    int count = countByR_I(resourcePrimKey, indexable);
5910    
5911                    if (count == 0) {
5912                            return null;
5913                    }
5914    
5915                    List<JournalArticle> list = findByR_I(resourcePrimKey, indexable,
5916                                    count - 1, count, orderByComparator);
5917    
5918                    if (!list.isEmpty()) {
5919                            return list.get(0);
5920                    }
5921    
5922                    return null;
5923            }
5924    
5925            /**
5926             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63;.
5927             *
5928             * @param id the primary key of the current journal article
5929             * @param resourcePrimKey the resource prim key
5930             * @param indexable the indexable
5931             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5932             * @return the previous, current, and next journal article
5933             * @throws NoSuchArticleException if a journal article with the primary key could not be found
5934             */
5935            @Override
5936            public JournalArticle[] findByR_I_PrevAndNext(long id,
5937                    long resourcePrimKey, boolean indexable,
5938                    OrderByComparator<JournalArticle> orderByComparator)
5939                    throws NoSuchArticleException {
5940                    JournalArticle journalArticle = findByPrimaryKey(id);
5941    
5942                    Session session = null;
5943    
5944                    try {
5945                            session = openSession();
5946    
5947                            JournalArticle[] array = new JournalArticleImpl[3];
5948    
5949                            array[0] = getByR_I_PrevAndNext(session, journalArticle,
5950                                            resourcePrimKey, indexable, orderByComparator, true);
5951    
5952                            array[1] = journalArticle;
5953    
5954                            array[2] = getByR_I_PrevAndNext(session, journalArticle,
5955                                            resourcePrimKey, indexable, orderByComparator, false);
5956    
5957                            return array;
5958                    }
5959                    catch (Exception e) {
5960                            throw processException(e);
5961                    }
5962                    finally {
5963                            closeSession(session);
5964                    }
5965            }
5966    
5967            protected JournalArticle getByR_I_PrevAndNext(Session session,
5968                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
5969                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
5970                    StringBundler query = null;
5971    
5972                    if (orderByComparator != null) {
5973                            query = new StringBundler(6 +
5974                                            (orderByComparator.getOrderByFields().length * 6));
5975                    }
5976                    else {
5977                            query = new StringBundler(3);
5978                    }
5979    
5980                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5981    
5982                    query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
5983    
5984                    query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
5985    
5986                    if (orderByComparator != null) {
5987                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5988    
5989                            if (orderByConditionFields.length > 0) {
5990                                    query.append(WHERE_AND);
5991                            }
5992    
5993                            for (int i = 0; i < orderByConditionFields.length; i++) {
5994                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5995                                    query.append(orderByConditionFields[i]);
5996    
5997                                    if ((i + 1) < orderByConditionFields.length) {
5998                                            if (orderByComparator.isAscending() ^ previous) {
5999                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6000                                            }
6001                                            else {
6002                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6003                                            }
6004                                    }
6005                                    else {
6006                                            if (orderByComparator.isAscending() ^ previous) {
6007                                                    query.append(WHERE_GREATER_THAN);
6008                                            }
6009                                            else {
6010                                                    query.append(WHERE_LESSER_THAN);
6011                                            }
6012                                    }
6013                            }
6014    
6015                            query.append(ORDER_BY_CLAUSE);
6016    
6017                            String[] orderByFields = orderByComparator.getOrderByFields();
6018    
6019                            for (int i = 0; i < orderByFields.length; i++) {
6020                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6021                                    query.append(orderByFields[i]);
6022    
6023                                    if ((i + 1) < orderByFields.length) {
6024                                            if (orderByComparator.isAscending() ^ previous) {
6025                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6026                                            }
6027                                            else {
6028                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6029                                            }
6030                                    }
6031                                    else {
6032                                            if (orderByComparator.isAscending() ^ previous) {
6033                                                    query.append(ORDER_BY_ASC);
6034                                            }
6035                                            else {
6036                                                    query.append(ORDER_BY_DESC);
6037                                            }
6038                                    }
6039                            }
6040                    }
6041                    else {
6042                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6043                    }
6044    
6045                    String sql = query.toString();
6046    
6047                    Query q = session.createQuery(sql);
6048    
6049                    q.setFirstResult(0);
6050                    q.setMaxResults(2);
6051    
6052                    QueryPos qPos = QueryPos.getInstance(q);
6053    
6054                    qPos.add(resourcePrimKey);
6055    
6056                    qPos.add(indexable);
6057    
6058                    if (orderByComparator != null) {
6059                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6060    
6061                            for (Object value : values) {
6062                                    qPos.add(value);
6063                            }
6064                    }
6065    
6066                    List<JournalArticle> list = q.list();
6067    
6068                    if (list.size() == 2) {
6069                            return list.get(1);
6070                    }
6071                    else {
6072                            return null;
6073                    }
6074            }
6075    
6076            /**
6077             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; from the database.
6078             *
6079             * @param resourcePrimKey the resource prim key
6080             * @param indexable the indexable
6081             */
6082            @Override
6083            public void removeByR_I(long resourcePrimKey, boolean indexable) {
6084                    for (JournalArticle journalArticle : findByR_I(resourcePrimKey,
6085                                    indexable, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6086                            remove(journalArticle);
6087                    }
6088            }
6089    
6090            /**
6091             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63;.
6092             *
6093             * @param resourcePrimKey the resource prim key
6094             * @param indexable the indexable
6095             * @return the number of matching journal articles
6096             */
6097            @Override
6098            public int countByR_I(long resourcePrimKey, boolean indexable) {
6099                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I;
6100    
6101                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable };
6102    
6103                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6104                                    this);
6105    
6106                    if (count == null) {
6107                            StringBundler query = new StringBundler(3);
6108    
6109                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6110    
6111                            query.append(_FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2);
6112    
6113                            query.append(_FINDER_COLUMN_R_I_INDEXABLE_2);
6114    
6115                            String sql = query.toString();
6116    
6117                            Session session = null;
6118    
6119                            try {
6120                                    session = openSession();
6121    
6122                                    Query q = session.createQuery(sql);
6123    
6124                                    QueryPos qPos = QueryPos.getInstance(q);
6125    
6126                                    qPos.add(resourcePrimKey);
6127    
6128                                    qPos.add(indexable);
6129    
6130                                    count = (Long)q.uniqueResult();
6131    
6132                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6133                            }
6134                            catch (Exception e) {
6135                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6136    
6137                                    throw processException(e);
6138                            }
6139                            finally {
6140                                    closeSession(session);
6141                            }
6142                    }
6143    
6144                    return count.intValue();
6145            }
6146    
6147            private static final String _FINDER_COLUMN_R_I_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
6148            private static final String _FINDER_COLUMN_R_I_INDEXABLE_2 = "journalArticle.indexable = ?";
6149            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6150                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6151                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6152                            "findByR_ST",
6153                            new String[] {
6154                                    Long.class.getName(), Integer.class.getName(),
6155                                    
6156                            Integer.class.getName(), Integer.class.getName(),
6157                                    OrderByComparator.class.getName()
6158                            });
6159            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6160                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6161                            JournalArticleImpl.class,
6162                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
6163                            new String[] { Long.class.getName(), Integer.class.getName() },
6164                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
6165                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
6166                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6167                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6168            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6169                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6170                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
6171                            new String[] { Long.class.getName(), Integer.class.getName() });
6172            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6173                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6174                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_ST",
6175                            new String[] { Long.class.getName(), Integer.class.getName() });
6176    
6177            /**
6178             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6179             *
6180             * @param resourcePrimKey the resource prim key
6181             * @param status the status
6182             * @return the matching journal articles
6183             */
6184            @Override
6185            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status) {
6186                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
6187                            QueryUtil.ALL_POS, null);
6188            }
6189    
6190            /**
6191             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6192             *
6193             * <p>
6194             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6195             * </p>
6196             *
6197             * @param resourcePrimKey the resource prim key
6198             * @param status the status
6199             * @param start the lower bound of the range of journal articles
6200             * @param end the upper bound of the range of journal articles (not inclusive)
6201             * @return the range of matching journal articles
6202             */
6203            @Override
6204            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6205                    int start, int end) {
6206                    return findByR_ST(resourcePrimKey, status, start, end, null);
6207            }
6208    
6209            /**
6210             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6211             *
6212             * <p>
6213             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6214             * </p>
6215             *
6216             * @param resourcePrimKey the resource prim key
6217             * @param status the status
6218             * @param start the lower bound of the range of journal articles
6219             * @param end the upper bound of the range of journal articles (not inclusive)
6220             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6221             * @return the ordered range of matching journal articles
6222             */
6223            @Override
6224            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6225                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
6226                    boolean pagination = true;
6227                    FinderPath finderPath = null;
6228                    Object[] finderArgs = null;
6229    
6230                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6231                                    (orderByComparator == null)) {
6232                            pagination = false;
6233                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
6234                            finderArgs = new Object[] { resourcePrimKey, status };
6235                    }
6236                    else {
6237                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
6238                            finderArgs = new Object[] {
6239                                            resourcePrimKey, status,
6240                                            
6241                                            start, end, orderByComparator
6242                                    };
6243                    }
6244    
6245                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6246                                    finderArgs, this);
6247    
6248                    if ((list != null) && !list.isEmpty()) {
6249                            for (JournalArticle journalArticle : list) {
6250                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6251                                                    (status != journalArticle.getStatus())) {
6252                                            list = null;
6253    
6254                                            break;
6255                                    }
6256                            }
6257                    }
6258    
6259                    if (list == null) {
6260                            StringBundler query = null;
6261    
6262                            if (orderByComparator != null) {
6263                                    query = new StringBundler(4 +
6264                                                    (orderByComparator.getOrderByFields().length * 3));
6265                            }
6266                            else {
6267                                    query = new StringBundler(4);
6268                            }
6269    
6270                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6271    
6272                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6273    
6274                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6275    
6276                            if (orderByComparator != null) {
6277                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6278                                            orderByComparator);
6279                            }
6280                            else
6281                             if (pagination) {
6282                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6283                            }
6284    
6285                            String sql = query.toString();
6286    
6287                            Session session = null;
6288    
6289                            try {
6290                                    session = openSession();
6291    
6292                                    Query q = session.createQuery(sql);
6293    
6294                                    QueryPos qPos = QueryPos.getInstance(q);
6295    
6296                                    qPos.add(resourcePrimKey);
6297    
6298                                    qPos.add(status);
6299    
6300                                    if (!pagination) {
6301                                            list = (List<JournalArticle>)QueryUtil.list(q,
6302                                                            getDialect(), start, end, false);
6303    
6304                                            Collections.sort(list);
6305    
6306                                            list = Collections.unmodifiableList(list);
6307                                    }
6308                                    else {
6309                                            list = (List<JournalArticle>)QueryUtil.list(q,
6310                                                            getDialect(), start, end);
6311                                    }
6312    
6313                                    cacheResult(list);
6314    
6315                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6316                            }
6317                            catch (Exception e) {
6318                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6319    
6320                                    throw processException(e);
6321                            }
6322                            finally {
6323                                    closeSession(session);
6324                            }
6325                    }
6326    
6327                    return list;
6328            }
6329    
6330            /**
6331             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6332             *
6333             * @param resourcePrimKey the resource prim key
6334             * @param status the status
6335             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6336             * @return the first matching journal article
6337             * @throws NoSuchArticleException if a matching journal article could not be found
6338             */
6339            @Override
6340            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
6341                    OrderByComparator<JournalArticle> orderByComparator)
6342                    throws NoSuchArticleException {
6343                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
6344                                    status, orderByComparator);
6345    
6346                    if (journalArticle != null) {
6347                            return journalArticle;
6348                    }
6349    
6350                    StringBundler msg = new StringBundler(6);
6351    
6352                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6353    
6354                    msg.append("resourcePrimKey=");
6355                    msg.append(resourcePrimKey);
6356    
6357                    msg.append(", status=");
6358                    msg.append(status);
6359    
6360                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6361    
6362                    throw new NoSuchArticleException(msg.toString());
6363            }
6364    
6365            /**
6366             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6367             *
6368             * @param resourcePrimKey the resource prim key
6369             * @param status the status
6370             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6371             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6372             */
6373            @Override
6374            public JournalArticle fetchByR_ST_First(long resourcePrimKey, int status,
6375                    OrderByComparator<JournalArticle> orderByComparator) {
6376                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
6377                                    orderByComparator);
6378    
6379                    if (!list.isEmpty()) {
6380                            return list.get(0);
6381                    }
6382    
6383                    return null;
6384            }
6385    
6386            /**
6387             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6388             *
6389             * @param resourcePrimKey the resource prim key
6390             * @param status the status
6391             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6392             * @return the last matching journal article
6393             * @throws NoSuchArticleException if a matching journal article could not be found
6394             */
6395            @Override
6396            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
6397                    OrderByComparator<JournalArticle> orderByComparator)
6398                    throws NoSuchArticleException {
6399                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
6400                                    status, orderByComparator);
6401    
6402                    if (journalArticle != null) {
6403                            return journalArticle;
6404                    }
6405    
6406                    StringBundler msg = new StringBundler(6);
6407    
6408                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6409    
6410                    msg.append("resourcePrimKey=");
6411                    msg.append(resourcePrimKey);
6412    
6413                    msg.append(", status=");
6414                    msg.append(status);
6415    
6416                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6417    
6418                    throw new NoSuchArticleException(msg.toString());
6419            }
6420    
6421            /**
6422             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6423             *
6424             * @param resourcePrimKey the resource prim key
6425             * @param status the status
6426             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6427             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6428             */
6429            @Override
6430            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
6431                    OrderByComparator<JournalArticle> orderByComparator) {
6432                    int count = countByR_ST(resourcePrimKey, status);
6433    
6434                    if (count == 0) {
6435                            return null;
6436                    }
6437    
6438                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
6439                                    count - 1, count, orderByComparator);
6440    
6441                    if (!list.isEmpty()) {
6442                            return list.get(0);
6443                    }
6444    
6445                    return null;
6446            }
6447    
6448            /**
6449             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6450             *
6451             * @param id the primary key of the current journal article
6452             * @param resourcePrimKey the resource prim key
6453             * @param status the status
6454             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6455             * @return the previous, current, and next journal article
6456             * @throws NoSuchArticleException if a journal article with the primary key could not be found
6457             */
6458            @Override
6459            public JournalArticle[] findByR_ST_PrevAndNext(long id,
6460                    long resourcePrimKey, int status,
6461                    OrderByComparator<JournalArticle> orderByComparator)
6462                    throws NoSuchArticleException {
6463                    JournalArticle journalArticle = findByPrimaryKey(id);
6464    
6465                    Session session = null;
6466    
6467                    try {
6468                            session = openSession();
6469    
6470                            JournalArticle[] array = new JournalArticleImpl[3];
6471    
6472                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
6473                                            resourcePrimKey, status, orderByComparator, true);
6474    
6475                            array[1] = journalArticle;
6476    
6477                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
6478                                            resourcePrimKey, status, orderByComparator, false);
6479    
6480                            return array;
6481                    }
6482                    catch (Exception e) {
6483                            throw processException(e);
6484                    }
6485                    finally {
6486                            closeSession(session);
6487                    }
6488            }
6489    
6490            protected JournalArticle getByR_ST_PrevAndNext(Session session,
6491                    JournalArticle journalArticle, long resourcePrimKey, int status,
6492                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
6493                    StringBundler query = null;
6494    
6495                    if (orderByComparator != null) {
6496                            query = new StringBundler(6 +
6497                                            (orderByComparator.getOrderByFields().length * 6));
6498                    }
6499                    else {
6500                            query = new StringBundler(3);
6501                    }
6502    
6503                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6504    
6505                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6506    
6507                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6508    
6509                    if (orderByComparator != null) {
6510                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6511    
6512                            if (orderByConditionFields.length > 0) {
6513                                    query.append(WHERE_AND);
6514                            }
6515    
6516                            for (int i = 0; i < orderByConditionFields.length; i++) {
6517                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6518                                    query.append(orderByConditionFields[i]);
6519    
6520                                    if ((i + 1) < orderByConditionFields.length) {
6521                                            if (orderByComparator.isAscending() ^ previous) {
6522                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6523                                            }
6524                                            else {
6525                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6526                                            }
6527                                    }
6528                                    else {
6529                                            if (orderByComparator.isAscending() ^ previous) {
6530                                                    query.append(WHERE_GREATER_THAN);
6531                                            }
6532                                            else {
6533                                                    query.append(WHERE_LESSER_THAN);
6534                                            }
6535                                    }
6536                            }
6537    
6538                            query.append(ORDER_BY_CLAUSE);
6539    
6540                            String[] orderByFields = orderByComparator.getOrderByFields();
6541    
6542                            for (int i = 0; i < orderByFields.length; i++) {
6543                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6544                                    query.append(orderByFields[i]);
6545    
6546                                    if ((i + 1) < orderByFields.length) {
6547                                            if (orderByComparator.isAscending() ^ previous) {
6548                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6549                                            }
6550                                            else {
6551                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6552                                            }
6553                                    }
6554                                    else {
6555                                            if (orderByComparator.isAscending() ^ previous) {
6556                                                    query.append(ORDER_BY_ASC);
6557                                            }
6558                                            else {
6559                                                    query.append(ORDER_BY_DESC);
6560                                            }
6561                                    }
6562                            }
6563                    }
6564                    else {
6565                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6566                    }
6567    
6568                    String sql = query.toString();
6569    
6570                    Query q = session.createQuery(sql);
6571    
6572                    q.setFirstResult(0);
6573                    q.setMaxResults(2);
6574    
6575                    QueryPos qPos = QueryPos.getInstance(q);
6576    
6577                    qPos.add(resourcePrimKey);
6578    
6579                    qPos.add(status);
6580    
6581                    if (orderByComparator != null) {
6582                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6583    
6584                            for (Object value : values) {
6585                                    qPos.add(value);
6586                            }
6587                    }
6588    
6589                    List<JournalArticle> list = q.list();
6590    
6591                    if (list.size() == 2) {
6592                            return list.get(1);
6593                    }
6594                    else {
6595                            return null;
6596                    }
6597            }
6598    
6599            /**
6600             * Returns all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6601             *
6602             * <p>
6603             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6604             * </p>
6605             *
6606             * @param resourcePrimKey the resource prim key
6607             * @param statuses the statuses
6608             * @return the matching journal articles
6609             */
6610            @Override
6611            public List<JournalArticle> findByR_ST(long resourcePrimKey, int[] statuses) {
6612                    return findByR_ST(resourcePrimKey, statuses, QueryUtil.ALL_POS,
6613                            QueryUtil.ALL_POS, null);
6614            }
6615    
6616            /**
6617             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6618             *
6619             * <p>
6620             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6621             * </p>
6622             *
6623             * @param resourcePrimKey the resource prim key
6624             * @param statuses the statuses
6625             * @param start the lower bound of the range of journal articles
6626             * @param end the upper bound of the range of journal articles (not inclusive)
6627             * @return the range of matching journal articles
6628             */
6629            @Override
6630            public List<JournalArticle> findByR_ST(long resourcePrimKey,
6631                    int[] statuses, int start, int end) {
6632                    return findByR_ST(resourcePrimKey, statuses, start, end, null);
6633            }
6634    
6635            /**
6636             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = any &#63;.
6637             *
6638             * <p>
6639             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6640             * </p>
6641             *
6642             * @param resourcePrimKey the resource prim key
6643             * @param statuses the statuses
6644             * @param start the lower bound of the range of journal articles
6645             * @param end the upper bound of the range of journal articles (not inclusive)
6646             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6647             * @return the ordered range of matching journal articles
6648             */
6649            @Override
6650            public List<JournalArticle> findByR_ST(long resourcePrimKey,
6651                    int[] statuses, int start, int end,
6652                    OrderByComparator<JournalArticle> orderByComparator) {
6653                    if (statuses == null) {
6654                            statuses = new int[0];
6655                    }
6656                    else {
6657                            statuses = ArrayUtil.unique(statuses);
6658                    }
6659    
6660                    if (statuses.length == 1) {
6661                            return findByR_ST(resourcePrimKey, statuses[0], start, end,
6662                                    orderByComparator);
6663                    }
6664    
6665                    boolean pagination = true;
6666                    Object[] finderArgs = null;
6667    
6668                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6669                                    (orderByComparator == null)) {
6670                            pagination = false;
6671                            finderArgs = new Object[] {
6672                                            resourcePrimKey, StringUtil.merge(statuses)
6673                                    };
6674                    }
6675                    else {
6676                            finderArgs = new Object[] {
6677                                            resourcePrimKey, StringUtil.merge(statuses),
6678                                            
6679                                            start, end, orderByComparator
6680                                    };
6681                    }
6682    
6683                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6684                                    finderArgs, this);
6685    
6686                    if ((list != null) && !list.isEmpty()) {
6687                            for (JournalArticle journalArticle : list) {
6688                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6689                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
6690                                            list = null;
6691    
6692                                            break;
6693                                    }
6694                            }
6695                    }
6696    
6697                    if (list == null) {
6698                            StringBundler query = new StringBundler();
6699    
6700                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6701    
6702                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6703    
6704                            if (statuses.length > 0) {
6705                                    query.append(StringPool.OPEN_PARENTHESIS);
6706    
6707                                    query.append(_FINDER_COLUMN_R_ST_STATUS_7);
6708    
6709                                    query.append(StringUtil.merge(statuses));
6710    
6711                                    query.append(StringPool.CLOSE_PARENTHESIS);
6712    
6713                                    query.append(StringPool.CLOSE_PARENTHESIS);
6714                            }
6715    
6716                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
6717                                                    1)), query.index() - 1);
6718    
6719                            if (orderByComparator != null) {
6720                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6721                                            orderByComparator);
6722                            }
6723                            else
6724                             if (pagination) {
6725                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6726                            }
6727    
6728                            String sql = query.toString();
6729    
6730                            Session session = null;
6731    
6732                            try {
6733                                    session = openSession();
6734    
6735                                    Query q = session.createQuery(sql);
6736    
6737                                    QueryPos qPos = QueryPos.getInstance(q);
6738    
6739                                    qPos.add(resourcePrimKey);
6740    
6741                                    if (!pagination) {
6742                                            list = (List<JournalArticle>)QueryUtil.list(q,
6743                                                            getDialect(), start, end, false);
6744    
6745                                            Collections.sort(list);
6746    
6747                                            list = Collections.unmodifiableList(list);
6748                                    }
6749                                    else {
6750                                            list = (List<JournalArticle>)QueryUtil.list(q,
6751                                                            getDialect(), start, end);
6752                                    }
6753    
6754                                    cacheResult(list);
6755    
6756                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6757                                            finderArgs, list);
6758                            }
6759                            catch (Exception e) {
6760                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST,
6761                                            finderArgs);
6762    
6763                                    throw processException(e);
6764                            }
6765                            finally {
6766                                    closeSession(session);
6767                            }
6768                    }
6769    
6770                    return list;
6771            }
6772    
6773            /**
6774             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
6775             *
6776             * @param resourcePrimKey the resource prim key
6777             * @param status the status
6778             */
6779            @Override
6780            public void removeByR_ST(long resourcePrimKey, int status) {
6781                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey,
6782                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6783                            remove(journalArticle);
6784                    }
6785            }
6786    
6787            /**
6788             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
6789             *
6790             * @param resourcePrimKey the resource prim key
6791             * @param status the status
6792             * @return the number of matching journal articles
6793             */
6794            @Override
6795            public int countByR_ST(long resourcePrimKey, int status) {
6796                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_ST;
6797    
6798                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
6799    
6800                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6801                                    this);
6802    
6803                    if (count == null) {
6804                            StringBundler query = new StringBundler(3);
6805    
6806                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6807    
6808                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6809    
6810                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6811    
6812                            String sql = query.toString();
6813    
6814                            Session session = null;
6815    
6816                            try {
6817                                    session = openSession();
6818    
6819                                    Query q = session.createQuery(sql);
6820    
6821                                    QueryPos qPos = QueryPos.getInstance(q);
6822    
6823                                    qPos.add(resourcePrimKey);
6824    
6825                                    qPos.add(status);
6826    
6827                                    count = (Long)q.uniqueResult();
6828    
6829                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6830                            }
6831                            catch (Exception e) {
6832                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6833    
6834                                    throw processException(e);
6835                            }
6836                            finally {
6837                                    closeSession(session);
6838                            }
6839                    }
6840    
6841                    return count.intValue();
6842            }
6843    
6844            /**
6845             * Returns the number of journal articles where resourcePrimKey = &#63; and status = any &#63;.
6846             *
6847             * @param resourcePrimKey the resource prim key
6848             * @param statuses the statuses
6849             * @return the number of matching journal articles
6850             */
6851            @Override
6852            public int countByR_ST(long resourcePrimKey, int[] statuses) {
6853                    if (statuses == null) {
6854                            statuses = new int[0];
6855                    }
6856                    else {
6857                            statuses = ArrayUtil.unique(statuses);
6858                    }
6859    
6860                    Object[] finderArgs = new Object[] {
6861                                    resourcePrimKey, StringUtil.merge(statuses)
6862                            };
6863    
6864                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
6865                                    finderArgs, this);
6866    
6867                    if (count == null) {
6868                            StringBundler query = new StringBundler();
6869    
6870                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
6871    
6872                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6873    
6874                            if (statuses.length > 0) {
6875                                    query.append(StringPool.OPEN_PARENTHESIS);
6876    
6877                                    query.append(_FINDER_COLUMN_R_ST_STATUS_7);
6878    
6879                                    query.append(StringUtil.merge(statuses));
6880    
6881                                    query.append(StringPool.CLOSE_PARENTHESIS);
6882    
6883                                    query.append(StringPool.CLOSE_PARENTHESIS);
6884                            }
6885    
6886                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
6887                                                    1)), query.index() - 1);
6888    
6889                            String sql = query.toString();
6890    
6891                            Session session = null;
6892    
6893                            try {
6894                                    session = openSession();
6895    
6896                                    Query q = session.createQuery(sql);
6897    
6898                                    QueryPos qPos = QueryPos.getInstance(q);
6899    
6900                                    qPos.add(resourcePrimKey);
6901    
6902                                    count = (Long)q.uniqueResult();
6903    
6904                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
6905                                            finderArgs, count);
6906                            }
6907                            catch (Exception e) {
6908                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_ST,
6909                                            finderArgs);
6910    
6911                                    throw processException(e);
6912                            }
6913                            finally {
6914                                    closeSession(session);
6915                            }
6916                    }
6917    
6918                    return count.intValue();
6919            }
6920    
6921            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
6922            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
6923            private static final String _FINDER_COLUMN_R_ST_STATUS_7 = "journalArticle.status IN (";
6924            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6925                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6926                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6927                            "findByG_U",
6928                            new String[] {
6929                                    Long.class.getName(), Long.class.getName(),
6930                                    
6931                            Integer.class.getName(), Integer.class.getName(),
6932                                    OrderByComparator.class.getName()
6933                            });
6934            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6935                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
6936                            JournalArticleImpl.class,
6937                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
6938                            new String[] { Long.class.getName(), Long.class.getName() },
6939                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
6940                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
6941                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
6942                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
6943            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
6944                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
6945                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
6946                            new String[] { Long.class.getName(), Long.class.getName() });
6947    
6948            /**
6949             * Returns all the journal articles where groupId = &#63; and userId = &#63;.
6950             *
6951             * @param groupId the group ID
6952             * @param userId the user ID
6953             * @return the matching journal articles
6954             */
6955            @Override
6956            public List<JournalArticle> findByG_U(long groupId, long userId) {
6957                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6958                            null);
6959            }
6960    
6961            /**
6962             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63;.
6963             *
6964             * <p>
6965             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6966             * </p>
6967             *
6968             * @param groupId the group ID
6969             * @param userId the user ID
6970             * @param start the lower bound of the range of journal articles
6971             * @param end the upper bound of the range of journal articles (not inclusive)
6972             * @return the range of matching journal articles
6973             */
6974            @Override
6975            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6976                    int end) {
6977                    return findByG_U(groupId, userId, start, end, null);
6978            }
6979    
6980            /**
6981             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63;.
6982             *
6983             * <p>
6984             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6985             * </p>
6986             *
6987             * @param groupId the group ID
6988             * @param userId the user ID
6989             * @param start the lower bound of the range of journal articles
6990             * @param end the upper bound of the range of journal articles (not inclusive)
6991             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6992             * @return the ordered range of matching journal articles
6993             */
6994            @Override
6995            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6996                    int end, OrderByComparator<JournalArticle> orderByComparator) {
6997                    boolean pagination = true;
6998                    FinderPath finderPath = null;
6999                    Object[] finderArgs = null;
7000    
7001                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7002                                    (orderByComparator == null)) {
7003                            pagination = false;
7004                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
7005                            finderArgs = new Object[] { groupId, userId };
7006                    }
7007                    else {
7008                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
7009                            finderArgs = new Object[] {
7010                                            groupId, userId,
7011                                            
7012                                            start, end, orderByComparator
7013                                    };
7014                    }
7015    
7016                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7017                                    finderArgs, this);
7018    
7019                    if ((list != null) && !list.isEmpty()) {
7020                            for (JournalArticle journalArticle : list) {
7021                                    if ((groupId != journalArticle.getGroupId()) ||
7022                                                    (userId != journalArticle.getUserId())) {
7023                                            list = null;
7024    
7025                                            break;
7026                                    }
7027                            }
7028                    }
7029    
7030                    if (list == null) {
7031                            StringBundler query = null;
7032    
7033                            if (orderByComparator != null) {
7034                                    query = new StringBundler(4 +
7035                                                    (orderByComparator.getOrderByFields().length * 3));
7036                            }
7037                            else {
7038                                    query = new StringBundler(4);
7039                            }
7040    
7041                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7042    
7043                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7044    
7045                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7046    
7047                            if (orderByComparator != null) {
7048                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7049                                            orderByComparator);
7050                            }
7051                            else
7052                             if (pagination) {
7053                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7054                            }
7055    
7056                            String sql = query.toString();
7057    
7058                            Session session = null;
7059    
7060                            try {
7061                                    session = openSession();
7062    
7063                                    Query q = session.createQuery(sql);
7064    
7065                                    QueryPos qPos = QueryPos.getInstance(q);
7066    
7067                                    qPos.add(groupId);
7068    
7069                                    qPos.add(userId);
7070    
7071                                    if (!pagination) {
7072                                            list = (List<JournalArticle>)QueryUtil.list(q,
7073                                                            getDialect(), start, end, false);
7074    
7075                                            Collections.sort(list);
7076    
7077                                            list = Collections.unmodifiableList(list);
7078                                    }
7079                                    else {
7080                                            list = (List<JournalArticle>)QueryUtil.list(q,
7081                                                            getDialect(), start, end);
7082                                    }
7083    
7084                                    cacheResult(list);
7085    
7086                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7087                            }
7088                            catch (Exception e) {
7089                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7090    
7091                                    throw processException(e);
7092                            }
7093                            finally {
7094                                    closeSession(session);
7095                            }
7096                    }
7097    
7098                    return list;
7099            }
7100    
7101            /**
7102             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
7103             *
7104             * @param groupId the group ID
7105             * @param userId the user ID
7106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7107             * @return the first matching journal article
7108             * @throws NoSuchArticleException if a matching journal article could not be found
7109             */
7110            @Override
7111            public JournalArticle findByG_U_First(long groupId, long userId,
7112                    OrderByComparator<JournalArticle> orderByComparator)
7113                    throws NoSuchArticleException {
7114                    JournalArticle journalArticle = fetchByG_U_First(groupId, userId,
7115                                    orderByComparator);
7116    
7117                    if (journalArticle != null) {
7118                            return journalArticle;
7119                    }
7120    
7121                    StringBundler msg = new StringBundler(6);
7122    
7123                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7124    
7125                    msg.append("groupId=");
7126                    msg.append(groupId);
7127    
7128                    msg.append(", userId=");
7129                    msg.append(userId);
7130    
7131                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7132    
7133                    throw new NoSuchArticleException(msg.toString());
7134            }
7135    
7136            /**
7137             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
7138             *
7139             * @param groupId the group ID
7140             * @param userId the user ID
7141             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7142             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7143             */
7144            @Override
7145            public JournalArticle fetchByG_U_First(long groupId, long userId,
7146                    OrderByComparator<JournalArticle> orderByComparator) {
7147                    List<JournalArticle> list = findByG_U(groupId, userId, 0, 1,
7148                                    orderByComparator);
7149    
7150                    if (!list.isEmpty()) {
7151                            return list.get(0);
7152                    }
7153    
7154                    return null;
7155            }
7156    
7157            /**
7158             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7159             *
7160             * @param groupId the group ID
7161             * @param userId the user ID
7162             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7163             * @return the last matching journal article
7164             * @throws NoSuchArticleException if a matching journal article could not be found
7165             */
7166            @Override
7167            public JournalArticle findByG_U_Last(long groupId, long userId,
7168                    OrderByComparator<JournalArticle> orderByComparator)
7169                    throws NoSuchArticleException {
7170                    JournalArticle journalArticle = fetchByG_U_Last(groupId, userId,
7171                                    orderByComparator);
7172    
7173                    if (journalArticle != null) {
7174                            return journalArticle;
7175                    }
7176    
7177                    StringBundler msg = new StringBundler(6);
7178    
7179                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7180    
7181                    msg.append("groupId=");
7182                    msg.append(groupId);
7183    
7184                    msg.append(", userId=");
7185                    msg.append(userId);
7186    
7187                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7188    
7189                    throw new NoSuchArticleException(msg.toString());
7190            }
7191    
7192            /**
7193             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
7194             *
7195             * @param groupId the group ID
7196             * @param userId the user ID
7197             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7198             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7199             */
7200            @Override
7201            public JournalArticle fetchByG_U_Last(long groupId, long userId,
7202                    OrderByComparator<JournalArticle> orderByComparator) {
7203                    int count = countByG_U(groupId, userId);
7204    
7205                    if (count == 0) {
7206                            return null;
7207                    }
7208    
7209                    List<JournalArticle> list = findByG_U(groupId, userId, count - 1,
7210                                    count, orderByComparator);
7211    
7212                    if (!list.isEmpty()) {
7213                            return list.get(0);
7214                    }
7215    
7216                    return null;
7217            }
7218    
7219            /**
7220             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63;.
7221             *
7222             * @param id the primary key of the current journal article
7223             * @param groupId the group ID
7224             * @param userId the user ID
7225             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7226             * @return the previous, current, and next journal article
7227             * @throws NoSuchArticleException if a journal article with the primary key could not be found
7228             */
7229            @Override
7230            public JournalArticle[] findByG_U_PrevAndNext(long id, long groupId,
7231                    long userId, OrderByComparator<JournalArticle> orderByComparator)
7232                    throws NoSuchArticleException {
7233                    JournalArticle journalArticle = findByPrimaryKey(id);
7234    
7235                    Session session = null;
7236    
7237                    try {
7238                            session = openSession();
7239    
7240                            JournalArticle[] array = new JournalArticleImpl[3];
7241    
7242                            array[0] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7243                                            userId, orderByComparator, true);
7244    
7245                            array[1] = journalArticle;
7246    
7247                            array[2] = getByG_U_PrevAndNext(session, journalArticle, groupId,
7248                                            userId, orderByComparator, false);
7249    
7250                            return array;
7251                    }
7252                    catch (Exception e) {
7253                            throw processException(e);
7254                    }
7255                    finally {
7256                            closeSession(session);
7257                    }
7258            }
7259    
7260            protected JournalArticle getByG_U_PrevAndNext(Session session,
7261                    JournalArticle journalArticle, long groupId, long userId,
7262                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
7263                    StringBundler query = null;
7264    
7265                    if (orderByComparator != null) {
7266                            query = new StringBundler(6 +
7267                                            (orderByComparator.getOrderByFields().length * 6));
7268                    }
7269                    else {
7270                            query = new StringBundler(3);
7271                    }
7272    
7273                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7274    
7275                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7276    
7277                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7278    
7279                    if (orderByComparator != null) {
7280                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7281    
7282                            if (orderByConditionFields.length > 0) {
7283                                    query.append(WHERE_AND);
7284                            }
7285    
7286                            for (int i = 0; i < orderByConditionFields.length; i++) {
7287                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7288                                    query.append(orderByConditionFields[i]);
7289    
7290                                    if ((i + 1) < orderByConditionFields.length) {
7291                                            if (orderByComparator.isAscending() ^ previous) {
7292                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7293                                            }
7294                                            else {
7295                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7296                                            }
7297                                    }
7298                                    else {
7299                                            if (orderByComparator.isAscending() ^ previous) {
7300                                                    query.append(WHERE_GREATER_THAN);
7301                                            }
7302                                            else {
7303                                                    query.append(WHERE_LESSER_THAN);
7304                                            }
7305                                    }
7306                            }
7307    
7308                            query.append(ORDER_BY_CLAUSE);
7309    
7310                            String[] orderByFields = orderByComparator.getOrderByFields();
7311    
7312                            for (int i = 0; i < orderByFields.length; i++) {
7313                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7314                                    query.append(orderByFields[i]);
7315    
7316                                    if ((i + 1) < orderByFields.length) {
7317                                            if (orderByComparator.isAscending() ^ previous) {
7318                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7319                                            }
7320                                            else {
7321                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7322                                            }
7323                                    }
7324                                    else {
7325                                            if (orderByComparator.isAscending() ^ previous) {
7326                                                    query.append(ORDER_BY_ASC);
7327                                            }
7328                                            else {
7329                                                    query.append(ORDER_BY_DESC);
7330                                            }
7331                                    }
7332                            }
7333                    }
7334                    else {
7335                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7336                    }
7337    
7338                    String sql = query.toString();
7339    
7340                    Query q = session.createQuery(sql);
7341    
7342                    q.setFirstResult(0);
7343                    q.setMaxResults(2);
7344    
7345                    QueryPos qPos = QueryPos.getInstance(q);
7346    
7347                    qPos.add(groupId);
7348    
7349                    qPos.add(userId);
7350    
7351                    if (orderByComparator != null) {
7352                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7353    
7354                            for (Object value : values) {
7355                                    qPos.add(value);
7356                            }
7357                    }
7358    
7359                    List<JournalArticle> list = q.list();
7360    
7361                    if (list.size() == 2) {
7362                            return list.get(1);
7363                    }
7364                    else {
7365                            return null;
7366                    }
7367            }
7368    
7369            /**
7370             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7371             *
7372             * @param groupId the group ID
7373             * @param userId the user ID
7374             * @return the matching journal articles that the user has permission to view
7375             */
7376            @Override
7377            public List<JournalArticle> filterFindByG_U(long groupId, long userId) {
7378                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
7379                            QueryUtil.ALL_POS, null);
7380            }
7381    
7382            /**
7383             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7384             *
7385             * <p>
7386             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7387             * </p>
7388             *
7389             * @param groupId the group ID
7390             * @param userId the user ID
7391             * @param start the lower bound of the range of journal articles
7392             * @param end the upper bound of the range of journal articles (not inclusive)
7393             * @return the range of matching journal articles that the user has permission to view
7394             */
7395            @Override
7396            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7397                    int start, int end) {
7398                    return filterFindByG_U(groupId, userId, start, end, null);
7399            }
7400    
7401            /**
7402             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63;.
7403             *
7404             * <p>
7405             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7406             * </p>
7407             *
7408             * @param groupId the group ID
7409             * @param userId the user ID
7410             * @param start the lower bound of the range of journal articles
7411             * @param end the upper bound of the range of journal articles (not inclusive)
7412             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7413             * @return the ordered range of matching journal articles that the user has permission to view
7414             */
7415            @Override
7416            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
7417                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
7418                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7419                            return findByG_U(groupId, userId, start, end, orderByComparator);
7420                    }
7421    
7422                    StringBundler query = null;
7423    
7424                    if (orderByComparator != null) {
7425                            query = new StringBundler(4 +
7426                                            (orderByComparator.getOrderByFields().length * 3));
7427                    }
7428                    else {
7429                            query = new StringBundler(4);
7430                    }
7431    
7432                    if (getDB().isSupportsInlineDistinct()) {
7433                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7434                    }
7435                    else {
7436                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7437                    }
7438    
7439                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7440    
7441                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7442    
7443                    if (!getDB().isSupportsInlineDistinct()) {
7444                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7445                    }
7446    
7447                    if (orderByComparator != null) {
7448                            if (getDB().isSupportsInlineDistinct()) {
7449                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7450                                            orderByComparator, true);
7451                            }
7452                            else {
7453                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7454                                            orderByComparator, true);
7455                            }
7456                    }
7457                    else {
7458                            if (getDB().isSupportsInlineDistinct()) {
7459                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7460                            }
7461                            else {
7462                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7463                            }
7464                    }
7465    
7466                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7467                                    JournalArticle.class.getName(),
7468                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7469    
7470                    Session session = null;
7471    
7472                    try {
7473                            session = openSession();
7474    
7475                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
7476    
7477                            if (getDB().isSupportsInlineDistinct()) {
7478                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7479                            }
7480                            else {
7481                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7482                            }
7483    
7484                            QueryPos qPos = QueryPos.getInstance(q);
7485    
7486                            qPos.add(groupId);
7487    
7488                            qPos.add(userId);
7489    
7490                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7491                                    end);
7492                    }
7493                    catch (Exception e) {
7494                            throw processException(e);
7495                    }
7496                    finally {
7497                            closeSession(session);
7498                    }
7499            }
7500    
7501            /**
7502             * 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;.
7503             *
7504             * @param id the primary key of the current journal article
7505             * @param groupId the group ID
7506             * @param userId the user ID
7507             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7508             * @return the previous, current, and next journal article
7509             * @throws NoSuchArticleException if a journal article with the primary key could not be found
7510             */
7511            @Override
7512            public JournalArticle[] filterFindByG_U_PrevAndNext(long id, long groupId,
7513                    long userId, OrderByComparator<JournalArticle> orderByComparator)
7514                    throws NoSuchArticleException {
7515                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7516                            return findByG_U_PrevAndNext(id, groupId, userId, orderByComparator);
7517                    }
7518    
7519                    JournalArticle journalArticle = findByPrimaryKey(id);
7520    
7521                    Session session = null;
7522    
7523                    try {
7524                            session = openSession();
7525    
7526                            JournalArticle[] array = new JournalArticleImpl[3];
7527    
7528                            array[0] = filterGetByG_U_PrevAndNext(session, journalArticle,
7529                                            groupId, userId, orderByComparator, true);
7530    
7531                            array[1] = journalArticle;
7532    
7533                            array[2] = filterGetByG_U_PrevAndNext(session, journalArticle,
7534                                            groupId, userId, orderByComparator, false);
7535    
7536                            return array;
7537                    }
7538                    catch (Exception e) {
7539                            throw processException(e);
7540                    }
7541                    finally {
7542                            closeSession(session);
7543                    }
7544            }
7545    
7546            protected JournalArticle filterGetByG_U_PrevAndNext(Session session,
7547                    JournalArticle journalArticle, long groupId, long userId,
7548                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
7549                    StringBundler query = null;
7550    
7551                    if (orderByComparator != null) {
7552                            query = new StringBundler(6 +
7553                                            (orderByComparator.getOrderByFields().length * 6));
7554                    }
7555                    else {
7556                            query = new StringBundler(3);
7557                    }
7558    
7559                    if (getDB().isSupportsInlineDistinct()) {
7560                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7561                    }
7562                    else {
7563                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7564                    }
7565    
7566                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7567    
7568                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7569    
7570                    if (!getDB().isSupportsInlineDistinct()) {
7571                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7572                    }
7573    
7574                    if (orderByComparator != null) {
7575                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7576    
7577                            if (orderByConditionFields.length > 0) {
7578                                    query.append(WHERE_AND);
7579                            }
7580    
7581                            for (int i = 0; i < orderByConditionFields.length; i++) {
7582                                    if (getDB().isSupportsInlineDistinct()) {
7583                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7584                                    }
7585                                    else {
7586                                            query.append(_ORDER_BY_ENTITY_TABLE);
7587                                    }
7588    
7589                                    query.append(orderByConditionFields[i]);
7590    
7591                                    if ((i + 1) < orderByConditionFields.length) {
7592                                            if (orderByComparator.isAscending() ^ previous) {
7593                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7594                                            }
7595                                            else {
7596                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7597                                            }
7598                                    }
7599                                    else {
7600                                            if (orderByComparator.isAscending() ^ previous) {
7601                                                    query.append(WHERE_GREATER_THAN);
7602                                            }
7603                                            else {
7604                                                    query.append(WHERE_LESSER_THAN);
7605                                            }
7606                                    }
7607                            }
7608    
7609                            query.append(ORDER_BY_CLAUSE);
7610    
7611                            String[] orderByFields = orderByComparator.getOrderByFields();
7612    
7613                            for (int i = 0; i < orderByFields.length; i++) {
7614                                    if (getDB().isSupportsInlineDistinct()) {
7615                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7616                                    }
7617                                    else {
7618                                            query.append(_ORDER_BY_ENTITY_TABLE);
7619                                    }
7620    
7621                                    query.append(orderByFields[i]);
7622    
7623                                    if ((i + 1) < orderByFields.length) {
7624                                            if (orderByComparator.isAscending() ^ previous) {
7625                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7626                                            }
7627                                            else {
7628                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7629                                            }
7630                                    }
7631                                    else {
7632                                            if (orderByComparator.isAscending() ^ previous) {
7633                                                    query.append(ORDER_BY_ASC);
7634                                            }
7635                                            else {
7636                                                    query.append(ORDER_BY_DESC);
7637                                            }
7638                                    }
7639                            }
7640                    }
7641                    else {
7642                            if (getDB().isSupportsInlineDistinct()) {
7643                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7644                            }
7645                            else {
7646                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7647                            }
7648                    }
7649    
7650                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7651                                    JournalArticle.class.getName(),
7652                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7653    
7654                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
7655    
7656                    q.setFirstResult(0);
7657                    q.setMaxResults(2);
7658    
7659                    if (getDB().isSupportsInlineDistinct()) {
7660                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7661                    }
7662                    else {
7663                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7664                    }
7665    
7666                    QueryPos qPos = QueryPos.getInstance(q);
7667    
7668                    qPos.add(groupId);
7669    
7670                    qPos.add(userId);
7671    
7672                    if (orderByComparator != null) {
7673                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7674    
7675                            for (Object value : values) {
7676                                    qPos.add(value);
7677                            }
7678                    }
7679    
7680                    List<JournalArticle> list = q.list();
7681    
7682                    if (list.size() == 2) {
7683                            return list.get(1);
7684                    }
7685                    else {
7686                            return null;
7687                    }
7688            }
7689    
7690            /**
7691             * Removes all the journal articles where groupId = &#63; and userId = &#63; from the database.
7692             *
7693             * @param groupId the group ID
7694             * @param userId the user ID
7695             */
7696            @Override
7697            public void removeByG_U(long groupId, long userId) {
7698                    for (JournalArticle journalArticle : findByG_U(groupId, userId,
7699                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7700                            remove(journalArticle);
7701                    }
7702            }
7703    
7704            /**
7705             * Returns the number of journal articles where groupId = &#63; and userId = &#63;.
7706             *
7707             * @param groupId the group ID
7708             * @param userId the user ID
7709             * @return the number of matching journal articles
7710             */
7711            @Override
7712            public int countByG_U(long groupId, long userId) {
7713                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
7714    
7715                    Object[] finderArgs = new Object[] { groupId, userId };
7716    
7717                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7718                                    this);
7719    
7720                    if (count == null) {
7721                            StringBundler query = new StringBundler(3);
7722    
7723                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7724    
7725                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7726    
7727                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7728    
7729                            String sql = query.toString();
7730    
7731                            Session session = null;
7732    
7733                            try {
7734                                    session = openSession();
7735    
7736                                    Query q = session.createQuery(sql);
7737    
7738                                    QueryPos qPos = QueryPos.getInstance(q);
7739    
7740                                    qPos.add(groupId);
7741    
7742                                    qPos.add(userId);
7743    
7744                                    count = (Long)q.uniqueResult();
7745    
7746                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7747                            }
7748                            catch (Exception e) {
7749                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7750    
7751                                    throw processException(e);
7752                            }
7753                            finally {
7754                                    closeSession(session);
7755                            }
7756                    }
7757    
7758                    return count.intValue();
7759            }
7760    
7761            /**
7762             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
7763             *
7764             * @param groupId the group ID
7765             * @param userId the user ID
7766             * @return the number of matching journal articles that the user has permission to view
7767             */
7768            @Override
7769            public int filterCountByG_U(long groupId, long userId) {
7770                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7771                            return countByG_U(groupId, userId);
7772                    }
7773    
7774                    StringBundler query = new StringBundler(3);
7775    
7776                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
7777    
7778                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7779    
7780                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7781    
7782                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7783                                    JournalArticle.class.getName(),
7784                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7785    
7786                    Session session = null;
7787    
7788                    try {
7789                            session = openSession();
7790    
7791                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
7792    
7793                            q.addScalar(COUNT_COLUMN_NAME,
7794                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7795    
7796                            QueryPos qPos = QueryPos.getInstance(q);
7797    
7798                            qPos.add(groupId);
7799    
7800                            qPos.add(userId);
7801    
7802                            Long count = (Long)q.uniqueResult();
7803    
7804                            return count.intValue();
7805                    }
7806                    catch (Exception e) {
7807                            throw processException(e);
7808                    }
7809                    finally {
7810                            closeSession(session);
7811                    }
7812            }
7813    
7814            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "journalArticle.groupId = ? AND ";
7815            private static final String _FINDER_COLUMN_G_U_USERID_2 = "journalArticle.userId = ?";
7816            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7817                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7818                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7819                            "findByG_F",
7820                            new String[] {
7821                                    Long.class.getName(), Long.class.getName(),
7822                                    
7823                            Integer.class.getName(), Integer.class.getName(),
7824                                    OrderByComparator.class.getName()
7825                            });
7826            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7827                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
7828                            JournalArticleImpl.class,
7829                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
7830                            new String[] { Long.class.getName(), Long.class.getName() },
7831                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
7832                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
7833                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
7834                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
7835            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7836                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7837                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
7838                            new String[] { Long.class.getName(), Long.class.getName() });
7839            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
7840                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
7841                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
7842                            new String[] { Long.class.getName(), Long.class.getName() });
7843    
7844            /**
7845             * Returns all the journal articles where groupId = &#63; and folderId = &#63;.
7846             *
7847             * @param groupId the group ID
7848             * @param folderId the folder ID
7849             * @return the matching journal articles
7850             */
7851            @Override
7852            public List<JournalArticle> findByG_F(long groupId, long folderId) {
7853                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
7854                            QueryUtil.ALL_POS, null);
7855            }
7856    
7857            /**
7858             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63;.
7859             *
7860             * <p>
7861             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7862             * </p>
7863             *
7864             * @param groupId the group ID
7865             * @param folderId the folder ID
7866             * @param start the lower bound of the range of journal articles
7867             * @param end the upper bound of the range of journal articles (not inclusive)
7868             * @return the range of matching journal articles
7869             */
7870            @Override
7871            public List<JournalArticle> findByG_F(long groupId, long folderId,
7872                    int start, int end) {
7873                    return findByG_F(groupId, folderId, start, end, null);
7874            }
7875    
7876            /**
7877             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63;.
7878             *
7879             * <p>
7880             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7881             * </p>
7882             *
7883             * @param groupId the group ID
7884             * @param folderId the folder ID
7885             * @param start the lower bound of the range of journal articles
7886             * @param end the upper bound of the range of journal articles (not inclusive)
7887             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7888             * @return the ordered range of matching journal articles
7889             */
7890            @Override
7891            public List<JournalArticle> findByG_F(long groupId, long folderId,
7892                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
7893                    boolean pagination = true;
7894                    FinderPath finderPath = null;
7895                    Object[] finderArgs = null;
7896    
7897                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7898                                    (orderByComparator == null)) {
7899                            pagination = false;
7900                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
7901                            finderArgs = new Object[] { groupId, folderId };
7902                    }
7903                    else {
7904                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
7905                            finderArgs = new Object[] {
7906                                            groupId, folderId,
7907                                            
7908                                            start, end, orderByComparator
7909                                    };
7910                    }
7911    
7912                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7913                                    finderArgs, this);
7914    
7915                    if ((list != null) && !list.isEmpty()) {
7916                            for (JournalArticle journalArticle : list) {
7917                                    if ((groupId != journalArticle.getGroupId()) ||
7918                                                    (folderId != journalArticle.getFolderId())) {
7919                                            list = null;
7920    
7921                                            break;
7922                                    }
7923                            }
7924                    }
7925    
7926                    if (list == null) {
7927                            StringBundler query = null;
7928    
7929                            if (orderByComparator != null) {
7930                                    query = new StringBundler(4 +
7931                                                    (orderByComparator.getOrderByFields().length * 3));
7932                            }
7933                            else {
7934                                    query = new StringBundler(4);
7935                            }
7936    
7937                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7938    
7939                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7940    
7941                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7942    
7943                            if (orderByComparator != null) {
7944                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7945                                            orderByComparator);
7946                            }
7947                            else
7948                             if (pagination) {
7949                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7950                            }
7951    
7952                            String sql = query.toString();
7953    
7954                            Session session = null;
7955    
7956                            try {
7957                                    session = openSession();
7958    
7959                                    Query q = session.createQuery(sql);
7960    
7961                                    QueryPos qPos = QueryPos.getInstance(q);
7962    
7963                                    qPos.add(groupId);
7964    
7965                                    qPos.add(folderId);
7966    
7967                                    if (!pagination) {
7968                                            list = (List<JournalArticle>)QueryUtil.list(q,
7969                                                            getDialect(), start, end, false);
7970    
7971                                            Collections.sort(list);
7972    
7973                                            list = Collections.unmodifiableList(list);
7974                                    }
7975                                    else {
7976                                            list = (List<JournalArticle>)QueryUtil.list(q,
7977                                                            getDialect(), start, end);
7978                                    }
7979    
7980                                    cacheResult(list);
7981    
7982                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7983                            }
7984                            catch (Exception e) {
7985                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7986    
7987                                    throw processException(e);
7988                            }
7989                            finally {
7990                                    closeSession(session);
7991                            }
7992                    }
7993    
7994                    return list;
7995            }
7996    
7997            /**
7998             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7999             *
8000             * @param groupId the group ID
8001             * @param folderId the folder ID
8002             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8003             * @return the first matching journal article
8004             * @throws NoSuchArticleException if a matching journal article could not be found
8005             */
8006            @Override
8007            public JournalArticle findByG_F_First(long groupId, long folderId,
8008                    OrderByComparator<JournalArticle> orderByComparator)
8009                    throws NoSuchArticleException {
8010                    JournalArticle journalArticle = fetchByG_F_First(groupId, folderId,
8011                                    orderByComparator);
8012    
8013                    if (journalArticle != null) {
8014                            return journalArticle;
8015                    }
8016    
8017                    StringBundler msg = new StringBundler(6);
8018    
8019                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8020    
8021                    msg.append("groupId=");
8022                    msg.append(groupId);
8023    
8024                    msg.append(", folderId=");
8025                    msg.append(folderId);
8026    
8027                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8028    
8029                    throw new NoSuchArticleException(msg.toString());
8030            }
8031    
8032            /**
8033             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8034             *
8035             * @param groupId the group ID
8036             * @param folderId the folder ID
8037             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8038             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
8039             */
8040            @Override
8041            public JournalArticle fetchByG_F_First(long groupId, long folderId,
8042                    OrderByComparator<JournalArticle> orderByComparator) {
8043                    List<JournalArticle> list = findByG_F(groupId, folderId, 0, 1,
8044                                    orderByComparator);
8045    
8046                    if (!list.isEmpty()) {
8047                            return list.get(0);
8048                    }
8049    
8050                    return null;
8051            }
8052    
8053            /**
8054             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8055             *
8056             * @param groupId the group ID
8057             * @param folderId the folder ID
8058             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8059             * @return the last matching journal article
8060             * @throws NoSuchArticleException if a matching journal article could not be found
8061             */
8062            @Override
8063            public JournalArticle findByG_F_Last(long groupId, long folderId,
8064                    OrderByComparator<JournalArticle> orderByComparator)
8065                    throws NoSuchArticleException {
8066                    JournalArticle journalArticle = fetchByG_F_Last(groupId, folderId,
8067                                    orderByComparator);
8068    
8069                    if (journalArticle != null) {
8070                            return journalArticle;
8071                    }
8072    
8073                    StringBundler msg = new StringBundler(6);
8074    
8075                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8076    
8077                    msg.append("groupId=");
8078                    msg.append(groupId);
8079    
8080                    msg.append(", folderId=");
8081                    msg.append(folderId);
8082    
8083                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8084    
8085                    throw new NoSuchArticleException(msg.toString());
8086            }
8087    
8088            /**
8089             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8090             *
8091             * @param groupId the group ID
8092             * @param folderId the folder ID
8093             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8094             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
8095             */
8096            @Override
8097            public JournalArticle fetchByG_F_Last(long groupId, long folderId,
8098                    OrderByComparator<JournalArticle> orderByComparator) {
8099                    int count = countByG_F(groupId, folderId);
8100    
8101                    if (count == 0) {
8102                            return null;
8103                    }
8104    
8105                    List<JournalArticle> list = findByG_F(groupId, folderId, count - 1,
8106                                    count, orderByComparator);
8107    
8108                    if (!list.isEmpty()) {
8109                            return list.get(0);
8110                    }
8111    
8112                    return null;
8113            }
8114    
8115            /**
8116             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63;.
8117             *
8118             * @param id the primary key of the current journal article
8119             * @param groupId the group ID
8120             * @param folderId the folder ID
8121             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8122             * @return the previous, current, and next journal article
8123             * @throws NoSuchArticleException if a journal article with the primary key could not be found
8124             */
8125            @Override
8126            public JournalArticle[] findByG_F_PrevAndNext(long id, long groupId,
8127                    long folderId, OrderByComparator<JournalArticle> orderByComparator)
8128                    throws NoSuchArticleException {
8129                    JournalArticle journalArticle = findByPrimaryKey(id);
8130    
8131                    Session session = null;
8132    
8133                    try {
8134                            session = openSession();
8135    
8136                            JournalArticle[] array = new JournalArticleImpl[3];
8137    
8138                            array[0] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8139                                            folderId, orderByComparator, true);
8140    
8141                            array[1] = journalArticle;
8142    
8143                            array[2] = getByG_F_PrevAndNext(session, journalArticle, groupId,
8144                                            folderId, orderByComparator, false);
8145    
8146                            return array;
8147                    }
8148                    catch (Exception e) {
8149                            throw processException(e);
8150                    }
8151                    finally {
8152                            closeSession(session);
8153                    }
8154            }
8155    
8156            protected JournalArticle getByG_F_PrevAndNext(Session session,
8157                    JournalArticle journalArticle, long groupId, long folderId,
8158                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
8159                    StringBundler query = null;
8160    
8161                    if (orderByComparator != null) {
8162                            query = new StringBundler(6 +
8163                                            (orderByComparator.getOrderByFields().length * 6));
8164                    }
8165                    else {
8166                            query = new StringBundler(3);
8167                    }
8168    
8169                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8170    
8171                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8172    
8173                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8174    
8175                    if (orderByComparator != null) {
8176                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8177    
8178                            if (orderByConditionFields.length > 0) {
8179                                    query.append(WHERE_AND);
8180                            }
8181    
8182                            for (int i = 0; i < orderByConditionFields.length; i++) {
8183                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8184                                    query.append(orderByConditionFields[i]);
8185    
8186                                    if ((i + 1) < orderByConditionFields.length) {
8187                                            if (orderByComparator.isAscending() ^ previous) {
8188                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8189                                            }
8190                                            else {
8191                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8192                                            }
8193                                    }
8194                                    else {
8195                                            if (orderByComparator.isAscending() ^ previous) {
8196                                                    query.append(WHERE_GREATER_THAN);
8197                                            }
8198                                            else {
8199                                                    query.append(WHERE_LESSER_THAN);
8200                                            }
8201                                    }
8202                            }
8203    
8204                            query.append(ORDER_BY_CLAUSE);
8205    
8206                            String[] orderByFields = orderByComparator.getOrderByFields();
8207    
8208                            for (int i = 0; i < orderByFields.length; i++) {
8209                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8210                                    query.append(orderByFields[i]);
8211    
8212                                    if ((i + 1) < orderByFields.length) {
8213                                            if (orderByComparator.isAscending() ^ previous) {
8214                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8215                                            }
8216                                            else {
8217                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8218                                            }
8219                                    }
8220                                    else {
8221                                            if (orderByComparator.isAscending() ^ previous) {
8222                                                    query.append(ORDER_BY_ASC);
8223                                            }
8224                                            else {
8225                                                    query.append(ORDER_BY_DESC);
8226                                            }
8227                                    }
8228                            }
8229                    }
8230                    else {
8231                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8232                    }
8233    
8234                    String sql = query.toString();
8235    
8236                    Query q = session.createQuery(sql);
8237    
8238                    q.setFirstResult(0);
8239                    q.setMaxResults(2);
8240    
8241                    QueryPos qPos = QueryPos.getInstance(q);
8242    
8243                    qPos.add(groupId);
8244    
8245                    qPos.add(folderId);
8246    
8247                    if (orderByComparator != null) {
8248                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8249    
8250                            for (Object value : values) {
8251                                    qPos.add(value);
8252                            }
8253                    }
8254    
8255                    List<JournalArticle> list = q.list();
8256    
8257                    if (list.size() == 2) {
8258                            return list.get(1);
8259                    }
8260                    else {
8261                            return null;
8262                    }
8263            }
8264    
8265            /**
8266             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8267             *
8268             * @param groupId the group ID
8269             * @param folderId the folder ID
8270             * @return the matching journal articles that the user has permission to view
8271             */
8272            @Override
8273            public List<JournalArticle> filterFindByG_F(long groupId, long folderId) {
8274                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
8275                            QueryUtil.ALL_POS, null);
8276            }
8277    
8278            /**
8279             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
8280             *
8281             * <p>
8282             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8283             * </p>
8284             *
8285             * @param groupId the group ID
8286             * @param folderId the folder ID
8287             * @param start the lower bound of the range of journal articles
8288             * @param end the upper bound of the range of journal articles (not inclusive)
8289             * @return the range of matching journal articles that the user has permission to view
8290             */
8291            @Override
8292            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8293                    int start, int end) {
8294                    return filterFindByG_F(groupId, folderId, start, end, null);
8295            }
8296    
8297            /**
8298             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63;.
8299             *
8300             * <p>
8301             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8302             * </p>
8303             *
8304             * @param groupId the group ID
8305             * @param folderId the folder ID
8306             * @param start the lower bound of the range of journal articles
8307             * @param end the upper bound of the range of journal articles (not inclusive)
8308             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8309             * @return the ordered range of matching journal articles that the user has permission to view
8310             */
8311            @Override
8312            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
8313                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
8314                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8315                            return findByG_F(groupId, folderId, start, end, orderByComparator);
8316                    }
8317    
8318                    StringBundler query = null;
8319    
8320                    if (orderByComparator != null) {
8321                            query = new StringBundler(4 +
8322                                            (orderByComparator.getOrderByFields().length * 3));
8323                    }
8324                    else {
8325                            query = new StringBundler(4);
8326                    }
8327    
8328                    if (getDB().isSupportsInlineDistinct()) {
8329                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8330                    }
8331                    else {
8332                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8333                    }
8334    
8335                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8336    
8337                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8338    
8339                    if (!getDB().isSupportsInlineDistinct()) {
8340                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8341                    }
8342    
8343                    if (orderByComparator != null) {
8344                            if (getDB().isSupportsInlineDistinct()) {
8345                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8346                                            orderByComparator, true);
8347                            }
8348                            else {
8349                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8350                                            orderByComparator, true);
8351                            }
8352                    }
8353                    else {
8354                            if (getDB().isSupportsInlineDistinct()) {
8355                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8356                            }
8357                            else {
8358                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8359                            }
8360                    }
8361    
8362                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8363                                    JournalArticle.class.getName(),
8364                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8365    
8366                    Session session = null;
8367    
8368                    try {
8369                            session = openSession();
8370    
8371                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8372    
8373                            if (getDB().isSupportsInlineDistinct()) {
8374                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8375                            }
8376                            else {
8377                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8378                            }
8379    
8380                            QueryPos qPos = QueryPos.getInstance(q);
8381    
8382                            qPos.add(groupId);
8383    
8384                            qPos.add(folderId);
8385    
8386                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8387                                    end);
8388                    }
8389                    catch (Exception e) {
8390                            throw processException(e);
8391                    }
8392                    finally {
8393                            closeSession(session);
8394                    }
8395            }
8396    
8397            /**
8398             * 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;.
8399             *
8400             * @param id the primary key of the current journal article
8401             * @param groupId the group ID
8402             * @param folderId the folder ID
8403             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8404             * @return the previous, current, and next journal article
8405             * @throws NoSuchArticleException if a journal article with the primary key could not be found
8406             */
8407            @Override
8408            public JournalArticle[] filterFindByG_F_PrevAndNext(long id, long groupId,
8409                    long folderId, OrderByComparator<JournalArticle> orderByComparator)
8410                    throws NoSuchArticleException {
8411                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8412                            return findByG_F_PrevAndNext(id, groupId, folderId,
8413                                    orderByComparator);
8414                    }
8415    
8416                    JournalArticle journalArticle = findByPrimaryKey(id);
8417    
8418                    Session session = null;
8419    
8420                    try {
8421                            session = openSession();
8422    
8423                            JournalArticle[] array = new JournalArticleImpl[3];
8424    
8425                            array[0] = filterGetByG_F_PrevAndNext(session, journalArticle,
8426                                            groupId, folderId, orderByComparator, true);
8427    
8428                            array[1] = journalArticle;
8429    
8430                            array[2] = filterGetByG_F_PrevAndNext(session, journalArticle,
8431                                            groupId, folderId, orderByComparator, false);
8432    
8433                            return array;
8434                    }
8435                    catch (Exception e) {
8436                            throw processException(e);
8437                    }
8438                    finally {
8439                            closeSession(session);
8440                    }
8441            }
8442    
8443            protected JournalArticle filterGetByG_F_PrevAndNext(Session session,
8444                    JournalArticle journalArticle, long groupId, long folderId,
8445                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
8446                    StringBundler query = null;
8447    
8448                    if (orderByComparator != null) {
8449                            query = new StringBundler(6 +
8450                                            (orderByComparator.getOrderByFields().length * 6));
8451                    }
8452                    else {
8453                            query = new StringBundler(3);
8454                    }
8455    
8456                    if (getDB().isSupportsInlineDistinct()) {
8457                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8458                    }
8459                    else {
8460                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8461                    }
8462    
8463                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8464    
8465                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8466    
8467                    if (!getDB().isSupportsInlineDistinct()) {
8468                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8469                    }
8470    
8471                    if (orderByComparator != null) {
8472                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8473    
8474                            if (orderByConditionFields.length > 0) {
8475                                    query.append(WHERE_AND);
8476                            }
8477    
8478                            for (int i = 0; i < orderByConditionFields.length; i++) {
8479                                    if (getDB().isSupportsInlineDistinct()) {
8480                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8481                                    }
8482                                    else {
8483                                            query.append(_ORDER_BY_ENTITY_TABLE);
8484                                    }
8485    
8486                                    query.append(orderByConditionFields[i]);
8487    
8488                                    if ((i + 1) < orderByConditionFields.length) {
8489                                            if (orderByComparator.isAscending() ^ previous) {
8490                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8491                                            }
8492                                            else {
8493                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8494                                            }
8495                                    }
8496                                    else {
8497                                            if (orderByComparator.isAscending() ^ previous) {
8498                                                    query.append(WHERE_GREATER_THAN);
8499                                            }
8500                                            else {
8501                                                    query.append(WHERE_LESSER_THAN);
8502                                            }
8503                                    }
8504                            }
8505    
8506                            query.append(ORDER_BY_CLAUSE);
8507    
8508                            String[] orderByFields = orderByComparator.getOrderByFields();
8509    
8510                            for (int i = 0; i < orderByFields.length; i++) {
8511                                    if (getDB().isSupportsInlineDistinct()) {
8512                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8513                                    }
8514                                    else {
8515                                            query.append(_ORDER_BY_ENTITY_TABLE);
8516                                    }
8517    
8518                                    query.append(orderByFields[i]);
8519    
8520                                    if ((i + 1) < orderByFields.length) {
8521                                            if (orderByComparator.isAscending() ^ previous) {
8522                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8523                                            }
8524                                            else {
8525                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8526                                            }
8527                                    }
8528                                    else {
8529                                            if (orderByComparator.isAscending() ^ previous) {
8530                                                    query.append(ORDER_BY_ASC);
8531                                            }
8532                                            else {
8533                                                    query.append(ORDER_BY_DESC);
8534                                            }
8535                                    }
8536                            }
8537                    }
8538                    else {
8539                            if (getDB().isSupportsInlineDistinct()) {
8540                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8541                            }
8542                            else {
8543                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8544                            }
8545                    }
8546    
8547                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8548                                    JournalArticle.class.getName(),
8549                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8550    
8551                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
8552    
8553                    q.setFirstResult(0);
8554                    q.setMaxResults(2);
8555    
8556                    if (getDB().isSupportsInlineDistinct()) {
8557                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8558                    }
8559                    else {
8560                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8561                    }
8562    
8563                    QueryPos qPos = QueryPos.getInstance(q);
8564    
8565                    qPos.add(groupId);
8566    
8567                    qPos.add(folderId);
8568    
8569                    if (orderByComparator != null) {
8570                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8571    
8572                            for (Object value : values) {
8573                                    qPos.add(value);
8574                            }
8575                    }
8576    
8577                    List<JournalArticle> list = q.list();
8578    
8579                    if (list.size() == 2) {
8580                            return list.get(1);
8581                    }
8582                    else {
8583                            return null;
8584                    }
8585            }
8586    
8587            /**
8588             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8589             *
8590             * @param groupId the group ID
8591             * @param folderIds the folder IDs
8592             * @return the matching journal articles that the user has permission to view
8593             */
8594            @Override
8595            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds) {
8596                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8597                            QueryUtil.ALL_POS, null);
8598            }
8599    
8600            /**
8601             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8602             *
8603             * <p>
8604             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8605             * </p>
8606             *
8607             * @param groupId the group ID
8608             * @param folderIds the folder IDs
8609             * @param start the lower bound of the range of journal articles
8610             * @param end the upper bound of the range of journal articles (not inclusive)
8611             * @return the range of matching journal articles that the user has permission to view
8612             */
8613            @Override
8614            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8615                    int start, int end) {
8616                    return filterFindByG_F(groupId, folderIds, start, end, null);
8617            }
8618    
8619            /**
8620             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8621             *
8622             * <p>
8623             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8624             * </p>
8625             *
8626             * @param groupId the group ID
8627             * @param folderIds the folder IDs
8628             * @param start the lower bound of the range of journal articles
8629             * @param end the upper bound of the range of journal articles (not inclusive)
8630             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8631             * @return the ordered range of matching journal articles that the user has permission to view
8632             */
8633            @Override
8634            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8635                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
8636                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8637                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
8638                    }
8639    
8640                    if (folderIds == null) {
8641                            folderIds = new long[0];
8642                    }
8643                    else {
8644                            folderIds = ArrayUtil.unique(folderIds);
8645                    }
8646    
8647                    StringBundler query = new StringBundler();
8648    
8649                    if (getDB().isSupportsInlineDistinct()) {
8650                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8651                    }
8652                    else {
8653                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8654                    }
8655    
8656                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8657    
8658                    if (folderIds.length > 0) {
8659                            query.append(StringPool.OPEN_PARENTHESIS);
8660    
8661                            query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
8662    
8663                            query.append(StringUtil.merge(folderIds));
8664    
8665                            query.append(StringPool.CLOSE_PARENTHESIS);
8666    
8667                            query.append(StringPool.CLOSE_PARENTHESIS);
8668                    }
8669    
8670                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8671                            query.index() - 1);
8672    
8673                    if (!getDB().isSupportsInlineDistinct()) {
8674                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8675                    }
8676    
8677                    if (orderByComparator != null) {
8678                            if (getDB().isSupportsInlineDistinct()) {
8679                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8680                                            orderByComparator, true);
8681                            }
8682                            else {
8683                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8684                                            orderByComparator, true);
8685                            }
8686                    }
8687                    else {
8688                            if (getDB().isSupportsInlineDistinct()) {
8689                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8690                            }
8691                            else {
8692                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8693                            }
8694                    }
8695    
8696                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8697                                    JournalArticle.class.getName(),
8698                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8699    
8700                    Session session = null;
8701    
8702                    try {
8703                            session = openSession();
8704    
8705                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8706    
8707                            if (getDB().isSupportsInlineDistinct()) {
8708                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8709                            }
8710                            else {
8711                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8712                            }
8713    
8714                            QueryPos qPos = QueryPos.getInstance(q);
8715    
8716                            qPos.add(groupId);
8717    
8718                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8719                                    end);
8720                    }
8721                    catch (Exception e) {
8722                            throw processException(e);
8723                    }
8724                    finally {
8725                            closeSession(session);
8726                    }
8727            }
8728    
8729            /**
8730             * Returns all the journal articles where groupId = &#63; and folderId = any &#63;.
8731             *
8732             * <p>
8733             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8734             * </p>
8735             *
8736             * @param groupId the group ID
8737             * @param folderIds the folder IDs
8738             * @return the matching journal articles
8739             */
8740            @Override
8741            public List<JournalArticle> findByG_F(long groupId, long[] folderIds) {
8742                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8743                            QueryUtil.ALL_POS, null);
8744            }
8745    
8746            /**
8747             * Returns a range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8748             *
8749             * <p>
8750             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8751             * </p>
8752             *
8753             * @param groupId the group ID
8754             * @param folderIds the folder IDs
8755             * @param start the lower bound of the range of journal articles
8756             * @param end the upper bound of the range of journal articles (not inclusive)
8757             * @return the range of matching journal articles
8758             */
8759            @Override
8760            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8761                    int start, int end) {
8762                    return findByG_F(groupId, folderIds, start, end, null);
8763            }
8764    
8765            /**
8766             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = any &#63;.
8767             *
8768             * <p>
8769             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8770             * </p>
8771             *
8772             * @param groupId the group ID
8773             * @param folderIds the folder IDs
8774             * @param start the lower bound of the range of journal articles
8775             * @param end the upper bound of the range of journal articles (not inclusive)
8776             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8777             * @return the ordered range of matching journal articles
8778             */
8779            @Override
8780            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
8781                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
8782                    if (folderIds == null) {
8783                            folderIds = new long[0];
8784                    }
8785                    else {
8786                            folderIds = ArrayUtil.unique(folderIds);
8787                    }
8788    
8789                    if (folderIds.length == 1) {
8790                            return findByG_F(groupId, folderIds[0], start, end,
8791                                    orderByComparator);
8792                    }
8793    
8794                    boolean pagination = true;
8795                    Object[] finderArgs = null;
8796    
8797                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8798                                    (orderByComparator == null)) {
8799                            pagination = false;
8800                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
8801                    }
8802                    else {
8803                            finderArgs = new Object[] {
8804                                            groupId, StringUtil.merge(folderIds),
8805                                            
8806                                            start, end, orderByComparator
8807                                    };
8808                    }
8809    
8810                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8811                                    finderArgs, this);
8812    
8813                    if ((list != null) && !list.isEmpty()) {
8814                            for (JournalArticle journalArticle : list) {
8815                                    if ((groupId != journalArticle.getGroupId()) ||
8816                                                    !ArrayUtil.contains(folderIds,
8817                                                            journalArticle.getFolderId())) {
8818                                            list = null;
8819    
8820                                            break;
8821                                    }
8822                            }
8823                    }
8824    
8825                    if (list == null) {
8826                            StringBundler query = new StringBundler();
8827    
8828                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8829    
8830                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8831    
8832                            if (folderIds.length > 0) {
8833                                    query.append(StringPool.OPEN_PARENTHESIS);
8834    
8835                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
8836    
8837                                    query.append(StringUtil.merge(folderIds));
8838    
8839                                    query.append(StringPool.CLOSE_PARENTHESIS);
8840    
8841                                    query.append(StringPool.CLOSE_PARENTHESIS);
8842                            }
8843    
8844                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
8845                                                    1)), query.index() - 1);
8846    
8847                            if (orderByComparator != null) {
8848                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8849                                            orderByComparator);
8850                            }
8851                            else
8852                             if (pagination) {
8853                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8854                            }
8855    
8856                            String sql = query.toString();
8857    
8858                            Session session = null;
8859    
8860                            try {
8861                                    session = openSession();
8862    
8863                                    Query q = session.createQuery(sql);
8864    
8865                                    QueryPos qPos = QueryPos.getInstance(q);
8866    
8867                                    qPos.add(groupId);
8868    
8869                                    if (!pagination) {
8870                                            list = (List<JournalArticle>)QueryUtil.list(q,
8871                                                            getDialect(), start, end, false);
8872    
8873                                            Collections.sort(list);
8874    
8875                                            list = Collections.unmodifiableList(list);
8876                                    }
8877                                    else {
8878                                            list = (List<JournalArticle>)QueryUtil.list(q,
8879                                                            getDialect(), start, end);
8880                                    }
8881    
8882                                    cacheResult(list);
8883    
8884                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8885                                            finderArgs, list);
8886                            }
8887                            catch (Exception e) {
8888                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
8889                                            finderArgs);
8890    
8891                                    throw processException(e);
8892                            }
8893                            finally {
8894                                    closeSession(session);
8895                            }
8896                    }
8897    
8898                    return list;
8899            }
8900    
8901            /**
8902             * Removes all the journal articles where groupId = &#63; and folderId = &#63; from the database.
8903             *
8904             * @param groupId the group ID
8905             * @param folderId the folder ID
8906             */
8907            @Override
8908            public void removeByG_F(long groupId, long folderId) {
8909                    for (JournalArticle journalArticle : findByG_F(groupId, folderId,
8910                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8911                            remove(journalArticle);
8912                    }
8913            }
8914    
8915            /**
8916             * Returns the number of journal articles where groupId = &#63; and folderId = &#63;.
8917             *
8918             * @param groupId the group ID
8919             * @param folderId the folder ID
8920             * @return the number of matching journal articles
8921             */
8922            @Override
8923            public int countByG_F(long groupId, long folderId) {
8924                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
8925    
8926                    Object[] finderArgs = new Object[] { groupId, folderId };
8927    
8928                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8929                                    this);
8930    
8931                    if (count == null) {
8932                            StringBundler query = new StringBundler(3);
8933    
8934                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8935    
8936                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8937    
8938                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
8939    
8940                            String sql = query.toString();
8941    
8942                            Session session = null;
8943    
8944                            try {
8945                                    session = openSession();
8946    
8947                                    Query q = session.createQuery(sql);
8948    
8949                                    QueryPos qPos = QueryPos.getInstance(q);
8950    
8951                                    qPos.add(groupId);
8952    
8953                                    qPos.add(folderId);
8954    
8955                                    count = (Long)q.uniqueResult();
8956    
8957                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8958                            }
8959                            catch (Exception e) {
8960                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8961    
8962                                    throw processException(e);
8963                            }
8964                            finally {
8965                                    closeSession(session);
8966                            }
8967                    }
8968    
8969                    return count.intValue();
8970            }
8971    
8972            /**
8973             * Returns the number of journal articles where groupId = &#63; and folderId = any &#63;.
8974             *
8975             * @param groupId the group ID
8976             * @param folderIds the folder IDs
8977             * @return the number of matching journal articles
8978             */
8979            @Override
8980            public int countByG_F(long groupId, long[] folderIds) {
8981                    if (folderIds == null) {
8982                            folderIds = new long[0];
8983                    }
8984                    else {
8985                            folderIds = ArrayUtil.unique(folderIds);
8986                    }
8987    
8988                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
8989    
8990                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
8991                                    finderArgs, this);
8992    
8993                    if (count == null) {
8994                            StringBundler query = new StringBundler();
8995    
8996                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8997    
8998                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
8999    
9000                            if (folderIds.length > 0) {
9001                                    query.append(StringPool.OPEN_PARENTHESIS);
9002    
9003                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
9004    
9005                                    query.append(StringUtil.merge(folderIds));
9006    
9007                                    query.append(StringPool.CLOSE_PARENTHESIS);
9008    
9009                                    query.append(StringPool.CLOSE_PARENTHESIS);
9010                            }
9011    
9012                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
9013                                                    1)), query.index() - 1);
9014    
9015                            String sql = query.toString();
9016    
9017                            Session session = null;
9018    
9019                            try {
9020                                    session = openSession();
9021    
9022                                    Query q = session.createQuery(sql);
9023    
9024                                    QueryPos qPos = QueryPos.getInstance(q);
9025    
9026                                    qPos.add(groupId);
9027    
9028                                    count = (Long)q.uniqueResult();
9029    
9030                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9031                                            finderArgs, count);
9032                            }
9033                            catch (Exception e) {
9034                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
9035                                            finderArgs);
9036    
9037                                    throw processException(e);
9038                            }
9039                            finally {
9040                                    closeSession(session);
9041                            }
9042                    }
9043    
9044                    return count.intValue();
9045            }
9046    
9047            /**
9048             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
9049             *
9050             * @param groupId the group ID
9051             * @param folderId the folder ID
9052             * @return the number of matching journal articles that the user has permission to view
9053             */
9054            @Override
9055            public int filterCountByG_F(long groupId, long folderId) {
9056                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9057                            return countByG_F(groupId, folderId);
9058                    }
9059    
9060                    StringBundler query = new StringBundler(3);
9061    
9062                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9063    
9064                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
9065    
9066                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
9067    
9068                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9069                                    JournalArticle.class.getName(),
9070                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9071    
9072                    Session session = null;
9073    
9074                    try {
9075                            session = openSession();
9076    
9077                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9078    
9079                            q.addScalar(COUNT_COLUMN_NAME,
9080                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9081    
9082                            QueryPos qPos = QueryPos.getInstance(q);
9083    
9084                            qPos.add(groupId);
9085    
9086                            qPos.add(folderId);
9087    
9088                            Long count = (Long)q.uniqueResult();
9089    
9090                            return count.intValue();
9091                    }
9092                    catch (Exception e) {
9093                            throw processException(e);
9094                    }
9095                    finally {
9096                            closeSession(session);
9097                    }
9098            }
9099    
9100            /**
9101             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
9102             *
9103             * @param groupId the group ID
9104             * @param folderIds the folder IDs
9105             * @return the number of matching journal articles that the user has permission to view
9106             */
9107            @Override
9108            public int filterCountByG_F(long groupId, long[] folderIds) {
9109                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9110                            return countByG_F(groupId, folderIds);
9111                    }
9112    
9113                    if (folderIds == null) {
9114                            folderIds = new long[0];
9115                    }
9116                    else {
9117                            folderIds = ArrayUtil.unique(folderIds);
9118                    }
9119    
9120                    StringBundler query = new StringBundler();
9121    
9122                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9123    
9124                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
9125    
9126                    if (folderIds.length > 0) {
9127                            query.append(StringPool.OPEN_PARENTHESIS);
9128    
9129                            query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
9130    
9131                            query.append(StringUtil.merge(folderIds));
9132    
9133                            query.append(StringPool.CLOSE_PARENTHESIS);
9134    
9135                            query.append(StringPool.CLOSE_PARENTHESIS);
9136                    }
9137    
9138                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
9139                            query.index() - 1);
9140    
9141                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9142                                    JournalArticle.class.getName(),
9143                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9144    
9145                    Session session = null;
9146    
9147                    try {
9148                            session = openSession();
9149    
9150                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9151    
9152                            q.addScalar(COUNT_COLUMN_NAME,
9153                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9154    
9155                            QueryPos qPos = QueryPos.getInstance(q);
9156    
9157                            qPos.add(groupId);
9158    
9159                            Long count = (Long)q.uniqueResult();
9160    
9161                            return count.intValue();
9162                    }
9163                    catch (Exception e) {
9164                            throw processException(e);
9165                    }
9166                    finally {
9167                            closeSession(session);
9168                    }
9169            }
9170    
9171            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalArticle.groupId = ? AND ";
9172            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "journalArticle.folderId = ?";
9173            private static final String _FINDER_COLUMN_G_F_FOLDERID_7 = "journalArticle.folderId IN (";
9174            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9175                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9176                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9177                            "findByG_A",
9178                            new String[] {
9179                                    Long.class.getName(), String.class.getName(),
9180                                    
9181                            Integer.class.getName(), Integer.class.getName(),
9182                                    OrderByComparator.class.getName()
9183                            });
9184            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9185                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
9186                            JournalArticleImpl.class,
9187                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
9188                            new String[] { Long.class.getName(), String.class.getName() },
9189                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
9190                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
9191                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
9192            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
9193                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
9194                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
9195                            new String[] { Long.class.getName(), String.class.getName() });
9196    
9197            /**
9198             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
9199             *
9200             * @param groupId the group ID
9201             * @param articleId the article ID
9202             * @return the matching journal articles
9203             */
9204            @Override
9205            public List<JournalArticle> findByG_A(long groupId, String articleId) {
9206                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
9207                            QueryUtil.ALL_POS, null);
9208            }
9209    
9210            /**
9211             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
9212             *
9213             * <p>
9214             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9215             * </p>
9216             *
9217             * @param groupId the group ID
9218             * @param articleId the article ID
9219             * @param start the lower bound of the range of journal articles
9220             * @param end the upper bound of the range of journal articles (not inclusive)
9221             * @return the range of matching journal articles
9222             */
9223            @Override
9224            public List<JournalArticle> findByG_A(long groupId, String articleId,
9225                    int start, int end) {
9226                    return findByG_A(groupId, articleId, start, end, null);
9227            }
9228    
9229            /**
9230             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
9231             *
9232             * <p>
9233             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9234             * </p>
9235             *
9236             * @param groupId the group ID
9237             * @param articleId the article ID
9238             * @param start the lower bound of the range of journal articles
9239             * @param end the upper bound of the range of journal articles (not inclusive)
9240             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9241             * @return the ordered range of matching journal articles
9242             */
9243            @Override
9244            public List<JournalArticle> findByG_A(long groupId, String articleId,
9245                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
9246                    boolean pagination = true;
9247                    FinderPath finderPath = null;
9248                    Object[] finderArgs = null;
9249    
9250                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9251                                    (orderByComparator == null)) {
9252                            pagination = false;
9253                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
9254                            finderArgs = new Object[] { groupId, articleId };
9255                    }
9256                    else {
9257                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
9258                            finderArgs = new Object[] {
9259                                            groupId, articleId,
9260                                            
9261                                            start, end, orderByComparator
9262                                    };
9263                    }
9264    
9265                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9266                                    finderArgs, this);
9267    
9268                    if ((list != null) && !list.isEmpty()) {
9269                            for (JournalArticle journalArticle : list) {
9270                                    if ((groupId != journalArticle.getGroupId()) ||
9271                                                    !Validator.equals(articleId,
9272                                                            journalArticle.getArticleId())) {
9273                                            list = null;
9274    
9275                                            break;
9276                                    }
9277                            }
9278                    }
9279    
9280                    if (list == null) {
9281                            StringBundler query = null;
9282    
9283                            if (orderByComparator != null) {
9284                                    query = new StringBundler(4 +
9285                                                    (orderByComparator.getOrderByFields().length * 3));
9286                            }
9287                            else {
9288                                    query = new StringBundler(4);
9289                            }
9290    
9291                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9292    
9293                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9294    
9295                            boolean bindArticleId = false;
9296    
9297                            if (articleId == null) {
9298                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9299                            }
9300                            else if (articleId.equals(StringPool.BLANK)) {
9301                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9302                            }
9303                            else {
9304                                    bindArticleId = true;
9305    
9306                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9307                            }
9308    
9309                            if (orderByComparator != null) {
9310                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9311                                            orderByComparator);
9312                            }
9313                            else
9314                             if (pagination) {
9315                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9316                            }
9317    
9318                            String sql = query.toString();
9319    
9320                            Session session = null;
9321    
9322                            try {
9323                                    session = openSession();
9324    
9325                                    Query q = session.createQuery(sql);
9326    
9327                                    QueryPos qPos = QueryPos.getInstance(q);
9328    
9329                                    qPos.add(groupId);
9330    
9331                                    if (bindArticleId) {
9332                                            qPos.add(articleId);
9333                                    }
9334    
9335                                    if (!pagination) {
9336                                            list = (List<JournalArticle>)QueryUtil.list(q,
9337                                                            getDialect(), start, end, false);
9338    
9339                                            Collections.sort(list);
9340    
9341                                            list = Collections.unmodifiableList(list);
9342                                    }
9343                                    else {
9344                                            list = (List<JournalArticle>)QueryUtil.list(q,
9345                                                            getDialect(), start, end);
9346                                    }
9347    
9348                                    cacheResult(list);
9349    
9350                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9351                            }
9352                            catch (Exception e) {
9353                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9354    
9355                                    throw processException(e);
9356                            }
9357                            finally {
9358                                    closeSession(session);
9359                            }
9360                    }
9361    
9362                    return list;
9363            }
9364    
9365            /**
9366             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9367             *
9368             * @param groupId the group ID
9369             * @param articleId the article ID
9370             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9371             * @return the first matching journal article
9372             * @throws NoSuchArticleException if a matching journal article could not be found
9373             */
9374            @Override
9375            public JournalArticle findByG_A_First(long groupId, String articleId,
9376                    OrderByComparator<JournalArticle> orderByComparator)
9377                    throws NoSuchArticleException {
9378                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
9379                                    orderByComparator);
9380    
9381                    if (journalArticle != null) {
9382                            return journalArticle;
9383                    }
9384    
9385                    StringBundler msg = new StringBundler(6);
9386    
9387                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9388    
9389                    msg.append("groupId=");
9390                    msg.append(groupId);
9391    
9392                    msg.append(", articleId=");
9393                    msg.append(articleId);
9394    
9395                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9396    
9397                    throw new NoSuchArticleException(msg.toString());
9398            }
9399    
9400            /**
9401             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9402             *
9403             * @param groupId the group ID
9404             * @param articleId the article ID
9405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9406             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9407             */
9408            @Override
9409            public JournalArticle fetchByG_A_First(long groupId, String articleId,
9410                    OrderByComparator<JournalArticle> orderByComparator) {
9411                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
9412                                    orderByComparator);
9413    
9414                    if (!list.isEmpty()) {
9415                            return list.get(0);
9416                    }
9417    
9418                    return null;
9419            }
9420    
9421            /**
9422             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9423             *
9424             * @param groupId the group ID
9425             * @param articleId the article ID
9426             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9427             * @return the last matching journal article
9428             * @throws NoSuchArticleException if a matching journal article could not be found
9429             */
9430            @Override
9431            public JournalArticle findByG_A_Last(long groupId, String articleId,
9432                    OrderByComparator<JournalArticle> orderByComparator)
9433                    throws NoSuchArticleException {
9434                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
9435                                    orderByComparator);
9436    
9437                    if (journalArticle != null) {
9438                            return journalArticle;
9439                    }
9440    
9441                    StringBundler msg = new StringBundler(6);
9442    
9443                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9444    
9445                    msg.append("groupId=");
9446                    msg.append(groupId);
9447    
9448                    msg.append(", articleId=");
9449                    msg.append(articleId);
9450    
9451                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9452    
9453                    throw new NoSuchArticleException(msg.toString());
9454            }
9455    
9456            /**
9457             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9458             *
9459             * @param groupId the group ID
9460             * @param articleId the article ID
9461             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9462             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9463             */
9464            @Override
9465            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
9466                    OrderByComparator<JournalArticle> orderByComparator) {
9467                    int count = countByG_A(groupId, articleId);
9468    
9469                    if (count == 0) {
9470                            return null;
9471                    }
9472    
9473                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
9474                                    count, orderByComparator);
9475    
9476                    if (!list.isEmpty()) {
9477                            return list.get(0);
9478                    }
9479    
9480                    return null;
9481            }
9482    
9483            /**
9484             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
9485             *
9486             * @param id the primary key of the current journal article
9487             * @param groupId the group ID
9488             * @param articleId the article ID
9489             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9490             * @return the previous, current, and next journal article
9491             * @throws NoSuchArticleException if a journal article with the primary key could not be found
9492             */
9493            @Override
9494            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
9495                    String articleId, OrderByComparator<JournalArticle> orderByComparator)
9496                    throws NoSuchArticleException {
9497                    JournalArticle journalArticle = findByPrimaryKey(id);
9498    
9499                    Session session = null;
9500    
9501                    try {
9502                            session = openSession();
9503    
9504                            JournalArticle[] array = new JournalArticleImpl[3];
9505    
9506                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9507                                            articleId, orderByComparator, true);
9508    
9509                            array[1] = journalArticle;
9510    
9511                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
9512                                            articleId, orderByComparator, false);
9513    
9514                            return array;
9515                    }
9516                    catch (Exception e) {
9517                            throw processException(e);
9518                    }
9519                    finally {
9520                            closeSession(session);
9521                    }
9522            }
9523    
9524            protected JournalArticle getByG_A_PrevAndNext(Session session,
9525                    JournalArticle journalArticle, long groupId, String articleId,
9526                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
9527                    StringBundler query = null;
9528    
9529                    if (orderByComparator != null) {
9530                            query = new StringBundler(6 +
9531                                            (orderByComparator.getOrderByFields().length * 6));
9532                    }
9533                    else {
9534                            query = new StringBundler(3);
9535                    }
9536    
9537                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9538    
9539                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9540    
9541                    boolean bindArticleId = false;
9542    
9543                    if (articleId == null) {
9544                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9545                    }
9546                    else if (articleId.equals(StringPool.BLANK)) {
9547                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9548                    }
9549                    else {
9550                            bindArticleId = true;
9551    
9552                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9553                    }
9554    
9555                    if (orderByComparator != null) {
9556                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9557    
9558                            if (orderByConditionFields.length > 0) {
9559                                    query.append(WHERE_AND);
9560                            }
9561    
9562                            for (int i = 0; i < orderByConditionFields.length; i++) {
9563                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9564                                    query.append(orderByConditionFields[i]);
9565    
9566                                    if ((i + 1) < orderByConditionFields.length) {
9567                                            if (orderByComparator.isAscending() ^ previous) {
9568                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9569                                            }
9570                                            else {
9571                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9572                                            }
9573                                    }
9574                                    else {
9575                                            if (orderByComparator.isAscending() ^ previous) {
9576                                                    query.append(WHERE_GREATER_THAN);
9577                                            }
9578                                            else {
9579                                                    query.append(WHERE_LESSER_THAN);
9580                                            }
9581                                    }
9582                            }
9583    
9584                            query.append(ORDER_BY_CLAUSE);
9585    
9586                            String[] orderByFields = orderByComparator.getOrderByFields();
9587    
9588                            for (int i = 0; i < orderByFields.length; i++) {
9589                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9590                                    query.append(orderByFields[i]);
9591    
9592                                    if ((i + 1) < orderByFields.length) {
9593                                            if (orderByComparator.isAscending() ^ previous) {
9594                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9595                                            }
9596                                            else {
9597                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9598                                            }
9599                                    }
9600                                    else {
9601                                            if (orderByComparator.isAscending() ^ previous) {
9602                                                    query.append(ORDER_BY_ASC);
9603                                            }
9604                                            else {
9605                                                    query.append(ORDER_BY_DESC);
9606                                            }
9607                                    }
9608                            }
9609                    }
9610                    else {
9611                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9612                    }
9613    
9614                    String sql = query.toString();
9615    
9616                    Query q = session.createQuery(sql);
9617    
9618                    q.setFirstResult(0);
9619                    q.setMaxResults(2);
9620    
9621                    QueryPos qPos = QueryPos.getInstance(q);
9622    
9623                    qPos.add(groupId);
9624    
9625                    if (bindArticleId) {
9626                            qPos.add(articleId);
9627                    }
9628    
9629                    if (orderByComparator != null) {
9630                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9631    
9632                            for (Object value : values) {
9633                                    qPos.add(value);
9634                            }
9635                    }
9636    
9637                    List<JournalArticle> list = q.list();
9638    
9639                    if (list.size() == 2) {
9640                            return list.get(1);
9641                    }
9642                    else {
9643                            return null;
9644                    }
9645            }
9646    
9647            /**
9648             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9649             *
9650             * @param groupId the group ID
9651             * @param articleId the article ID
9652             * @return the matching journal articles that the user has permission to view
9653             */
9654            @Override
9655            public List<JournalArticle> filterFindByG_A(long groupId, String articleId) {
9656                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
9657                            QueryUtil.ALL_POS, null);
9658            }
9659    
9660            /**
9661             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
9662             *
9663             * <p>
9664             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9665             * </p>
9666             *
9667             * @param groupId the group ID
9668             * @param articleId the article ID
9669             * @param start the lower bound of the range of journal articles
9670             * @param end the upper bound of the range of journal articles (not inclusive)
9671             * @return the range of matching journal articles that the user has permission to view
9672             */
9673            @Override
9674            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9675                    int start, int end) {
9676                    return filterFindByG_A(groupId, articleId, start, end, null);
9677            }
9678    
9679            /**
9680             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
9681             *
9682             * <p>
9683             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9684             * </p>
9685             *
9686             * @param groupId the group ID
9687             * @param articleId the article ID
9688             * @param start the lower bound of the range of journal articles
9689             * @param end the upper bound of the range of journal articles (not inclusive)
9690             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9691             * @return the ordered range of matching journal articles that the user has permission to view
9692             */
9693            @Override
9694            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
9695                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
9696                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9697                            return findByG_A(groupId, articleId, start, end, orderByComparator);
9698                    }
9699    
9700                    StringBundler query = null;
9701    
9702                    if (orderByComparator != null) {
9703                            query = new StringBundler(4 +
9704                                            (orderByComparator.getOrderByFields().length * 3));
9705                    }
9706                    else {
9707                            query = new StringBundler(4);
9708                    }
9709    
9710                    if (getDB().isSupportsInlineDistinct()) {
9711                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9712                    }
9713                    else {
9714                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9715                    }
9716    
9717                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9718    
9719                    boolean bindArticleId = false;
9720    
9721                    if (articleId == null) {
9722                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9723                    }
9724                    else if (articleId.equals(StringPool.BLANK)) {
9725                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9726                    }
9727                    else {
9728                            bindArticleId = true;
9729    
9730                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9731                    }
9732    
9733                    if (!getDB().isSupportsInlineDistinct()) {
9734                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9735                    }
9736    
9737                    if (orderByComparator != null) {
9738                            if (getDB().isSupportsInlineDistinct()) {
9739                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9740                                            orderByComparator, true);
9741                            }
9742                            else {
9743                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9744                                            orderByComparator, true);
9745                            }
9746                    }
9747                    else {
9748                            if (getDB().isSupportsInlineDistinct()) {
9749                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9750                            }
9751                            else {
9752                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9753                            }
9754                    }
9755    
9756                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9757                                    JournalArticle.class.getName(),
9758                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9759    
9760                    Session session = null;
9761    
9762                    try {
9763                            session = openSession();
9764    
9765                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9766    
9767                            if (getDB().isSupportsInlineDistinct()) {
9768                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9769                            }
9770                            else {
9771                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9772                            }
9773    
9774                            QueryPos qPos = QueryPos.getInstance(q);
9775    
9776                            qPos.add(groupId);
9777    
9778                            if (bindArticleId) {
9779                                    qPos.add(articleId);
9780                            }
9781    
9782                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9783                                    end);
9784                    }
9785                    catch (Exception e) {
9786                            throw processException(e);
9787                    }
9788                    finally {
9789                            closeSession(session);
9790                    }
9791            }
9792    
9793            /**
9794             * 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;.
9795             *
9796             * @param id the primary key of the current journal article
9797             * @param groupId the group ID
9798             * @param articleId the article ID
9799             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9800             * @return the previous, current, and next journal article
9801             * @throws NoSuchArticleException if a journal article with the primary key could not be found
9802             */
9803            @Override
9804            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
9805                    String articleId, OrderByComparator<JournalArticle> orderByComparator)
9806                    throws NoSuchArticleException {
9807                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9808                            return findByG_A_PrevAndNext(id, groupId, articleId,
9809                                    orderByComparator);
9810                    }
9811    
9812                    JournalArticle journalArticle = findByPrimaryKey(id);
9813    
9814                    Session session = null;
9815    
9816                    try {
9817                            session = openSession();
9818    
9819                            JournalArticle[] array = new JournalArticleImpl[3];
9820    
9821                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
9822                                            groupId, articleId, orderByComparator, true);
9823    
9824                            array[1] = journalArticle;
9825    
9826                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
9827                                            groupId, articleId, orderByComparator, false);
9828    
9829                            return array;
9830                    }
9831                    catch (Exception e) {
9832                            throw processException(e);
9833                    }
9834                    finally {
9835                            closeSession(session);
9836                    }
9837            }
9838    
9839            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
9840                    JournalArticle journalArticle, long groupId, String articleId,
9841                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
9842                    StringBundler query = null;
9843    
9844                    if (orderByComparator != null) {
9845                            query = new StringBundler(6 +
9846                                            (orderByComparator.getOrderByFields().length * 6));
9847                    }
9848                    else {
9849                            query = new StringBundler(3);
9850                    }
9851    
9852                    if (getDB().isSupportsInlineDistinct()) {
9853                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9854                    }
9855                    else {
9856                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9857                    }
9858    
9859                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
9860    
9861                    boolean bindArticleId = false;
9862    
9863                    if (articleId == null) {
9864                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
9865                    }
9866                    else if (articleId.equals(StringPool.BLANK)) {
9867                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
9868                    }
9869                    else {
9870                            bindArticleId = true;
9871    
9872                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
9873                    }
9874    
9875                    if (!getDB().isSupportsInlineDistinct()) {
9876                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9877                    }
9878    
9879                    if (orderByComparator != null) {
9880                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9881    
9882                            if (orderByConditionFields.length > 0) {
9883                                    query.append(WHERE_AND);
9884                            }
9885    
9886                            for (int i = 0; i < orderByConditionFields.length; i++) {
9887                                    if (getDB().isSupportsInlineDistinct()) {
9888                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9889                                    }
9890                                    else {
9891                                            query.append(_ORDER_BY_ENTITY_TABLE);
9892                                    }
9893    
9894                                    query.append(orderByConditionFields[i]);
9895    
9896                                    if ((i + 1) < orderByConditionFields.length) {
9897                                            if (orderByComparator.isAscending() ^ previous) {
9898                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9899                                            }
9900                                            else {
9901                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9902                                            }
9903                                    }
9904                                    else {
9905                                            if (orderByComparator.isAscending() ^ previous) {
9906                                                    query.append(WHERE_GREATER_THAN);
9907                                            }
9908                                            else {
9909                                                    query.append(WHERE_LESSER_THAN);
9910                                            }
9911                                    }
9912                            }
9913    
9914                            query.append(ORDER_BY_CLAUSE);
9915    
9916                            String[] orderByFields = orderByComparator.getOrderByFields();
9917    
9918                            for (int i = 0; i < orderByFields.length; i++) {
9919                                    if (getDB().isSupportsInlineDistinct()) {
9920                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9921                                    }
9922                                    else {
9923                                            query.append(_ORDER_BY_ENTITY_TABLE);
9924                                    }
9925    
9926                                    query.append(orderByFields[i]);
9927    
9928                                    if ((i + 1) < orderByFields.length) {
9929                                            if (orderByComparator.isAscending() ^ previous) {
9930                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9931                                            }
9932                                            else {
9933                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9934                                            }
9935                                    }
9936                                    else {
9937                                            if (orderByComparator.isAscending() ^ previous) {
9938                                                    query.append(ORDER_BY_ASC);
9939                                            }
9940                                            else {
9941                                                    query.append(ORDER_BY_DESC);
9942                                            }
9943                                    }
9944                            }
9945                    }
9946                    else {
9947                            if (getDB().isSupportsInlineDistinct()) {
9948                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9949                            }
9950                            else {
9951                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9952                            }
9953                    }
9954    
9955                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9956                                    JournalArticle.class.getName(),
9957                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9958    
9959                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9960    
9961                    q.setFirstResult(0);
9962                    q.setMaxResults(2);
9963    
9964                    if (getDB().isSupportsInlineDistinct()) {
9965                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9966                    }
9967                    else {
9968                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9969                    }
9970    
9971                    QueryPos qPos = QueryPos.getInstance(q);
9972    
9973                    qPos.add(groupId);
9974    
9975                    if (bindArticleId) {
9976                            qPos.add(articleId);
9977                    }
9978    
9979                    if (orderByComparator != null) {
9980                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9981    
9982                            for (Object value : values) {
9983                                    qPos.add(value);
9984                            }
9985                    }
9986    
9987                    List<JournalArticle> list = q.list();
9988    
9989                    if (list.size() == 2) {
9990                            return list.get(1);
9991                    }
9992                    else {
9993                            return null;
9994                    }
9995            }
9996    
9997            /**
9998             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
9999             *
10000             * @param groupId the group ID
10001             * @param articleId the article ID
10002             */
10003            @Override
10004            public void removeByG_A(long groupId, String articleId) {
10005                    for (JournalArticle journalArticle : findByG_A(groupId, articleId,
10006                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10007                            remove(journalArticle);
10008                    }
10009            }
10010    
10011            /**
10012             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
10013             *
10014             * @param groupId the group ID
10015             * @param articleId the article ID
10016             * @return the number of matching journal articles
10017             */
10018            @Override
10019            public int countByG_A(long groupId, String articleId) {
10020                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A;
10021    
10022                    Object[] finderArgs = new Object[] { groupId, articleId };
10023    
10024                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10025                                    this);
10026    
10027                    if (count == null) {
10028                            StringBundler query = new StringBundler(3);
10029    
10030                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
10031    
10032                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10033    
10034                            boolean bindArticleId = false;
10035    
10036                            if (articleId == null) {
10037                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10038                            }
10039                            else if (articleId.equals(StringPool.BLANK)) {
10040                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10041                            }
10042                            else {
10043                                    bindArticleId = true;
10044    
10045                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10046                            }
10047    
10048                            String sql = query.toString();
10049    
10050                            Session session = null;
10051    
10052                            try {
10053                                    session = openSession();
10054    
10055                                    Query q = session.createQuery(sql);
10056    
10057                                    QueryPos qPos = QueryPos.getInstance(q);
10058    
10059                                    qPos.add(groupId);
10060    
10061                                    if (bindArticleId) {
10062                                            qPos.add(articleId);
10063                                    }
10064    
10065                                    count = (Long)q.uniqueResult();
10066    
10067                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10068                            }
10069                            catch (Exception e) {
10070                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10071    
10072                                    throw processException(e);
10073                            }
10074                            finally {
10075                                    closeSession(session);
10076                            }
10077                    }
10078    
10079                    return count.intValue();
10080            }
10081    
10082            /**
10083             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
10084             *
10085             * @param groupId the group ID
10086             * @param articleId the article ID
10087             * @return the number of matching journal articles that the user has permission to view
10088             */
10089            @Override
10090            public int filterCountByG_A(long groupId, String articleId) {
10091                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10092                            return countByG_A(groupId, articleId);
10093                    }
10094    
10095                    StringBundler query = new StringBundler(3);
10096    
10097                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
10098    
10099                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
10100    
10101                    boolean bindArticleId = false;
10102    
10103                    if (articleId == null) {
10104                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
10105                    }
10106                    else if (articleId.equals(StringPool.BLANK)) {
10107                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
10108                    }
10109                    else {
10110                            bindArticleId = true;
10111    
10112                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
10113                    }
10114    
10115                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10116                                    JournalArticle.class.getName(),
10117                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10118    
10119                    Session session = null;
10120    
10121                    try {
10122                            session = openSession();
10123    
10124                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10125    
10126                            q.addScalar(COUNT_COLUMN_NAME,
10127                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10128    
10129                            QueryPos qPos = QueryPos.getInstance(q);
10130    
10131                            qPos.add(groupId);
10132    
10133                            if (bindArticleId) {
10134                                    qPos.add(articleId);
10135                            }
10136    
10137                            Long count = (Long)q.uniqueResult();
10138    
10139                            return count.intValue();
10140                    }
10141                    catch (Exception e) {
10142                            throw processException(e);
10143                    }
10144                    finally {
10145                            closeSession(session);
10146                    }
10147            }
10148    
10149            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
10150            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
10151            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
10152            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '')";
10153            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10154                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10155                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10156                            "findByG_UT",
10157                            new String[] {
10158                                    Long.class.getName(), String.class.getName(),
10159                                    
10160                            Integer.class.getName(), Integer.class.getName(),
10161                                    OrderByComparator.class.getName()
10162                            });
10163            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10164                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
10165                            JournalArticleImpl.class,
10166                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
10167                            new String[] { Long.class.getName(), String.class.getName() },
10168                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
10169                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
10170                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
10171                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
10172            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
10173                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
10174                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
10175                            new String[] { Long.class.getName(), String.class.getName() });
10176    
10177            /**
10178             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
10179             *
10180             * @param groupId the group ID
10181             * @param urlTitle the url title
10182             * @return the matching journal articles
10183             */
10184            @Override
10185            public List<JournalArticle> findByG_UT(long groupId, String urlTitle) {
10186                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10187                            QueryUtil.ALL_POS, null);
10188            }
10189    
10190            /**
10191             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10192             *
10193             * <p>
10194             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10195             * </p>
10196             *
10197             * @param groupId the group ID
10198             * @param urlTitle the url title
10199             * @param start the lower bound of the range of journal articles
10200             * @param end the upper bound of the range of journal articles (not inclusive)
10201             * @return the range of matching journal articles
10202             */
10203            @Override
10204            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10205                    int start, int end) {
10206                    return findByG_UT(groupId, urlTitle, start, end, null);
10207            }
10208    
10209            /**
10210             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
10211             *
10212             * <p>
10213             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10214             * </p>
10215             *
10216             * @param groupId the group ID
10217             * @param urlTitle the url title
10218             * @param start the lower bound of the range of journal articles
10219             * @param end the upper bound of the range of journal articles (not inclusive)
10220             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10221             * @return the ordered range of matching journal articles
10222             */
10223            @Override
10224            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
10225                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
10226                    boolean pagination = true;
10227                    FinderPath finderPath = null;
10228                    Object[] finderArgs = null;
10229    
10230                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10231                                    (orderByComparator == null)) {
10232                            pagination = false;
10233                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
10234                            finderArgs = new Object[] { groupId, urlTitle };
10235                    }
10236                    else {
10237                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
10238                            finderArgs = new Object[] {
10239                                            groupId, urlTitle,
10240                                            
10241                                            start, end, orderByComparator
10242                                    };
10243                    }
10244    
10245                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10246                                    finderArgs, this);
10247    
10248                    if ((list != null) && !list.isEmpty()) {
10249                            for (JournalArticle journalArticle : list) {
10250                                    if ((groupId != journalArticle.getGroupId()) ||
10251                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
10252                                            list = null;
10253    
10254                                            break;
10255                                    }
10256                            }
10257                    }
10258    
10259                    if (list == null) {
10260                            StringBundler query = null;
10261    
10262                            if (orderByComparator != null) {
10263                                    query = new StringBundler(4 +
10264                                                    (orderByComparator.getOrderByFields().length * 3));
10265                            }
10266                            else {
10267                                    query = new StringBundler(4);
10268                            }
10269    
10270                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10271    
10272                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10273    
10274                            boolean bindUrlTitle = false;
10275    
10276                            if (urlTitle == null) {
10277                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10278                            }
10279                            else if (urlTitle.equals(StringPool.BLANK)) {
10280                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10281                            }
10282                            else {
10283                                    bindUrlTitle = true;
10284    
10285                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10286                            }
10287    
10288                            if (orderByComparator != null) {
10289                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10290                                            orderByComparator);
10291                            }
10292                            else
10293                             if (pagination) {
10294                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10295                            }
10296    
10297                            String sql = query.toString();
10298    
10299                            Session session = null;
10300    
10301                            try {
10302                                    session = openSession();
10303    
10304                                    Query q = session.createQuery(sql);
10305    
10306                                    QueryPos qPos = QueryPos.getInstance(q);
10307    
10308                                    qPos.add(groupId);
10309    
10310                                    if (bindUrlTitle) {
10311                                            qPos.add(urlTitle);
10312                                    }
10313    
10314                                    if (!pagination) {
10315                                            list = (List<JournalArticle>)QueryUtil.list(q,
10316                                                            getDialect(), start, end, false);
10317    
10318                                            Collections.sort(list);
10319    
10320                                            list = Collections.unmodifiableList(list);
10321                                    }
10322                                    else {
10323                                            list = (List<JournalArticle>)QueryUtil.list(q,
10324                                                            getDialect(), start, end);
10325                                    }
10326    
10327                                    cacheResult(list);
10328    
10329                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10330                            }
10331                            catch (Exception e) {
10332                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10333    
10334                                    throw processException(e);
10335                            }
10336                            finally {
10337                                    closeSession(session);
10338                            }
10339                    }
10340    
10341                    return list;
10342            }
10343    
10344            /**
10345             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10346             *
10347             * @param groupId the group ID
10348             * @param urlTitle the url title
10349             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10350             * @return the first matching journal article
10351             * @throws NoSuchArticleException if a matching journal article could not be found
10352             */
10353            @Override
10354            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
10355                    OrderByComparator<JournalArticle> orderByComparator)
10356                    throws NoSuchArticleException {
10357                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
10358                                    orderByComparator);
10359    
10360                    if (journalArticle != null) {
10361                            return journalArticle;
10362                    }
10363    
10364                    StringBundler msg = new StringBundler(6);
10365    
10366                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10367    
10368                    msg.append("groupId=");
10369                    msg.append(groupId);
10370    
10371                    msg.append(", urlTitle=");
10372                    msg.append(urlTitle);
10373    
10374                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10375    
10376                    throw new NoSuchArticleException(msg.toString());
10377            }
10378    
10379            /**
10380             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10381             *
10382             * @param groupId the group ID
10383             * @param urlTitle the url title
10384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10385             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10386             */
10387            @Override
10388            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
10389                    OrderByComparator<JournalArticle> orderByComparator) {
10390                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
10391                                    orderByComparator);
10392    
10393                    if (!list.isEmpty()) {
10394                            return list.get(0);
10395                    }
10396    
10397                    return null;
10398            }
10399    
10400            /**
10401             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10402             *
10403             * @param groupId the group ID
10404             * @param urlTitle the url title
10405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10406             * @return the last matching journal article
10407             * @throws NoSuchArticleException if a matching journal article could not be found
10408             */
10409            @Override
10410            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
10411                    OrderByComparator<JournalArticle> orderByComparator)
10412                    throws NoSuchArticleException {
10413                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
10414                                    orderByComparator);
10415    
10416                    if (journalArticle != null) {
10417                            return journalArticle;
10418                    }
10419    
10420                    StringBundler msg = new StringBundler(6);
10421    
10422                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10423    
10424                    msg.append("groupId=");
10425                    msg.append(groupId);
10426    
10427                    msg.append(", urlTitle=");
10428                    msg.append(urlTitle);
10429    
10430                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10431    
10432                    throw new NoSuchArticleException(msg.toString());
10433            }
10434    
10435            /**
10436             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10437             *
10438             * @param groupId the group ID
10439             * @param urlTitle the url title
10440             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10441             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10442             */
10443            @Override
10444            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
10445                    OrderByComparator<JournalArticle> orderByComparator) {
10446                    int count = countByG_UT(groupId, urlTitle);
10447    
10448                    if (count == 0) {
10449                            return null;
10450                    }
10451    
10452                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
10453                                    count, orderByComparator);
10454    
10455                    if (!list.isEmpty()) {
10456                            return list.get(0);
10457                    }
10458    
10459                    return null;
10460            }
10461    
10462            /**
10463             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
10464             *
10465             * @param id the primary key of the current journal article
10466             * @param groupId the group ID
10467             * @param urlTitle the url title
10468             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10469             * @return the previous, current, and next journal article
10470             * @throws NoSuchArticleException if a journal article with the primary key could not be found
10471             */
10472            @Override
10473            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
10474                    String urlTitle, OrderByComparator<JournalArticle> orderByComparator)
10475                    throws NoSuchArticleException {
10476                    JournalArticle journalArticle = findByPrimaryKey(id);
10477    
10478                    Session session = null;
10479    
10480                    try {
10481                            session = openSession();
10482    
10483                            JournalArticle[] array = new JournalArticleImpl[3];
10484    
10485                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10486                                            urlTitle, orderByComparator, true);
10487    
10488                            array[1] = journalArticle;
10489    
10490                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
10491                                            urlTitle, orderByComparator, false);
10492    
10493                            return array;
10494                    }
10495                    catch (Exception e) {
10496                            throw processException(e);
10497                    }
10498                    finally {
10499                            closeSession(session);
10500                    }
10501            }
10502    
10503            protected JournalArticle getByG_UT_PrevAndNext(Session session,
10504                    JournalArticle journalArticle, long groupId, String urlTitle,
10505                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
10506                    StringBundler query = null;
10507    
10508                    if (orderByComparator != null) {
10509                            query = new StringBundler(6 +
10510                                            (orderByComparator.getOrderByFields().length * 6));
10511                    }
10512                    else {
10513                            query = new StringBundler(3);
10514                    }
10515    
10516                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10517    
10518                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10519    
10520                    boolean bindUrlTitle = false;
10521    
10522                    if (urlTitle == null) {
10523                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10524                    }
10525                    else if (urlTitle.equals(StringPool.BLANK)) {
10526                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10527                    }
10528                    else {
10529                            bindUrlTitle = true;
10530    
10531                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10532                    }
10533    
10534                    if (orderByComparator != null) {
10535                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10536    
10537                            if (orderByConditionFields.length > 0) {
10538                                    query.append(WHERE_AND);
10539                            }
10540    
10541                            for (int i = 0; i < orderByConditionFields.length; i++) {
10542                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10543                                    query.append(orderByConditionFields[i]);
10544    
10545                                    if ((i + 1) < orderByConditionFields.length) {
10546                                            if (orderByComparator.isAscending() ^ previous) {
10547                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10548                                            }
10549                                            else {
10550                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10551                                            }
10552                                    }
10553                                    else {
10554                                            if (orderByComparator.isAscending() ^ previous) {
10555                                                    query.append(WHERE_GREATER_THAN);
10556                                            }
10557                                            else {
10558                                                    query.append(WHERE_LESSER_THAN);
10559                                            }
10560                                    }
10561                            }
10562    
10563                            query.append(ORDER_BY_CLAUSE);
10564    
10565                            String[] orderByFields = orderByComparator.getOrderByFields();
10566    
10567                            for (int i = 0; i < orderByFields.length; i++) {
10568                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10569                                    query.append(orderByFields[i]);
10570    
10571                                    if ((i + 1) < orderByFields.length) {
10572                                            if (orderByComparator.isAscending() ^ previous) {
10573                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10574                                            }
10575                                            else {
10576                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10577                                            }
10578                                    }
10579                                    else {
10580                                            if (orderByComparator.isAscending() ^ previous) {
10581                                                    query.append(ORDER_BY_ASC);
10582                                            }
10583                                            else {
10584                                                    query.append(ORDER_BY_DESC);
10585                                            }
10586                                    }
10587                            }
10588                    }
10589                    else {
10590                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10591                    }
10592    
10593                    String sql = query.toString();
10594    
10595                    Query q = session.createQuery(sql);
10596    
10597                    q.setFirstResult(0);
10598                    q.setMaxResults(2);
10599    
10600                    QueryPos qPos = QueryPos.getInstance(q);
10601    
10602                    qPos.add(groupId);
10603    
10604                    if (bindUrlTitle) {
10605                            qPos.add(urlTitle);
10606                    }
10607    
10608                    if (orderByComparator != null) {
10609                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10610    
10611                            for (Object value : values) {
10612                                    qPos.add(value);
10613                            }
10614                    }
10615    
10616                    List<JournalArticle> list = q.list();
10617    
10618                    if (list.size() == 2) {
10619                            return list.get(1);
10620                    }
10621                    else {
10622                            return null;
10623                    }
10624            }
10625    
10626            /**
10627             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10628             *
10629             * @param groupId the group ID
10630             * @param urlTitle the url title
10631             * @return the matching journal articles that the user has permission to view
10632             */
10633            @Override
10634            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle) {
10635                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
10636                            QueryUtil.ALL_POS, null);
10637            }
10638    
10639            /**
10640             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
10641             *
10642             * <p>
10643             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10644             * </p>
10645             *
10646             * @param groupId the group ID
10647             * @param urlTitle the url title
10648             * @param start the lower bound of the range of journal articles
10649             * @param end the upper bound of the range of journal articles (not inclusive)
10650             * @return the range of matching journal articles that the user has permission to view
10651             */
10652            @Override
10653            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10654                    int start, int end) {
10655                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
10656            }
10657    
10658            /**
10659             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
10660             *
10661             * <p>
10662             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10663             * </p>
10664             *
10665             * @param groupId the group ID
10666             * @param urlTitle the url title
10667             * @param start the lower bound of the range of journal articles
10668             * @param end the upper bound of the range of journal articles (not inclusive)
10669             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10670             * @return the ordered range of matching journal articles that the user has permission to view
10671             */
10672            @Override
10673            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
10674                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
10675                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10676                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
10677                    }
10678    
10679                    StringBundler query = null;
10680    
10681                    if (orderByComparator != null) {
10682                            query = new StringBundler(4 +
10683                                            (orderByComparator.getOrderByFields().length * 3));
10684                    }
10685                    else {
10686                            query = new StringBundler(4);
10687                    }
10688    
10689                    if (getDB().isSupportsInlineDistinct()) {
10690                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10691                    }
10692                    else {
10693                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10694                    }
10695    
10696                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10697    
10698                    boolean bindUrlTitle = false;
10699    
10700                    if (urlTitle == null) {
10701                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10702                    }
10703                    else if (urlTitle.equals(StringPool.BLANK)) {
10704                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10705                    }
10706                    else {
10707                            bindUrlTitle = true;
10708    
10709                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10710                    }
10711    
10712                    if (!getDB().isSupportsInlineDistinct()) {
10713                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10714                    }
10715    
10716                    if (orderByComparator != null) {
10717                            if (getDB().isSupportsInlineDistinct()) {
10718                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10719                                            orderByComparator, true);
10720                            }
10721                            else {
10722                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10723                                            orderByComparator, true);
10724                            }
10725                    }
10726                    else {
10727                            if (getDB().isSupportsInlineDistinct()) {
10728                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10729                            }
10730                            else {
10731                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10732                            }
10733                    }
10734    
10735                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10736                                    JournalArticle.class.getName(),
10737                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10738    
10739                    Session session = null;
10740    
10741                    try {
10742                            session = openSession();
10743    
10744                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10745    
10746                            if (getDB().isSupportsInlineDistinct()) {
10747                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10748                            }
10749                            else {
10750                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10751                            }
10752    
10753                            QueryPos qPos = QueryPos.getInstance(q);
10754    
10755                            qPos.add(groupId);
10756    
10757                            if (bindUrlTitle) {
10758                                    qPos.add(urlTitle);
10759                            }
10760    
10761                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10762                                    end);
10763                    }
10764                    catch (Exception e) {
10765                            throw processException(e);
10766                    }
10767                    finally {
10768                            closeSession(session);
10769                    }
10770            }
10771    
10772            /**
10773             * 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;.
10774             *
10775             * @param id the primary key of the current journal article
10776             * @param groupId the group ID
10777             * @param urlTitle the url title
10778             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10779             * @return the previous, current, and next journal article
10780             * @throws NoSuchArticleException if a journal article with the primary key could not be found
10781             */
10782            @Override
10783            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
10784                    String urlTitle, OrderByComparator<JournalArticle> orderByComparator)
10785                    throws NoSuchArticleException {
10786                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10787                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
10788                                    orderByComparator);
10789                    }
10790    
10791                    JournalArticle journalArticle = findByPrimaryKey(id);
10792    
10793                    Session session = null;
10794    
10795                    try {
10796                            session = openSession();
10797    
10798                            JournalArticle[] array = new JournalArticleImpl[3];
10799    
10800                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
10801                                            groupId, urlTitle, orderByComparator, true);
10802    
10803                            array[1] = journalArticle;
10804    
10805                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
10806                                            groupId, urlTitle, orderByComparator, false);
10807    
10808                            return array;
10809                    }
10810                    catch (Exception e) {
10811                            throw processException(e);
10812                    }
10813                    finally {
10814                            closeSession(session);
10815                    }
10816            }
10817    
10818            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
10819                    JournalArticle journalArticle, long groupId, String urlTitle,
10820                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
10821                    StringBundler query = null;
10822    
10823                    if (orderByComparator != null) {
10824                            query = new StringBundler(6 +
10825                                            (orderByComparator.getOrderByFields().length * 6));
10826                    }
10827                    else {
10828                            query = new StringBundler(3);
10829                    }
10830    
10831                    if (getDB().isSupportsInlineDistinct()) {
10832                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10833                    }
10834                    else {
10835                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10836                    }
10837    
10838                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
10839    
10840                    boolean bindUrlTitle = false;
10841    
10842                    if (urlTitle == null) {
10843                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
10844                    }
10845                    else if (urlTitle.equals(StringPool.BLANK)) {
10846                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
10847                    }
10848                    else {
10849                            bindUrlTitle = true;
10850    
10851                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
10852                    }
10853    
10854                    if (!getDB().isSupportsInlineDistinct()) {
10855                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10856                    }
10857    
10858                    if (orderByComparator != null) {
10859                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10860    
10861                            if (orderByConditionFields.length > 0) {
10862                                    query.append(WHERE_AND);
10863                            }
10864    
10865                            for (int i = 0; i < orderByConditionFields.length; i++) {
10866                                    if (getDB().isSupportsInlineDistinct()) {
10867                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10868                                    }
10869                                    else {
10870                                            query.append(_ORDER_BY_ENTITY_TABLE);
10871                                    }
10872    
10873                                    query.append(orderByConditionFields[i]);
10874    
10875                                    if ((i + 1) < orderByConditionFields.length) {
10876                                            if (orderByComparator.isAscending() ^ previous) {
10877                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10878                                            }
10879                                            else {
10880                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10881                                            }
10882                                    }
10883                                    else {
10884                                            if (orderByComparator.isAscending() ^ previous) {
10885                                                    query.append(WHERE_GREATER_THAN);
10886                                            }
10887                                            else {
10888                                                    query.append(WHERE_LESSER_THAN);
10889                                            }
10890                                    }
10891                            }
10892    
10893                            query.append(ORDER_BY_CLAUSE);
10894    
10895                            String[] orderByFields = orderByComparator.getOrderByFields();
10896    
10897                            for (int i = 0; i < orderByFields.length; i++) {
10898                                    if (getDB().isSupportsInlineDistinct()) {
10899                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10900                                    }
10901                                    else {
10902                                            query.append(_ORDER_BY_ENTITY_TABLE);
10903                                    }
10904    
10905                                    query.append(orderByFields[i]);
10906    
10907                                    if ((i + 1) < orderByFields.length) {
10908                                            if (orderByComparator.isAscending() ^ previous) {
10909                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10910                                            }
10911                                            else {
10912                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10913                                            }
10914                                    }
10915                                    else {
10916                                            if (orderByComparator.isAscending() ^ previous) {
10917                                                    query.append(ORDER_BY_ASC);
10918                                            }
10919                                            else {
10920                                                    query.append(ORDER_BY_DESC);
10921                                            }
10922                                    }
10923                            }
10924                    }
10925                    else {
10926                            if (getDB().isSupportsInlineDistinct()) {
10927                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10928                            }
10929                            else {
10930                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10931                            }
10932                    }
10933    
10934                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10935                                    JournalArticle.class.getName(),
10936                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10937    
10938                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10939    
10940                    q.setFirstResult(0);
10941                    q.setMaxResults(2);
10942    
10943                    if (getDB().isSupportsInlineDistinct()) {
10944                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10945                    }
10946                    else {
10947                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10948                    }
10949    
10950                    QueryPos qPos = QueryPos.getInstance(q);
10951    
10952                    qPos.add(groupId);
10953    
10954                    if (bindUrlTitle) {
10955                            qPos.add(urlTitle);
10956                    }
10957    
10958                    if (orderByComparator != null) {
10959                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10960    
10961                            for (Object value : values) {
10962                                    qPos.add(value);
10963                            }
10964                    }
10965    
10966                    List<JournalArticle> list = q.list();
10967    
10968                    if (list.size() == 2) {
10969                            return list.get(1);
10970                    }
10971                    else {
10972                            return null;
10973                    }
10974            }
10975    
10976            /**
10977             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
10978             *
10979             * @param groupId the group ID
10980             * @param urlTitle the url title
10981             */
10982            @Override
10983            public void removeByG_UT(long groupId, String urlTitle) {
10984                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle,
10985                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10986                            remove(journalArticle);
10987                    }
10988            }
10989    
10990            /**
10991             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
10992             *
10993             * @param groupId the group ID
10994             * @param urlTitle the url title
10995             * @return the number of matching journal articles
10996             */
10997            @Override
10998            public int countByG_UT(long groupId, String urlTitle) {
10999                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
11000    
11001                    Object[] finderArgs = new Object[] { groupId, urlTitle };
11002    
11003                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11004                                    this);
11005    
11006                    if (count == null) {
11007                            StringBundler query = new StringBundler(3);
11008    
11009                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
11010    
11011                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11012    
11013                            boolean bindUrlTitle = false;
11014    
11015                            if (urlTitle == null) {
11016                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11017                            }
11018                            else if (urlTitle.equals(StringPool.BLANK)) {
11019                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11020                            }
11021                            else {
11022                                    bindUrlTitle = true;
11023    
11024                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11025                            }
11026    
11027                            String sql = query.toString();
11028    
11029                            Session session = null;
11030    
11031                            try {
11032                                    session = openSession();
11033    
11034                                    Query q = session.createQuery(sql);
11035    
11036                                    QueryPos qPos = QueryPos.getInstance(q);
11037    
11038                                    qPos.add(groupId);
11039    
11040                                    if (bindUrlTitle) {
11041                                            qPos.add(urlTitle);
11042                                    }
11043    
11044                                    count = (Long)q.uniqueResult();
11045    
11046                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11047                            }
11048                            catch (Exception e) {
11049                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11050    
11051                                    throw processException(e);
11052                            }
11053                            finally {
11054                                    closeSession(session);
11055                            }
11056                    }
11057    
11058                    return count.intValue();
11059            }
11060    
11061            /**
11062             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
11063             *
11064             * @param groupId the group ID
11065             * @param urlTitle the url title
11066             * @return the number of matching journal articles that the user has permission to view
11067             */
11068            @Override
11069            public int filterCountByG_UT(long groupId, String urlTitle) {
11070                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11071                            return countByG_UT(groupId, urlTitle);
11072                    }
11073    
11074                    StringBundler query = new StringBundler(3);
11075    
11076                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
11077    
11078                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
11079    
11080                    boolean bindUrlTitle = false;
11081    
11082                    if (urlTitle == null) {
11083                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
11084                    }
11085                    else if (urlTitle.equals(StringPool.BLANK)) {
11086                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
11087                    }
11088                    else {
11089                            bindUrlTitle = true;
11090    
11091                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
11092                    }
11093    
11094                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11095                                    JournalArticle.class.getName(),
11096                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11097    
11098                    Session session = null;
11099    
11100                    try {
11101                            session = openSession();
11102    
11103                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11104    
11105                            q.addScalar(COUNT_COLUMN_NAME,
11106                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11107    
11108                            QueryPos qPos = QueryPos.getInstance(q);
11109    
11110                            qPos.add(groupId);
11111    
11112                            if (bindUrlTitle) {
11113                                    qPos.add(urlTitle);
11114                            }
11115    
11116                            Long count = (Long)q.uniqueResult();
11117    
11118                            return count.intValue();
11119                    }
11120                    catch (Exception e) {
11121                            throw processException(e);
11122                    }
11123                    finally {
11124                            closeSession(session);
11125                    }
11126            }
11127    
11128            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
11129            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
11130            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
11131            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '')";
11132            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_DDMSK = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11133                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11134                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
11135                            "findByG_DDMSK",
11136                            new String[] {
11137                                    Long.class.getName(), String.class.getName(),
11138                                    
11139                            Integer.class.getName(), Integer.class.getName(),
11140                                    OrderByComparator.class.getName()
11141                            });
11142            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_DDMSK =
11143                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11144                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
11145                            JournalArticleImpl.class,
11146                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_DDMSK",
11147                            new String[] { Long.class.getName(), String.class.getName() },
11148                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
11149                            JournalArticleModelImpl.DDMSTRUCTUREKEY_COLUMN_BITMASK |
11150                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
11151                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
11152            public static final FinderPath FINDER_PATH_COUNT_BY_G_DDMSK = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
11153                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
11154                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_DDMSK",
11155                            new String[] { Long.class.getName(), String.class.getName() });
11156    
11157            /**
11158             * Returns all the journal articles where groupId = &#63; and DDMStructureKey = &#63;.
11159             *
11160             * @param groupId the group ID
11161             * @param DDMStructureKey the d d m structure key
11162             * @return the matching journal articles
11163             */
11164            @Override
11165            public List<JournalArticle> findByG_DDMSK(long groupId,
11166                    String DDMStructureKey) {
11167                    return findByG_DDMSK(groupId, DDMStructureKey, QueryUtil.ALL_POS,
11168                            QueryUtil.ALL_POS, null);
11169            }
11170    
11171            /**
11172             * Returns a range of all the journal articles where groupId = &#63; and DDMStructureKey = &#63;.
11173             *
11174             * <p>
11175             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11176             * </p>
11177             *
11178             * @param groupId the group ID
11179             * @param DDMStructureKey the d d m structure key
11180             * @param start the lower bound of the range of journal articles
11181             * @param end the upper bound of the range of journal articles (not inclusive)
11182             * @return the range of matching journal articles
11183             */
11184            @Override
11185            public List<JournalArticle> findByG_DDMSK(long groupId,
11186                    String DDMStructureKey, int start, int end) {
11187                    return findByG_DDMSK(groupId, DDMStructureKey, start, end, null);
11188            }
11189    
11190            /**
11191             * Returns an ordered range of all the journal articles where groupId = &#63; and DDMStructureKey = &#63;.
11192             *
11193             * <p>
11194             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11195             * </p>
11196             *
11197             * @param groupId the group ID
11198             * @param DDMStructureKey the d d m structure key
11199             * @param start the lower bound of the range of journal articles
11200             * @param end the upper bound of the range of journal articles (not inclusive)
11201             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11202             * @return the ordered range of matching journal articles
11203             */
11204            @Override
11205            public List<JournalArticle> findByG_DDMSK(long groupId,
11206                    String DDMStructureKey, int start, int end,
11207                    OrderByComparator<JournalArticle> orderByComparator) {
11208                    boolean pagination = true;
11209                    FinderPath finderPath = null;
11210                    Object[] finderArgs = null;
11211    
11212                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11213                                    (orderByComparator == null)) {
11214                            pagination = false;
11215                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_DDMSK;
11216                            finderArgs = new Object[] { groupId, DDMStructureKey };
11217                    }
11218                    else {
11219                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_DDMSK;
11220                            finderArgs = new Object[] {
11221                                            groupId, DDMStructureKey,
11222                                            
11223                                            start, end, orderByComparator
11224                                    };
11225                    }
11226    
11227                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11228                                    finderArgs, this);
11229    
11230                    if ((list != null) && !list.isEmpty()) {
11231                            for (JournalArticle journalArticle : list) {
11232                                    if ((groupId != journalArticle.getGroupId()) ||
11233                                                    !Validator.equals(DDMStructureKey,
11234                                                            journalArticle.getDDMStructureKey())) {
11235                                            list = null;
11236    
11237                                            break;
11238                                    }
11239                            }
11240                    }
11241    
11242                    if (list == null) {
11243                            StringBundler query = null;
11244    
11245                            if (orderByComparator != null) {
11246                                    query = new StringBundler(4 +
11247                                                    (orderByComparator.getOrderByFields().length * 3));
11248                            }
11249                            else {
11250                                    query = new StringBundler(4);
11251                            }
11252    
11253                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11254    
11255                            query.append(_FINDER_COLUMN_G_DDMSK_GROUPID_2);
11256    
11257                            boolean bindDDMStructureKey = false;
11258    
11259                            if (DDMStructureKey == null) {
11260                                    query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_1);
11261                            }
11262                            else if (DDMStructureKey.equals(StringPool.BLANK)) {
11263                                    query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_3);
11264                            }
11265                            else {
11266                                    bindDDMStructureKey = true;
11267    
11268                                    query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_2);
11269                            }
11270    
11271                            if (orderByComparator != null) {
11272                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11273                                            orderByComparator);
11274                            }
11275                            else
11276                             if (pagination) {
11277                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11278                            }
11279    
11280                            String sql = query.toString();
11281    
11282                            Session session = null;
11283    
11284                            try {
11285                                    session = openSession();
11286    
11287                                    Query q = session.createQuery(sql);
11288    
11289                                    QueryPos qPos = QueryPos.getInstance(q);
11290    
11291                                    qPos.add(groupId);
11292    
11293                                    if (bindDDMStructureKey) {
11294                                            qPos.add(DDMStructureKey);
11295                                    }
11296    
11297                                    if (!pagination) {
11298                                            list = (List<JournalArticle>)QueryUtil.list(q,
11299                                                            getDialect(), start, end, false);
11300    
11301                                            Collections.sort(list);
11302    
11303                                            list = Collections.unmodifiableList(list);
11304                                    }
11305                                    else {
11306                                            list = (List<JournalArticle>)QueryUtil.list(q,
11307                                                            getDialect(), start, end);
11308                                    }
11309    
11310                                    cacheResult(list);
11311    
11312                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11313                            }
11314                            catch (Exception e) {
11315                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11316    
11317                                    throw processException(e);
11318                            }
11319                            finally {
11320                                    closeSession(session);
11321                            }
11322                    }
11323    
11324                    return list;
11325            }
11326    
11327            /**
11328             * Returns the first journal article in the ordered set where groupId = &#63; and DDMStructureKey = &#63;.
11329             *
11330             * @param groupId the group ID
11331             * @param DDMStructureKey the d d m structure key
11332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11333             * @return the first matching journal article
11334             * @throws NoSuchArticleException if a matching journal article could not be found
11335             */
11336            @Override
11337            public JournalArticle findByG_DDMSK_First(long groupId,
11338                    String DDMStructureKey,
11339                    OrderByComparator<JournalArticle> orderByComparator)
11340                    throws NoSuchArticleException {
11341                    JournalArticle journalArticle = fetchByG_DDMSK_First(groupId,
11342                                    DDMStructureKey, orderByComparator);
11343    
11344                    if (journalArticle != null) {
11345                            return journalArticle;
11346                    }
11347    
11348                    StringBundler msg = new StringBundler(6);
11349    
11350                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11351    
11352                    msg.append("groupId=");
11353                    msg.append(groupId);
11354    
11355                    msg.append(", DDMStructureKey=");
11356                    msg.append(DDMStructureKey);
11357    
11358                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11359    
11360                    throw new NoSuchArticleException(msg.toString());
11361            }
11362    
11363            /**
11364             * Returns the first journal article in the ordered set where groupId = &#63; and DDMStructureKey = &#63;.
11365             *
11366             * @param groupId the group ID
11367             * @param DDMStructureKey the d d m structure key
11368             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11369             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11370             */
11371            @Override
11372            public JournalArticle fetchByG_DDMSK_First(long groupId,
11373                    String DDMStructureKey,
11374                    OrderByComparator<JournalArticle> orderByComparator) {
11375                    List<JournalArticle> list = findByG_DDMSK(groupId, DDMStructureKey, 0,
11376                                    1, orderByComparator);
11377    
11378                    if (!list.isEmpty()) {
11379                            return list.get(0);
11380                    }
11381    
11382                    return null;
11383            }
11384    
11385            /**
11386             * Returns the last journal article in the ordered set where groupId = &#63; and DDMStructureKey = &#63;.
11387             *
11388             * @param groupId the group ID
11389             * @param DDMStructureKey the d d m structure key
11390             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11391             * @return the last matching journal article
11392             * @throws NoSuchArticleException if a matching journal article could not be found
11393             */
11394            @Override
11395            public JournalArticle findByG_DDMSK_Last(long groupId,
11396                    String DDMStructureKey,
11397                    OrderByComparator<JournalArticle> orderByComparator)
11398                    throws NoSuchArticleException {
11399                    JournalArticle journalArticle = fetchByG_DDMSK_Last(groupId,
11400                                    DDMStructureKey, orderByComparator);
11401    
11402                    if (journalArticle != null) {
11403                            return journalArticle;
11404                    }
11405    
11406                    StringBundler msg = new StringBundler(6);
11407    
11408                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11409    
11410                    msg.append("groupId=");
11411                    msg.append(groupId);
11412    
11413                    msg.append(", DDMStructureKey=");
11414                    msg.append(DDMStructureKey);
11415    
11416                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11417    
11418                    throw new NoSuchArticleException(msg.toString());
11419            }
11420    
11421            /**
11422             * Returns the last journal article in the ordered set where groupId = &#63; and DDMStructureKey = &#63;.
11423             *
11424             * @param groupId the group ID
11425             * @param DDMStructureKey the d d m structure key
11426             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11427             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
11428             */
11429            @Override
11430            public JournalArticle fetchByG_DDMSK_Last(long groupId,
11431                    String DDMStructureKey,
11432                    OrderByComparator<JournalArticle> orderByComparator) {
11433                    int count = countByG_DDMSK(groupId, DDMStructureKey);
11434    
11435                    if (count == 0) {
11436                            return null;
11437                    }
11438    
11439                    List<JournalArticle> list = findByG_DDMSK(groupId, DDMStructureKey,
11440                                    count - 1, count, orderByComparator);
11441    
11442                    if (!list.isEmpty()) {
11443                            return list.get(0);
11444                    }
11445    
11446                    return null;
11447            }
11448    
11449            /**
11450             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and DDMStructureKey = &#63;.
11451             *
11452             * @param id the primary key of the current journal article
11453             * @param groupId the group ID
11454             * @param DDMStructureKey the d d m structure key
11455             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11456             * @return the previous, current, and next journal article
11457             * @throws NoSuchArticleException if a journal article with the primary key could not be found
11458             */
11459            @Override
11460            public JournalArticle[] findByG_DDMSK_PrevAndNext(long id, long groupId,
11461                    String DDMStructureKey,
11462                    OrderByComparator<JournalArticle> orderByComparator)
11463                    throws NoSuchArticleException {
11464                    JournalArticle journalArticle = findByPrimaryKey(id);
11465    
11466                    Session session = null;
11467    
11468                    try {
11469                            session = openSession();
11470    
11471                            JournalArticle[] array = new JournalArticleImpl[3];
11472    
11473                            array[0] = getByG_DDMSK_PrevAndNext(session, journalArticle,
11474                                            groupId, DDMStructureKey, orderByComparator, true);
11475    
11476                            array[1] = journalArticle;
11477    
11478                            array[2] = getByG_DDMSK_PrevAndNext(session, journalArticle,
11479                                            groupId, DDMStructureKey, orderByComparator, false);
11480    
11481                            return array;
11482                    }
11483                    catch (Exception e) {
11484                            throw processException(e);
11485                    }
11486                    finally {
11487                            closeSession(session);
11488                    }
11489            }
11490    
11491            protected JournalArticle getByG_DDMSK_PrevAndNext(Session session,
11492                    JournalArticle journalArticle, long groupId, String DDMStructureKey,
11493                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
11494                    StringBundler query = null;
11495    
11496                    if (orderByComparator != null) {
11497                            query = new StringBundler(6 +
11498                                            (orderByComparator.getOrderByFields().length * 6));
11499                    }
11500                    else {
11501                            query = new StringBundler(3);
11502                    }
11503    
11504                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11505    
11506                    query.append(_FINDER_COLUMN_G_DDMSK_GROUPID_2);
11507    
11508                    boolean bindDDMStructureKey = false;
11509    
11510                    if (DDMStructureKey == null) {
11511                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_1);
11512                    }
11513                    else if (DDMStructureKey.equals(StringPool.BLANK)) {
11514                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_3);
11515                    }
11516                    else {
11517                            bindDDMStructureKey = true;
11518    
11519                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_2);
11520                    }
11521    
11522                    if (orderByComparator != null) {
11523                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11524    
11525                            if (orderByConditionFields.length > 0) {
11526                                    query.append(WHERE_AND);
11527                            }
11528    
11529                            for (int i = 0; i < orderByConditionFields.length; i++) {
11530                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11531                                    query.append(orderByConditionFields[i]);
11532    
11533                                    if ((i + 1) < orderByConditionFields.length) {
11534                                            if (orderByComparator.isAscending() ^ previous) {
11535                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11536                                            }
11537                                            else {
11538                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11539                                            }
11540                                    }
11541                                    else {
11542                                            if (orderByComparator.isAscending() ^ previous) {
11543                                                    query.append(WHERE_GREATER_THAN);
11544                                            }
11545                                            else {
11546                                                    query.append(WHERE_LESSER_THAN);
11547                                            }
11548                                    }
11549                            }
11550    
11551                            query.append(ORDER_BY_CLAUSE);
11552    
11553                            String[] orderByFields = orderByComparator.getOrderByFields();
11554    
11555                            for (int i = 0; i < orderByFields.length; i++) {
11556                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11557                                    query.append(orderByFields[i]);
11558    
11559                                    if ((i + 1) < orderByFields.length) {
11560                                            if (orderByComparator.isAscending() ^ previous) {
11561                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11562                                            }
11563                                            else {
11564                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11565                                            }
11566                                    }
11567                                    else {
11568                                            if (orderByComparator.isAscending() ^ previous) {
11569                                                    query.append(ORDER_BY_ASC);
11570                                            }
11571                                            else {
11572                                                    query.append(ORDER_BY_DESC);
11573                                            }
11574                                    }
11575                            }
11576                    }
11577                    else {
11578                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11579                    }
11580    
11581                    String sql = query.toString();
11582    
11583                    Query q = session.createQuery(sql);
11584    
11585                    q.setFirstResult(0);
11586                    q.setMaxResults(2);
11587    
11588                    QueryPos qPos = QueryPos.getInstance(q);
11589    
11590                    qPos.add(groupId);
11591    
11592                    if (bindDDMStructureKey) {
11593                            qPos.add(DDMStructureKey);
11594                    }
11595    
11596                    if (orderByComparator != null) {
11597                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11598    
11599                            for (Object value : values) {
11600                                    qPos.add(value);
11601                            }
11602                    }
11603    
11604                    List<JournalArticle> list = q.list();
11605    
11606                    if (list.size() == 2) {
11607                            return list.get(1);
11608                    }
11609                    else {
11610                            return null;
11611                    }
11612            }
11613    
11614            /**
11615             * Returns all the journal articles that the user has permission to view where groupId = &#63; and DDMStructureKey = &#63;.
11616             *
11617             * @param groupId the group ID
11618             * @param DDMStructureKey the d d m structure key
11619             * @return the matching journal articles that the user has permission to view
11620             */
11621            @Override
11622            public List<JournalArticle> filterFindByG_DDMSK(long groupId,
11623                    String DDMStructureKey) {
11624                    return filterFindByG_DDMSK(groupId, DDMStructureKey, QueryUtil.ALL_POS,
11625                            QueryUtil.ALL_POS, null);
11626            }
11627    
11628            /**
11629             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and DDMStructureKey = &#63;.
11630             *
11631             * <p>
11632             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11633             * </p>
11634             *
11635             * @param groupId the group ID
11636             * @param DDMStructureKey the d d m structure key
11637             * @param start the lower bound of the range of journal articles
11638             * @param end the upper bound of the range of journal articles (not inclusive)
11639             * @return the range of matching journal articles that the user has permission to view
11640             */
11641            @Override
11642            public List<JournalArticle> filterFindByG_DDMSK(long groupId,
11643                    String DDMStructureKey, int start, int end) {
11644                    return filterFindByG_DDMSK(groupId, DDMStructureKey, start, end, null);
11645            }
11646    
11647            /**
11648             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and DDMStructureKey = &#63;.
11649             *
11650             * <p>
11651             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11652             * </p>
11653             *
11654             * @param groupId the group ID
11655             * @param DDMStructureKey the d d m structure key
11656             * @param start the lower bound of the range of journal articles
11657             * @param end the upper bound of the range of journal articles (not inclusive)
11658             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11659             * @return the ordered range of matching journal articles that the user has permission to view
11660             */
11661            @Override
11662            public List<JournalArticle> filterFindByG_DDMSK(long groupId,
11663                    String DDMStructureKey, int start, int end,
11664                    OrderByComparator<JournalArticle> orderByComparator) {
11665                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11666                            return findByG_DDMSK(groupId, DDMStructureKey, start, end,
11667                                    orderByComparator);
11668                    }
11669    
11670                    StringBundler query = null;
11671    
11672                    if (orderByComparator != null) {
11673                            query = new StringBundler(4 +
11674                                            (orderByComparator.getOrderByFields().length * 3));
11675                    }
11676                    else {
11677                            query = new StringBundler(4);
11678                    }
11679    
11680                    if (getDB().isSupportsInlineDistinct()) {
11681                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11682                    }
11683                    else {
11684                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11685                    }
11686    
11687                    query.append(_FINDER_COLUMN_G_DDMSK_GROUPID_2);
11688    
11689                    boolean bindDDMStructureKey = false;
11690    
11691                    if (DDMStructureKey == null) {
11692                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_1);
11693                    }
11694                    else if (DDMStructureKey.equals(StringPool.BLANK)) {
11695                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_3);
11696                    }
11697                    else {
11698                            bindDDMStructureKey = true;
11699    
11700                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_2);
11701                    }
11702    
11703                    if (!getDB().isSupportsInlineDistinct()) {
11704                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11705                    }
11706    
11707                    if (orderByComparator != null) {
11708                            if (getDB().isSupportsInlineDistinct()) {
11709                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11710                                            orderByComparator, true);
11711                            }
11712                            else {
11713                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11714                                            orderByComparator, true);
11715                            }
11716                    }
11717                    else {
11718                            if (getDB().isSupportsInlineDistinct()) {
11719                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11720                            }
11721                            else {
11722                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11723                            }
11724                    }
11725    
11726                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11727                                    JournalArticle.class.getName(),
11728                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11729    
11730                    Session session = null;
11731    
11732                    try {
11733                            session = openSession();
11734    
11735                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11736    
11737                            if (getDB().isSupportsInlineDistinct()) {
11738                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11739                            }
11740                            else {
11741                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11742                            }
11743    
11744                            QueryPos qPos = QueryPos.getInstance(q);
11745    
11746                            qPos.add(groupId);
11747    
11748                            if (bindDDMStructureKey) {
11749                                    qPos.add(DDMStructureKey);
11750                            }
11751    
11752                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11753                                    end);
11754                    }
11755                    catch (Exception e) {
11756                            throw processException(e);
11757                    }
11758                    finally {
11759                            closeSession(session);
11760                    }
11761            }
11762    
11763            /**
11764             * 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 DDMStructureKey = &#63;.
11765             *
11766             * @param id the primary key of the current journal article
11767             * @param groupId the group ID
11768             * @param DDMStructureKey the d d m structure key
11769             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11770             * @return the previous, current, and next journal article
11771             * @throws NoSuchArticleException if a journal article with the primary key could not be found
11772             */
11773            @Override
11774            public JournalArticle[] filterFindByG_DDMSK_PrevAndNext(long id,
11775                    long groupId, String DDMStructureKey,
11776                    OrderByComparator<JournalArticle> orderByComparator)
11777                    throws NoSuchArticleException {
11778                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11779                            return findByG_DDMSK_PrevAndNext(id, groupId, DDMStructureKey,
11780                                    orderByComparator);
11781                    }
11782    
11783                    JournalArticle journalArticle = findByPrimaryKey(id);
11784    
11785                    Session session = null;
11786    
11787                    try {
11788                            session = openSession();
11789    
11790                            JournalArticle[] array = new JournalArticleImpl[3];
11791    
11792                            array[0] = filterGetByG_DDMSK_PrevAndNext(session, journalArticle,
11793                                            groupId, DDMStructureKey, orderByComparator, true);
11794    
11795                            array[1] = journalArticle;
11796    
11797                            array[2] = filterGetByG_DDMSK_PrevAndNext(session, journalArticle,
11798                                            groupId, DDMStructureKey, orderByComparator, false);
11799    
11800                            return array;
11801                    }
11802                    catch (Exception e) {
11803                            throw processException(e);
11804                    }
11805                    finally {
11806                            closeSession(session);
11807                    }
11808            }
11809    
11810            protected JournalArticle filterGetByG_DDMSK_PrevAndNext(Session session,
11811                    JournalArticle journalArticle, long groupId, String DDMStructureKey,
11812                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
11813                    StringBundler query = null;
11814    
11815                    if (orderByComparator != null) {
11816                            query = new StringBundler(6 +
11817                                            (orderByComparator.getOrderByFields().length * 6));
11818                    }
11819                    else {
11820                            query = new StringBundler(3);
11821                    }
11822    
11823                    if (getDB().isSupportsInlineDistinct()) {
11824                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11825                    }
11826                    else {
11827                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11828                    }
11829    
11830                    query.append(_FINDER_COLUMN_G_DDMSK_GROUPID_2);
11831    
11832                    boolean bindDDMStructureKey = false;
11833    
11834                    if (DDMStructureKey == null) {
11835                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_1);
11836                    }
11837                    else if (DDMStructureKey.equals(StringPool.BLANK)) {
11838                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_3);
11839                    }
11840                    else {
11841                            bindDDMStructureKey = true;
11842    
11843                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_2);
11844                    }
11845    
11846                    if (!getDB().isSupportsInlineDistinct()) {
11847                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11848                    }
11849    
11850                    if (orderByComparator != null) {
11851                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11852    
11853                            if (orderByConditionFields.length > 0) {
11854                                    query.append(WHERE_AND);
11855                            }
11856    
11857                            for (int i = 0; i < orderByConditionFields.length; i++) {
11858                                    if (getDB().isSupportsInlineDistinct()) {
11859                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11860                                    }
11861                                    else {
11862                                            query.append(_ORDER_BY_ENTITY_TABLE);
11863                                    }
11864    
11865                                    query.append(orderByConditionFields[i]);
11866    
11867                                    if ((i + 1) < orderByConditionFields.length) {
11868                                            if (orderByComparator.isAscending() ^ previous) {
11869                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11870                                            }
11871                                            else {
11872                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11873                                            }
11874                                    }
11875                                    else {
11876                                            if (orderByComparator.isAscending() ^ previous) {
11877                                                    query.append(WHERE_GREATER_THAN);
11878                                            }
11879                                            else {
11880                                                    query.append(WHERE_LESSER_THAN);
11881                                            }
11882                                    }
11883                            }
11884    
11885                            query.append(ORDER_BY_CLAUSE);
11886    
11887                            String[] orderByFields = orderByComparator.getOrderByFields();
11888    
11889                            for (int i = 0; i < orderByFields.length; i++) {
11890                                    if (getDB().isSupportsInlineDistinct()) {
11891                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11892                                    }
11893                                    else {
11894                                            query.append(_ORDER_BY_ENTITY_TABLE);
11895                                    }
11896    
11897                                    query.append(orderByFields[i]);
11898    
11899                                    if ((i + 1) < orderByFields.length) {
11900                                            if (orderByComparator.isAscending() ^ previous) {
11901                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11902                                            }
11903                                            else {
11904                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11905                                            }
11906                                    }
11907                                    else {
11908                                            if (orderByComparator.isAscending() ^ previous) {
11909                                                    query.append(ORDER_BY_ASC);
11910                                            }
11911                                            else {
11912                                                    query.append(ORDER_BY_DESC);
11913                                            }
11914                                    }
11915                            }
11916                    }
11917                    else {
11918                            if (getDB().isSupportsInlineDistinct()) {
11919                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11920                            }
11921                            else {
11922                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11923                            }
11924                    }
11925    
11926                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11927                                    JournalArticle.class.getName(),
11928                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11929    
11930                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11931    
11932                    q.setFirstResult(0);
11933                    q.setMaxResults(2);
11934    
11935                    if (getDB().isSupportsInlineDistinct()) {
11936                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11937                    }
11938                    else {
11939                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11940                    }
11941    
11942                    QueryPos qPos = QueryPos.getInstance(q);
11943    
11944                    qPos.add(groupId);
11945    
11946                    if (bindDDMStructureKey) {
11947                            qPos.add(DDMStructureKey);
11948                    }
11949    
11950                    if (orderByComparator != null) {
11951                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11952    
11953                            for (Object value : values) {
11954                                    qPos.add(value);
11955                            }
11956                    }
11957    
11958                    List<JournalArticle> list = q.list();
11959    
11960                    if (list.size() == 2) {
11961                            return list.get(1);
11962                    }
11963                    else {
11964                            return null;
11965                    }
11966            }
11967    
11968            /**
11969             * Removes all the journal articles where groupId = &#63; and DDMStructureKey = &#63; from the database.
11970             *
11971             * @param groupId the group ID
11972             * @param DDMStructureKey the d d m structure key
11973             */
11974            @Override
11975            public void removeByG_DDMSK(long groupId, String DDMStructureKey) {
11976                    for (JournalArticle journalArticle : findByG_DDMSK(groupId,
11977                                    DDMStructureKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11978                            remove(journalArticle);
11979                    }
11980            }
11981    
11982            /**
11983             * Returns the number of journal articles where groupId = &#63; and DDMStructureKey = &#63;.
11984             *
11985             * @param groupId the group ID
11986             * @param DDMStructureKey the d d m structure key
11987             * @return the number of matching journal articles
11988             */
11989            @Override
11990            public int countByG_DDMSK(long groupId, String DDMStructureKey) {
11991                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_DDMSK;
11992    
11993                    Object[] finderArgs = new Object[] { groupId, DDMStructureKey };
11994    
11995                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11996                                    this);
11997    
11998                    if (count == null) {
11999                            StringBundler query = new StringBundler(3);
12000    
12001                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
12002    
12003                            query.append(_FINDER_COLUMN_G_DDMSK_GROUPID_2);
12004    
12005                            boolean bindDDMStructureKey = false;
12006    
12007                            if (DDMStructureKey == null) {
12008                                    query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_1);
12009                            }
12010                            else if (DDMStructureKey.equals(StringPool.BLANK)) {
12011                                    query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_3);
12012                            }
12013                            else {
12014                                    bindDDMStructureKey = true;
12015    
12016                                    query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_2);
12017                            }
12018    
12019                            String sql = query.toString();
12020    
12021                            Session session = null;
12022    
12023                            try {
12024                                    session = openSession();
12025    
12026                                    Query q = session.createQuery(sql);
12027    
12028                                    QueryPos qPos = QueryPos.getInstance(q);
12029    
12030                                    qPos.add(groupId);
12031    
12032                                    if (bindDDMStructureKey) {
12033                                            qPos.add(DDMStructureKey);
12034                                    }
12035    
12036                                    count = (Long)q.uniqueResult();
12037    
12038                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12039                            }
12040                            catch (Exception e) {
12041                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12042    
12043                                    throw processException(e);
12044                            }
12045                            finally {
12046                                    closeSession(session);
12047                            }
12048                    }
12049    
12050                    return count.intValue();
12051            }
12052    
12053            /**
12054             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and DDMStructureKey = &#63;.
12055             *
12056             * @param groupId the group ID
12057             * @param DDMStructureKey the d d m structure key
12058             * @return the number of matching journal articles that the user has permission to view
12059             */
12060            @Override
12061            public int filterCountByG_DDMSK(long groupId, String DDMStructureKey) {
12062                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12063                            return countByG_DDMSK(groupId, DDMStructureKey);
12064                    }
12065    
12066                    StringBundler query = new StringBundler(3);
12067    
12068                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
12069    
12070                    query.append(_FINDER_COLUMN_G_DDMSK_GROUPID_2);
12071    
12072                    boolean bindDDMStructureKey = false;
12073    
12074                    if (DDMStructureKey == null) {
12075                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_1);
12076                    }
12077                    else if (DDMStructureKey.equals(StringPool.BLANK)) {
12078                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_3);
12079                    }
12080                    else {
12081                            bindDDMStructureKey = true;
12082    
12083                            query.append(_FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_2);
12084                    }
12085    
12086                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12087                                    JournalArticle.class.getName(),
12088                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12089    
12090                    Session session = null;
12091    
12092                    try {
12093                            session = openSession();
12094    
12095                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12096    
12097                            q.addScalar(COUNT_COLUMN_NAME,
12098                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12099    
12100                            QueryPos qPos = QueryPos.getInstance(q);
12101    
12102                            qPos.add(groupId);
12103    
12104                            if (bindDDMStructureKey) {
12105                                    qPos.add(DDMStructureKey);
12106                            }
12107    
12108                            Long count = (Long)q.uniqueResult();
12109    
12110                            return count.intValue();
12111                    }
12112                    catch (Exception e) {
12113                            throw processException(e);
12114                    }
12115                    finally {
12116                            closeSession(session);
12117                    }
12118            }
12119    
12120            private static final String _FINDER_COLUMN_G_DDMSK_GROUPID_2 = "journalArticle.groupId = ? AND ";
12121            private static final String _FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_1 = "journalArticle.DDMStructureKey IS NULL";
12122            private static final String _FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_2 = "journalArticle.DDMStructureKey = ?";
12123            private static final String _FINDER_COLUMN_G_DDMSK_DDMSTRUCTUREKEY_3 = "(journalArticle.DDMStructureKey IS NULL OR journalArticle.DDMStructureKey = '')";
12124            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_DDMTK = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12125                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12126                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
12127                            "findByG_DDMTK",
12128                            new String[] {
12129                                    Long.class.getName(), String.class.getName(),
12130                                    
12131                            Integer.class.getName(), Integer.class.getName(),
12132                                    OrderByComparator.class.getName()
12133                            });
12134            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_DDMTK =
12135                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12136                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
12137                            JournalArticleImpl.class,
12138                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_DDMTK",
12139                            new String[] { Long.class.getName(), String.class.getName() },
12140                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
12141                            JournalArticleModelImpl.DDMTEMPLATEKEY_COLUMN_BITMASK |
12142                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
12143                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
12144            public static final FinderPath FINDER_PATH_COUNT_BY_G_DDMTK = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
12145                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
12146                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_DDMTK",
12147                            new String[] { Long.class.getName(), String.class.getName() });
12148    
12149            /**
12150             * Returns all the journal articles where groupId = &#63; and DDMTemplateKey = &#63;.
12151             *
12152             * @param groupId the group ID
12153             * @param DDMTemplateKey the d d m template key
12154             * @return the matching journal articles
12155             */
12156            @Override
12157            public List<JournalArticle> findByG_DDMTK(long groupId,
12158                    String DDMTemplateKey) {
12159                    return findByG_DDMTK(groupId, DDMTemplateKey, QueryUtil.ALL_POS,
12160                            QueryUtil.ALL_POS, null);
12161            }
12162    
12163            /**
12164             * Returns a range of all the journal articles where groupId = &#63; and DDMTemplateKey = &#63;.
12165             *
12166             * <p>
12167             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12168             * </p>
12169             *
12170             * @param groupId the group ID
12171             * @param DDMTemplateKey the d d m template key
12172             * @param start the lower bound of the range of journal articles
12173             * @param end the upper bound of the range of journal articles (not inclusive)
12174             * @return the range of matching journal articles
12175             */
12176            @Override
12177            public List<JournalArticle> findByG_DDMTK(long groupId,
12178                    String DDMTemplateKey, int start, int end) {
12179                    return findByG_DDMTK(groupId, DDMTemplateKey, start, end, null);
12180            }
12181    
12182            /**
12183             * Returns an ordered range of all the journal articles where groupId = &#63; and DDMTemplateKey = &#63;.
12184             *
12185             * <p>
12186             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12187             * </p>
12188             *
12189             * @param groupId the group ID
12190             * @param DDMTemplateKey the d d m template key
12191             * @param start the lower bound of the range of journal articles
12192             * @param end the upper bound of the range of journal articles (not inclusive)
12193             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12194             * @return the ordered range of matching journal articles
12195             */
12196            @Override
12197            public List<JournalArticle> findByG_DDMTK(long groupId,
12198                    String DDMTemplateKey, int start, int end,
12199                    OrderByComparator<JournalArticle> orderByComparator) {
12200                    boolean pagination = true;
12201                    FinderPath finderPath = null;
12202                    Object[] finderArgs = null;
12203    
12204                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12205                                    (orderByComparator == null)) {
12206                            pagination = false;
12207                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_DDMTK;
12208                            finderArgs = new Object[] { groupId, DDMTemplateKey };
12209                    }
12210                    else {
12211                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_DDMTK;
12212                            finderArgs = new Object[] {
12213                                            groupId, DDMTemplateKey,
12214                                            
12215                                            start, end, orderByComparator
12216                                    };
12217                    }
12218    
12219                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12220                                    finderArgs, this);
12221    
12222                    if ((list != null) && !list.isEmpty()) {
12223                            for (JournalArticle journalArticle : list) {
12224                                    if ((groupId != journalArticle.getGroupId()) ||
12225                                                    !Validator.equals(DDMTemplateKey,
12226                                                            journalArticle.getDDMTemplateKey())) {
12227                                            list = null;
12228    
12229                                            break;
12230                                    }
12231                            }
12232                    }
12233    
12234                    if (list == null) {
12235                            StringBundler query = null;
12236    
12237                            if (orderByComparator != null) {
12238                                    query = new StringBundler(4 +
12239                                                    (orderByComparator.getOrderByFields().length * 3));
12240                            }
12241                            else {
12242                                    query = new StringBundler(4);
12243                            }
12244    
12245                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12246    
12247                            query.append(_FINDER_COLUMN_G_DDMTK_GROUPID_2);
12248    
12249                            boolean bindDDMTemplateKey = false;
12250    
12251                            if (DDMTemplateKey == null) {
12252                                    query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_1);
12253                            }
12254                            else if (DDMTemplateKey.equals(StringPool.BLANK)) {
12255                                    query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_3);
12256                            }
12257                            else {
12258                                    bindDDMTemplateKey = true;
12259    
12260                                    query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_2);
12261                            }
12262    
12263                            if (orderByComparator != null) {
12264                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12265                                            orderByComparator);
12266                            }
12267                            else
12268                             if (pagination) {
12269                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12270                            }
12271    
12272                            String sql = query.toString();
12273    
12274                            Session session = null;
12275    
12276                            try {
12277                                    session = openSession();
12278    
12279                                    Query q = session.createQuery(sql);
12280    
12281                                    QueryPos qPos = QueryPos.getInstance(q);
12282    
12283                                    qPos.add(groupId);
12284    
12285                                    if (bindDDMTemplateKey) {
12286                                            qPos.add(DDMTemplateKey);
12287                                    }
12288    
12289                                    if (!pagination) {
12290                                            list = (List<JournalArticle>)QueryUtil.list(q,
12291                                                            getDialect(), start, end, false);
12292    
12293                                            Collections.sort(list);
12294    
12295                                            list = Collections.unmodifiableList(list);
12296                                    }
12297                                    else {
12298                                            list = (List<JournalArticle>)QueryUtil.list(q,
12299                                                            getDialect(), start, end);
12300                                    }
12301    
12302                                    cacheResult(list);
12303    
12304                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12305                            }
12306                            catch (Exception e) {
12307                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12308    
12309                                    throw processException(e);
12310                            }
12311                            finally {
12312                                    closeSession(session);
12313                            }
12314                    }
12315    
12316                    return list;
12317            }
12318    
12319            /**
12320             * Returns the first journal article in the ordered set where groupId = &#63; and DDMTemplateKey = &#63;.
12321             *
12322             * @param groupId the group ID
12323             * @param DDMTemplateKey the d d m template key
12324             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12325             * @return the first matching journal article
12326             * @throws NoSuchArticleException if a matching journal article could not be found
12327             */
12328            @Override
12329            public JournalArticle findByG_DDMTK_First(long groupId,
12330                    String DDMTemplateKey,
12331                    OrderByComparator<JournalArticle> orderByComparator)
12332                    throws NoSuchArticleException {
12333                    JournalArticle journalArticle = fetchByG_DDMTK_First(groupId,
12334                                    DDMTemplateKey, orderByComparator);
12335    
12336                    if (journalArticle != null) {
12337                            return journalArticle;
12338                    }
12339    
12340                    StringBundler msg = new StringBundler(6);
12341    
12342                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12343    
12344                    msg.append("groupId=");
12345                    msg.append(groupId);
12346    
12347                    msg.append(", DDMTemplateKey=");
12348                    msg.append(DDMTemplateKey);
12349    
12350                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12351    
12352                    throw new NoSuchArticleException(msg.toString());
12353            }
12354    
12355            /**
12356             * Returns the first journal article in the ordered set where groupId = &#63; and DDMTemplateKey = &#63;.
12357             *
12358             * @param groupId the group ID
12359             * @param DDMTemplateKey the d d m template key
12360             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12361             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12362             */
12363            @Override
12364            public JournalArticle fetchByG_DDMTK_First(long groupId,
12365                    String DDMTemplateKey,
12366                    OrderByComparator<JournalArticle> orderByComparator) {
12367                    List<JournalArticle> list = findByG_DDMTK(groupId, DDMTemplateKey, 0,
12368                                    1, orderByComparator);
12369    
12370                    if (!list.isEmpty()) {
12371                            return list.get(0);
12372                    }
12373    
12374                    return null;
12375            }
12376    
12377            /**
12378             * Returns the last journal article in the ordered set where groupId = &#63; and DDMTemplateKey = &#63;.
12379             *
12380             * @param groupId the group ID
12381             * @param DDMTemplateKey the d d m template key
12382             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12383             * @return the last matching journal article
12384             * @throws NoSuchArticleException if a matching journal article could not be found
12385             */
12386            @Override
12387            public JournalArticle findByG_DDMTK_Last(long groupId,
12388                    String DDMTemplateKey,
12389                    OrderByComparator<JournalArticle> orderByComparator)
12390                    throws NoSuchArticleException {
12391                    JournalArticle journalArticle = fetchByG_DDMTK_Last(groupId,
12392                                    DDMTemplateKey, orderByComparator);
12393    
12394                    if (journalArticle != null) {
12395                            return journalArticle;
12396                    }
12397    
12398                    StringBundler msg = new StringBundler(6);
12399    
12400                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12401    
12402                    msg.append("groupId=");
12403                    msg.append(groupId);
12404    
12405                    msg.append(", DDMTemplateKey=");
12406                    msg.append(DDMTemplateKey);
12407    
12408                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12409    
12410                    throw new NoSuchArticleException(msg.toString());
12411            }
12412    
12413            /**
12414             * Returns the last journal article in the ordered set where groupId = &#63; and DDMTemplateKey = &#63;.
12415             *
12416             * @param groupId the group ID
12417             * @param DDMTemplateKey the d d m template key
12418             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12419             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12420             */
12421            @Override
12422            public JournalArticle fetchByG_DDMTK_Last(long groupId,
12423                    String DDMTemplateKey,
12424                    OrderByComparator<JournalArticle> orderByComparator) {
12425                    int count = countByG_DDMTK(groupId, DDMTemplateKey);
12426    
12427                    if (count == 0) {
12428                            return null;
12429                    }
12430    
12431                    List<JournalArticle> list = findByG_DDMTK(groupId, DDMTemplateKey,
12432                                    count - 1, count, orderByComparator);
12433    
12434                    if (!list.isEmpty()) {
12435                            return list.get(0);
12436                    }
12437    
12438                    return null;
12439            }
12440    
12441            /**
12442             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and DDMTemplateKey = &#63;.
12443             *
12444             * @param id the primary key of the current journal article
12445             * @param groupId the group ID
12446             * @param DDMTemplateKey the d d m template key
12447             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12448             * @return the previous, current, and next journal article
12449             * @throws NoSuchArticleException if a journal article with the primary key could not be found
12450             */
12451            @Override
12452            public JournalArticle[] findByG_DDMTK_PrevAndNext(long id, long groupId,
12453                    String DDMTemplateKey,
12454                    OrderByComparator<JournalArticle> orderByComparator)
12455                    throws NoSuchArticleException {
12456                    JournalArticle journalArticle = findByPrimaryKey(id);
12457    
12458                    Session session = null;
12459    
12460                    try {
12461                            session = openSession();
12462    
12463                            JournalArticle[] array = new JournalArticleImpl[3];
12464    
12465                            array[0] = getByG_DDMTK_PrevAndNext(session, journalArticle,
12466                                            groupId, DDMTemplateKey, orderByComparator, true);
12467    
12468                            array[1] = journalArticle;
12469    
12470                            array[2] = getByG_DDMTK_PrevAndNext(session, journalArticle,
12471                                            groupId, DDMTemplateKey, orderByComparator, false);
12472    
12473                            return array;
12474                    }
12475                    catch (Exception e) {
12476                            throw processException(e);
12477                    }
12478                    finally {
12479                            closeSession(session);
12480                    }
12481            }
12482    
12483            protected JournalArticle getByG_DDMTK_PrevAndNext(Session session,
12484                    JournalArticle journalArticle, long groupId, String DDMTemplateKey,
12485                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
12486                    StringBundler query = null;
12487    
12488                    if (orderByComparator != null) {
12489                            query = new StringBundler(6 +
12490                                            (orderByComparator.getOrderByFields().length * 6));
12491                    }
12492                    else {
12493                            query = new StringBundler(3);
12494                    }
12495    
12496                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12497    
12498                    query.append(_FINDER_COLUMN_G_DDMTK_GROUPID_2);
12499    
12500                    boolean bindDDMTemplateKey = false;
12501    
12502                    if (DDMTemplateKey == null) {
12503                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_1);
12504                    }
12505                    else if (DDMTemplateKey.equals(StringPool.BLANK)) {
12506                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_3);
12507                    }
12508                    else {
12509                            bindDDMTemplateKey = true;
12510    
12511                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_2);
12512                    }
12513    
12514                    if (orderByComparator != null) {
12515                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12516    
12517                            if (orderByConditionFields.length > 0) {
12518                                    query.append(WHERE_AND);
12519                            }
12520    
12521                            for (int i = 0; i < orderByConditionFields.length; i++) {
12522                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12523                                    query.append(orderByConditionFields[i]);
12524    
12525                                    if ((i + 1) < orderByConditionFields.length) {
12526                                            if (orderByComparator.isAscending() ^ previous) {
12527                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12528                                            }
12529                                            else {
12530                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12531                                            }
12532                                    }
12533                                    else {
12534                                            if (orderByComparator.isAscending() ^ previous) {
12535                                                    query.append(WHERE_GREATER_THAN);
12536                                            }
12537                                            else {
12538                                                    query.append(WHERE_LESSER_THAN);
12539                                            }
12540                                    }
12541                            }
12542    
12543                            query.append(ORDER_BY_CLAUSE);
12544    
12545                            String[] orderByFields = orderByComparator.getOrderByFields();
12546    
12547                            for (int i = 0; i < orderByFields.length; i++) {
12548                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12549                                    query.append(orderByFields[i]);
12550    
12551                                    if ((i + 1) < orderByFields.length) {
12552                                            if (orderByComparator.isAscending() ^ previous) {
12553                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12554                                            }
12555                                            else {
12556                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12557                                            }
12558                                    }
12559                                    else {
12560                                            if (orderByComparator.isAscending() ^ previous) {
12561                                                    query.append(ORDER_BY_ASC);
12562                                            }
12563                                            else {
12564                                                    query.append(ORDER_BY_DESC);
12565                                            }
12566                                    }
12567                            }
12568                    }
12569                    else {
12570                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12571                    }
12572    
12573                    String sql = query.toString();
12574    
12575                    Query q = session.createQuery(sql);
12576    
12577                    q.setFirstResult(0);
12578                    q.setMaxResults(2);
12579    
12580                    QueryPos qPos = QueryPos.getInstance(q);
12581    
12582                    qPos.add(groupId);
12583    
12584                    if (bindDDMTemplateKey) {
12585                            qPos.add(DDMTemplateKey);
12586                    }
12587    
12588                    if (orderByComparator != null) {
12589                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12590    
12591                            for (Object value : values) {
12592                                    qPos.add(value);
12593                            }
12594                    }
12595    
12596                    List<JournalArticle> list = q.list();
12597    
12598                    if (list.size() == 2) {
12599                            return list.get(1);
12600                    }
12601                    else {
12602                            return null;
12603                    }
12604            }
12605    
12606            /**
12607             * Returns all the journal articles that the user has permission to view where groupId = &#63; and DDMTemplateKey = &#63;.
12608             *
12609             * @param groupId the group ID
12610             * @param DDMTemplateKey the d d m template key
12611             * @return the matching journal articles that the user has permission to view
12612             */
12613            @Override
12614            public List<JournalArticle> filterFindByG_DDMTK(long groupId,
12615                    String DDMTemplateKey) {
12616                    return filterFindByG_DDMTK(groupId, DDMTemplateKey, QueryUtil.ALL_POS,
12617                            QueryUtil.ALL_POS, null);
12618            }
12619    
12620            /**
12621             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and DDMTemplateKey = &#63;.
12622             *
12623             * <p>
12624             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12625             * </p>
12626             *
12627             * @param groupId the group ID
12628             * @param DDMTemplateKey the d d m template key
12629             * @param start the lower bound of the range of journal articles
12630             * @param end the upper bound of the range of journal articles (not inclusive)
12631             * @return the range of matching journal articles that the user has permission to view
12632             */
12633            @Override
12634            public List<JournalArticle> filterFindByG_DDMTK(long groupId,
12635                    String DDMTemplateKey, int start, int end) {
12636                    return filterFindByG_DDMTK(groupId, DDMTemplateKey, start, end, null);
12637            }
12638    
12639            /**
12640             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and DDMTemplateKey = &#63;.
12641             *
12642             * <p>
12643             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12644             * </p>
12645             *
12646             * @param groupId the group ID
12647             * @param DDMTemplateKey the d d m template key
12648             * @param start the lower bound of the range of journal articles
12649             * @param end the upper bound of the range of journal articles (not inclusive)
12650             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12651             * @return the ordered range of matching journal articles that the user has permission to view
12652             */
12653            @Override
12654            public List<JournalArticle> filterFindByG_DDMTK(long groupId,
12655                    String DDMTemplateKey, int start, int end,
12656                    OrderByComparator<JournalArticle> orderByComparator) {
12657                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12658                            return findByG_DDMTK(groupId, DDMTemplateKey, start, end,
12659                                    orderByComparator);
12660                    }
12661    
12662                    StringBundler query = null;
12663    
12664                    if (orderByComparator != null) {
12665                            query = new StringBundler(4 +
12666                                            (orderByComparator.getOrderByFields().length * 3));
12667                    }
12668                    else {
12669                            query = new StringBundler(4);
12670                    }
12671    
12672                    if (getDB().isSupportsInlineDistinct()) {
12673                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12674                    }
12675                    else {
12676                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12677                    }
12678    
12679                    query.append(_FINDER_COLUMN_G_DDMTK_GROUPID_2);
12680    
12681                    boolean bindDDMTemplateKey = false;
12682    
12683                    if (DDMTemplateKey == null) {
12684                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_1);
12685                    }
12686                    else if (DDMTemplateKey.equals(StringPool.BLANK)) {
12687                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_3);
12688                    }
12689                    else {
12690                            bindDDMTemplateKey = true;
12691    
12692                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_2);
12693                    }
12694    
12695                    if (!getDB().isSupportsInlineDistinct()) {
12696                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12697                    }
12698    
12699                    if (orderByComparator != null) {
12700                            if (getDB().isSupportsInlineDistinct()) {
12701                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12702                                            orderByComparator, true);
12703                            }
12704                            else {
12705                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12706                                            orderByComparator, true);
12707                            }
12708                    }
12709                    else {
12710                            if (getDB().isSupportsInlineDistinct()) {
12711                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12712                            }
12713                            else {
12714                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12715                            }
12716                    }
12717    
12718                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12719                                    JournalArticle.class.getName(),
12720                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12721    
12722                    Session session = null;
12723    
12724                    try {
12725                            session = openSession();
12726    
12727                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12728    
12729                            if (getDB().isSupportsInlineDistinct()) {
12730                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12731                            }
12732                            else {
12733                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12734                            }
12735    
12736                            QueryPos qPos = QueryPos.getInstance(q);
12737    
12738                            qPos.add(groupId);
12739    
12740                            if (bindDDMTemplateKey) {
12741                                    qPos.add(DDMTemplateKey);
12742                            }
12743    
12744                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12745                                    end);
12746                    }
12747                    catch (Exception e) {
12748                            throw processException(e);
12749                    }
12750                    finally {
12751                            closeSession(session);
12752                    }
12753            }
12754    
12755            /**
12756             * 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 DDMTemplateKey = &#63;.
12757             *
12758             * @param id the primary key of the current journal article
12759             * @param groupId the group ID
12760             * @param DDMTemplateKey the d d m template key
12761             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12762             * @return the previous, current, and next journal article
12763             * @throws NoSuchArticleException if a journal article with the primary key could not be found
12764             */
12765            @Override
12766            public JournalArticle[] filterFindByG_DDMTK_PrevAndNext(long id,
12767                    long groupId, String DDMTemplateKey,
12768                    OrderByComparator<JournalArticle> orderByComparator)
12769                    throws NoSuchArticleException {
12770                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12771                            return findByG_DDMTK_PrevAndNext(id, groupId, DDMTemplateKey,
12772                                    orderByComparator);
12773                    }
12774    
12775                    JournalArticle journalArticle = findByPrimaryKey(id);
12776    
12777                    Session session = null;
12778    
12779                    try {
12780                            session = openSession();
12781    
12782                            JournalArticle[] array = new JournalArticleImpl[3];
12783    
12784                            array[0] = filterGetByG_DDMTK_PrevAndNext(session, journalArticle,
12785                                            groupId, DDMTemplateKey, orderByComparator, true);
12786    
12787                            array[1] = journalArticle;
12788    
12789                            array[2] = filterGetByG_DDMTK_PrevAndNext(session, journalArticle,
12790                                            groupId, DDMTemplateKey, orderByComparator, false);
12791    
12792                            return array;
12793                    }
12794                    catch (Exception e) {
12795                            throw processException(e);
12796                    }
12797                    finally {
12798                            closeSession(session);
12799                    }
12800            }
12801    
12802            protected JournalArticle filterGetByG_DDMTK_PrevAndNext(Session session,
12803                    JournalArticle journalArticle, long groupId, String DDMTemplateKey,
12804                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
12805                    StringBundler query = null;
12806    
12807                    if (orderByComparator != null) {
12808                            query = new StringBundler(6 +
12809                                            (orderByComparator.getOrderByFields().length * 6));
12810                    }
12811                    else {
12812                            query = new StringBundler(3);
12813                    }
12814    
12815                    if (getDB().isSupportsInlineDistinct()) {
12816                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12817                    }
12818                    else {
12819                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12820                    }
12821    
12822                    query.append(_FINDER_COLUMN_G_DDMTK_GROUPID_2);
12823    
12824                    boolean bindDDMTemplateKey = false;
12825    
12826                    if (DDMTemplateKey == null) {
12827                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_1);
12828                    }
12829                    else if (DDMTemplateKey.equals(StringPool.BLANK)) {
12830                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_3);
12831                    }
12832                    else {
12833                            bindDDMTemplateKey = true;
12834    
12835                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_2);
12836                    }
12837    
12838                    if (!getDB().isSupportsInlineDistinct()) {
12839                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12840                    }
12841    
12842                    if (orderByComparator != null) {
12843                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12844    
12845                            if (orderByConditionFields.length > 0) {
12846                                    query.append(WHERE_AND);
12847                            }
12848    
12849                            for (int i = 0; i < orderByConditionFields.length; i++) {
12850                                    if (getDB().isSupportsInlineDistinct()) {
12851                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12852                                    }
12853                                    else {
12854                                            query.append(_ORDER_BY_ENTITY_TABLE);
12855                                    }
12856    
12857                                    query.append(orderByConditionFields[i]);
12858    
12859                                    if ((i + 1) < orderByConditionFields.length) {
12860                                            if (orderByComparator.isAscending() ^ previous) {
12861                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12862                                            }
12863                                            else {
12864                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12865                                            }
12866                                    }
12867                                    else {
12868                                            if (orderByComparator.isAscending() ^ previous) {
12869                                                    query.append(WHERE_GREATER_THAN);
12870                                            }
12871                                            else {
12872                                                    query.append(WHERE_LESSER_THAN);
12873                                            }
12874                                    }
12875                            }
12876    
12877                            query.append(ORDER_BY_CLAUSE);
12878    
12879                            String[] orderByFields = orderByComparator.getOrderByFields();
12880    
12881                            for (int i = 0; i < orderByFields.length; i++) {
12882                                    if (getDB().isSupportsInlineDistinct()) {
12883                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12884                                    }
12885                                    else {
12886                                            query.append(_ORDER_BY_ENTITY_TABLE);
12887                                    }
12888    
12889                                    query.append(orderByFields[i]);
12890    
12891                                    if ((i + 1) < orderByFields.length) {
12892                                            if (orderByComparator.isAscending() ^ previous) {
12893                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12894                                            }
12895                                            else {
12896                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12897                                            }
12898                                    }
12899                                    else {
12900                                            if (orderByComparator.isAscending() ^ previous) {
12901                                                    query.append(ORDER_BY_ASC);
12902                                            }
12903                                            else {
12904                                                    query.append(ORDER_BY_DESC);
12905                                            }
12906                                    }
12907                            }
12908                    }
12909                    else {
12910                            if (getDB().isSupportsInlineDistinct()) {
12911                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12912                            }
12913                            else {
12914                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12915                            }
12916                    }
12917    
12918                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12919                                    JournalArticle.class.getName(),
12920                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12921    
12922                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
12923    
12924                    q.setFirstResult(0);
12925                    q.setMaxResults(2);
12926    
12927                    if (getDB().isSupportsInlineDistinct()) {
12928                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12929                    }
12930                    else {
12931                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12932                    }
12933    
12934                    QueryPos qPos = QueryPos.getInstance(q);
12935    
12936                    qPos.add(groupId);
12937    
12938                    if (bindDDMTemplateKey) {
12939                            qPos.add(DDMTemplateKey);
12940                    }
12941    
12942                    if (orderByComparator != null) {
12943                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12944    
12945                            for (Object value : values) {
12946                                    qPos.add(value);
12947                            }
12948                    }
12949    
12950                    List<JournalArticle> list = q.list();
12951    
12952                    if (list.size() == 2) {
12953                            return list.get(1);
12954                    }
12955                    else {
12956                            return null;
12957                    }
12958            }
12959    
12960            /**
12961             * Removes all the journal articles where groupId = &#63; and DDMTemplateKey = &#63; from the database.
12962             *
12963             * @param groupId the group ID
12964             * @param DDMTemplateKey the d d m template key
12965             */
12966            @Override
12967            public void removeByG_DDMTK(long groupId, String DDMTemplateKey) {
12968                    for (JournalArticle journalArticle : findByG_DDMTK(groupId,
12969                                    DDMTemplateKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12970                            remove(journalArticle);
12971                    }
12972            }
12973    
12974            /**
12975             * Returns the number of journal articles where groupId = &#63; and DDMTemplateKey = &#63;.
12976             *
12977             * @param groupId the group ID
12978             * @param DDMTemplateKey the d d m template key
12979             * @return the number of matching journal articles
12980             */
12981            @Override
12982            public int countByG_DDMTK(long groupId, String DDMTemplateKey) {
12983                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_DDMTK;
12984    
12985                    Object[] finderArgs = new Object[] { groupId, DDMTemplateKey };
12986    
12987                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12988                                    this);
12989    
12990                    if (count == null) {
12991                            StringBundler query = new StringBundler(3);
12992    
12993                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
12994    
12995                            query.append(_FINDER_COLUMN_G_DDMTK_GROUPID_2);
12996    
12997                            boolean bindDDMTemplateKey = false;
12998    
12999                            if (DDMTemplateKey == null) {
13000                                    query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_1);
13001                            }
13002                            else if (DDMTemplateKey.equals(StringPool.BLANK)) {
13003                                    query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_3);
13004                            }
13005                            else {
13006                                    bindDDMTemplateKey = true;
13007    
13008                                    query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_2);
13009                            }
13010    
13011                            String sql = query.toString();
13012    
13013                            Session session = null;
13014    
13015                            try {
13016                                    session = openSession();
13017    
13018                                    Query q = session.createQuery(sql);
13019    
13020                                    QueryPos qPos = QueryPos.getInstance(q);
13021    
13022                                    qPos.add(groupId);
13023    
13024                                    if (bindDDMTemplateKey) {
13025                                            qPos.add(DDMTemplateKey);
13026                                    }
13027    
13028                                    count = (Long)q.uniqueResult();
13029    
13030                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13031                            }
13032                            catch (Exception e) {
13033                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13034    
13035                                    throw processException(e);
13036                            }
13037                            finally {
13038                                    closeSession(session);
13039                            }
13040                    }
13041    
13042                    return count.intValue();
13043            }
13044    
13045            /**
13046             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and DDMTemplateKey = &#63;.
13047             *
13048             * @param groupId the group ID
13049             * @param DDMTemplateKey the d d m template key
13050             * @return the number of matching journal articles that the user has permission to view
13051             */
13052            @Override
13053            public int filterCountByG_DDMTK(long groupId, String DDMTemplateKey) {
13054                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13055                            return countByG_DDMTK(groupId, DDMTemplateKey);
13056                    }
13057    
13058                    StringBundler query = new StringBundler(3);
13059    
13060                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
13061    
13062                    query.append(_FINDER_COLUMN_G_DDMTK_GROUPID_2);
13063    
13064                    boolean bindDDMTemplateKey = false;
13065    
13066                    if (DDMTemplateKey == null) {
13067                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_1);
13068                    }
13069                    else if (DDMTemplateKey.equals(StringPool.BLANK)) {
13070                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_3);
13071                    }
13072                    else {
13073                            bindDDMTemplateKey = true;
13074    
13075                            query.append(_FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_2);
13076                    }
13077    
13078                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13079                                    JournalArticle.class.getName(),
13080                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13081    
13082                    Session session = null;
13083    
13084                    try {
13085                            session = openSession();
13086    
13087                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13088    
13089                            q.addScalar(COUNT_COLUMN_NAME,
13090                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13091    
13092                            QueryPos qPos = QueryPos.getInstance(q);
13093    
13094                            qPos.add(groupId);
13095    
13096                            if (bindDDMTemplateKey) {
13097                                    qPos.add(DDMTemplateKey);
13098                            }
13099    
13100                            Long count = (Long)q.uniqueResult();
13101    
13102                            return count.intValue();
13103                    }
13104                    catch (Exception e) {
13105                            throw processException(e);
13106                    }
13107                    finally {
13108                            closeSession(session);
13109                    }
13110            }
13111    
13112            private static final String _FINDER_COLUMN_G_DDMTK_GROUPID_2 = "journalArticle.groupId = ? AND ";
13113            private static final String _FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_1 = "journalArticle.DDMTemplateKey IS NULL";
13114            private static final String _FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_2 = "journalArticle.DDMTemplateKey = ?";
13115            private static final String _FINDER_COLUMN_G_DDMTK_DDMTEMPLATEKEY_3 = "(journalArticle.DDMTemplateKey IS NULL OR journalArticle.DDMTemplateKey = '')";
13116            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13117                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13118                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
13119                            "findByG_L",
13120                            new String[] {
13121                                    Long.class.getName(), String.class.getName(),
13122                                    
13123                            Integer.class.getName(), Integer.class.getName(),
13124                                    OrderByComparator.class.getName()
13125                            });
13126            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13127                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
13128                            JournalArticleImpl.class,
13129                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
13130                            new String[] { Long.class.getName(), String.class.getName() },
13131                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
13132                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
13133                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
13134                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
13135            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
13136                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
13137                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
13138                            new String[] { Long.class.getName(), String.class.getName() });
13139    
13140            /**
13141             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13142             *
13143             * @param groupId the group ID
13144             * @param layoutUuid the layout uuid
13145             * @return the matching journal articles
13146             */
13147            @Override
13148            public List<JournalArticle> findByG_L(long groupId, String layoutUuid) {
13149                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13150                            QueryUtil.ALL_POS, null);
13151            }
13152    
13153            /**
13154             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13155             *
13156             * <p>
13157             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13158             * </p>
13159             *
13160             * @param groupId the group ID
13161             * @param layoutUuid the layout uuid
13162             * @param start the lower bound of the range of journal articles
13163             * @param end the upper bound of the range of journal articles (not inclusive)
13164             * @return the range of matching journal articles
13165             */
13166            @Override
13167            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13168                    int start, int end) {
13169                    return findByG_L(groupId, layoutUuid, start, end, null);
13170            }
13171    
13172            /**
13173             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
13174             *
13175             * <p>
13176             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13177             * </p>
13178             *
13179             * @param groupId the group ID
13180             * @param layoutUuid the layout uuid
13181             * @param start the lower bound of the range of journal articles
13182             * @param end the upper bound of the range of journal articles (not inclusive)
13183             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13184             * @return the ordered range of matching journal articles
13185             */
13186            @Override
13187            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
13188                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
13189                    boolean pagination = true;
13190                    FinderPath finderPath = null;
13191                    Object[] finderArgs = null;
13192    
13193                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13194                                    (orderByComparator == null)) {
13195                            pagination = false;
13196                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
13197                            finderArgs = new Object[] { groupId, layoutUuid };
13198                    }
13199                    else {
13200                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
13201                            finderArgs = new Object[] {
13202                                            groupId, layoutUuid,
13203                                            
13204                                            start, end, orderByComparator
13205                                    };
13206                    }
13207    
13208                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13209                                    finderArgs, this);
13210    
13211                    if ((list != null) && !list.isEmpty()) {
13212                            for (JournalArticle journalArticle : list) {
13213                                    if ((groupId != journalArticle.getGroupId()) ||
13214                                                    !Validator.equals(layoutUuid,
13215                                                            journalArticle.getLayoutUuid())) {
13216                                            list = null;
13217    
13218                                            break;
13219                                    }
13220                            }
13221                    }
13222    
13223                    if (list == null) {
13224                            StringBundler query = null;
13225    
13226                            if (orderByComparator != null) {
13227                                    query = new StringBundler(4 +
13228                                                    (orderByComparator.getOrderByFields().length * 3));
13229                            }
13230                            else {
13231                                    query = new StringBundler(4);
13232                            }
13233    
13234                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13235    
13236                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13237    
13238                            boolean bindLayoutUuid = false;
13239    
13240                            if (layoutUuid == null) {
13241                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13242                            }
13243                            else if (layoutUuid.equals(StringPool.BLANK)) {
13244                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13245                            }
13246                            else {
13247                                    bindLayoutUuid = true;
13248    
13249                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13250                            }
13251    
13252                            if (orderByComparator != null) {
13253                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13254                                            orderByComparator);
13255                            }
13256                            else
13257                             if (pagination) {
13258                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13259                            }
13260    
13261                            String sql = query.toString();
13262    
13263                            Session session = null;
13264    
13265                            try {
13266                                    session = openSession();
13267    
13268                                    Query q = session.createQuery(sql);
13269    
13270                                    QueryPos qPos = QueryPos.getInstance(q);
13271    
13272                                    qPos.add(groupId);
13273    
13274                                    if (bindLayoutUuid) {
13275                                            qPos.add(layoutUuid);
13276                                    }
13277    
13278                                    if (!pagination) {
13279                                            list = (List<JournalArticle>)QueryUtil.list(q,
13280                                                            getDialect(), start, end, false);
13281    
13282                                            Collections.sort(list);
13283    
13284                                            list = Collections.unmodifiableList(list);
13285                                    }
13286                                    else {
13287                                            list = (List<JournalArticle>)QueryUtil.list(q,
13288                                                            getDialect(), start, end);
13289                                    }
13290    
13291                                    cacheResult(list);
13292    
13293                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13294                            }
13295                            catch (Exception e) {
13296                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13297    
13298                                    throw processException(e);
13299                            }
13300                            finally {
13301                                    closeSession(session);
13302                            }
13303                    }
13304    
13305                    return list;
13306            }
13307    
13308            /**
13309             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13310             *
13311             * @param groupId the group ID
13312             * @param layoutUuid the layout uuid
13313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13314             * @return the first matching journal article
13315             * @throws NoSuchArticleException if a matching journal article could not be found
13316             */
13317            @Override
13318            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
13319                    OrderByComparator<JournalArticle> orderByComparator)
13320                    throws NoSuchArticleException {
13321                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
13322                                    orderByComparator);
13323    
13324                    if (journalArticle != null) {
13325                            return journalArticle;
13326                    }
13327    
13328                    StringBundler msg = new StringBundler(6);
13329    
13330                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13331    
13332                    msg.append("groupId=");
13333                    msg.append(groupId);
13334    
13335                    msg.append(", layoutUuid=");
13336                    msg.append(layoutUuid);
13337    
13338                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13339    
13340                    throw new NoSuchArticleException(msg.toString());
13341            }
13342    
13343            /**
13344             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13345             *
13346             * @param groupId the group ID
13347             * @param layoutUuid the layout uuid
13348             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13349             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13350             */
13351            @Override
13352            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
13353                    OrderByComparator<JournalArticle> orderByComparator) {
13354                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
13355                                    orderByComparator);
13356    
13357                    if (!list.isEmpty()) {
13358                            return list.get(0);
13359                    }
13360    
13361                    return null;
13362            }
13363    
13364            /**
13365             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13366             *
13367             * @param groupId the group ID
13368             * @param layoutUuid the layout uuid
13369             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13370             * @return the last matching journal article
13371             * @throws NoSuchArticleException if a matching journal article could not be found
13372             */
13373            @Override
13374            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
13375                    OrderByComparator<JournalArticle> orderByComparator)
13376                    throws NoSuchArticleException {
13377                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
13378                                    orderByComparator);
13379    
13380                    if (journalArticle != null) {
13381                            return journalArticle;
13382                    }
13383    
13384                    StringBundler msg = new StringBundler(6);
13385    
13386                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13387    
13388                    msg.append("groupId=");
13389                    msg.append(groupId);
13390    
13391                    msg.append(", layoutUuid=");
13392                    msg.append(layoutUuid);
13393    
13394                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13395    
13396                    throw new NoSuchArticleException(msg.toString());
13397            }
13398    
13399            /**
13400             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13401             *
13402             * @param groupId the group ID
13403             * @param layoutUuid the layout uuid
13404             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13405             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13406             */
13407            @Override
13408            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
13409                    OrderByComparator<JournalArticle> orderByComparator) {
13410                    int count = countByG_L(groupId, layoutUuid);
13411    
13412                    if (count == 0) {
13413                            return null;
13414                    }
13415    
13416                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
13417                                    count, orderByComparator);
13418    
13419                    if (!list.isEmpty()) {
13420                            return list.get(0);
13421                    }
13422    
13423                    return null;
13424            }
13425    
13426            /**
13427             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
13428             *
13429             * @param id the primary key of the current journal article
13430             * @param groupId the group ID
13431             * @param layoutUuid the layout uuid
13432             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13433             * @return the previous, current, and next journal article
13434             * @throws NoSuchArticleException if a journal article with the primary key could not be found
13435             */
13436            @Override
13437            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
13438                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator)
13439                    throws NoSuchArticleException {
13440                    JournalArticle journalArticle = findByPrimaryKey(id);
13441    
13442                    Session session = null;
13443    
13444                    try {
13445                            session = openSession();
13446    
13447                            JournalArticle[] array = new JournalArticleImpl[3];
13448    
13449                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13450                                            layoutUuid, orderByComparator, true);
13451    
13452                            array[1] = journalArticle;
13453    
13454                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
13455                                            layoutUuid, orderByComparator, false);
13456    
13457                            return array;
13458                    }
13459                    catch (Exception e) {
13460                            throw processException(e);
13461                    }
13462                    finally {
13463                            closeSession(session);
13464                    }
13465            }
13466    
13467            protected JournalArticle getByG_L_PrevAndNext(Session session,
13468                    JournalArticle journalArticle, long groupId, String layoutUuid,
13469                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
13470                    StringBundler query = null;
13471    
13472                    if (orderByComparator != null) {
13473                            query = new StringBundler(6 +
13474                                            (orderByComparator.getOrderByFields().length * 6));
13475                    }
13476                    else {
13477                            query = new StringBundler(3);
13478                    }
13479    
13480                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13481    
13482                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13483    
13484                    boolean bindLayoutUuid = false;
13485    
13486                    if (layoutUuid == null) {
13487                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13488                    }
13489                    else if (layoutUuid.equals(StringPool.BLANK)) {
13490                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13491                    }
13492                    else {
13493                            bindLayoutUuid = true;
13494    
13495                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13496                    }
13497    
13498                    if (orderByComparator != null) {
13499                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13500    
13501                            if (orderByConditionFields.length > 0) {
13502                                    query.append(WHERE_AND);
13503                            }
13504    
13505                            for (int i = 0; i < orderByConditionFields.length; i++) {
13506                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13507                                    query.append(orderByConditionFields[i]);
13508    
13509                                    if ((i + 1) < orderByConditionFields.length) {
13510                                            if (orderByComparator.isAscending() ^ previous) {
13511                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13512                                            }
13513                                            else {
13514                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13515                                            }
13516                                    }
13517                                    else {
13518                                            if (orderByComparator.isAscending() ^ previous) {
13519                                                    query.append(WHERE_GREATER_THAN);
13520                                            }
13521                                            else {
13522                                                    query.append(WHERE_LESSER_THAN);
13523                                            }
13524                                    }
13525                            }
13526    
13527                            query.append(ORDER_BY_CLAUSE);
13528    
13529                            String[] orderByFields = orderByComparator.getOrderByFields();
13530    
13531                            for (int i = 0; i < orderByFields.length; i++) {
13532                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13533                                    query.append(orderByFields[i]);
13534    
13535                                    if ((i + 1) < orderByFields.length) {
13536                                            if (orderByComparator.isAscending() ^ previous) {
13537                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13538                                            }
13539                                            else {
13540                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13541                                            }
13542                                    }
13543                                    else {
13544                                            if (orderByComparator.isAscending() ^ previous) {
13545                                                    query.append(ORDER_BY_ASC);
13546                                            }
13547                                            else {
13548                                                    query.append(ORDER_BY_DESC);
13549                                            }
13550                                    }
13551                            }
13552                    }
13553                    else {
13554                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13555                    }
13556    
13557                    String sql = query.toString();
13558    
13559                    Query q = session.createQuery(sql);
13560    
13561                    q.setFirstResult(0);
13562                    q.setMaxResults(2);
13563    
13564                    QueryPos qPos = QueryPos.getInstance(q);
13565    
13566                    qPos.add(groupId);
13567    
13568                    if (bindLayoutUuid) {
13569                            qPos.add(layoutUuid);
13570                    }
13571    
13572                    if (orderByComparator != null) {
13573                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13574    
13575                            for (Object value : values) {
13576                                    qPos.add(value);
13577                            }
13578                    }
13579    
13580                    List<JournalArticle> list = q.list();
13581    
13582                    if (list.size() == 2) {
13583                            return list.get(1);
13584                    }
13585                    else {
13586                            return null;
13587                    }
13588            }
13589    
13590            /**
13591             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13592             *
13593             * @param groupId the group ID
13594             * @param layoutUuid the layout uuid
13595             * @return the matching journal articles that the user has permission to view
13596             */
13597            @Override
13598            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid) {
13599                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
13600                            QueryUtil.ALL_POS, null);
13601            }
13602    
13603            /**
13604             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
13605             *
13606             * <p>
13607             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13608             * </p>
13609             *
13610             * @param groupId the group ID
13611             * @param layoutUuid the layout uuid
13612             * @param start the lower bound of the range of journal articles
13613             * @param end the upper bound of the range of journal articles (not inclusive)
13614             * @return the range of matching journal articles that the user has permission to view
13615             */
13616            @Override
13617            public List<JournalArticle> filterFindByG_L(long groupId,
13618                    String layoutUuid, int start, int end) {
13619                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
13620            }
13621    
13622            /**
13623             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
13624             *
13625             * <p>
13626             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13627             * </p>
13628             *
13629             * @param groupId the group ID
13630             * @param layoutUuid the layout uuid
13631             * @param start the lower bound of the range of journal articles
13632             * @param end the upper bound of the range of journal articles (not inclusive)
13633             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13634             * @return the ordered range of matching journal articles that the user has permission to view
13635             */
13636            @Override
13637            public List<JournalArticle> filterFindByG_L(long groupId,
13638                    String layoutUuid, int start, int end,
13639                    OrderByComparator<JournalArticle> orderByComparator) {
13640                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13641                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
13642                    }
13643    
13644                    StringBundler query = null;
13645    
13646                    if (orderByComparator != null) {
13647                            query = new StringBundler(4 +
13648                                            (orderByComparator.getOrderByFields().length * 3));
13649                    }
13650                    else {
13651                            query = new StringBundler(4);
13652                    }
13653    
13654                    if (getDB().isSupportsInlineDistinct()) {
13655                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13656                    }
13657                    else {
13658                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13659                    }
13660    
13661                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13662    
13663                    boolean bindLayoutUuid = false;
13664    
13665                    if (layoutUuid == null) {
13666                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13667                    }
13668                    else if (layoutUuid.equals(StringPool.BLANK)) {
13669                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13670                    }
13671                    else {
13672                            bindLayoutUuid = true;
13673    
13674                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13675                    }
13676    
13677                    if (!getDB().isSupportsInlineDistinct()) {
13678                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13679                    }
13680    
13681                    if (orderByComparator != null) {
13682                            if (getDB().isSupportsInlineDistinct()) {
13683                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13684                                            orderByComparator, true);
13685                            }
13686                            else {
13687                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13688                                            orderByComparator, true);
13689                            }
13690                    }
13691                    else {
13692                            if (getDB().isSupportsInlineDistinct()) {
13693                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13694                            }
13695                            else {
13696                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13697                            }
13698                    }
13699    
13700                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13701                                    JournalArticle.class.getName(),
13702                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13703    
13704                    Session session = null;
13705    
13706                    try {
13707                            session = openSession();
13708    
13709                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13710    
13711                            if (getDB().isSupportsInlineDistinct()) {
13712                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13713                            }
13714                            else {
13715                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13716                            }
13717    
13718                            QueryPos qPos = QueryPos.getInstance(q);
13719    
13720                            qPos.add(groupId);
13721    
13722                            if (bindLayoutUuid) {
13723                                    qPos.add(layoutUuid);
13724                            }
13725    
13726                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13727                                    end);
13728                    }
13729                    catch (Exception e) {
13730                            throw processException(e);
13731                    }
13732                    finally {
13733                            closeSession(session);
13734                    }
13735            }
13736    
13737            /**
13738             * 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;.
13739             *
13740             * @param id the primary key of the current journal article
13741             * @param groupId the group ID
13742             * @param layoutUuid the layout uuid
13743             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13744             * @return the previous, current, and next journal article
13745             * @throws NoSuchArticleException if a journal article with the primary key could not be found
13746             */
13747            @Override
13748            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
13749                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator)
13750                    throws NoSuchArticleException {
13751                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13752                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
13753                                    orderByComparator);
13754                    }
13755    
13756                    JournalArticle journalArticle = findByPrimaryKey(id);
13757    
13758                    Session session = null;
13759    
13760                    try {
13761                            session = openSession();
13762    
13763                            JournalArticle[] array = new JournalArticleImpl[3];
13764    
13765                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
13766                                            groupId, layoutUuid, orderByComparator, true);
13767    
13768                            array[1] = journalArticle;
13769    
13770                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
13771                                            groupId, layoutUuid, orderByComparator, false);
13772    
13773                            return array;
13774                    }
13775                    catch (Exception e) {
13776                            throw processException(e);
13777                    }
13778                    finally {
13779                            closeSession(session);
13780                    }
13781            }
13782    
13783            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
13784                    JournalArticle journalArticle, long groupId, String layoutUuid,
13785                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
13786                    StringBundler query = null;
13787    
13788                    if (orderByComparator != null) {
13789                            query = new StringBundler(6 +
13790                                            (orderByComparator.getOrderByFields().length * 6));
13791                    }
13792                    else {
13793                            query = new StringBundler(3);
13794                    }
13795    
13796                    if (getDB().isSupportsInlineDistinct()) {
13797                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13798                    }
13799                    else {
13800                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13801                    }
13802    
13803                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13804    
13805                    boolean bindLayoutUuid = false;
13806    
13807                    if (layoutUuid == null) {
13808                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13809                    }
13810                    else if (layoutUuid.equals(StringPool.BLANK)) {
13811                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13812                    }
13813                    else {
13814                            bindLayoutUuid = true;
13815    
13816                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13817                    }
13818    
13819                    if (!getDB().isSupportsInlineDistinct()) {
13820                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13821                    }
13822    
13823                    if (orderByComparator != null) {
13824                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13825    
13826                            if (orderByConditionFields.length > 0) {
13827                                    query.append(WHERE_AND);
13828                            }
13829    
13830                            for (int i = 0; i < orderByConditionFields.length; i++) {
13831                                    if (getDB().isSupportsInlineDistinct()) {
13832                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13833                                    }
13834                                    else {
13835                                            query.append(_ORDER_BY_ENTITY_TABLE);
13836                                    }
13837    
13838                                    query.append(orderByConditionFields[i]);
13839    
13840                                    if ((i + 1) < orderByConditionFields.length) {
13841                                            if (orderByComparator.isAscending() ^ previous) {
13842                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13843                                            }
13844                                            else {
13845                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13846                                            }
13847                                    }
13848                                    else {
13849                                            if (orderByComparator.isAscending() ^ previous) {
13850                                                    query.append(WHERE_GREATER_THAN);
13851                                            }
13852                                            else {
13853                                                    query.append(WHERE_LESSER_THAN);
13854                                            }
13855                                    }
13856                            }
13857    
13858                            query.append(ORDER_BY_CLAUSE);
13859    
13860                            String[] orderByFields = orderByComparator.getOrderByFields();
13861    
13862                            for (int i = 0; i < orderByFields.length; i++) {
13863                                    if (getDB().isSupportsInlineDistinct()) {
13864                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13865                                    }
13866                                    else {
13867                                            query.append(_ORDER_BY_ENTITY_TABLE);
13868                                    }
13869    
13870                                    query.append(orderByFields[i]);
13871    
13872                                    if ((i + 1) < orderByFields.length) {
13873                                            if (orderByComparator.isAscending() ^ previous) {
13874                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13875                                            }
13876                                            else {
13877                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13878                                            }
13879                                    }
13880                                    else {
13881                                            if (orderByComparator.isAscending() ^ previous) {
13882                                                    query.append(ORDER_BY_ASC);
13883                                            }
13884                                            else {
13885                                                    query.append(ORDER_BY_DESC);
13886                                            }
13887                                    }
13888                            }
13889                    }
13890                    else {
13891                            if (getDB().isSupportsInlineDistinct()) {
13892                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13893                            }
13894                            else {
13895                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13896                            }
13897                    }
13898    
13899                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13900                                    JournalArticle.class.getName(),
13901                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13902    
13903                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
13904    
13905                    q.setFirstResult(0);
13906                    q.setMaxResults(2);
13907    
13908                    if (getDB().isSupportsInlineDistinct()) {
13909                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13910                    }
13911                    else {
13912                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13913                    }
13914    
13915                    QueryPos qPos = QueryPos.getInstance(q);
13916    
13917                    qPos.add(groupId);
13918    
13919                    if (bindLayoutUuid) {
13920                            qPos.add(layoutUuid);
13921                    }
13922    
13923                    if (orderByComparator != null) {
13924                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13925    
13926                            for (Object value : values) {
13927                                    qPos.add(value);
13928                            }
13929                    }
13930    
13931                    List<JournalArticle> list = q.list();
13932    
13933                    if (list.size() == 2) {
13934                            return list.get(1);
13935                    }
13936                    else {
13937                            return null;
13938                    }
13939            }
13940    
13941            /**
13942             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
13943             *
13944             * @param groupId the group ID
13945             * @param layoutUuid the layout uuid
13946             */
13947            @Override
13948            public void removeByG_L(long groupId, String layoutUuid) {
13949                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid,
13950                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13951                            remove(journalArticle);
13952                    }
13953            }
13954    
13955            /**
13956             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
13957             *
13958             * @param groupId the group ID
13959             * @param layoutUuid the layout uuid
13960             * @return the number of matching journal articles
13961             */
13962            @Override
13963            public int countByG_L(long groupId, String layoutUuid) {
13964                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_L;
13965    
13966                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
13967    
13968                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13969                                    this);
13970    
13971                    if (count == null) {
13972                            StringBundler query = new StringBundler(3);
13973    
13974                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
13975    
13976                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
13977    
13978                            boolean bindLayoutUuid = false;
13979    
13980                            if (layoutUuid == null) {
13981                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
13982                            }
13983                            else if (layoutUuid.equals(StringPool.BLANK)) {
13984                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
13985                            }
13986                            else {
13987                                    bindLayoutUuid = true;
13988    
13989                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
13990                            }
13991    
13992                            String sql = query.toString();
13993    
13994                            Session session = null;
13995    
13996                            try {
13997                                    session = openSession();
13998    
13999                                    Query q = session.createQuery(sql);
14000    
14001                                    QueryPos qPos = QueryPos.getInstance(q);
14002    
14003                                    qPos.add(groupId);
14004    
14005                                    if (bindLayoutUuid) {
14006                                            qPos.add(layoutUuid);
14007                                    }
14008    
14009                                    count = (Long)q.uniqueResult();
14010    
14011                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14012                            }
14013                            catch (Exception e) {
14014                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14015    
14016                                    throw processException(e);
14017                            }
14018                            finally {
14019                                    closeSession(session);
14020                            }
14021                    }
14022    
14023                    return count.intValue();
14024            }
14025    
14026            /**
14027             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
14028             *
14029             * @param groupId the group ID
14030             * @param layoutUuid the layout uuid
14031             * @return the number of matching journal articles that the user has permission to view
14032             */
14033            @Override
14034            public int filterCountByG_L(long groupId, String layoutUuid) {
14035                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14036                            return countByG_L(groupId, layoutUuid);
14037                    }
14038    
14039                    StringBundler query = new StringBundler(3);
14040    
14041                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14042    
14043                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
14044    
14045                    boolean bindLayoutUuid = false;
14046    
14047                    if (layoutUuid == null) {
14048                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
14049                    }
14050                    else if (layoutUuid.equals(StringPool.BLANK)) {
14051                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
14052                    }
14053                    else {
14054                            bindLayoutUuid = true;
14055    
14056                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
14057                    }
14058    
14059                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14060                                    JournalArticle.class.getName(),
14061                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14062    
14063                    Session session = null;
14064    
14065                    try {
14066                            session = openSession();
14067    
14068                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
14069    
14070                            q.addScalar(COUNT_COLUMN_NAME,
14071                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14072    
14073                            QueryPos qPos = QueryPos.getInstance(q);
14074    
14075                            qPos.add(groupId);
14076    
14077                            if (bindLayoutUuid) {
14078                                    qPos.add(layoutUuid);
14079                            }
14080    
14081                            Long count = (Long)q.uniqueResult();
14082    
14083                            return count.intValue();
14084                    }
14085                    catch (Exception e) {
14086                            throw processException(e);
14087                    }
14088                    finally {
14089                            closeSession(session);
14090                    }
14091            }
14092    
14093            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
14094            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
14095            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
14096            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
14097            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14098                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14099                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14100                            "findByG_ST",
14101                            new String[] {
14102                                    Long.class.getName(), Integer.class.getName(),
14103                                    
14104                            Integer.class.getName(), Integer.class.getName(),
14105                                    OrderByComparator.class.getName()
14106                            });
14107            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14108                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14109                            JournalArticleImpl.class,
14110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
14111                            new String[] { Long.class.getName(), Integer.class.getName() },
14112                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
14113                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
14114                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
14115                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
14116            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14117                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
14118                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
14119                            new String[] { Long.class.getName(), Integer.class.getName() });
14120    
14121            /**
14122             * Returns all the journal articles where groupId = &#63; and status = &#63;.
14123             *
14124             * @param groupId the group ID
14125             * @param status the status
14126             * @return the matching journal articles
14127             */
14128            @Override
14129            public List<JournalArticle> findByG_ST(long groupId, int status) {
14130                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
14131                            QueryUtil.ALL_POS, null);
14132            }
14133    
14134            /**
14135             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
14136             *
14137             * <p>
14138             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14139             * </p>
14140             *
14141             * @param groupId the group ID
14142             * @param status the status
14143             * @param start the lower bound of the range of journal articles
14144             * @param end the upper bound of the range of journal articles (not inclusive)
14145             * @return the range of matching journal articles
14146             */
14147            @Override
14148            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
14149                    int end) {
14150                    return findByG_ST(groupId, status, start, end, null);
14151            }
14152    
14153            /**
14154             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
14155             *
14156             * <p>
14157             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14158             * </p>
14159             *
14160             * @param groupId the group ID
14161             * @param status the status
14162             * @param start the lower bound of the range of journal articles
14163             * @param end the upper bound of the range of journal articles (not inclusive)
14164             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14165             * @return the ordered range of matching journal articles
14166             */
14167            @Override
14168            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
14169                    int end, OrderByComparator<JournalArticle> orderByComparator) {
14170                    boolean pagination = true;
14171                    FinderPath finderPath = null;
14172                    Object[] finderArgs = null;
14173    
14174                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14175                                    (orderByComparator == null)) {
14176                            pagination = false;
14177                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
14178                            finderArgs = new Object[] { groupId, status };
14179                    }
14180                    else {
14181                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
14182                            finderArgs = new Object[] {
14183                                            groupId, status,
14184                                            
14185                                            start, end, orderByComparator
14186                                    };
14187                    }
14188    
14189                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14190                                    finderArgs, this);
14191    
14192                    if ((list != null) && !list.isEmpty()) {
14193                            for (JournalArticle journalArticle : list) {
14194                                    if ((groupId != journalArticle.getGroupId()) ||
14195                                                    (status != journalArticle.getStatus())) {
14196                                            list = null;
14197    
14198                                            break;
14199                                    }
14200                            }
14201                    }
14202    
14203                    if (list == null) {
14204                            StringBundler query = null;
14205    
14206                            if (orderByComparator != null) {
14207                                    query = new StringBundler(4 +
14208                                                    (orderByComparator.getOrderByFields().length * 3));
14209                            }
14210                            else {
14211                                    query = new StringBundler(4);
14212                            }
14213    
14214                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14215    
14216                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14217    
14218                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14219    
14220                            if (orderByComparator != null) {
14221                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14222                                            orderByComparator);
14223                            }
14224                            else
14225                             if (pagination) {
14226                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14227                            }
14228    
14229                            String sql = query.toString();
14230    
14231                            Session session = null;
14232    
14233                            try {
14234                                    session = openSession();
14235    
14236                                    Query q = session.createQuery(sql);
14237    
14238                                    QueryPos qPos = QueryPos.getInstance(q);
14239    
14240                                    qPos.add(groupId);
14241    
14242                                    qPos.add(status);
14243    
14244                                    if (!pagination) {
14245                                            list = (List<JournalArticle>)QueryUtil.list(q,
14246                                                            getDialect(), start, end, false);
14247    
14248                                            Collections.sort(list);
14249    
14250                                            list = Collections.unmodifiableList(list);
14251                                    }
14252                                    else {
14253                                            list = (List<JournalArticle>)QueryUtil.list(q,
14254                                                            getDialect(), start, end);
14255                                    }
14256    
14257                                    cacheResult(list);
14258    
14259                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14260                            }
14261                            catch (Exception e) {
14262                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14263    
14264                                    throw processException(e);
14265                            }
14266                            finally {
14267                                    closeSession(session);
14268                            }
14269                    }
14270    
14271                    return list;
14272            }
14273    
14274            /**
14275             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
14276             *
14277             * @param groupId the group ID
14278             * @param status the status
14279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14280             * @return the first matching journal article
14281             * @throws NoSuchArticleException if a matching journal article could not be found
14282             */
14283            @Override
14284            public JournalArticle findByG_ST_First(long groupId, int status,
14285                    OrderByComparator<JournalArticle> orderByComparator)
14286                    throws NoSuchArticleException {
14287                    JournalArticle journalArticle = fetchByG_ST_First(groupId, status,
14288                                    orderByComparator);
14289    
14290                    if (journalArticle != null) {
14291                            return journalArticle;
14292                    }
14293    
14294                    StringBundler msg = new StringBundler(6);
14295    
14296                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14297    
14298                    msg.append("groupId=");
14299                    msg.append(groupId);
14300    
14301                    msg.append(", status=");
14302                    msg.append(status);
14303    
14304                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14305    
14306                    throw new NoSuchArticleException(msg.toString());
14307            }
14308    
14309            /**
14310             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
14311             *
14312             * @param groupId the group ID
14313             * @param status the status
14314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14315             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14316             */
14317            @Override
14318            public JournalArticle fetchByG_ST_First(long groupId, int status,
14319                    OrderByComparator<JournalArticle> orderByComparator) {
14320                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
14321                                    orderByComparator);
14322    
14323                    if (!list.isEmpty()) {
14324                            return list.get(0);
14325                    }
14326    
14327                    return null;
14328            }
14329    
14330            /**
14331             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
14332             *
14333             * @param groupId the group ID
14334             * @param status the status
14335             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14336             * @return the last matching journal article
14337             * @throws NoSuchArticleException if a matching journal article could not be found
14338             */
14339            @Override
14340            public JournalArticle findByG_ST_Last(long groupId, int status,
14341                    OrderByComparator<JournalArticle> orderByComparator)
14342                    throws NoSuchArticleException {
14343                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
14344                                    orderByComparator);
14345    
14346                    if (journalArticle != null) {
14347                            return journalArticle;
14348                    }
14349    
14350                    StringBundler msg = new StringBundler(6);
14351    
14352                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14353    
14354                    msg.append("groupId=");
14355                    msg.append(groupId);
14356    
14357                    msg.append(", status=");
14358                    msg.append(status);
14359    
14360                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14361    
14362                    throw new NoSuchArticleException(msg.toString());
14363            }
14364    
14365            /**
14366             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
14367             *
14368             * @param groupId the group ID
14369             * @param status the status
14370             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14371             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
14372             */
14373            @Override
14374            public JournalArticle fetchByG_ST_Last(long groupId, int status,
14375                    OrderByComparator<JournalArticle> orderByComparator) {
14376                    int count = countByG_ST(groupId, status);
14377    
14378                    if (count == 0) {
14379                            return null;
14380                    }
14381    
14382                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
14383                                    count, orderByComparator);
14384    
14385                    if (!list.isEmpty()) {
14386                            return list.get(0);
14387                    }
14388    
14389                    return null;
14390            }
14391    
14392            /**
14393             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
14394             *
14395             * @param id the primary key of the current journal article
14396             * @param groupId the group ID
14397             * @param status the status
14398             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14399             * @return the previous, current, and next journal article
14400             * @throws NoSuchArticleException if a journal article with the primary key could not be found
14401             */
14402            @Override
14403            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
14404                    int status, OrderByComparator<JournalArticle> orderByComparator)
14405                    throws NoSuchArticleException {
14406                    JournalArticle journalArticle = findByPrimaryKey(id);
14407    
14408                    Session session = null;
14409    
14410                    try {
14411                            session = openSession();
14412    
14413                            JournalArticle[] array = new JournalArticleImpl[3];
14414    
14415                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
14416                                            status, orderByComparator, true);
14417    
14418                            array[1] = journalArticle;
14419    
14420                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
14421                                            status, orderByComparator, false);
14422    
14423                            return array;
14424                    }
14425                    catch (Exception e) {
14426                            throw processException(e);
14427                    }
14428                    finally {
14429                            closeSession(session);
14430                    }
14431            }
14432    
14433            protected JournalArticle getByG_ST_PrevAndNext(Session session,
14434                    JournalArticle journalArticle, long groupId, int status,
14435                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
14436                    StringBundler query = null;
14437    
14438                    if (orderByComparator != null) {
14439                            query = new StringBundler(6 +
14440                                            (orderByComparator.getOrderByFields().length * 6));
14441                    }
14442                    else {
14443                            query = new StringBundler(3);
14444                    }
14445    
14446                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14447    
14448                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14449    
14450                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14451    
14452                    if (orderByComparator != null) {
14453                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14454    
14455                            if (orderByConditionFields.length > 0) {
14456                                    query.append(WHERE_AND);
14457                            }
14458    
14459                            for (int i = 0; i < orderByConditionFields.length; i++) {
14460                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14461                                    query.append(orderByConditionFields[i]);
14462    
14463                                    if ((i + 1) < orderByConditionFields.length) {
14464                                            if (orderByComparator.isAscending() ^ previous) {
14465                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14466                                            }
14467                                            else {
14468                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14469                                            }
14470                                    }
14471                                    else {
14472                                            if (orderByComparator.isAscending() ^ previous) {
14473                                                    query.append(WHERE_GREATER_THAN);
14474                                            }
14475                                            else {
14476                                                    query.append(WHERE_LESSER_THAN);
14477                                            }
14478                                    }
14479                            }
14480    
14481                            query.append(ORDER_BY_CLAUSE);
14482    
14483                            String[] orderByFields = orderByComparator.getOrderByFields();
14484    
14485                            for (int i = 0; i < orderByFields.length; i++) {
14486                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14487                                    query.append(orderByFields[i]);
14488    
14489                                    if ((i + 1) < orderByFields.length) {
14490                                            if (orderByComparator.isAscending() ^ previous) {
14491                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14492                                            }
14493                                            else {
14494                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14495                                            }
14496                                    }
14497                                    else {
14498                                            if (orderByComparator.isAscending() ^ previous) {
14499                                                    query.append(ORDER_BY_ASC);
14500                                            }
14501                                            else {
14502                                                    query.append(ORDER_BY_DESC);
14503                                            }
14504                                    }
14505                            }
14506                    }
14507                    else {
14508                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14509                    }
14510    
14511                    String sql = query.toString();
14512    
14513                    Query q = session.createQuery(sql);
14514    
14515                    q.setFirstResult(0);
14516                    q.setMaxResults(2);
14517    
14518                    QueryPos qPos = QueryPos.getInstance(q);
14519    
14520                    qPos.add(groupId);
14521    
14522                    qPos.add(status);
14523    
14524                    if (orderByComparator != null) {
14525                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14526    
14527                            for (Object value : values) {
14528                                    qPos.add(value);
14529                            }
14530                    }
14531    
14532                    List<JournalArticle> list = q.list();
14533    
14534                    if (list.size() == 2) {
14535                            return list.get(1);
14536                    }
14537                    else {
14538                            return null;
14539                    }
14540            }
14541    
14542            /**
14543             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14544             *
14545             * @param groupId the group ID
14546             * @param status the status
14547             * @return the matching journal articles that the user has permission to view
14548             */
14549            @Override
14550            public List<JournalArticle> filterFindByG_ST(long groupId, int status) {
14551                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
14552                            QueryUtil.ALL_POS, null);
14553            }
14554    
14555            /**
14556             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14557             *
14558             * <p>
14559             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14560             * </p>
14561             *
14562             * @param groupId the group ID
14563             * @param status the status
14564             * @param start the lower bound of the range of journal articles
14565             * @param end the upper bound of the range of journal articles (not inclusive)
14566             * @return the range of matching journal articles that the user has permission to view
14567             */
14568            @Override
14569            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
14570                    int start, int end) {
14571                    return filterFindByG_ST(groupId, status, start, end, null);
14572            }
14573    
14574            /**
14575             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
14576             *
14577             * <p>
14578             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14579             * </p>
14580             *
14581             * @param groupId the group ID
14582             * @param status the status
14583             * @param start the lower bound of the range of journal articles
14584             * @param end the upper bound of the range of journal articles (not inclusive)
14585             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14586             * @return the ordered range of matching journal articles that the user has permission to view
14587             */
14588            @Override
14589            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
14590                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
14591                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14592                            return findByG_ST(groupId, status, start, end, orderByComparator);
14593                    }
14594    
14595                    StringBundler query = null;
14596    
14597                    if (orderByComparator != null) {
14598                            query = new StringBundler(4 +
14599                                            (orderByComparator.getOrderByFields().length * 3));
14600                    }
14601                    else {
14602                            query = new StringBundler(4);
14603                    }
14604    
14605                    if (getDB().isSupportsInlineDistinct()) {
14606                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14607                    }
14608                    else {
14609                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14610                    }
14611    
14612                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14613    
14614                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14615    
14616                    if (!getDB().isSupportsInlineDistinct()) {
14617                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14618                    }
14619    
14620                    if (orderByComparator != null) {
14621                            if (getDB().isSupportsInlineDistinct()) {
14622                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14623                                            orderByComparator, true);
14624                            }
14625                            else {
14626                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14627                                            orderByComparator, true);
14628                            }
14629                    }
14630                    else {
14631                            if (getDB().isSupportsInlineDistinct()) {
14632                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14633                            }
14634                            else {
14635                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14636                            }
14637                    }
14638    
14639                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14640                                    JournalArticle.class.getName(),
14641                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14642    
14643                    Session session = null;
14644    
14645                    try {
14646                            session = openSession();
14647    
14648                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
14649    
14650                            if (getDB().isSupportsInlineDistinct()) {
14651                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14652                            }
14653                            else {
14654                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14655                            }
14656    
14657                            QueryPos qPos = QueryPos.getInstance(q);
14658    
14659                            qPos.add(groupId);
14660    
14661                            qPos.add(status);
14662    
14663                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14664                                    end);
14665                    }
14666                    catch (Exception e) {
14667                            throw processException(e);
14668                    }
14669                    finally {
14670                            closeSession(session);
14671                    }
14672            }
14673    
14674            /**
14675             * 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;.
14676             *
14677             * @param id the primary key of the current journal article
14678             * @param groupId the group ID
14679             * @param status the status
14680             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14681             * @return the previous, current, and next journal article
14682             * @throws NoSuchArticleException if a journal article with the primary key could not be found
14683             */
14684            @Override
14685            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
14686                    int status, OrderByComparator<JournalArticle> orderByComparator)
14687                    throws NoSuchArticleException {
14688                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14689                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
14690                    }
14691    
14692                    JournalArticle journalArticle = findByPrimaryKey(id);
14693    
14694                    Session session = null;
14695    
14696                    try {
14697                            session = openSession();
14698    
14699                            JournalArticle[] array = new JournalArticleImpl[3];
14700    
14701                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
14702                                            groupId, status, orderByComparator, true);
14703    
14704                            array[1] = journalArticle;
14705    
14706                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
14707                                            groupId, status, orderByComparator, false);
14708    
14709                            return array;
14710                    }
14711                    catch (Exception e) {
14712                            throw processException(e);
14713                    }
14714                    finally {
14715                            closeSession(session);
14716                    }
14717            }
14718    
14719            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
14720                    JournalArticle journalArticle, long groupId, int status,
14721                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
14722                    StringBundler query = null;
14723    
14724                    if (orderByComparator != null) {
14725                            query = new StringBundler(6 +
14726                                            (orderByComparator.getOrderByFields().length * 6));
14727                    }
14728                    else {
14729                            query = new StringBundler(3);
14730                    }
14731    
14732                    if (getDB().isSupportsInlineDistinct()) {
14733                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14734                    }
14735                    else {
14736                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14737                    }
14738    
14739                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14740    
14741                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14742    
14743                    if (!getDB().isSupportsInlineDistinct()) {
14744                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14745                    }
14746    
14747                    if (orderByComparator != null) {
14748                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14749    
14750                            if (orderByConditionFields.length > 0) {
14751                                    query.append(WHERE_AND);
14752                            }
14753    
14754                            for (int i = 0; i < orderByConditionFields.length; i++) {
14755                                    if (getDB().isSupportsInlineDistinct()) {
14756                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14757                                    }
14758                                    else {
14759                                            query.append(_ORDER_BY_ENTITY_TABLE);
14760                                    }
14761    
14762                                    query.append(orderByConditionFields[i]);
14763    
14764                                    if ((i + 1) < orderByConditionFields.length) {
14765                                            if (orderByComparator.isAscending() ^ previous) {
14766                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14767                                            }
14768                                            else {
14769                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14770                                            }
14771                                    }
14772                                    else {
14773                                            if (orderByComparator.isAscending() ^ previous) {
14774                                                    query.append(WHERE_GREATER_THAN);
14775                                            }
14776                                            else {
14777                                                    query.append(WHERE_LESSER_THAN);
14778                                            }
14779                                    }
14780                            }
14781    
14782                            query.append(ORDER_BY_CLAUSE);
14783    
14784                            String[] orderByFields = orderByComparator.getOrderByFields();
14785    
14786                            for (int i = 0; i < orderByFields.length; i++) {
14787                                    if (getDB().isSupportsInlineDistinct()) {
14788                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14789                                    }
14790                                    else {
14791                                            query.append(_ORDER_BY_ENTITY_TABLE);
14792                                    }
14793    
14794                                    query.append(orderByFields[i]);
14795    
14796                                    if ((i + 1) < orderByFields.length) {
14797                                            if (orderByComparator.isAscending() ^ previous) {
14798                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14799                                            }
14800                                            else {
14801                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14802                                            }
14803                                    }
14804                                    else {
14805                                            if (orderByComparator.isAscending() ^ previous) {
14806                                                    query.append(ORDER_BY_ASC);
14807                                            }
14808                                            else {
14809                                                    query.append(ORDER_BY_DESC);
14810                                            }
14811                                    }
14812                            }
14813                    }
14814                    else {
14815                            if (getDB().isSupportsInlineDistinct()) {
14816                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14817                            }
14818                            else {
14819                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14820                            }
14821                    }
14822    
14823                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14824                                    JournalArticle.class.getName(),
14825                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14826    
14827                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
14828    
14829                    q.setFirstResult(0);
14830                    q.setMaxResults(2);
14831    
14832                    if (getDB().isSupportsInlineDistinct()) {
14833                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14834                    }
14835                    else {
14836                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14837                    }
14838    
14839                    QueryPos qPos = QueryPos.getInstance(q);
14840    
14841                    qPos.add(groupId);
14842    
14843                    qPos.add(status);
14844    
14845                    if (orderByComparator != null) {
14846                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14847    
14848                            for (Object value : values) {
14849                                    qPos.add(value);
14850                            }
14851                    }
14852    
14853                    List<JournalArticle> list = q.list();
14854    
14855                    if (list.size() == 2) {
14856                            return list.get(1);
14857                    }
14858                    else {
14859                            return null;
14860                    }
14861            }
14862    
14863            /**
14864             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
14865             *
14866             * @param groupId the group ID
14867             * @param status the status
14868             */
14869            @Override
14870            public void removeByG_ST(long groupId, int status) {
14871                    for (JournalArticle journalArticle : findByG_ST(groupId, status,
14872                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14873                            remove(journalArticle);
14874                    }
14875            }
14876    
14877            /**
14878             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
14879             *
14880             * @param groupId the group ID
14881             * @param status the status
14882             * @return the number of matching journal articles
14883             */
14884            @Override
14885            public int countByG_ST(long groupId, int status) {
14886                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_ST;
14887    
14888                    Object[] finderArgs = new Object[] { groupId, status };
14889    
14890                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14891                                    this);
14892    
14893                    if (count == null) {
14894                            StringBundler query = new StringBundler(3);
14895    
14896                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14897    
14898                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14899    
14900                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14901    
14902                            String sql = query.toString();
14903    
14904                            Session session = null;
14905    
14906                            try {
14907                                    session = openSession();
14908    
14909                                    Query q = session.createQuery(sql);
14910    
14911                                    QueryPos qPos = QueryPos.getInstance(q);
14912    
14913                                    qPos.add(groupId);
14914    
14915                                    qPos.add(status);
14916    
14917                                    count = (Long)q.uniqueResult();
14918    
14919                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14920                            }
14921                            catch (Exception e) {
14922                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14923    
14924                                    throw processException(e);
14925                            }
14926                            finally {
14927                                    closeSession(session);
14928                            }
14929                    }
14930    
14931                    return count.intValue();
14932            }
14933    
14934            /**
14935             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
14936             *
14937             * @param groupId the group ID
14938             * @param status the status
14939             * @return the number of matching journal articles that the user has permission to view
14940             */
14941            @Override
14942            public int filterCountByG_ST(long groupId, int status) {
14943                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14944                            return countByG_ST(groupId, status);
14945                    }
14946    
14947                    StringBundler query = new StringBundler(3);
14948    
14949                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14950    
14951                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
14952    
14953                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
14954    
14955                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14956                                    JournalArticle.class.getName(),
14957                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14958    
14959                    Session session = null;
14960    
14961                    try {
14962                            session = openSession();
14963    
14964                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
14965    
14966                            q.addScalar(COUNT_COLUMN_NAME,
14967                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14968    
14969                            QueryPos qPos = QueryPos.getInstance(q);
14970    
14971                            qPos.add(groupId);
14972    
14973                            qPos.add(status);
14974    
14975                            Long count = (Long)q.uniqueResult();
14976    
14977                            return count.intValue();
14978                    }
14979                    catch (Exception e) {
14980                            throw processException(e);
14981                    }
14982                    finally {
14983                            closeSession(session);
14984                    }
14985            }
14986    
14987            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
14988            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
14989            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
14990                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
14991                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
14992                            "findByC_V",
14993                            new String[] {
14994                                    Long.class.getName(), Double.class.getName(),
14995                                    
14996                            Integer.class.getName(), Integer.class.getName(),
14997                                    OrderByComparator.class.getName()
14998                            });
14999            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15000                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15001                            JournalArticleImpl.class,
15002                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
15003                            new String[] { Long.class.getName(), Double.class.getName() },
15004                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
15005                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
15006                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
15007            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15008                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15009                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
15010                            new String[] { Long.class.getName(), Double.class.getName() });
15011    
15012            /**
15013             * Returns all the journal articles where companyId = &#63; and version = &#63;.
15014             *
15015             * @param companyId the company ID
15016             * @param version the version
15017             * @return the matching journal articles
15018             */
15019            @Override
15020            public List<JournalArticle> findByC_V(long companyId, double version) {
15021                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
15022                            QueryUtil.ALL_POS, null);
15023            }
15024    
15025            /**
15026             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
15027             *
15028             * <p>
15029             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15030             * </p>
15031             *
15032             * @param companyId the company ID
15033             * @param version the version
15034             * @param start the lower bound of the range of journal articles
15035             * @param end the upper bound of the range of journal articles (not inclusive)
15036             * @return the range of matching journal articles
15037             */
15038            @Override
15039            public List<JournalArticle> findByC_V(long companyId, double version,
15040                    int start, int end) {
15041                    return findByC_V(companyId, version, start, end, null);
15042            }
15043    
15044            /**
15045             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
15046             *
15047             * <p>
15048             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15049             * </p>
15050             *
15051             * @param companyId the company ID
15052             * @param version the version
15053             * @param start the lower bound of the range of journal articles
15054             * @param end the upper bound of the range of journal articles (not inclusive)
15055             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15056             * @return the ordered range of matching journal articles
15057             */
15058            @Override
15059            public List<JournalArticle> findByC_V(long companyId, double version,
15060                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
15061                    boolean pagination = true;
15062                    FinderPath finderPath = null;
15063                    Object[] finderArgs = null;
15064    
15065                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15066                                    (orderByComparator == null)) {
15067                            pagination = false;
15068                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
15069                            finderArgs = new Object[] { companyId, version };
15070                    }
15071                    else {
15072                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
15073                            finderArgs = new Object[] {
15074                                            companyId, version,
15075                                            
15076                                            start, end, orderByComparator
15077                                    };
15078                    }
15079    
15080                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15081                                    finderArgs, this);
15082    
15083                    if ((list != null) && !list.isEmpty()) {
15084                            for (JournalArticle journalArticle : list) {
15085                                    if ((companyId != journalArticle.getCompanyId()) ||
15086                                                    (version != journalArticle.getVersion())) {
15087                                            list = null;
15088    
15089                                            break;
15090                                    }
15091                            }
15092                    }
15093    
15094                    if (list == null) {
15095                            StringBundler query = null;
15096    
15097                            if (orderByComparator != null) {
15098                                    query = new StringBundler(4 +
15099                                                    (orderByComparator.getOrderByFields().length * 3));
15100                            }
15101                            else {
15102                                    query = new StringBundler(4);
15103                            }
15104    
15105                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15106    
15107                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15108    
15109                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15110    
15111                            if (orderByComparator != null) {
15112                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15113                                            orderByComparator);
15114                            }
15115                            else
15116                             if (pagination) {
15117                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15118                            }
15119    
15120                            String sql = query.toString();
15121    
15122                            Session session = null;
15123    
15124                            try {
15125                                    session = openSession();
15126    
15127                                    Query q = session.createQuery(sql);
15128    
15129                                    QueryPos qPos = QueryPos.getInstance(q);
15130    
15131                                    qPos.add(companyId);
15132    
15133                                    qPos.add(version);
15134    
15135                                    if (!pagination) {
15136                                            list = (List<JournalArticle>)QueryUtil.list(q,
15137                                                            getDialect(), start, end, false);
15138    
15139                                            Collections.sort(list);
15140    
15141                                            list = Collections.unmodifiableList(list);
15142                                    }
15143                                    else {
15144                                            list = (List<JournalArticle>)QueryUtil.list(q,
15145                                                            getDialect(), start, end);
15146                                    }
15147    
15148                                    cacheResult(list);
15149    
15150                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15151                            }
15152                            catch (Exception e) {
15153                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15154    
15155                                    throw processException(e);
15156                            }
15157                            finally {
15158                                    closeSession(session);
15159                            }
15160                    }
15161    
15162                    return list;
15163            }
15164    
15165            /**
15166             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
15167             *
15168             * @param companyId the company ID
15169             * @param version the version
15170             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15171             * @return the first matching journal article
15172             * @throws NoSuchArticleException if a matching journal article could not be found
15173             */
15174            @Override
15175            public JournalArticle findByC_V_First(long companyId, double version,
15176                    OrderByComparator<JournalArticle> orderByComparator)
15177                    throws NoSuchArticleException {
15178                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
15179                                    orderByComparator);
15180    
15181                    if (journalArticle != null) {
15182                            return journalArticle;
15183                    }
15184    
15185                    StringBundler msg = new StringBundler(6);
15186    
15187                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15188    
15189                    msg.append("companyId=");
15190                    msg.append(companyId);
15191    
15192                    msg.append(", version=");
15193                    msg.append(version);
15194    
15195                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15196    
15197                    throw new NoSuchArticleException(msg.toString());
15198            }
15199    
15200            /**
15201             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
15202             *
15203             * @param companyId the company ID
15204             * @param version the version
15205             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15206             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15207             */
15208            @Override
15209            public JournalArticle fetchByC_V_First(long companyId, double version,
15210                    OrderByComparator<JournalArticle> orderByComparator) {
15211                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
15212                                    orderByComparator);
15213    
15214                    if (!list.isEmpty()) {
15215                            return list.get(0);
15216                    }
15217    
15218                    return null;
15219            }
15220    
15221            /**
15222             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
15223             *
15224             * @param companyId the company ID
15225             * @param version the version
15226             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15227             * @return the last matching journal article
15228             * @throws NoSuchArticleException if a matching journal article could not be found
15229             */
15230            @Override
15231            public JournalArticle findByC_V_Last(long companyId, double version,
15232                    OrderByComparator<JournalArticle> orderByComparator)
15233                    throws NoSuchArticleException {
15234                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
15235                                    orderByComparator);
15236    
15237                    if (journalArticle != null) {
15238                            return journalArticle;
15239                    }
15240    
15241                    StringBundler msg = new StringBundler(6);
15242    
15243                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15244    
15245                    msg.append("companyId=");
15246                    msg.append(companyId);
15247    
15248                    msg.append(", version=");
15249                    msg.append(version);
15250    
15251                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15252    
15253                    throw new NoSuchArticleException(msg.toString());
15254            }
15255    
15256            /**
15257             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
15258             *
15259             * @param companyId the company ID
15260             * @param version the version
15261             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15262             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15263             */
15264            @Override
15265            public JournalArticle fetchByC_V_Last(long companyId, double version,
15266                    OrderByComparator<JournalArticle> orderByComparator) {
15267                    int count = countByC_V(companyId, version);
15268    
15269                    if (count == 0) {
15270                            return null;
15271                    }
15272    
15273                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
15274                                    count, orderByComparator);
15275    
15276                    if (!list.isEmpty()) {
15277                            return list.get(0);
15278                    }
15279    
15280                    return null;
15281            }
15282    
15283            /**
15284             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
15285             *
15286             * @param id the primary key of the current journal article
15287             * @param companyId the company ID
15288             * @param version the version
15289             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15290             * @return the previous, current, and next journal article
15291             * @throws NoSuchArticleException if a journal article with the primary key could not be found
15292             */
15293            @Override
15294            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
15295                    double version, OrderByComparator<JournalArticle> orderByComparator)
15296                    throws NoSuchArticleException {
15297                    JournalArticle journalArticle = findByPrimaryKey(id);
15298    
15299                    Session session = null;
15300    
15301                    try {
15302                            session = openSession();
15303    
15304                            JournalArticle[] array = new JournalArticleImpl[3];
15305    
15306                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
15307                                            version, orderByComparator, true);
15308    
15309                            array[1] = journalArticle;
15310    
15311                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
15312                                            version, orderByComparator, false);
15313    
15314                            return array;
15315                    }
15316                    catch (Exception e) {
15317                            throw processException(e);
15318                    }
15319                    finally {
15320                            closeSession(session);
15321                    }
15322            }
15323    
15324            protected JournalArticle getByC_V_PrevAndNext(Session session,
15325                    JournalArticle journalArticle, long companyId, double version,
15326                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
15327                    StringBundler query = null;
15328    
15329                    if (orderByComparator != null) {
15330                            query = new StringBundler(6 +
15331                                            (orderByComparator.getOrderByFields().length * 6));
15332                    }
15333                    else {
15334                            query = new StringBundler(3);
15335                    }
15336    
15337                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15338    
15339                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15340    
15341                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
15342    
15343                    if (orderByComparator != null) {
15344                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15345    
15346                            if (orderByConditionFields.length > 0) {
15347                                    query.append(WHERE_AND);
15348                            }
15349    
15350                            for (int i = 0; i < orderByConditionFields.length; i++) {
15351                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15352                                    query.append(orderByConditionFields[i]);
15353    
15354                                    if ((i + 1) < orderByConditionFields.length) {
15355                                            if (orderByComparator.isAscending() ^ previous) {
15356                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15357                                            }
15358                                            else {
15359                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15360                                            }
15361                                    }
15362                                    else {
15363                                            if (orderByComparator.isAscending() ^ previous) {
15364                                                    query.append(WHERE_GREATER_THAN);
15365                                            }
15366                                            else {
15367                                                    query.append(WHERE_LESSER_THAN);
15368                                            }
15369                                    }
15370                            }
15371    
15372                            query.append(ORDER_BY_CLAUSE);
15373    
15374                            String[] orderByFields = orderByComparator.getOrderByFields();
15375    
15376                            for (int i = 0; i < orderByFields.length; i++) {
15377                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15378                                    query.append(orderByFields[i]);
15379    
15380                                    if ((i + 1) < orderByFields.length) {
15381                                            if (orderByComparator.isAscending() ^ previous) {
15382                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15383                                            }
15384                                            else {
15385                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15386                                            }
15387                                    }
15388                                    else {
15389                                            if (orderByComparator.isAscending() ^ previous) {
15390                                                    query.append(ORDER_BY_ASC);
15391                                            }
15392                                            else {
15393                                                    query.append(ORDER_BY_DESC);
15394                                            }
15395                                    }
15396                            }
15397                    }
15398                    else {
15399                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15400                    }
15401    
15402                    String sql = query.toString();
15403    
15404                    Query q = session.createQuery(sql);
15405    
15406                    q.setFirstResult(0);
15407                    q.setMaxResults(2);
15408    
15409                    QueryPos qPos = QueryPos.getInstance(q);
15410    
15411                    qPos.add(companyId);
15412    
15413                    qPos.add(version);
15414    
15415                    if (orderByComparator != null) {
15416                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15417    
15418                            for (Object value : values) {
15419                                    qPos.add(value);
15420                            }
15421                    }
15422    
15423                    List<JournalArticle> list = q.list();
15424    
15425                    if (list.size() == 2) {
15426                            return list.get(1);
15427                    }
15428                    else {
15429                            return null;
15430                    }
15431            }
15432    
15433            /**
15434             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
15435             *
15436             * @param companyId the company ID
15437             * @param version the version
15438             */
15439            @Override
15440            public void removeByC_V(long companyId, double version) {
15441                    for (JournalArticle journalArticle : findByC_V(companyId, version,
15442                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15443                            remove(journalArticle);
15444                    }
15445            }
15446    
15447            /**
15448             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
15449             *
15450             * @param companyId the company ID
15451             * @param version the version
15452             * @return the number of matching journal articles
15453             */
15454            @Override
15455            public int countByC_V(long companyId, double version) {
15456                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V;
15457    
15458                    Object[] finderArgs = new Object[] { companyId, version };
15459    
15460                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15461                                    this);
15462    
15463                    if (count == null) {
15464                            StringBundler query = new StringBundler(3);
15465    
15466                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15467    
15468                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15469    
15470                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15471    
15472                            String sql = query.toString();
15473    
15474                            Session session = null;
15475    
15476                            try {
15477                                    session = openSession();
15478    
15479                                    Query q = session.createQuery(sql);
15480    
15481                                    QueryPos qPos = QueryPos.getInstance(q);
15482    
15483                                    qPos.add(companyId);
15484    
15485                                    qPos.add(version);
15486    
15487                                    count = (Long)q.uniqueResult();
15488    
15489                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15490                            }
15491                            catch (Exception e) {
15492                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15493    
15494                                    throw processException(e);
15495                            }
15496                            finally {
15497                                    closeSession(session);
15498                            }
15499                    }
15500    
15501                    return count.intValue();
15502            }
15503    
15504            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
15505            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
15506            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15507                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15508                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
15509                            "findByC_ST",
15510                            new String[] {
15511                                    Long.class.getName(), Integer.class.getName(),
15512                                    
15513                            Integer.class.getName(), Integer.class.getName(),
15514                                    OrderByComparator.class.getName()
15515                            });
15516            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15517                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
15518                            JournalArticleImpl.class,
15519                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
15520                            new String[] { Long.class.getName(), Integer.class.getName() },
15521                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
15522                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
15523                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
15524                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
15525            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
15526                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
15527                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
15528                            new String[] { Long.class.getName(), Integer.class.getName() });
15529    
15530            /**
15531             * Returns all the journal articles where companyId = &#63; and status = &#63;.
15532             *
15533             * @param companyId the company ID
15534             * @param status the status
15535             * @return the matching journal articles
15536             */
15537            @Override
15538            public List<JournalArticle> findByC_ST(long companyId, int status) {
15539                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
15540                            QueryUtil.ALL_POS, null);
15541            }
15542    
15543            /**
15544             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
15545             *
15546             * <p>
15547             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15548             * </p>
15549             *
15550             * @param companyId the company ID
15551             * @param status the status
15552             * @param start the lower bound of the range of journal articles
15553             * @param end the upper bound of the range of journal articles (not inclusive)
15554             * @return the range of matching journal articles
15555             */
15556            @Override
15557            public List<JournalArticle> findByC_ST(long companyId, int status,
15558                    int start, int end) {
15559                    return findByC_ST(companyId, status, start, end, null);
15560            }
15561    
15562            /**
15563             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
15564             *
15565             * <p>
15566             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15567             * </p>
15568             *
15569             * @param companyId the company ID
15570             * @param status the status
15571             * @param start the lower bound of the range of journal articles
15572             * @param end the upper bound of the range of journal articles (not inclusive)
15573             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15574             * @return the ordered range of matching journal articles
15575             */
15576            @Override
15577            public List<JournalArticle> findByC_ST(long companyId, int status,
15578                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
15579                    boolean pagination = true;
15580                    FinderPath finderPath = null;
15581                    Object[] finderArgs = null;
15582    
15583                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15584                                    (orderByComparator == null)) {
15585                            pagination = false;
15586                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
15587                            finderArgs = new Object[] { companyId, status };
15588                    }
15589                    else {
15590                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
15591                            finderArgs = new Object[] {
15592                                            companyId, status,
15593                                            
15594                                            start, end, orderByComparator
15595                                    };
15596                    }
15597    
15598                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15599                                    finderArgs, this);
15600    
15601                    if ((list != null) && !list.isEmpty()) {
15602                            for (JournalArticle journalArticle : list) {
15603                                    if ((companyId != journalArticle.getCompanyId()) ||
15604                                                    (status != journalArticle.getStatus())) {
15605                                            list = null;
15606    
15607                                            break;
15608                                    }
15609                            }
15610                    }
15611    
15612                    if (list == null) {
15613                            StringBundler query = null;
15614    
15615                            if (orderByComparator != null) {
15616                                    query = new StringBundler(4 +
15617                                                    (orderByComparator.getOrderByFields().length * 3));
15618                            }
15619                            else {
15620                                    query = new StringBundler(4);
15621                            }
15622    
15623                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15624    
15625                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15626    
15627                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15628    
15629                            if (orderByComparator != null) {
15630                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15631                                            orderByComparator);
15632                            }
15633                            else
15634                             if (pagination) {
15635                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15636                            }
15637    
15638                            String sql = query.toString();
15639    
15640                            Session session = null;
15641    
15642                            try {
15643                                    session = openSession();
15644    
15645                                    Query q = session.createQuery(sql);
15646    
15647                                    QueryPos qPos = QueryPos.getInstance(q);
15648    
15649                                    qPos.add(companyId);
15650    
15651                                    qPos.add(status);
15652    
15653                                    if (!pagination) {
15654                                            list = (List<JournalArticle>)QueryUtil.list(q,
15655                                                            getDialect(), start, end, false);
15656    
15657                                            Collections.sort(list);
15658    
15659                                            list = Collections.unmodifiableList(list);
15660                                    }
15661                                    else {
15662                                            list = (List<JournalArticle>)QueryUtil.list(q,
15663                                                            getDialect(), start, end);
15664                                    }
15665    
15666                                    cacheResult(list);
15667    
15668                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15669                            }
15670                            catch (Exception e) {
15671                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15672    
15673                                    throw processException(e);
15674                            }
15675                            finally {
15676                                    closeSession(session);
15677                            }
15678                    }
15679    
15680                    return list;
15681            }
15682    
15683            /**
15684             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
15685             *
15686             * @param companyId the company ID
15687             * @param status the status
15688             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15689             * @return the first matching journal article
15690             * @throws NoSuchArticleException if a matching journal article could not be found
15691             */
15692            @Override
15693            public JournalArticle findByC_ST_First(long companyId, int status,
15694                    OrderByComparator<JournalArticle> orderByComparator)
15695                    throws NoSuchArticleException {
15696                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
15697                                    orderByComparator);
15698    
15699                    if (journalArticle != null) {
15700                            return journalArticle;
15701                    }
15702    
15703                    StringBundler msg = new StringBundler(6);
15704    
15705                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15706    
15707                    msg.append("companyId=");
15708                    msg.append(companyId);
15709    
15710                    msg.append(", status=");
15711                    msg.append(status);
15712    
15713                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15714    
15715                    throw new NoSuchArticleException(msg.toString());
15716            }
15717    
15718            /**
15719             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
15720             *
15721             * @param companyId the company ID
15722             * @param status the status
15723             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15724             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15725             */
15726            @Override
15727            public JournalArticle fetchByC_ST_First(long companyId, int status,
15728                    OrderByComparator<JournalArticle> orderByComparator) {
15729                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
15730                                    orderByComparator);
15731    
15732                    if (!list.isEmpty()) {
15733                            return list.get(0);
15734                    }
15735    
15736                    return null;
15737            }
15738    
15739            /**
15740             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
15741             *
15742             * @param companyId the company ID
15743             * @param status the status
15744             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15745             * @return the last matching journal article
15746             * @throws NoSuchArticleException if a matching journal article could not be found
15747             */
15748            @Override
15749            public JournalArticle findByC_ST_Last(long companyId, int status,
15750                    OrderByComparator<JournalArticle> orderByComparator)
15751                    throws NoSuchArticleException {
15752                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
15753                                    orderByComparator);
15754    
15755                    if (journalArticle != null) {
15756                            return journalArticle;
15757                    }
15758    
15759                    StringBundler msg = new StringBundler(6);
15760    
15761                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15762    
15763                    msg.append("companyId=");
15764                    msg.append(companyId);
15765    
15766                    msg.append(", status=");
15767                    msg.append(status);
15768    
15769                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15770    
15771                    throw new NoSuchArticleException(msg.toString());
15772            }
15773    
15774            /**
15775             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
15776             *
15777             * @param companyId the company ID
15778             * @param status the status
15779             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15780             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15781             */
15782            @Override
15783            public JournalArticle fetchByC_ST_Last(long companyId, int status,
15784                    OrderByComparator<JournalArticle> orderByComparator) {
15785                    int count = countByC_ST(companyId, status);
15786    
15787                    if (count == 0) {
15788                            return null;
15789                    }
15790    
15791                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
15792                                    count, orderByComparator);
15793    
15794                    if (!list.isEmpty()) {
15795                            return list.get(0);
15796                    }
15797    
15798                    return null;
15799            }
15800    
15801            /**
15802             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
15803             *
15804             * @param id the primary key of the current journal article
15805             * @param companyId the company ID
15806             * @param status the status
15807             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15808             * @return the previous, current, and next journal article
15809             * @throws NoSuchArticleException if a journal article with the primary key could not be found
15810             */
15811            @Override
15812            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
15813                    int status, OrderByComparator<JournalArticle> orderByComparator)
15814                    throws NoSuchArticleException {
15815                    JournalArticle journalArticle = findByPrimaryKey(id);
15816    
15817                    Session session = null;
15818    
15819                    try {
15820                            session = openSession();
15821    
15822                            JournalArticle[] array = new JournalArticleImpl[3];
15823    
15824                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
15825                                            companyId, status, orderByComparator, true);
15826    
15827                            array[1] = journalArticle;
15828    
15829                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
15830                                            companyId, status, orderByComparator, false);
15831    
15832                            return array;
15833                    }
15834                    catch (Exception e) {
15835                            throw processException(e);
15836                    }
15837                    finally {
15838                            closeSession(session);
15839                    }
15840            }
15841    
15842            protected JournalArticle getByC_ST_PrevAndNext(Session session,
15843                    JournalArticle journalArticle, long companyId, int status,
15844                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
15845                    StringBundler query = null;
15846    
15847                    if (orderByComparator != null) {
15848                            query = new StringBundler(6 +
15849                                            (orderByComparator.getOrderByFields().length * 6));
15850                    }
15851                    else {
15852                            query = new StringBundler(3);
15853                    }
15854    
15855                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15856    
15857                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15858    
15859                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15860    
15861                    if (orderByComparator != null) {
15862                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15863    
15864                            if (orderByConditionFields.length > 0) {
15865                                    query.append(WHERE_AND);
15866                            }
15867    
15868                            for (int i = 0; i < orderByConditionFields.length; i++) {
15869                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15870                                    query.append(orderByConditionFields[i]);
15871    
15872                                    if ((i + 1) < orderByConditionFields.length) {
15873                                            if (orderByComparator.isAscending() ^ previous) {
15874                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15875                                            }
15876                                            else {
15877                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15878                                            }
15879                                    }
15880                                    else {
15881                                            if (orderByComparator.isAscending() ^ previous) {
15882                                                    query.append(WHERE_GREATER_THAN);
15883                                            }
15884                                            else {
15885                                                    query.append(WHERE_LESSER_THAN);
15886                                            }
15887                                    }
15888                            }
15889    
15890                            query.append(ORDER_BY_CLAUSE);
15891    
15892                            String[] orderByFields = orderByComparator.getOrderByFields();
15893    
15894                            for (int i = 0; i < orderByFields.length; i++) {
15895                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15896                                    query.append(orderByFields[i]);
15897    
15898                                    if ((i + 1) < orderByFields.length) {
15899                                            if (orderByComparator.isAscending() ^ previous) {
15900                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15901                                            }
15902                                            else {
15903                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15904                                            }
15905                                    }
15906                                    else {
15907                                            if (orderByComparator.isAscending() ^ previous) {
15908                                                    query.append(ORDER_BY_ASC);
15909                                            }
15910                                            else {
15911                                                    query.append(ORDER_BY_DESC);
15912                                            }
15913                                    }
15914                            }
15915                    }
15916                    else {
15917                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15918                    }
15919    
15920                    String sql = query.toString();
15921    
15922                    Query q = session.createQuery(sql);
15923    
15924                    q.setFirstResult(0);
15925                    q.setMaxResults(2);
15926    
15927                    QueryPos qPos = QueryPos.getInstance(q);
15928    
15929                    qPos.add(companyId);
15930    
15931                    qPos.add(status);
15932    
15933                    if (orderByComparator != null) {
15934                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15935    
15936                            for (Object value : values) {
15937                                    qPos.add(value);
15938                            }
15939                    }
15940    
15941                    List<JournalArticle> list = q.list();
15942    
15943                    if (list.size() == 2) {
15944                            return list.get(1);
15945                    }
15946                    else {
15947                            return null;
15948                    }
15949            }
15950    
15951            /**
15952             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
15953             *
15954             * @param companyId the company ID
15955             * @param status the status
15956             */
15957            @Override
15958            public void removeByC_ST(long companyId, int status) {
15959                    for (JournalArticle journalArticle : findByC_ST(companyId, status,
15960                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15961                            remove(journalArticle);
15962                    }
15963            }
15964    
15965            /**
15966             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
15967             *
15968             * @param companyId the company ID
15969             * @param status the status
15970             * @return the number of matching journal articles
15971             */
15972            @Override
15973            public int countByC_ST(long companyId, int status) {
15974                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_ST;
15975    
15976                    Object[] finderArgs = new Object[] { companyId, status };
15977    
15978                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15979                                    this);
15980    
15981                    if (count == null) {
15982                            StringBundler query = new StringBundler(3);
15983    
15984                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15985    
15986                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15987    
15988                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15989    
15990                            String sql = query.toString();
15991    
15992                            Session session = null;
15993    
15994                            try {
15995                                    session = openSession();
15996    
15997                                    Query q = session.createQuery(sql);
15998    
15999                                    QueryPos qPos = QueryPos.getInstance(q);
16000    
16001                                    qPos.add(companyId);
16002    
16003                                    qPos.add(status);
16004    
16005                                    count = (Long)q.uniqueResult();
16006    
16007                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16008                            }
16009                            catch (Exception e) {
16010                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16011    
16012                                    throw processException(e);
16013                            }
16014                            finally {
16015                                    closeSession(session);
16016                            }
16017                    }
16018    
16019                    return count.intValue();
16020            }
16021    
16022            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16023            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
16024            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16025                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16026                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16027                            "findByC_NotST",
16028                            new String[] {
16029                                    Long.class.getName(), Integer.class.getName(),
16030                                    
16031                            Integer.class.getName(), Integer.class.getName(),
16032                                    OrderByComparator.class.getName()
16033                            });
16034            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16035                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16036                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotST",
16037                            new String[] { Long.class.getName(), Integer.class.getName() });
16038    
16039            /**
16040             * Returns all the journal articles where companyId = &#63; and status &ne; &#63;.
16041             *
16042             * @param companyId the company ID
16043             * @param status the status
16044             * @return the matching journal articles
16045             */
16046            @Override
16047            public List<JournalArticle> findByC_NotST(long companyId, int status) {
16048                    return findByC_NotST(companyId, status, QueryUtil.ALL_POS,
16049                            QueryUtil.ALL_POS, null);
16050            }
16051    
16052            /**
16053             * Returns a range of all the journal articles where companyId = &#63; and status &ne; &#63;.
16054             *
16055             * <p>
16056             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16057             * </p>
16058             *
16059             * @param companyId the company ID
16060             * @param status the status
16061             * @param start the lower bound of the range of journal articles
16062             * @param end the upper bound of the range of journal articles (not inclusive)
16063             * @return the range of matching journal articles
16064             */
16065            @Override
16066            public List<JournalArticle> findByC_NotST(long companyId, int status,
16067                    int start, int end) {
16068                    return findByC_NotST(companyId, status, start, end, null);
16069            }
16070    
16071            /**
16072             * Returns an ordered range of all the journal articles where companyId = &#63; and status &ne; &#63;.
16073             *
16074             * <p>
16075             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16076             * </p>
16077             *
16078             * @param companyId the company ID
16079             * @param status the status
16080             * @param start the lower bound of the range of journal articles
16081             * @param end the upper bound of the range of journal articles (not inclusive)
16082             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16083             * @return the ordered range of matching journal articles
16084             */
16085            @Override
16086            public List<JournalArticle> findByC_NotST(long companyId, int status,
16087                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
16088                    boolean pagination = true;
16089                    FinderPath finderPath = null;
16090                    Object[] finderArgs = null;
16091    
16092                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTST;
16093                    finderArgs = new Object[] {
16094                                    companyId, status,
16095                                    
16096                                    start, end, orderByComparator
16097                            };
16098    
16099                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16100                                    finderArgs, this);
16101    
16102                    if ((list != null) && !list.isEmpty()) {
16103                            for (JournalArticle journalArticle : list) {
16104                                    if ((companyId != journalArticle.getCompanyId()) ||
16105                                                    (status == journalArticle.getStatus())) {
16106                                            list = null;
16107    
16108                                            break;
16109                                    }
16110                            }
16111                    }
16112    
16113                    if (list == null) {
16114                            StringBundler query = null;
16115    
16116                            if (orderByComparator != null) {
16117                                    query = new StringBundler(4 +
16118                                                    (orderByComparator.getOrderByFields().length * 3));
16119                            }
16120                            else {
16121                                    query = new StringBundler(4);
16122                            }
16123    
16124                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16125    
16126                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16127    
16128                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16129    
16130                            if (orderByComparator != null) {
16131                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16132                                            orderByComparator);
16133                            }
16134                            else
16135                             if (pagination) {
16136                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16137                            }
16138    
16139                            String sql = query.toString();
16140    
16141                            Session session = null;
16142    
16143                            try {
16144                                    session = openSession();
16145    
16146                                    Query q = session.createQuery(sql);
16147    
16148                                    QueryPos qPos = QueryPos.getInstance(q);
16149    
16150                                    qPos.add(companyId);
16151    
16152                                    qPos.add(status);
16153    
16154                                    if (!pagination) {
16155                                            list = (List<JournalArticle>)QueryUtil.list(q,
16156                                                            getDialect(), start, end, false);
16157    
16158                                            Collections.sort(list);
16159    
16160                                            list = Collections.unmodifiableList(list);
16161                                    }
16162                                    else {
16163                                            list = (List<JournalArticle>)QueryUtil.list(q,
16164                                                            getDialect(), start, end);
16165                                    }
16166    
16167                                    cacheResult(list);
16168    
16169                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16170                            }
16171                            catch (Exception e) {
16172                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16173    
16174                                    throw processException(e);
16175                            }
16176                            finally {
16177                                    closeSession(session);
16178                            }
16179                    }
16180    
16181                    return list;
16182            }
16183    
16184            /**
16185             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16186             *
16187             * @param companyId the company ID
16188             * @param status the status
16189             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16190             * @return the first matching journal article
16191             * @throws NoSuchArticleException if a matching journal article could not be found
16192             */
16193            @Override
16194            public JournalArticle findByC_NotST_First(long companyId, int status,
16195                    OrderByComparator<JournalArticle> orderByComparator)
16196                    throws NoSuchArticleException {
16197                    JournalArticle journalArticle = fetchByC_NotST_First(companyId, status,
16198                                    orderByComparator);
16199    
16200                    if (journalArticle != null) {
16201                            return journalArticle;
16202                    }
16203    
16204                    StringBundler msg = new StringBundler(6);
16205    
16206                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16207    
16208                    msg.append("companyId=");
16209                    msg.append(companyId);
16210    
16211                    msg.append(", status=");
16212                    msg.append(status);
16213    
16214                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16215    
16216                    throw new NoSuchArticleException(msg.toString());
16217            }
16218    
16219            /**
16220             * Returns the first journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16221             *
16222             * @param companyId the company ID
16223             * @param status the status
16224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16225             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16226             */
16227            @Override
16228            public JournalArticle fetchByC_NotST_First(long companyId, int status,
16229                    OrderByComparator<JournalArticle> orderByComparator) {
16230                    List<JournalArticle> list = findByC_NotST(companyId, status, 0, 1,
16231                                    orderByComparator);
16232    
16233                    if (!list.isEmpty()) {
16234                            return list.get(0);
16235                    }
16236    
16237                    return null;
16238            }
16239    
16240            /**
16241             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16242             *
16243             * @param companyId the company ID
16244             * @param status the status
16245             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16246             * @return the last matching journal article
16247             * @throws NoSuchArticleException if a matching journal article could not be found
16248             */
16249            @Override
16250            public JournalArticle findByC_NotST_Last(long companyId, int status,
16251                    OrderByComparator<JournalArticle> orderByComparator)
16252                    throws NoSuchArticleException {
16253                    JournalArticle journalArticle = fetchByC_NotST_Last(companyId, status,
16254                                    orderByComparator);
16255    
16256                    if (journalArticle != null) {
16257                            return journalArticle;
16258                    }
16259    
16260                    StringBundler msg = new StringBundler(6);
16261    
16262                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16263    
16264                    msg.append("companyId=");
16265                    msg.append(companyId);
16266    
16267                    msg.append(", status=");
16268                    msg.append(status);
16269    
16270                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16271    
16272                    throw new NoSuchArticleException(msg.toString());
16273            }
16274    
16275            /**
16276             * Returns the last journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16277             *
16278             * @param companyId the company ID
16279             * @param status the status
16280             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16281             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16282             */
16283            @Override
16284            public JournalArticle fetchByC_NotST_Last(long companyId, int status,
16285                    OrderByComparator<JournalArticle> orderByComparator) {
16286                    int count = countByC_NotST(companyId, status);
16287    
16288                    if (count == 0) {
16289                            return null;
16290                    }
16291    
16292                    List<JournalArticle> list = findByC_NotST(companyId, status, count - 1,
16293                                    count, orderByComparator);
16294    
16295                    if (!list.isEmpty()) {
16296                            return list.get(0);
16297                    }
16298    
16299                    return null;
16300            }
16301    
16302            /**
16303             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status &ne; &#63;.
16304             *
16305             * @param id the primary key of the current journal article
16306             * @param companyId the company ID
16307             * @param status the status
16308             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16309             * @return the previous, current, and next journal article
16310             * @throws NoSuchArticleException if a journal article with the primary key could not be found
16311             */
16312            @Override
16313            public JournalArticle[] findByC_NotST_PrevAndNext(long id, long companyId,
16314                    int status, OrderByComparator<JournalArticle> orderByComparator)
16315                    throws NoSuchArticleException {
16316                    JournalArticle journalArticle = findByPrimaryKey(id);
16317    
16318                    Session session = null;
16319    
16320                    try {
16321                            session = openSession();
16322    
16323                            JournalArticle[] array = new JournalArticleImpl[3];
16324    
16325                            array[0] = getByC_NotST_PrevAndNext(session, journalArticle,
16326                                            companyId, status, orderByComparator, true);
16327    
16328                            array[1] = journalArticle;
16329    
16330                            array[2] = getByC_NotST_PrevAndNext(session, journalArticle,
16331                                            companyId, status, orderByComparator, false);
16332    
16333                            return array;
16334                    }
16335                    catch (Exception e) {
16336                            throw processException(e);
16337                    }
16338                    finally {
16339                            closeSession(session);
16340                    }
16341            }
16342    
16343            protected JournalArticle getByC_NotST_PrevAndNext(Session session,
16344                    JournalArticle journalArticle, long companyId, int status,
16345                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
16346                    StringBundler query = null;
16347    
16348                    if (orderByComparator != null) {
16349                            query = new StringBundler(6 +
16350                                            (orderByComparator.getOrderByFields().length * 6));
16351                    }
16352                    else {
16353                            query = new StringBundler(3);
16354                    }
16355    
16356                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16357    
16358                    query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16359    
16360                    query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16361    
16362                    if (orderByComparator != null) {
16363                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16364    
16365                            if (orderByConditionFields.length > 0) {
16366                                    query.append(WHERE_AND);
16367                            }
16368    
16369                            for (int i = 0; i < orderByConditionFields.length; i++) {
16370                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16371                                    query.append(orderByConditionFields[i]);
16372    
16373                                    if ((i + 1) < orderByConditionFields.length) {
16374                                            if (orderByComparator.isAscending() ^ previous) {
16375                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16376                                            }
16377                                            else {
16378                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16379                                            }
16380                                    }
16381                                    else {
16382                                            if (orderByComparator.isAscending() ^ previous) {
16383                                                    query.append(WHERE_GREATER_THAN);
16384                                            }
16385                                            else {
16386                                                    query.append(WHERE_LESSER_THAN);
16387                                            }
16388                                    }
16389                            }
16390    
16391                            query.append(ORDER_BY_CLAUSE);
16392    
16393                            String[] orderByFields = orderByComparator.getOrderByFields();
16394    
16395                            for (int i = 0; i < orderByFields.length; i++) {
16396                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16397                                    query.append(orderByFields[i]);
16398    
16399                                    if ((i + 1) < orderByFields.length) {
16400                                            if (orderByComparator.isAscending() ^ previous) {
16401                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16402                                            }
16403                                            else {
16404                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16405                                            }
16406                                    }
16407                                    else {
16408                                            if (orderByComparator.isAscending() ^ previous) {
16409                                                    query.append(ORDER_BY_ASC);
16410                                            }
16411                                            else {
16412                                                    query.append(ORDER_BY_DESC);
16413                                            }
16414                                    }
16415                            }
16416                    }
16417                    else {
16418                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16419                    }
16420    
16421                    String sql = query.toString();
16422    
16423                    Query q = session.createQuery(sql);
16424    
16425                    q.setFirstResult(0);
16426                    q.setMaxResults(2);
16427    
16428                    QueryPos qPos = QueryPos.getInstance(q);
16429    
16430                    qPos.add(companyId);
16431    
16432                    qPos.add(status);
16433    
16434                    if (orderByComparator != null) {
16435                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16436    
16437                            for (Object value : values) {
16438                                    qPos.add(value);
16439                            }
16440                    }
16441    
16442                    List<JournalArticle> list = q.list();
16443    
16444                    if (list.size() == 2) {
16445                            return list.get(1);
16446                    }
16447                    else {
16448                            return null;
16449                    }
16450            }
16451    
16452            /**
16453             * Removes all the journal articles where companyId = &#63; and status &ne; &#63; from the database.
16454             *
16455             * @param companyId the company ID
16456             * @param status the status
16457             */
16458            @Override
16459            public void removeByC_NotST(long companyId, int status) {
16460                    for (JournalArticle journalArticle : findByC_NotST(companyId, status,
16461                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16462                            remove(journalArticle);
16463                    }
16464            }
16465    
16466            /**
16467             * Returns the number of journal articles where companyId = &#63; and status &ne; &#63;.
16468             *
16469             * @param companyId the company ID
16470             * @param status the status
16471             * @return the number of matching journal articles
16472             */
16473            @Override
16474            public int countByC_NotST(long companyId, int status) {
16475                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTST;
16476    
16477                    Object[] finderArgs = new Object[] { companyId, status };
16478    
16479                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16480                                    this);
16481    
16482                    if (count == null) {
16483                            StringBundler query = new StringBundler(3);
16484    
16485                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16486    
16487                            query.append(_FINDER_COLUMN_C_NOTST_COMPANYID_2);
16488    
16489                            query.append(_FINDER_COLUMN_C_NOTST_STATUS_2);
16490    
16491                            String sql = query.toString();
16492    
16493                            Session session = null;
16494    
16495                            try {
16496                                    session = openSession();
16497    
16498                                    Query q = session.createQuery(sql);
16499    
16500                                    QueryPos qPos = QueryPos.getInstance(q);
16501    
16502                                    qPos.add(companyId);
16503    
16504                                    qPos.add(status);
16505    
16506                                    count = (Long)q.uniqueResult();
16507    
16508                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16509                            }
16510                            catch (Exception e) {
16511                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16512    
16513                                    throw processException(e);
16514                            }
16515                            finally {
16516                                    closeSession(session);
16517                            }
16518                    }
16519    
16520                    return count.intValue();
16521            }
16522    
16523            private static final String _FINDER_COLUMN_C_NOTST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16524            private static final String _FINDER_COLUMN_C_NOTST_STATUS_2 = "journalArticle.status != ?";
16525            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_DDMTK = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16526                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16527                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
16528                            "findByC_DDMTK",
16529                            new String[] {
16530                                    Long.class.getName(), String.class.getName(),
16531                                    
16532                            Integer.class.getName(), Integer.class.getName(),
16533                                    OrderByComparator.class.getName()
16534                            });
16535            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_DDMTK =
16536                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16537                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
16538                            JournalArticleImpl.class,
16539                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_DDMTK",
16540                            new String[] { Long.class.getName(), String.class.getName() },
16541                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
16542                            JournalArticleModelImpl.DDMTEMPLATEKEY_COLUMN_BITMASK |
16543                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
16544                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
16545            public static final FinderPath FINDER_PATH_COUNT_BY_C_DDMTK = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
16546                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
16547                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_DDMTK",
16548                            new String[] { Long.class.getName(), String.class.getName() });
16549    
16550            /**
16551             * Returns all the journal articles where classNameId = &#63; and DDMTemplateKey = &#63;.
16552             *
16553             * @param classNameId the class name ID
16554             * @param DDMTemplateKey the d d m template key
16555             * @return the matching journal articles
16556             */
16557            @Override
16558            public List<JournalArticle> findByC_DDMTK(long classNameId,
16559                    String DDMTemplateKey) {
16560                    return findByC_DDMTK(classNameId, DDMTemplateKey, QueryUtil.ALL_POS,
16561                            QueryUtil.ALL_POS, null);
16562            }
16563    
16564            /**
16565             * Returns a range of all the journal articles where classNameId = &#63; and DDMTemplateKey = &#63;.
16566             *
16567             * <p>
16568             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16569             * </p>
16570             *
16571             * @param classNameId the class name ID
16572             * @param DDMTemplateKey the d d m template key
16573             * @param start the lower bound of the range of journal articles
16574             * @param end the upper bound of the range of journal articles (not inclusive)
16575             * @return the range of matching journal articles
16576             */
16577            @Override
16578            public List<JournalArticle> findByC_DDMTK(long classNameId,
16579                    String DDMTemplateKey, int start, int end) {
16580                    return findByC_DDMTK(classNameId, DDMTemplateKey, start, end, null);
16581            }
16582    
16583            /**
16584             * Returns an ordered range of all the journal articles where classNameId = &#63; and DDMTemplateKey = &#63;.
16585             *
16586             * <p>
16587             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16588             * </p>
16589             *
16590             * @param classNameId the class name ID
16591             * @param DDMTemplateKey the d d m template key
16592             * @param start the lower bound of the range of journal articles
16593             * @param end the upper bound of the range of journal articles (not inclusive)
16594             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16595             * @return the ordered range of matching journal articles
16596             */
16597            @Override
16598            public List<JournalArticle> findByC_DDMTK(long classNameId,
16599                    String DDMTemplateKey, int start, int end,
16600                    OrderByComparator<JournalArticle> orderByComparator) {
16601                    boolean pagination = true;
16602                    FinderPath finderPath = null;
16603                    Object[] finderArgs = null;
16604    
16605                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16606                                    (orderByComparator == null)) {
16607                            pagination = false;
16608                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_DDMTK;
16609                            finderArgs = new Object[] { classNameId, DDMTemplateKey };
16610                    }
16611                    else {
16612                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_DDMTK;
16613                            finderArgs = new Object[] {
16614                                            classNameId, DDMTemplateKey,
16615                                            
16616                                            start, end, orderByComparator
16617                                    };
16618                    }
16619    
16620                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16621                                    finderArgs, this);
16622    
16623                    if ((list != null) && !list.isEmpty()) {
16624                            for (JournalArticle journalArticle : list) {
16625                                    if ((classNameId != journalArticle.getClassNameId()) ||
16626                                                    !Validator.equals(DDMTemplateKey,
16627                                                            journalArticle.getDDMTemplateKey())) {
16628                                            list = null;
16629    
16630                                            break;
16631                                    }
16632                            }
16633                    }
16634    
16635                    if (list == null) {
16636                            StringBundler query = null;
16637    
16638                            if (orderByComparator != null) {
16639                                    query = new StringBundler(4 +
16640                                                    (orderByComparator.getOrderByFields().length * 3));
16641                            }
16642                            else {
16643                                    query = new StringBundler(4);
16644                            }
16645    
16646                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16647    
16648                            query.append(_FINDER_COLUMN_C_DDMTK_CLASSNAMEID_2);
16649    
16650                            boolean bindDDMTemplateKey = false;
16651    
16652                            if (DDMTemplateKey == null) {
16653                                    query.append(_FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_1);
16654                            }
16655                            else if (DDMTemplateKey.equals(StringPool.BLANK)) {
16656                                    query.append(_FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_3);
16657                            }
16658                            else {
16659                                    bindDDMTemplateKey = true;
16660    
16661                                    query.append(_FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_2);
16662                            }
16663    
16664                            if (orderByComparator != null) {
16665                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16666                                            orderByComparator);
16667                            }
16668                            else
16669                             if (pagination) {
16670                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16671                            }
16672    
16673                            String sql = query.toString();
16674    
16675                            Session session = null;
16676    
16677                            try {
16678                                    session = openSession();
16679    
16680                                    Query q = session.createQuery(sql);
16681    
16682                                    QueryPos qPos = QueryPos.getInstance(q);
16683    
16684                                    qPos.add(classNameId);
16685    
16686                                    if (bindDDMTemplateKey) {
16687                                            qPos.add(DDMTemplateKey);
16688                                    }
16689    
16690                                    if (!pagination) {
16691                                            list = (List<JournalArticle>)QueryUtil.list(q,
16692                                                            getDialect(), start, end, false);
16693    
16694                                            Collections.sort(list);
16695    
16696                                            list = Collections.unmodifiableList(list);
16697                                    }
16698                                    else {
16699                                            list = (List<JournalArticle>)QueryUtil.list(q,
16700                                                            getDialect(), start, end);
16701                                    }
16702    
16703                                    cacheResult(list);
16704    
16705                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16706                            }
16707                            catch (Exception e) {
16708                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16709    
16710                                    throw processException(e);
16711                            }
16712                            finally {
16713                                    closeSession(session);
16714                            }
16715                    }
16716    
16717                    return list;
16718            }
16719    
16720            /**
16721             * Returns the first journal article in the ordered set where classNameId = &#63; and DDMTemplateKey = &#63;.
16722             *
16723             * @param classNameId the class name ID
16724             * @param DDMTemplateKey the d d m template key
16725             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16726             * @return the first matching journal article
16727             * @throws NoSuchArticleException if a matching journal article could not be found
16728             */
16729            @Override
16730            public JournalArticle findByC_DDMTK_First(long classNameId,
16731                    String DDMTemplateKey,
16732                    OrderByComparator<JournalArticle> orderByComparator)
16733                    throws NoSuchArticleException {
16734                    JournalArticle journalArticle = fetchByC_DDMTK_First(classNameId,
16735                                    DDMTemplateKey, orderByComparator);
16736    
16737                    if (journalArticle != null) {
16738                            return journalArticle;
16739                    }
16740    
16741                    StringBundler msg = new StringBundler(6);
16742    
16743                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16744    
16745                    msg.append("classNameId=");
16746                    msg.append(classNameId);
16747    
16748                    msg.append(", DDMTemplateKey=");
16749                    msg.append(DDMTemplateKey);
16750    
16751                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16752    
16753                    throw new NoSuchArticleException(msg.toString());
16754            }
16755    
16756            /**
16757             * Returns the first journal article in the ordered set where classNameId = &#63; and DDMTemplateKey = &#63;.
16758             *
16759             * @param classNameId the class name ID
16760             * @param DDMTemplateKey the d d m template key
16761             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16762             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16763             */
16764            @Override
16765            public JournalArticle fetchByC_DDMTK_First(long classNameId,
16766                    String DDMTemplateKey,
16767                    OrderByComparator<JournalArticle> orderByComparator) {
16768                    List<JournalArticle> list = findByC_DDMTK(classNameId, DDMTemplateKey,
16769                                    0, 1, orderByComparator);
16770    
16771                    if (!list.isEmpty()) {
16772                            return list.get(0);
16773                    }
16774    
16775                    return null;
16776            }
16777    
16778            /**
16779             * Returns the last journal article in the ordered set where classNameId = &#63; and DDMTemplateKey = &#63;.
16780             *
16781             * @param classNameId the class name ID
16782             * @param DDMTemplateKey the d d m template key
16783             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16784             * @return the last matching journal article
16785             * @throws NoSuchArticleException if a matching journal article could not be found
16786             */
16787            @Override
16788            public JournalArticle findByC_DDMTK_Last(long classNameId,
16789                    String DDMTemplateKey,
16790                    OrderByComparator<JournalArticle> orderByComparator)
16791                    throws NoSuchArticleException {
16792                    JournalArticle journalArticle = fetchByC_DDMTK_Last(classNameId,
16793                                    DDMTemplateKey, orderByComparator);
16794    
16795                    if (journalArticle != null) {
16796                            return journalArticle;
16797                    }
16798    
16799                    StringBundler msg = new StringBundler(6);
16800    
16801                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16802    
16803                    msg.append("classNameId=");
16804                    msg.append(classNameId);
16805    
16806                    msg.append(", DDMTemplateKey=");
16807                    msg.append(DDMTemplateKey);
16808    
16809                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16810    
16811                    throw new NoSuchArticleException(msg.toString());
16812            }
16813    
16814            /**
16815             * Returns the last journal article in the ordered set where classNameId = &#63; and DDMTemplateKey = &#63;.
16816             *
16817             * @param classNameId the class name ID
16818             * @param DDMTemplateKey the d d m template key
16819             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16820             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16821             */
16822            @Override
16823            public JournalArticle fetchByC_DDMTK_Last(long classNameId,
16824                    String DDMTemplateKey,
16825                    OrderByComparator<JournalArticle> orderByComparator) {
16826                    int count = countByC_DDMTK(classNameId, DDMTemplateKey);
16827    
16828                    if (count == 0) {
16829                            return null;
16830                    }
16831    
16832                    List<JournalArticle> list = findByC_DDMTK(classNameId, DDMTemplateKey,
16833                                    count - 1, count, orderByComparator);
16834    
16835                    if (!list.isEmpty()) {
16836                            return list.get(0);
16837                    }
16838    
16839                    return null;
16840            }
16841    
16842            /**
16843             * Returns the journal articles before and after the current journal article in the ordered set where classNameId = &#63; and DDMTemplateKey = &#63;.
16844             *
16845             * @param id the primary key of the current journal article
16846             * @param classNameId the class name ID
16847             * @param DDMTemplateKey the d d m template key
16848             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16849             * @return the previous, current, and next journal article
16850             * @throws NoSuchArticleException if a journal article with the primary key could not be found
16851             */
16852            @Override
16853            public JournalArticle[] findByC_DDMTK_PrevAndNext(long id,
16854                    long classNameId, String DDMTemplateKey,
16855                    OrderByComparator<JournalArticle> orderByComparator)
16856                    throws NoSuchArticleException {
16857                    JournalArticle journalArticle = findByPrimaryKey(id);
16858    
16859                    Session session = null;
16860    
16861                    try {
16862                            session = openSession();
16863    
16864                            JournalArticle[] array = new JournalArticleImpl[3];
16865    
16866                            array[0] = getByC_DDMTK_PrevAndNext(session, journalArticle,
16867                                            classNameId, DDMTemplateKey, orderByComparator, true);
16868    
16869                            array[1] = journalArticle;
16870    
16871                            array[2] = getByC_DDMTK_PrevAndNext(session, journalArticle,
16872                                            classNameId, DDMTemplateKey, orderByComparator, false);
16873    
16874                            return array;
16875                    }
16876                    catch (Exception e) {
16877                            throw processException(e);
16878                    }
16879                    finally {
16880                            closeSession(session);
16881                    }
16882            }
16883    
16884            protected JournalArticle getByC_DDMTK_PrevAndNext(Session session,
16885                    JournalArticle journalArticle, long classNameId, String DDMTemplateKey,
16886                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
16887                    StringBundler query = null;
16888    
16889                    if (orderByComparator != null) {
16890                            query = new StringBundler(6 +
16891                                            (orderByComparator.getOrderByFields().length * 6));
16892                    }
16893                    else {
16894                            query = new StringBundler(3);
16895                    }
16896    
16897                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16898    
16899                    query.append(_FINDER_COLUMN_C_DDMTK_CLASSNAMEID_2);
16900    
16901                    boolean bindDDMTemplateKey = false;
16902    
16903                    if (DDMTemplateKey == null) {
16904                            query.append(_FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_1);
16905                    }
16906                    else if (DDMTemplateKey.equals(StringPool.BLANK)) {
16907                            query.append(_FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_3);
16908                    }
16909                    else {
16910                            bindDDMTemplateKey = true;
16911    
16912                            query.append(_FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_2);
16913                    }
16914    
16915                    if (orderByComparator != null) {
16916                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16917    
16918                            if (orderByConditionFields.length > 0) {
16919                                    query.append(WHERE_AND);
16920                            }
16921    
16922                            for (int i = 0; i < orderByConditionFields.length; i++) {
16923                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16924                                    query.append(orderByConditionFields[i]);
16925    
16926                                    if ((i + 1) < orderByConditionFields.length) {
16927                                            if (orderByComparator.isAscending() ^ previous) {
16928                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16929                                            }
16930                                            else {
16931                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16932                                            }
16933                                    }
16934                                    else {
16935                                            if (orderByComparator.isAscending() ^ previous) {
16936                                                    query.append(WHERE_GREATER_THAN);
16937                                            }
16938                                            else {
16939                                                    query.append(WHERE_LESSER_THAN);
16940                                            }
16941                                    }
16942                            }
16943    
16944                            query.append(ORDER_BY_CLAUSE);
16945    
16946                            String[] orderByFields = orderByComparator.getOrderByFields();
16947    
16948                            for (int i = 0; i < orderByFields.length; i++) {
16949                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16950                                    query.append(orderByFields[i]);
16951    
16952                                    if ((i + 1) < orderByFields.length) {
16953                                            if (orderByComparator.isAscending() ^ previous) {
16954                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16955                                            }
16956                                            else {
16957                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16958                                            }
16959                                    }
16960                                    else {
16961                                            if (orderByComparator.isAscending() ^ previous) {
16962                                                    query.append(ORDER_BY_ASC);
16963                                            }
16964                                            else {
16965                                                    query.append(ORDER_BY_DESC);
16966                                            }
16967                                    }
16968                            }
16969                    }
16970                    else {
16971                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16972                    }
16973    
16974                    String sql = query.toString();
16975    
16976                    Query q = session.createQuery(sql);
16977    
16978                    q.setFirstResult(0);
16979                    q.setMaxResults(2);
16980    
16981                    QueryPos qPos = QueryPos.getInstance(q);
16982    
16983                    qPos.add(classNameId);
16984    
16985                    if (bindDDMTemplateKey) {
16986                            qPos.add(DDMTemplateKey);
16987                    }
16988    
16989                    if (orderByComparator != null) {
16990                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16991    
16992                            for (Object value : values) {
16993                                    qPos.add(value);
16994                            }
16995                    }
16996    
16997                    List<JournalArticle> list = q.list();
16998    
16999                    if (list.size() == 2) {
17000                            return list.get(1);
17001                    }
17002                    else {
17003                            return null;
17004                    }
17005            }
17006    
17007            /**
17008             * Removes all the journal articles where classNameId = &#63; and DDMTemplateKey = &#63; from the database.
17009             *
17010             * @param classNameId the class name ID
17011             * @param DDMTemplateKey the d d m template key
17012             */
17013            @Override
17014            public void removeByC_DDMTK(long classNameId, String DDMTemplateKey) {
17015                    for (JournalArticle journalArticle : findByC_DDMTK(classNameId,
17016                                    DDMTemplateKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17017                            remove(journalArticle);
17018                    }
17019            }
17020    
17021            /**
17022             * Returns the number of journal articles where classNameId = &#63; and DDMTemplateKey = &#63;.
17023             *
17024             * @param classNameId the class name ID
17025             * @param DDMTemplateKey the d d m template key
17026             * @return the number of matching journal articles
17027             */
17028            @Override
17029            public int countByC_DDMTK(long classNameId, String DDMTemplateKey) {
17030                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_DDMTK;
17031    
17032                    Object[] finderArgs = new Object[] { classNameId, DDMTemplateKey };
17033    
17034                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17035                                    this);
17036    
17037                    if (count == null) {
17038                            StringBundler query = new StringBundler(3);
17039    
17040                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17041    
17042                            query.append(_FINDER_COLUMN_C_DDMTK_CLASSNAMEID_2);
17043    
17044                            boolean bindDDMTemplateKey = false;
17045    
17046                            if (DDMTemplateKey == null) {
17047                                    query.append(_FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_1);
17048                            }
17049                            else if (DDMTemplateKey.equals(StringPool.BLANK)) {
17050                                    query.append(_FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_3);
17051                            }
17052                            else {
17053                                    bindDDMTemplateKey = true;
17054    
17055                                    query.append(_FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_2);
17056                            }
17057    
17058                            String sql = query.toString();
17059    
17060                            Session session = null;
17061    
17062                            try {
17063                                    session = openSession();
17064    
17065                                    Query q = session.createQuery(sql);
17066    
17067                                    QueryPos qPos = QueryPos.getInstance(q);
17068    
17069                                    qPos.add(classNameId);
17070    
17071                                    if (bindDDMTemplateKey) {
17072                                            qPos.add(DDMTemplateKey);
17073                                    }
17074    
17075                                    count = (Long)q.uniqueResult();
17076    
17077                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17078                            }
17079                            catch (Exception e) {
17080                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17081    
17082                                    throw processException(e);
17083                            }
17084                            finally {
17085                                    closeSession(session);
17086                            }
17087                    }
17088    
17089                    return count.intValue();
17090            }
17091    
17092            private static final String _FINDER_COLUMN_C_DDMTK_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
17093            private static final String _FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_1 = "journalArticle.DDMTemplateKey IS NULL";
17094            private static final String _FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_2 = "journalArticle.DDMTemplateKey = ?";
17095            private static final String _FINDER_COLUMN_C_DDMTK_DDMTEMPLATEKEY_3 = "(journalArticle.DDMTemplateKey IS NULL OR journalArticle.DDMTemplateKey = '')";
17096            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17097                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17098                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17099                            "findByLtD_S",
17100                            new String[] {
17101                                    Date.class.getName(), Integer.class.getName(),
17102                                    
17103                            Integer.class.getName(), Integer.class.getName(),
17104                                    OrderByComparator.class.getName()
17105                            });
17106            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17107                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17108                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
17109                            new String[] { Date.class.getName(), Integer.class.getName() });
17110    
17111            /**
17112             * Returns all the journal articles where displayDate &lt; &#63; and status = &#63;.
17113             *
17114             * @param displayDate the display date
17115             * @param status the status
17116             * @return the matching journal articles
17117             */
17118            @Override
17119            public List<JournalArticle> findByLtD_S(Date displayDate, int status) {
17120                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
17121                            QueryUtil.ALL_POS, null);
17122            }
17123    
17124            /**
17125             * Returns a range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
17126             *
17127             * <p>
17128             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17129             * </p>
17130             *
17131             * @param displayDate the display date
17132             * @param status the status
17133             * @param start the lower bound of the range of journal articles
17134             * @param end the upper bound of the range of journal articles (not inclusive)
17135             * @return the range of matching journal articles
17136             */
17137            @Override
17138            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
17139                    int start, int end) {
17140                    return findByLtD_S(displayDate, status, start, end, null);
17141            }
17142    
17143            /**
17144             * Returns an ordered range of all the journal articles where displayDate &lt; &#63; and status = &#63;.
17145             *
17146             * <p>
17147             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17148             * </p>
17149             *
17150             * @param displayDate the display date
17151             * @param status the status
17152             * @param start the lower bound of the range of journal articles
17153             * @param end the upper bound of the range of journal articles (not inclusive)
17154             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17155             * @return the ordered range of matching journal articles
17156             */
17157            @Override
17158            public List<JournalArticle> findByLtD_S(Date displayDate, int status,
17159                    int start, int end, OrderByComparator<JournalArticle> orderByComparator) {
17160                    boolean pagination = true;
17161                    FinderPath finderPath = null;
17162                    Object[] finderArgs = null;
17163    
17164                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
17165                    finderArgs = new Object[] {
17166                                    displayDate, status,
17167                                    
17168                                    start, end, orderByComparator
17169                            };
17170    
17171                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17172                                    finderArgs, this);
17173    
17174                    if ((list != null) && !list.isEmpty()) {
17175                            for (JournalArticle journalArticle : list) {
17176                                    if ((displayDate.getTime() <= journalArticle.getDisplayDate()
17177                                                                                                                                    .getTime()) ||
17178                                                    (status != journalArticle.getStatus())) {
17179                                            list = null;
17180    
17181                                            break;
17182                                    }
17183                            }
17184                    }
17185    
17186                    if (list == null) {
17187                            StringBundler query = null;
17188    
17189                            if (orderByComparator != null) {
17190                                    query = new StringBundler(4 +
17191                                                    (orderByComparator.getOrderByFields().length * 3));
17192                            }
17193                            else {
17194                                    query = new StringBundler(4);
17195                            }
17196    
17197                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17198    
17199                            boolean bindDisplayDate = false;
17200    
17201                            if (displayDate == null) {
17202                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17203                            }
17204                            else {
17205                                    bindDisplayDate = true;
17206    
17207                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17208                            }
17209    
17210                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17211    
17212                            if (orderByComparator != null) {
17213                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17214                                            orderByComparator);
17215                            }
17216                            else
17217                             if (pagination) {
17218                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17219                            }
17220    
17221                            String sql = query.toString();
17222    
17223                            Session session = null;
17224    
17225                            try {
17226                                    session = openSession();
17227    
17228                                    Query q = session.createQuery(sql);
17229    
17230                                    QueryPos qPos = QueryPos.getInstance(q);
17231    
17232                                    if (bindDisplayDate) {
17233                                            qPos.add(new Timestamp(displayDate.getTime()));
17234                                    }
17235    
17236                                    qPos.add(status);
17237    
17238                                    if (!pagination) {
17239                                            list = (List<JournalArticle>)QueryUtil.list(q,
17240                                                            getDialect(), start, end, false);
17241    
17242                                            Collections.sort(list);
17243    
17244                                            list = Collections.unmodifiableList(list);
17245                                    }
17246                                    else {
17247                                            list = (List<JournalArticle>)QueryUtil.list(q,
17248                                                            getDialect(), start, end);
17249                                    }
17250    
17251                                    cacheResult(list);
17252    
17253                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17254                            }
17255                            catch (Exception e) {
17256                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17257    
17258                                    throw processException(e);
17259                            }
17260                            finally {
17261                                    closeSession(session);
17262                            }
17263                    }
17264    
17265                    return list;
17266            }
17267    
17268            /**
17269             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17270             *
17271             * @param displayDate the display date
17272             * @param status the status
17273             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17274             * @return the first matching journal article
17275             * @throws NoSuchArticleException if a matching journal article could not be found
17276             */
17277            @Override
17278            public JournalArticle findByLtD_S_First(Date displayDate, int status,
17279                    OrderByComparator<JournalArticle> orderByComparator)
17280                    throws NoSuchArticleException {
17281                    JournalArticle journalArticle = fetchByLtD_S_First(displayDate, status,
17282                                    orderByComparator);
17283    
17284                    if (journalArticle != null) {
17285                            return journalArticle;
17286                    }
17287    
17288                    StringBundler msg = new StringBundler(6);
17289    
17290                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17291    
17292                    msg.append("displayDate=");
17293                    msg.append(displayDate);
17294    
17295                    msg.append(", status=");
17296                    msg.append(status);
17297    
17298                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17299    
17300                    throw new NoSuchArticleException(msg.toString());
17301            }
17302    
17303            /**
17304             * Returns the first journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17305             *
17306             * @param displayDate the display date
17307             * @param status the status
17308             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17309             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17310             */
17311            @Override
17312            public JournalArticle fetchByLtD_S_First(Date displayDate, int status,
17313                    OrderByComparator<JournalArticle> orderByComparator) {
17314                    List<JournalArticle> list = findByLtD_S(displayDate, status, 0, 1,
17315                                    orderByComparator);
17316    
17317                    if (!list.isEmpty()) {
17318                            return list.get(0);
17319                    }
17320    
17321                    return null;
17322            }
17323    
17324            /**
17325             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17326             *
17327             * @param displayDate the display date
17328             * @param status the status
17329             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17330             * @return the last matching journal article
17331             * @throws NoSuchArticleException if a matching journal article could not be found
17332             */
17333            @Override
17334            public JournalArticle findByLtD_S_Last(Date displayDate, int status,
17335                    OrderByComparator<JournalArticle> orderByComparator)
17336                    throws NoSuchArticleException {
17337                    JournalArticle journalArticle = fetchByLtD_S_Last(displayDate, status,
17338                                    orderByComparator);
17339    
17340                    if (journalArticle != null) {
17341                            return journalArticle;
17342                    }
17343    
17344                    StringBundler msg = new StringBundler(6);
17345    
17346                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17347    
17348                    msg.append("displayDate=");
17349                    msg.append(displayDate);
17350    
17351                    msg.append(", status=");
17352                    msg.append(status);
17353    
17354                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17355    
17356                    throw new NoSuchArticleException(msg.toString());
17357            }
17358    
17359            /**
17360             * Returns the last journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17361             *
17362             * @param displayDate the display date
17363             * @param status the status
17364             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17365             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17366             */
17367            @Override
17368            public JournalArticle fetchByLtD_S_Last(Date displayDate, int status,
17369                    OrderByComparator<JournalArticle> orderByComparator) {
17370                    int count = countByLtD_S(displayDate, status);
17371    
17372                    if (count == 0) {
17373                            return null;
17374                    }
17375    
17376                    List<JournalArticle> list = findByLtD_S(displayDate, status, count - 1,
17377                                    count, orderByComparator);
17378    
17379                    if (!list.isEmpty()) {
17380                            return list.get(0);
17381                    }
17382    
17383                    return null;
17384            }
17385    
17386            /**
17387             * Returns the journal articles before and after the current journal article in the ordered set where displayDate &lt; &#63; and status = &#63;.
17388             *
17389             * @param id the primary key of the current journal article
17390             * @param displayDate the display date
17391             * @param status the status
17392             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17393             * @return the previous, current, and next journal article
17394             * @throws NoSuchArticleException if a journal article with the primary key could not be found
17395             */
17396            @Override
17397            public JournalArticle[] findByLtD_S_PrevAndNext(long id, Date displayDate,
17398                    int status, OrderByComparator<JournalArticle> orderByComparator)
17399                    throws NoSuchArticleException {
17400                    JournalArticle journalArticle = findByPrimaryKey(id);
17401    
17402                    Session session = null;
17403    
17404                    try {
17405                            session = openSession();
17406    
17407                            JournalArticle[] array = new JournalArticleImpl[3];
17408    
17409                            array[0] = getByLtD_S_PrevAndNext(session, journalArticle,
17410                                            displayDate, status, orderByComparator, true);
17411    
17412                            array[1] = journalArticle;
17413    
17414                            array[2] = getByLtD_S_PrevAndNext(session, journalArticle,
17415                                            displayDate, status, orderByComparator, false);
17416    
17417                            return array;
17418                    }
17419                    catch (Exception e) {
17420                            throw processException(e);
17421                    }
17422                    finally {
17423                            closeSession(session);
17424                    }
17425            }
17426    
17427            protected JournalArticle getByLtD_S_PrevAndNext(Session session,
17428                    JournalArticle journalArticle, Date displayDate, int status,
17429                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
17430                    StringBundler query = null;
17431    
17432                    if (orderByComparator != null) {
17433                            query = new StringBundler(6 +
17434                                            (orderByComparator.getOrderByFields().length * 6));
17435                    }
17436                    else {
17437                            query = new StringBundler(3);
17438                    }
17439    
17440                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17441    
17442                    boolean bindDisplayDate = false;
17443    
17444                    if (displayDate == null) {
17445                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17446                    }
17447                    else {
17448                            bindDisplayDate = true;
17449    
17450                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17451                    }
17452    
17453                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17454    
17455                    if (orderByComparator != null) {
17456                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17457    
17458                            if (orderByConditionFields.length > 0) {
17459                                    query.append(WHERE_AND);
17460                            }
17461    
17462                            for (int i = 0; i < orderByConditionFields.length; i++) {
17463                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17464                                    query.append(orderByConditionFields[i]);
17465    
17466                                    if ((i + 1) < orderByConditionFields.length) {
17467                                            if (orderByComparator.isAscending() ^ previous) {
17468                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17469                                            }
17470                                            else {
17471                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17472                                            }
17473                                    }
17474                                    else {
17475                                            if (orderByComparator.isAscending() ^ previous) {
17476                                                    query.append(WHERE_GREATER_THAN);
17477                                            }
17478                                            else {
17479                                                    query.append(WHERE_LESSER_THAN);
17480                                            }
17481                                    }
17482                            }
17483    
17484                            query.append(ORDER_BY_CLAUSE);
17485    
17486                            String[] orderByFields = orderByComparator.getOrderByFields();
17487    
17488                            for (int i = 0; i < orderByFields.length; i++) {
17489                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17490                                    query.append(orderByFields[i]);
17491    
17492                                    if ((i + 1) < orderByFields.length) {
17493                                            if (orderByComparator.isAscending() ^ previous) {
17494                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17495                                            }
17496                                            else {
17497                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17498                                            }
17499                                    }
17500                                    else {
17501                                            if (orderByComparator.isAscending() ^ previous) {
17502                                                    query.append(ORDER_BY_ASC);
17503                                            }
17504                                            else {
17505                                                    query.append(ORDER_BY_DESC);
17506                                            }
17507                                    }
17508                            }
17509                    }
17510                    else {
17511                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17512                    }
17513    
17514                    String sql = query.toString();
17515    
17516                    Query q = session.createQuery(sql);
17517    
17518                    q.setFirstResult(0);
17519                    q.setMaxResults(2);
17520    
17521                    QueryPos qPos = QueryPos.getInstance(q);
17522    
17523                    if (bindDisplayDate) {
17524                            qPos.add(new Timestamp(displayDate.getTime()));
17525                    }
17526    
17527                    qPos.add(status);
17528    
17529                    if (orderByComparator != null) {
17530                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17531    
17532                            for (Object value : values) {
17533                                    qPos.add(value);
17534                            }
17535                    }
17536    
17537                    List<JournalArticle> list = q.list();
17538    
17539                    if (list.size() == 2) {
17540                            return list.get(1);
17541                    }
17542                    else {
17543                            return null;
17544                    }
17545            }
17546    
17547            /**
17548             * Removes all the journal articles where displayDate &lt; &#63; and status = &#63; from the database.
17549             *
17550             * @param displayDate the display date
17551             * @param status the status
17552             */
17553            @Override
17554            public void removeByLtD_S(Date displayDate, int status) {
17555                    for (JournalArticle journalArticle : findByLtD_S(displayDate, status,
17556                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17557                            remove(journalArticle);
17558                    }
17559            }
17560    
17561            /**
17562             * Returns the number of journal articles where displayDate &lt; &#63; and status = &#63;.
17563             *
17564             * @param displayDate the display date
17565             * @param status the status
17566             * @return the number of matching journal articles
17567             */
17568            @Override
17569            public int countByLtD_S(Date displayDate, int status) {
17570                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
17571    
17572                    Object[] finderArgs = new Object[] { displayDate, status };
17573    
17574                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17575                                    this);
17576    
17577                    if (count == null) {
17578                            StringBundler query = new StringBundler(3);
17579    
17580                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17581    
17582                            boolean bindDisplayDate = false;
17583    
17584                            if (displayDate == null) {
17585                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
17586                            }
17587                            else {
17588                                    bindDisplayDate = true;
17589    
17590                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
17591                            }
17592    
17593                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
17594    
17595                            String sql = query.toString();
17596    
17597                            Session session = null;
17598    
17599                            try {
17600                                    session = openSession();
17601    
17602                                    Query q = session.createQuery(sql);
17603    
17604                                    QueryPos qPos = QueryPos.getInstance(q);
17605    
17606                                    if (bindDisplayDate) {
17607                                            qPos.add(new Timestamp(displayDate.getTime()));
17608                                    }
17609    
17610                                    qPos.add(status);
17611    
17612                                    count = (Long)q.uniqueResult();
17613    
17614                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17615                            }
17616                            catch (Exception e) {
17617                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17618    
17619                                    throw processException(e);
17620                            }
17621                            finally {
17622                                    closeSession(session);
17623                            }
17624                    }
17625    
17626                    return count.intValue();
17627            }
17628    
17629            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "journalArticle.displayDate < NULL AND ";
17630            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "journalArticle.displayDate < ? AND ";
17631            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "journalArticle.status = ?";
17632            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17633                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17634                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
17635                            "findByR_I_S",
17636                            new String[] {
17637                                    Long.class.getName(), Boolean.class.getName(),
17638                                    Integer.class.getName(),
17639                                    
17640                            Integer.class.getName(), Integer.class.getName(),
17641                                    OrderByComparator.class.getName()
17642                            });
17643            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17644                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
17645                            JournalArticleImpl.class,
17646                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_I_S",
17647                            new String[] {
17648                                    Long.class.getName(), Boolean.class.getName(),
17649                                    Integer.class.getName()
17650                            },
17651                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
17652                            JournalArticleModelImpl.INDEXABLE_COLUMN_BITMASK |
17653                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
17654                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
17655                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
17656            public static final FinderPath FINDER_PATH_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17657                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17658                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_I_S",
17659                            new String[] {
17660                                    Long.class.getName(), Boolean.class.getName(),
17661                                    Integer.class.getName()
17662                            });
17663            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
17664                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
17665                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByR_I_S",
17666                            new String[] {
17667                                    Long.class.getName(), Boolean.class.getName(),
17668                                    Integer.class.getName()
17669                            });
17670    
17671            /**
17672             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17673             *
17674             * @param resourcePrimKey the resource prim key
17675             * @param indexable the indexable
17676             * @param status the status
17677             * @return the matching journal articles
17678             */
17679            @Override
17680            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17681                    boolean indexable, int status) {
17682                    return findByR_I_S(resourcePrimKey, indexable, status,
17683                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17684            }
17685    
17686            /**
17687             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17688             *
17689             * <p>
17690             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17691             * </p>
17692             *
17693             * @param resourcePrimKey the resource prim key
17694             * @param indexable the indexable
17695             * @param status the status
17696             * @param start the lower bound of the range of journal articles
17697             * @param end the upper bound of the range of journal articles (not inclusive)
17698             * @return the range of matching journal articles
17699             */
17700            @Override
17701            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17702                    boolean indexable, int status, int start, int end) {
17703                    return findByR_I_S(resourcePrimKey, indexable, status, start, end, null);
17704            }
17705    
17706            /**
17707             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17708             *
17709             * <p>
17710             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17711             * </p>
17712             *
17713             * @param resourcePrimKey the resource prim key
17714             * @param indexable the indexable
17715             * @param status the status
17716             * @param start the lower bound of the range of journal articles
17717             * @param end the upper bound of the range of journal articles (not inclusive)
17718             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17719             * @return the ordered range of matching journal articles
17720             */
17721            @Override
17722            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
17723                    boolean indexable, int status, int start, int end,
17724                    OrderByComparator<JournalArticle> orderByComparator) {
17725                    boolean pagination = true;
17726                    FinderPath finderPath = null;
17727                    Object[] finderArgs = null;
17728    
17729                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17730                                    (orderByComparator == null)) {
17731                            pagination = false;
17732                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S;
17733                            finderArgs = new Object[] { resourcePrimKey, indexable, status };
17734                    }
17735                    else {
17736                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S;
17737                            finderArgs = new Object[] {
17738                                            resourcePrimKey, indexable, status,
17739                                            
17740                                            start, end, orderByComparator
17741                                    };
17742                    }
17743    
17744                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17745                                    finderArgs, this);
17746    
17747                    if ((list != null) && !list.isEmpty()) {
17748                            for (JournalArticle journalArticle : list) {
17749                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
17750                                                    (indexable != journalArticle.getIndexable()) ||
17751                                                    (status != journalArticle.getStatus())) {
17752                                            list = null;
17753    
17754                                            break;
17755                                    }
17756                            }
17757                    }
17758    
17759                    if (list == null) {
17760                            StringBundler query = null;
17761    
17762                            if (orderByComparator != null) {
17763                                    query = new StringBundler(5 +
17764                                                    (orderByComparator.getOrderByFields().length * 3));
17765                            }
17766                            else {
17767                                    query = new StringBundler(5);
17768                            }
17769    
17770                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17771    
17772                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
17773    
17774                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
17775    
17776                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
17777    
17778                            if (orderByComparator != null) {
17779                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17780                                            orderByComparator);
17781                            }
17782                            else
17783                             if (pagination) {
17784                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17785                            }
17786    
17787                            String sql = query.toString();
17788    
17789                            Session session = null;
17790    
17791                            try {
17792                                    session = openSession();
17793    
17794                                    Query q = session.createQuery(sql);
17795    
17796                                    QueryPos qPos = QueryPos.getInstance(q);
17797    
17798                                    qPos.add(resourcePrimKey);
17799    
17800                                    qPos.add(indexable);
17801    
17802                                    qPos.add(status);
17803    
17804                                    if (!pagination) {
17805                                            list = (List<JournalArticle>)QueryUtil.list(q,
17806                                                            getDialect(), start, end, false);
17807    
17808                                            Collections.sort(list);
17809    
17810                                            list = Collections.unmodifiableList(list);
17811                                    }
17812                                    else {
17813                                            list = (List<JournalArticle>)QueryUtil.list(q,
17814                                                            getDialect(), start, end);
17815                                    }
17816    
17817                                    cacheResult(list);
17818    
17819                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17820                            }
17821                            catch (Exception e) {
17822                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17823    
17824                                    throw processException(e);
17825                            }
17826                            finally {
17827                                    closeSession(session);
17828                            }
17829                    }
17830    
17831                    return list;
17832            }
17833    
17834            /**
17835             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17836             *
17837             * @param resourcePrimKey the resource prim key
17838             * @param indexable the indexable
17839             * @param status the status
17840             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17841             * @return the first matching journal article
17842             * @throws NoSuchArticleException if a matching journal article could not be found
17843             */
17844            @Override
17845            public JournalArticle findByR_I_S_First(long resourcePrimKey,
17846                    boolean indexable, int status,
17847                    OrderByComparator<JournalArticle> orderByComparator)
17848                    throws NoSuchArticleException {
17849                    JournalArticle journalArticle = fetchByR_I_S_First(resourcePrimKey,
17850                                    indexable, status, orderByComparator);
17851    
17852                    if (journalArticle != null) {
17853                            return journalArticle;
17854                    }
17855    
17856                    StringBundler msg = new StringBundler(8);
17857    
17858                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17859    
17860                    msg.append("resourcePrimKey=");
17861                    msg.append(resourcePrimKey);
17862    
17863                    msg.append(", indexable=");
17864                    msg.append(indexable);
17865    
17866                    msg.append(", status=");
17867                    msg.append(status);
17868    
17869                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17870    
17871                    throw new NoSuchArticleException(msg.toString());
17872            }
17873    
17874            /**
17875             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17876             *
17877             * @param resourcePrimKey the resource prim key
17878             * @param indexable the indexable
17879             * @param status the status
17880             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17881             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17882             */
17883            @Override
17884            public JournalArticle fetchByR_I_S_First(long resourcePrimKey,
17885                    boolean indexable, int status,
17886                    OrderByComparator<JournalArticle> orderByComparator) {
17887                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
17888                                    status, 0, 1, orderByComparator);
17889    
17890                    if (!list.isEmpty()) {
17891                            return list.get(0);
17892                    }
17893    
17894                    return null;
17895            }
17896    
17897            /**
17898             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17899             *
17900             * @param resourcePrimKey the resource prim key
17901             * @param indexable the indexable
17902             * @param status the status
17903             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17904             * @return the last matching journal article
17905             * @throws NoSuchArticleException if a matching journal article could not be found
17906             */
17907            @Override
17908            public JournalArticle findByR_I_S_Last(long resourcePrimKey,
17909                    boolean indexable, int status,
17910                    OrderByComparator<JournalArticle> orderByComparator)
17911                    throws NoSuchArticleException {
17912                    JournalArticle journalArticle = fetchByR_I_S_Last(resourcePrimKey,
17913                                    indexable, status, orderByComparator);
17914    
17915                    if (journalArticle != null) {
17916                            return journalArticle;
17917                    }
17918    
17919                    StringBundler msg = new StringBundler(8);
17920    
17921                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17922    
17923                    msg.append("resourcePrimKey=");
17924                    msg.append(resourcePrimKey);
17925    
17926                    msg.append(", indexable=");
17927                    msg.append(indexable);
17928    
17929                    msg.append(", status=");
17930                    msg.append(status);
17931    
17932                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17933    
17934                    throw new NoSuchArticleException(msg.toString());
17935            }
17936    
17937            /**
17938             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17939             *
17940             * @param resourcePrimKey the resource prim key
17941             * @param indexable the indexable
17942             * @param status the status
17943             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17944             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17945             */
17946            @Override
17947            public JournalArticle fetchByR_I_S_Last(long resourcePrimKey,
17948                    boolean indexable, int status,
17949                    OrderByComparator<JournalArticle> orderByComparator) {
17950                    int count = countByR_I_S(resourcePrimKey, indexable, status);
17951    
17952                    if (count == 0) {
17953                            return null;
17954                    }
17955    
17956                    List<JournalArticle> list = findByR_I_S(resourcePrimKey, indexable,
17957                                    status, count - 1, count, orderByComparator);
17958    
17959                    if (!list.isEmpty()) {
17960                            return list.get(0);
17961                    }
17962    
17963                    return null;
17964            }
17965    
17966            /**
17967             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
17968             *
17969             * @param id the primary key of the current journal article
17970             * @param resourcePrimKey the resource prim key
17971             * @param indexable the indexable
17972             * @param status the status
17973             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17974             * @return the previous, current, and next journal article
17975             * @throws NoSuchArticleException if a journal article with the primary key could not be found
17976             */
17977            @Override
17978            public JournalArticle[] findByR_I_S_PrevAndNext(long id,
17979                    long resourcePrimKey, boolean indexable, int status,
17980                    OrderByComparator<JournalArticle> orderByComparator)
17981                    throws NoSuchArticleException {
17982                    JournalArticle journalArticle = findByPrimaryKey(id);
17983    
17984                    Session session = null;
17985    
17986                    try {
17987                            session = openSession();
17988    
17989                            JournalArticle[] array = new JournalArticleImpl[3];
17990    
17991                            array[0] = getByR_I_S_PrevAndNext(session, journalArticle,
17992                                            resourcePrimKey, indexable, status, orderByComparator, true);
17993    
17994                            array[1] = journalArticle;
17995    
17996                            array[2] = getByR_I_S_PrevAndNext(session, journalArticle,
17997                                            resourcePrimKey, indexable, status, orderByComparator, false);
17998    
17999                            return array;
18000                    }
18001                    catch (Exception e) {
18002                            throw processException(e);
18003                    }
18004                    finally {
18005                            closeSession(session);
18006                    }
18007            }
18008    
18009            protected JournalArticle getByR_I_S_PrevAndNext(Session session,
18010                    JournalArticle journalArticle, long resourcePrimKey, boolean indexable,
18011                    int status, OrderByComparator<JournalArticle> orderByComparator,
18012                    boolean previous) {
18013                    StringBundler query = null;
18014    
18015                    if (orderByComparator != null) {
18016                            query = new StringBundler(6 +
18017                                            (orderByComparator.getOrderByFields().length * 6));
18018                    }
18019                    else {
18020                            query = new StringBundler(3);
18021                    }
18022    
18023                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18024    
18025                    query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18026    
18027                    query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18028    
18029                    query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
18030    
18031                    if (orderByComparator != null) {
18032                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18033    
18034                            if (orderByConditionFields.length > 0) {
18035                                    query.append(WHERE_AND);
18036                            }
18037    
18038                            for (int i = 0; i < orderByConditionFields.length; i++) {
18039                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18040                                    query.append(orderByConditionFields[i]);
18041    
18042                                    if ((i + 1) < orderByConditionFields.length) {
18043                                            if (orderByComparator.isAscending() ^ previous) {
18044                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18045                                            }
18046                                            else {
18047                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18048                                            }
18049                                    }
18050                                    else {
18051                                            if (orderByComparator.isAscending() ^ previous) {
18052                                                    query.append(WHERE_GREATER_THAN);
18053                                            }
18054                                            else {
18055                                                    query.append(WHERE_LESSER_THAN);
18056                                            }
18057                                    }
18058                            }
18059    
18060                            query.append(ORDER_BY_CLAUSE);
18061    
18062                            String[] orderByFields = orderByComparator.getOrderByFields();
18063    
18064                            for (int i = 0; i < orderByFields.length; i++) {
18065                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18066                                    query.append(orderByFields[i]);
18067    
18068                                    if ((i + 1) < orderByFields.length) {
18069                                            if (orderByComparator.isAscending() ^ previous) {
18070                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18071                                            }
18072                                            else {
18073                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18074                                            }
18075                                    }
18076                                    else {
18077                                            if (orderByComparator.isAscending() ^ previous) {
18078                                                    query.append(ORDER_BY_ASC);
18079                                            }
18080                                            else {
18081                                                    query.append(ORDER_BY_DESC);
18082                                            }
18083                                    }
18084                            }
18085                    }
18086                    else {
18087                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18088                    }
18089    
18090                    String sql = query.toString();
18091    
18092                    Query q = session.createQuery(sql);
18093    
18094                    q.setFirstResult(0);
18095                    q.setMaxResults(2);
18096    
18097                    QueryPos qPos = QueryPos.getInstance(q);
18098    
18099                    qPos.add(resourcePrimKey);
18100    
18101                    qPos.add(indexable);
18102    
18103                    qPos.add(status);
18104    
18105                    if (orderByComparator != null) {
18106                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18107    
18108                            for (Object value : values) {
18109                                    qPos.add(value);
18110                            }
18111                    }
18112    
18113                    List<JournalArticle> list = q.list();
18114    
18115                    if (list.size() == 2) {
18116                            return list.get(1);
18117                    }
18118                    else {
18119                            return null;
18120                    }
18121            }
18122    
18123            /**
18124             * Returns all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18125             *
18126             * <p>
18127             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18128             * </p>
18129             *
18130             * @param resourcePrimKey the resource prim key
18131             * @param indexable the indexable
18132             * @param statuses the statuses
18133             * @return the matching journal articles
18134             */
18135            @Override
18136            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18137                    boolean indexable, int[] statuses) {
18138                    return findByR_I_S(resourcePrimKey, indexable, statuses,
18139                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18140            }
18141    
18142            /**
18143             * Returns a range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18144             *
18145             * <p>
18146             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18147             * </p>
18148             *
18149             * @param resourcePrimKey the resource prim key
18150             * @param indexable the indexable
18151             * @param statuses the statuses
18152             * @param start the lower bound of the range of journal articles
18153             * @param end the upper bound of the range of journal articles (not inclusive)
18154             * @return the range of matching journal articles
18155             */
18156            @Override
18157            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18158                    boolean indexable, int[] statuses, int start, int end) {
18159                    return findByR_I_S(resourcePrimKey, indexable, statuses, start, end,
18160                            null);
18161            }
18162    
18163            /**
18164             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18165             *
18166             * <p>
18167             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18168             * </p>
18169             *
18170             * @param resourcePrimKey the resource prim key
18171             * @param indexable the indexable
18172             * @param statuses the statuses
18173             * @param start the lower bound of the range of journal articles
18174             * @param end the upper bound of the range of journal articles (not inclusive)
18175             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18176             * @return the ordered range of matching journal articles
18177             */
18178            @Override
18179            public List<JournalArticle> findByR_I_S(long resourcePrimKey,
18180                    boolean indexable, int[] statuses, int start, int end,
18181                    OrderByComparator<JournalArticle> orderByComparator) {
18182                    if (statuses == null) {
18183                            statuses = new int[0];
18184                    }
18185                    else {
18186                            statuses = ArrayUtil.unique(statuses);
18187                    }
18188    
18189                    if (statuses.length == 1) {
18190                            return findByR_I_S(resourcePrimKey, indexable, statuses[0], start,
18191                                    end, orderByComparator);
18192                    }
18193    
18194                    boolean pagination = true;
18195                    Object[] finderArgs = null;
18196    
18197                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18198                                    (orderByComparator == null)) {
18199                            pagination = false;
18200                            finderArgs = new Object[] {
18201                                            resourcePrimKey, indexable, StringUtil.merge(statuses)
18202                                    };
18203                    }
18204                    else {
18205                            finderArgs = new Object[] {
18206                                            resourcePrimKey, indexable, StringUtil.merge(statuses),
18207                                            
18208                                            start, end, orderByComparator
18209                                    };
18210                    }
18211    
18212                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18213                                    finderArgs, this);
18214    
18215                    if ((list != null) && !list.isEmpty()) {
18216                            for (JournalArticle journalArticle : list) {
18217                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
18218                                                    (indexable != journalArticle.getIndexable()) ||
18219                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
18220                                            list = null;
18221    
18222                                            break;
18223                                    }
18224                            }
18225                    }
18226    
18227                    if (list == null) {
18228                            StringBundler query = new StringBundler();
18229    
18230                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18231    
18232                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18233    
18234                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18235    
18236                            if (statuses.length > 0) {
18237                                    query.append(StringPool.OPEN_PARENTHESIS);
18238    
18239                                    query.append(_FINDER_COLUMN_R_I_S_STATUS_7);
18240    
18241                                    query.append(StringUtil.merge(statuses));
18242    
18243                                    query.append(StringPool.CLOSE_PARENTHESIS);
18244    
18245                                    query.append(StringPool.CLOSE_PARENTHESIS);
18246                            }
18247    
18248                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
18249                                                    1)), query.index() - 1);
18250    
18251                            if (orderByComparator != null) {
18252                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18253                                            orderByComparator);
18254                            }
18255                            else
18256                             if (pagination) {
18257                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18258                            }
18259    
18260                            String sql = query.toString();
18261    
18262                            Session session = null;
18263    
18264                            try {
18265                                    session = openSession();
18266    
18267                                    Query q = session.createQuery(sql);
18268    
18269                                    QueryPos qPos = QueryPos.getInstance(q);
18270    
18271                                    qPos.add(resourcePrimKey);
18272    
18273                                    qPos.add(indexable);
18274    
18275                                    if (!pagination) {
18276                                            list = (List<JournalArticle>)QueryUtil.list(q,
18277                                                            getDialect(), start, end, false);
18278    
18279                                            Collections.sort(list);
18280    
18281                                            list = Collections.unmodifiableList(list);
18282                                    }
18283                                    else {
18284                                            list = (List<JournalArticle>)QueryUtil.list(q,
18285                                                            getDialect(), start, end);
18286                                    }
18287    
18288                                    cacheResult(list);
18289    
18290                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18291                                            finderArgs, list);
18292                            }
18293                            catch (Exception e) {
18294                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_R_I_S,
18295                                            finderArgs);
18296    
18297                                    throw processException(e);
18298                            }
18299                            finally {
18300                                    closeSession(session);
18301                            }
18302                    }
18303    
18304                    return list;
18305            }
18306    
18307            /**
18308             * Removes all the journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63; from the database.
18309             *
18310             * @param resourcePrimKey the resource prim key
18311             * @param indexable the indexable
18312             * @param status the status
18313             */
18314            @Override
18315            public void removeByR_I_S(long resourcePrimKey, boolean indexable,
18316                    int status) {
18317                    for (JournalArticle journalArticle : findByR_I_S(resourcePrimKey,
18318                                    indexable, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18319                            remove(journalArticle);
18320                    }
18321            }
18322    
18323            /**
18324             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = &#63;.
18325             *
18326             * @param resourcePrimKey the resource prim key
18327             * @param indexable the indexable
18328             * @param status the status
18329             * @return the number of matching journal articles
18330             */
18331            @Override
18332            public int countByR_I_S(long resourcePrimKey, boolean indexable, int status) {
18333                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_I_S;
18334    
18335                    Object[] finderArgs = new Object[] { resourcePrimKey, indexable, status };
18336    
18337                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
18338                                    this);
18339    
18340                    if (count == null) {
18341                            StringBundler query = new StringBundler(4);
18342    
18343                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18344    
18345                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18346    
18347                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18348    
18349                            query.append(_FINDER_COLUMN_R_I_S_STATUS_2);
18350    
18351                            String sql = query.toString();
18352    
18353                            Session session = null;
18354    
18355                            try {
18356                                    session = openSession();
18357    
18358                                    Query q = session.createQuery(sql);
18359    
18360                                    QueryPos qPos = QueryPos.getInstance(q);
18361    
18362                                    qPos.add(resourcePrimKey);
18363    
18364                                    qPos.add(indexable);
18365    
18366                                    qPos.add(status);
18367    
18368                                    count = (Long)q.uniqueResult();
18369    
18370                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
18371                            }
18372                            catch (Exception e) {
18373                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18374    
18375                                    throw processException(e);
18376                            }
18377                            finally {
18378                                    closeSession(session);
18379                            }
18380                    }
18381    
18382                    return count.intValue();
18383            }
18384    
18385            /**
18386             * Returns the number of journal articles where resourcePrimKey = &#63; and indexable = &#63; and status = any &#63;.
18387             *
18388             * @param resourcePrimKey the resource prim key
18389             * @param indexable the indexable
18390             * @param statuses the statuses
18391             * @return the number of matching journal articles
18392             */
18393            @Override
18394            public int countByR_I_S(long resourcePrimKey, boolean indexable,
18395                    int[] statuses) {
18396                    if (statuses == null) {
18397                            statuses = new int[0];
18398                    }
18399                    else {
18400                            statuses = ArrayUtil.unique(statuses);
18401                    }
18402    
18403                    Object[] finderArgs = new Object[] {
18404                                    resourcePrimKey, indexable, StringUtil.merge(statuses)
18405                            };
18406    
18407                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18408                                    finderArgs, this);
18409    
18410                    if (count == null) {
18411                            StringBundler query = new StringBundler();
18412    
18413                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18414    
18415                            query.append(_FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2);
18416    
18417                            query.append(_FINDER_COLUMN_R_I_S_INDEXABLE_2);
18418    
18419                            if (statuses.length > 0) {
18420                                    query.append(StringPool.OPEN_PARENTHESIS);
18421    
18422                                    query.append(_FINDER_COLUMN_R_I_S_STATUS_7);
18423    
18424                                    query.append(StringUtil.merge(statuses));
18425    
18426                                    query.append(StringPool.CLOSE_PARENTHESIS);
18427    
18428                                    query.append(StringPool.CLOSE_PARENTHESIS);
18429                            }
18430    
18431                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
18432                                                    1)), query.index() - 1);
18433    
18434                            String sql = query.toString();
18435    
18436                            Session session = null;
18437    
18438                            try {
18439                                    session = openSession();
18440    
18441                                    Query q = session.createQuery(sql);
18442    
18443                                    QueryPos qPos = QueryPos.getInstance(q);
18444    
18445                                    qPos.add(resourcePrimKey);
18446    
18447                                    qPos.add(indexable);
18448    
18449                                    count = (Long)q.uniqueResult();
18450    
18451                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18452                                            finderArgs, count);
18453                            }
18454                            catch (Exception e) {
18455                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_R_I_S,
18456                                            finderArgs);
18457    
18458                                    throw processException(e);
18459                            }
18460                            finally {
18461                                    closeSession(session);
18462                            }
18463                    }
18464    
18465                    return count.intValue();
18466            }
18467    
18468            private static final String _FINDER_COLUMN_R_I_S_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
18469            private static final String _FINDER_COLUMN_R_I_S_INDEXABLE_2 = "journalArticle.indexable = ? AND ";
18470            private static final String _FINDER_COLUMN_R_I_S_STATUS_2 = "journalArticle.status = ?";
18471            private static final String _FINDER_COLUMN_R_I_S_STATUS_7 = "journalArticle.status IN (";
18472            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18473                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18474                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
18475                            "findByG_U_C",
18476                            new String[] {
18477                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
18478                                    
18479                            Integer.class.getName(), Integer.class.getName(),
18480                                    OrderByComparator.class.getName()
18481                            });
18482            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18483                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
18484                            JournalArticleImpl.class,
18485                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C",
18486                            new String[] {
18487                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18488                            },
18489                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
18490                            JournalArticleModelImpl.USERID_COLUMN_BITMASK |
18491                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
18492                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
18493                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
18494            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
18495                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
18496                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C",
18497                            new String[] {
18498                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
18499                            });
18500    
18501            /**
18502             * Returns all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18503             *
18504             * @param groupId the group ID
18505             * @param userId the user ID
18506             * @param classNameId the class name ID
18507             * @return the matching journal articles
18508             */
18509            @Override
18510            public List<JournalArticle> findByG_U_C(long groupId, long userId,
18511                    long classNameId) {
18512                    return findByG_U_C(groupId, userId, classNameId, QueryUtil.ALL_POS,
18513                            QueryUtil.ALL_POS, null);
18514            }
18515    
18516            /**
18517             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18518             *
18519             * <p>
18520             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18521             * </p>
18522             *
18523             * @param groupId the group ID
18524             * @param userId the user ID
18525             * @param classNameId the class name ID
18526             * @param start the lower bound of the range of journal articles
18527             * @param end the upper bound of the range of journal articles (not inclusive)
18528             * @return the range of matching journal articles
18529             */
18530            @Override
18531            public List<JournalArticle> findByG_U_C(long groupId, long userId,
18532                    long classNameId, int start, int end) {
18533                    return findByG_U_C(groupId, userId, classNameId, start, end, null);
18534            }
18535    
18536            /**
18537             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18538             *
18539             * <p>
18540             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18541             * </p>
18542             *
18543             * @param groupId the group ID
18544             * @param userId the user ID
18545             * @param classNameId the class name ID
18546             * @param start the lower bound of the range of journal articles
18547             * @param end the upper bound of the range of journal articles (not inclusive)
18548             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18549             * @return the ordered range of matching journal articles
18550             */
18551            @Override
18552            public List<JournalArticle> findByG_U_C(long groupId, long userId,
18553                    long classNameId, int start, int end,
18554                    OrderByComparator<JournalArticle> orderByComparator) {
18555                    boolean pagination = true;
18556                    FinderPath finderPath = null;
18557                    Object[] finderArgs = null;
18558    
18559                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18560                                    (orderByComparator == null)) {
18561                            pagination = false;
18562                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C;
18563                            finderArgs = new Object[] { groupId, userId, classNameId };
18564                    }
18565                    else {
18566                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C;
18567                            finderArgs = new Object[] {
18568                                            groupId, userId, classNameId,
18569                                            
18570                                            start, end, orderByComparator
18571                                    };
18572                    }
18573    
18574                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18575                                    finderArgs, this);
18576    
18577                    if ((list != null) && !list.isEmpty()) {
18578                            for (JournalArticle journalArticle : list) {
18579                                    if ((groupId != journalArticle.getGroupId()) ||
18580                                                    (userId != journalArticle.getUserId()) ||
18581                                                    (classNameId != journalArticle.getClassNameId())) {
18582                                            list = null;
18583    
18584                                            break;
18585                                    }
18586                            }
18587                    }
18588    
18589                    if (list == null) {
18590                            StringBundler query = null;
18591    
18592                            if (orderByComparator != null) {
18593                                    query = new StringBundler(5 +
18594                                                    (orderByComparator.getOrderByFields().length * 3));
18595                            }
18596                            else {
18597                                    query = new StringBundler(5);
18598                            }
18599    
18600                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18601    
18602                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
18603    
18604                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
18605    
18606                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
18607    
18608                            if (orderByComparator != null) {
18609                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18610                                            orderByComparator);
18611                            }
18612                            else
18613                             if (pagination) {
18614                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18615                            }
18616    
18617                            String sql = query.toString();
18618    
18619                            Session session = null;
18620    
18621                            try {
18622                                    session = openSession();
18623    
18624                                    Query q = session.createQuery(sql);
18625    
18626                                    QueryPos qPos = QueryPos.getInstance(q);
18627    
18628                                    qPos.add(groupId);
18629    
18630                                    qPos.add(userId);
18631    
18632                                    qPos.add(classNameId);
18633    
18634                                    if (!pagination) {
18635                                            list = (List<JournalArticle>)QueryUtil.list(q,
18636                                                            getDialect(), start, end, false);
18637    
18638                                            Collections.sort(list);
18639    
18640                                            list = Collections.unmodifiableList(list);
18641                                    }
18642                                    else {
18643                                            list = (List<JournalArticle>)QueryUtil.list(q,
18644                                                            getDialect(), start, end);
18645                                    }
18646    
18647                                    cacheResult(list);
18648    
18649                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18650                            }
18651                            catch (Exception e) {
18652                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18653    
18654                                    throw processException(e);
18655                            }
18656                            finally {
18657                                    closeSession(session);
18658                            }
18659                    }
18660    
18661                    return list;
18662            }
18663    
18664            /**
18665             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18666             *
18667             * @param groupId the group ID
18668             * @param userId the user ID
18669             * @param classNameId the class name ID
18670             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18671             * @return the first matching journal article
18672             * @throws NoSuchArticleException if a matching journal article could not be found
18673             */
18674            @Override
18675            public JournalArticle findByG_U_C_First(long groupId, long userId,
18676                    long classNameId, OrderByComparator<JournalArticle> orderByComparator)
18677                    throws NoSuchArticleException {
18678                    JournalArticle journalArticle = fetchByG_U_C_First(groupId, userId,
18679                                    classNameId, orderByComparator);
18680    
18681                    if (journalArticle != null) {
18682                            return journalArticle;
18683                    }
18684    
18685                    StringBundler msg = new StringBundler(8);
18686    
18687                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18688    
18689                    msg.append("groupId=");
18690                    msg.append(groupId);
18691    
18692                    msg.append(", userId=");
18693                    msg.append(userId);
18694    
18695                    msg.append(", classNameId=");
18696                    msg.append(classNameId);
18697    
18698                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18699    
18700                    throw new NoSuchArticleException(msg.toString());
18701            }
18702    
18703            /**
18704             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18705             *
18706             * @param groupId the group ID
18707             * @param userId the user ID
18708             * @param classNameId the class name ID
18709             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18710             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
18711             */
18712            @Override
18713            public JournalArticle fetchByG_U_C_First(long groupId, long userId,
18714                    long classNameId, OrderByComparator<JournalArticle> orderByComparator) {
18715                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
18716                                    0, 1, orderByComparator);
18717    
18718                    if (!list.isEmpty()) {
18719                            return list.get(0);
18720                    }
18721    
18722                    return null;
18723            }
18724    
18725            /**
18726             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18727             *
18728             * @param groupId the group ID
18729             * @param userId the user ID
18730             * @param classNameId the class name ID
18731             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18732             * @return the last matching journal article
18733             * @throws NoSuchArticleException if a matching journal article could not be found
18734             */
18735            @Override
18736            public JournalArticle findByG_U_C_Last(long groupId, long userId,
18737                    long classNameId, OrderByComparator<JournalArticle> orderByComparator)
18738                    throws NoSuchArticleException {
18739                    JournalArticle journalArticle = fetchByG_U_C_Last(groupId, userId,
18740                                    classNameId, orderByComparator);
18741    
18742                    if (journalArticle != null) {
18743                            return journalArticle;
18744                    }
18745    
18746                    StringBundler msg = new StringBundler(8);
18747    
18748                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18749    
18750                    msg.append("groupId=");
18751                    msg.append(groupId);
18752    
18753                    msg.append(", userId=");
18754                    msg.append(userId);
18755    
18756                    msg.append(", classNameId=");
18757                    msg.append(classNameId);
18758    
18759                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18760    
18761                    throw new NoSuchArticleException(msg.toString());
18762            }
18763    
18764            /**
18765             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18766             *
18767             * @param groupId the group ID
18768             * @param userId the user ID
18769             * @param classNameId the class name ID
18770             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18771             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
18772             */
18773            @Override
18774            public JournalArticle fetchByG_U_C_Last(long groupId, long userId,
18775                    long classNameId, OrderByComparator<JournalArticle> orderByComparator) {
18776                    int count = countByG_U_C(groupId, userId, classNameId);
18777    
18778                    if (count == 0) {
18779                            return null;
18780                    }
18781    
18782                    List<JournalArticle> list = findByG_U_C(groupId, userId, classNameId,
18783                                    count - 1, count, orderByComparator);
18784    
18785                    if (!list.isEmpty()) {
18786                            return list.get(0);
18787                    }
18788    
18789                    return null;
18790            }
18791    
18792            /**
18793             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18794             *
18795             * @param id the primary key of the current journal article
18796             * @param groupId the group ID
18797             * @param userId the user ID
18798             * @param classNameId the class name ID
18799             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18800             * @return the previous, current, and next journal article
18801             * @throws NoSuchArticleException if a journal article with the primary key could not be found
18802             */
18803            @Override
18804            public JournalArticle[] findByG_U_C_PrevAndNext(long id, long groupId,
18805                    long userId, long classNameId,
18806                    OrderByComparator<JournalArticle> orderByComparator)
18807                    throws NoSuchArticleException {
18808                    JournalArticle journalArticle = findByPrimaryKey(id);
18809    
18810                    Session session = null;
18811    
18812                    try {
18813                            session = openSession();
18814    
18815                            JournalArticle[] array = new JournalArticleImpl[3];
18816    
18817                            array[0] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
18818                                            userId, classNameId, orderByComparator, true);
18819    
18820                            array[1] = journalArticle;
18821    
18822                            array[2] = getByG_U_C_PrevAndNext(session, journalArticle, groupId,
18823                                            userId, classNameId, orderByComparator, false);
18824    
18825                            return array;
18826                    }
18827                    catch (Exception e) {
18828                            throw processException(e);
18829                    }
18830                    finally {
18831                            closeSession(session);
18832                    }
18833            }
18834    
18835            protected JournalArticle getByG_U_C_PrevAndNext(Session session,
18836                    JournalArticle journalArticle, long groupId, long userId,
18837                    long classNameId, OrderByComparator<JournalArticle> orderByComparator,
18838                    boolean previous) {
18839                    StringBundler query = null;
18840    
18841                    if (orderByComparator != null) {
18842                            query = new StringBundler(6 +
18843                                            (orderByComparator.getOrderByFields().length * 6));
18844                    }
18845                    else {
18846                            query = new StringBundler(3);
18847                    }
18848    
18849                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18850    
18851                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
18852    
18853                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
18854    
18855                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
18856    
18857                    if (orderByComparator != null) {
18858                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18859    
18860                            if (orderByConditionFields.length > 0) {
18861                                    query.append(WHERE_AND);
18862                            }
18863    
18864                            for (int i = 0; i < orderByConditionFields.length; i++) {
18865                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18866                                    query.append(orderByConditionFields[i]);
18867    
18868                                    if ((i + 1) < orderByConditionFields.length) {
18869                                            if (orderByComparator.isAscending() ^ previous) {
18870                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18871                                            }
18872                                            else {
18873                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18874                                            }
18875                                    }
18876                                    else {
18877                                            if (orderByComparator.isAscending() ^ previous) {
18878                                                    query.append(WHERE_GREATER_THAN);
18879                                            }
18880                                            else {
18881                                                    query.append(WHERE_LESSER_THAN);
18882                                            }
18883                                    }
18884                            }
18885    
18886                            query.append(ORDER_BY_CLAUSE);
18887    
18888                            String[] orderByFields = orderByComparator.getOrderByFields();
18889    
18890                            for (int i = 0; i < orderByFields.length; i++) {
18891                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18892                                    query.append(orderByFields[i]);
18893    
18894                                    if ((i + 1) < orderByFields.length) {
18895                                            if (orderByComparator.isAscending() ^ previous) {
18896                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18897                                            }
18898                                            else {
18899                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18900                                            }
18901                                    }
18902                                    else {
18903                                            if (orderByComparator.isAscending() ^ previous) {
18904                                                    query.append(ORDER_BY_ASC);
18905                                            }
18906                                            else {
18907                                                    query.append(ORDER_BY_DESC);
18908                                            }
18909                                    }
18910                            }
18911                    }
18912                    else {
18913                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18914                    }
18915    
18916                    String sql = query.toString();
18917    
18918                    Query q = session.createQuery(sql);
18919    
18920                    q.setFirstResult(0);
18921                    q.setMaxResults(2);
18922    
18923                    QueryPos qPos = QueryPos.getInstance(q);
18924    
18925                    qPos.add(groupId);
18926    
18927                    qPos.add(userId);
18928    
18929                    qPos.add(classNameId);
18930    
18931                    if (orderByComparator != null) {
18932                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18933    
18934                            for (Object value : values) {
18935                                    qPos.add(value);
18936                            }
18937                    }
18938    
18939                    List<JournalArticle> list = q.list();
18940    
18941                    if (list.size() == 2) {
18942                            return list.get(1);
18943                    }
18944                    else {
18945                            return null;
18946                    }
18947            }
18948    
18949            /**
18950             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18951             *
18952             * @param groupId the group ID
18953             * @param userId the user ID
18954             * @param classNameId the class name ID
18955             * @return the matching journal articles that the user has permission to view
18956             */
18957            @Override
18958            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
18959                    long classNameId) {
18960                    return filterFindByG_U_C(groupId, userId, classNameId,
18961                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18962            }
18963    
18964            /**
18965             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
18966             *
18967             * <p>
18968             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18969             * </p>
18970             *
18971             * @param groupId the group ID
18972             * @param userId the user ID
18973             * @param classNameId the class name ID
18974             * @param start the lower bound of the range of journal articles
18975             * @param end the upper bound of the range of journal articles (not inclusive)
18976             * @return the range of matching journal articles that the user has permission to view
18977             */
18978            @Override
18979            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
18980                    long classNameId, int start, int end) {
18981                    return filterFindByG_U_C(groupId, userId, classNameId, start, end, null);
18982            }
18983    
18984            /**
18985             * 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;.
18986             *
18987             * <p>
18988             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18989             * </p>
18990             *
18991             * @param groupId the group ID
18992             * @param userId the user ID
18993             * @param classNameId the class name ID
18994             * @param start the lower bound of the range of journal articles
18995             * @param end the upper bound of the range of journal articles (not inclusive)
18996             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18997             * @return the ordered range of matching journal articles that the user has permission to view
18998             */
18999            @Override
19000            public List<JournalArticle> filterFindByG_U_C(long groupId, long userId,
19001                    long classNameId, int start, int end,
19002                    OrderByComparator<JournalArticle> orderByComparator) {
19003                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19004                            return findByG_U_C(groupId, userId, classNameId, start, end,
19005                                    orderByComparator);
19006                    }
19007    
19008                    StringBundler query = null;
19009    
19010                    if (orderByComparator != null) {
19011                            query = new StringBundler(5 +
19012                                            (orderByComparator.getOrderByFields().length * 3));
19013                    }
19014                    else {
19015                            query = new StringBundler(5);
19016                    }
19017    
19018                    if (getDB().isSupportsInlineDistinct()) {
19019                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19020                    }
19021                    else {
19022                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19023                    }
19024    
19025                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19026    
19027                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19028    
19029                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19030    
19031                    if (!getDB().isSupportsInlineDistinct()) {
19032                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19033                    }
19034    
19035                    if (orderByComparator != null) {
19036                            if (getDB().isSupportsInlineDistinct()) {
19037                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19038                                            orderByComparator, true);
19039                            }
19040                            else {
19041                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
19042                                            orderByComparator, true);
19043                            }
19044                    }
19045                    else {
19046                            if (getDB().isSupportsInlineDistinct()) {
19047                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19048                            }
19049                            else {
19050                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19051                            }
19052                    }
19053    
19054                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19055                                    JournalArticle.class.getName(),
19056                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19057    
19058                    Session session = null;
19059    
19060                    try {
19061                            session = openSession();
19062    
19063                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
19064    
19065                            if (getDB().isSupportsInlineDistinct()) {
19066                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19067                            }
19068                            else {
19069                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19070                            }
19071    
19072                            QueryPos qPos = QueryPos.getInstance(q);
19073    
19074                            qPos.add(groupId);
19075    
19076                            qPos.add(userId);
19077    
19078                            qPos.add(classNameId);
19079    
19080                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19081                                    end);
19082                    }
19083                    catch (Exception e) {
19084                            throw processException(e);
19085                    }
19086                    finally {
19087                            closeSession(session);
19088                    }
19089            }
19090    
19091            /**
19092             * 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;.
19093             *
19094             * @param id the primary key of the current journal article
19095             * @param groupId the group ID
19096             * @param userId the user ID
19097             * @param classNameId the class name ID
19098             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19099             * @return the previous, current, and next journal article
19100             * @throws NoSuchArticleException if a journal article with the primary key could not be found
19101             */
19102            @Override
19103            public JournalArticle[] filterFindByG_U_C_PrevAndNext(long id,
19104                    long groupId, long userId, long classNameId,
19105                    OrderByComparator<JournalArticle> orderByComparator)
19106                    throws NoSuchArticleException {
19107                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19108                            return findByG_U_C_PrevAndNext(id, groupId, userId, classNameId,
19109                                    orderByComparator);
19110                    }
19111    
19112                    JournalArticle journalArticle = findByPrimaryKey(id);
19113    
19114                    Session session = null;
19115    
19116                    try {
19117                            session = openSession();
19118    
19119                            JournalArticle[] array = new JournalArticleImpl[3];
19120    
19121                            array[0] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
19122                                            groupId, userId, classNameId, orderByComparator, true);
19123    
19124                            array[1] = journalArticle;
19125    
19126                            array[2] = filterGetByG_U_C_PrevAndNext(session, journalArticle,
19127                                            groupId, userId, classNameId, orderByComparator, false);
19128    
19129                            return array;
19130                    }
19131                    catch (Exception e) {
19132                            throw processException(e);
19133                    }
19134                    finally {
19135                            closeSession(session);
19136                    }
19137            }
19138    
19139            protected JournalArticle filterGetByG_U_C_PrevAndNext(Session session,
19140                    JournalArticle journalArticle, long groupId, long userId,
19141                    long classNameId, OrderByComparator<JournalArticle> orderByComparator,
19142                    boolean previous) {
19143                    StringBundler query = null;
19144    
19145                    if (orderByComparator != null) {
19146                            query = new StringBundler(6 +
19147                                            (orderByComparator.getOrderByFields().length * 6));
19148                    }
19149                    else {
19150                            query = new StringBundler(3);
19151                    }
19152    
19153                    if (getDB().isSupportsInlineDistinct()) {
19154                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19155                    }
19156                    else {
19157                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19158                    }
19159    
19160                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19161    
19162                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19163    
19164                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19165    
19166                    if (!getDB().isSupportsInlineDistinct()) {
19167                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19168                    }
19169    
19170                    if (orderByComparator != null) {
19171                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19172    
19173                            if (orderByConditionFields.length > 0) {
19174                                    query.append(WHERE_AND);
19175                            }
19176    
19177                            for (int i = 0; i < orderByConditionFields.length; i++) {
19178                                    if (getDB().isSupportsInlineDistinct()) {
19179                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19180                                    }
19181                                    else {
19182                                            query.append(_ORDER_BY_ENTITY_TABLE);
19183                                    }
19184    
19185                                    query.append(orderByConditionFields[i]);
19186    
19187                                    if ((i + 1) < orderByConditionFields.length) {
19188                                            if (orderByComparator.isAscending() ^ previous) {
19189                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19190                                            }
19191                                            else {
19192                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19193                                            }
19194                                    }
19195                                    else {
19196                                            if (orderByComparator.isAscending() ^ previous) {
19197                                                    query.append(WHERE_GREATER_THAN);
19198                                            }
19199                                            else {
19200                                                    query.append(WHERE_LESSER_THAN);
19201                                            }
19202                                    }
19203                            }
19204    
19205                            query.append(ORDER_BY_CLAUSE);
19206    
19207                            String[] orderByFields = orderByComparator.getOrderByFields();
19208    
19209                            for (int i = 0; i < orderByFields.length; i++) {
19210                                    if (getDB().isSupportsInlineDistinct()) {
19211                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19212                                    }
19213                                    else {
19214                                            query.append(_ORDER_BY_ENTITY_TABLE);
19215                                    }
19216    
19217                                    query.append(orderByFields[i]);
19218    
19219                                    if ((i + 1) < orderByFields.length) {
19220                                            if (orderByComparator.isAscending() ^ previous) {
19221                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19222                                            }
19223                                            else {
19224                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19225                                            }
19226                                    }
19227                                    else {
19228                                            if (orderByComparator.isAscending() ^ previous) {
19229                                                    query.append(ORDER_BY_ASC);
19230                                            }
19231                                            else {
19232                                                    query.append(ORDER_BY_DESC);
19233                                            }
19234                                    }
19235                            }
19236                    }
19237                    else {
19238                            if (getDB().isSupportsInlineDistinct()) {
19239                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19240                            }
19241                            else {
19242                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19243                            }
19244                    }
19245    
19246                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19247                                    JournalArticle.class.getName(),
19248                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19249    
19250                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
19251    
19252                    q.setFirstResult(0);
19253                    q.setMaxResults(2);
19254    
19255                    if (getDB().isSupportsInlineDistinct()) {
19256                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19257                    }
19258                    else {
19259                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19260                    }
19261    
19262                    QueryPos qPos = QueryPos.getInstance(q);
19263    
19264                    qPos.add(groupId);
19265    
19266                    qPos.add(userId);
19267    
19268                    qPos.add(classNameId);
19269    
19270                    if (orderByComparator != null) {
19271                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19272    
19273                            for (Object value : values) {
19274                                    qPos.add(value);
19275                            }
19276                    }
19277    
19278                    List<JournalArticle> list = q.list();
19279    
19280                    if (list.size() == 2) {
19281                            return list.get(1);
19282                    }
19283                    else {
19284                            return null;
19285                    }
19286            }
19287    
19288            /**
19289             * Removes all the journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63; from the database.
19290             *
19291             * @param groupId the group ID
19292             * @param userId the user ID
19293             * @param classNameId the class name ID
19294             */
19295            @Override
19296            public void removeByG_U_C(long groupId, long userId, long classNameId) {
19297                    for (JournalArticle journalArticle : findByG_U_C(groupId, userId,
19298                                    classNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
19299                            remove(journalArticle);
19300                    }
19301            }
19302    
19303            /**
19304             * Returns the number of journal articles where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19305             *
19306             * @param groupId the group ID
19307             * @param userId the user ID
19308             * @param classNameId the class name ID
19309             * @return the number of matching journal articles
19310             */
19311            @Override
19312            public int countByG_U_C(long groupId, long userId, long classNameId) {
19313                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C;
19314    
19315                    Object[] finderArgs = new Object[] { groupId, userId, classNameId };
19316    
19317                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
19318                                    this);
19319    
19320                    if (count == null) {
19321                            StringBundler query = new StringBundler(4);
19322    
19323                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19324    
19325                            query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19326    
19327                            query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19328    
19329                            query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19330    
19331                            String sql = query.toString();
19332    
19333                            Session session = null;
19334    
19335                            try {
19336                                    session = openSession();
19337    
19338                                    Query q = session.createQuery(sql);
19339    
19340                                    QueryPos qPos = QueryPos.getInstance(q);
19341    
19342                                    qPos.add(groupId);
19343    
19344                                    qPos.add(userId);
19345    
19346                                    qPos.add(classNameId);
19347    
19348                                    count = (Long)q.uniqueResult();
19349    
19350                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
19351                            }
19352                            catch (Exception e) {
19353                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19354    
19355                                    throw processException(e);
19356                            }
19357                            finally {
19358                                    closeSession(session);
19359                            }
19360                    }
19361    
19362                    return count.intValue();
19363            }
19364    
19365            /**
19366             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63; and classNameId = &#63;.
19367             *
19368             * @param groupId the group ID
19369             * @param userId the user ID
19370             * @param classNameId the class name ID
19371             * @return the number of matching journal articles that the user has permission to view
19372             */
19373            @Override
19374            public int filterCountByG_U_C(long groupId, long userId, long classNameId) {
19375                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19376                            return countByG_U_C(groupId, userId, classNameId);
19377                    }
19378    
19379                    StringBundler query = new StringBundler(4);
19380    
19381                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
19382    
19383                    query.append(_FINDER_COLUMN_G_U_C_GROUPID_2);
19384    
19385                    query.append(_FINDER_COLUMN_G_U_C_USERID_2);
19386    
19387                    query.append(_FINDER_COLUMN_G_U_C_CLASSNAMEID_2);
19388    
19389                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19390                                    JournalArticle.class.getName(),
19391                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19392    
19393                    Session session = null;
19394    
19395                    try {
19396                            session = openSession();
19397    
19398                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
19399    
19400                            q.addScalar(COUNT_COLUMN_NAME,
19401                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
19402    
19403                            QueryPos qPos = QueryPos.getInstance(q);
19404    
19405                            qPos.add(groupId);
19406    
19407                            qPos.add(userId);
19408    
19409                            qPos.add(classNameId);
19410    
19411                            Long count = (Long)q.uniqueResult();
19412    
19413                            return count.intValue();
19414                    }
19415                    catch (Exception e) {
19416                            throw processException(e);
19417                    }
19418                    finally {
19419                            closeSession(session);
19420                    }
19421            }
19422    
19423            private static final String _FINDER_COLUMN_G_U_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
19424            private static final String _FINDER_COLUMN_G_U_C_USERID_2 = "journalArticle.userId = ? AND ";
19425            private static final String _FINDER_COLUMN_G_U_C_CLASSNAMEID_2 = "journalArticle.classNameId = ?";
19426            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19427                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19428                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
19429                            "findByG_F_ST",
19430                            new String[] {
19431                                    Long.class.getName(), Long.class.getName(),
19432                                    Integer.class.getName(),
19433                                    
19434                            Integer.class.getName(), Integer.class.getName(),
19435                                    OrderByComparator.class.getName()
19436                            });
19437            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
19438                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19439                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
19440                            JournalArticleImpl.class,
19441                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
19442                            new String[] {
19443                                    Long.class.getName(), Long.class.getName(),
19444                                    Integer.class.getName()
19445                            },
19446                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
19447                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
19448                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
19449                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
19450                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
19451            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19452                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19453                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
19454                            new String[] {
19455                                    Long.class.getName(), Long.class.getName(),
19456                                    Integer.class.getName()
19457                            });
19458            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
19459                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
19460                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
19461                            new String[] {
19462                                    Long.class.getName(), Long.class.getName(),
19463                                    Integer.class.getName()
19464                            });
19465    
19466            /**
19467             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19468             *
19469             * @param groupId the group ID
19470             * @param folderId the folder ID
19471             * @param status the status
19472             * @return the matching journal articles
19473             */
19474            @Override
19475            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19476                    int status) {
19477                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
19478                            QueryUtil.ALL_POS, null);
19479            }
19480    
19481            /**
19482             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19483             *
19484             * <p>
19485             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19486             * </p>
19487             *
19488             * @param groupId the group ID
19489             * @param folderId the folder ID
19490             * @param status the status
19491             * @param start the lower bound of the range of journal articles
19492             * @param end the upper bound of the range of journal articles (not inclusive)
19493             * @return the range of matching journal articles
19494             */
19495            @Override
19496            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19497                    int status, int start, int end) {
19498                    return findByG_F_ST(groupId, folderId, status, start, end, null);
19499            }
19500    
19501            /**
19502             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
19503             *
19504             * <p>
19505             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19506             * </p>
19507             *
19508             * @param groupId the group ID
19509             * @param folderId the folder ID
19510             * @param status the status
19511             * @param start the lower bound of the range of journal articles
19512             * @param end the upper bound of the range of journal articles (not inclusive)
19513             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19514             * @return the ordered range of matching journal articles
19515             */
19516            @Override
19517            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
19518                    int status, int start, int end,
19519                    OrderByComparator<JournalArticle> orderByComparator) {
19520                    boolean pagination = true;
19521                    FinderPath finderPath = null;
19522                    Object[] finderArgs = null;
19523    
19524                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19525                                    (orderByComparator == null)) {
19526                            pagination = false;
19527                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
19528                            finderArgs = new Object[] { groupId, folderId, status };
19529                    }
19530                    else {
19531                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
19532                            finderArgs = new Object[] {
19533                                            groupId, folderId, status,
19534                                            
19535                                            start, end, orderByComparator
19536                                    };
19537                    }
19538    
19539                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19540                                    finderArgs, this);
19541    
19542                    if ((list != null) && !list.isEmpty()) {
19543                            for (JournalArticle journalArticle : list) {
19544                                    if ((groupId != journalArticle.getGroupId()) ||
19545                                                    (folderId != journalArticle.getFolderId()) ||
19546                                                    (status != journalArticle.getStatus())) {
19547                                            list = null;
19548    
19549                                            break;
19550                                    }
19551                            }
19552                    }
19553    
19554                    if (list == null) {
19555                            StringBundler query = null;
19556    
19557                            if (orderByComparator != null) {
19558                                    query = new StringBundler(5 +
19559                                                    (orderByComparator.getOrderByFields().length * 3));
19560                            }
19561                            else {
19562                                    query = new StringBundler(5);
19563                            }
19564    
19565                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19566    
19567                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
19568    
19569                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
19570    
19571                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
19572    
19573                            if (orderByComparator != null) {
19574                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19575                                            orderByComparator);
19576                            }
19577                            else
19578                             if (pagination) {
19579                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19580                            }
19581    
19582                            String sql = query.toString();
19583    
19584                            Session session = null;
19585    
19586                            try {
19587                                    session = openSession();
19588    
19589                                    Query q = session.createQuery(sql);
19590    
19591                                    QueryPos qPos = QueryPos.getInstance(q);
19592    
19593                                    qPos.add(groupId);
19594    
19595                                    qPos.add(folderId);
19596    
19597                                    qPos.add(status);
19598    
19599                                    if (!pagination) {
19600                                            list = (List<JournalArticle>)QueryUtil.list(q,
19601                                                            getDialect(), start, end, false);
19602    
19603                                            Collections.sort(list);
19604    
19605                                            list = Collections.unmodifiableList(list);
19606                                    }
19607                                    else {
19608                                            list = (List<JournalArticle>)QueryUtil.list(q,
19609                                                            getDialect(), start, end);
19610                                    }
19611    
19612                                    cacheResult(list);
19613    
19614                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
19615                            }
19616                            catch (Exception e) {
19617                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
19618    
19619                                    throw processException(e);
19620                            }
19621                            finally {
19622                                    closeSession(session);
19623                            }
19624                    }
19625    
19626                    return list;
19627            }
19628    
19629            /**
19630             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19631             *
19632             * @param groupId the group ID
19633             * @param folderId the folder ID
19634             * @param status the status
19635             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19636             * @return the first matching journal article
19637             * @throws NoSuchArticleException if a matching journal article could not be found
19638             */
19639            @Override
19640            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
19641                    int status, OrderByComparator<JournalArticle> orderByComparator)
19642                    throws NoSuchArticleException {
19643                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
19644                                    status, orderByComparator);
19645    
19646                    if (journalArticle != null) {
19647                            return journalArticle;
19648                    }
19649    
19650                    StringBundler msg = new StringBundler(8);
19651    
19652                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19653    
19654                    msg.append("groupId=");
19655                    msg.append(groupId);
19656    
19657                    msg.append(", folderId=");
19658                    msg.append(folderId);
19659    
19660                    msg.append(", status=");
19661                    msg.append(status);
19662    
19663                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19664    
19665                    throw new NoSuchArticleException(msg.toString());
19666            }
19667    
19668            /**
19669             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19670             *
19671             * @param groupId the group ID
19672             * @param folderId the folder ID
19673             * @param status the status
19674             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19675             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19676             */
19677            @Override
19678            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
19679                    int status, OrderByComparator<JournalArticle> orderByComparator) {
19680                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
19681                                    1, orderByComparator);
19682    
19683                    if (!list.isEmpty()) {
19684                            return list.get(0);
19685                    }
19686    
19687                    return null;
19688            }
19689    
19690            /**
19691             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19692             *
19693             * @param groupId the group ID
19694             * @param folderId the folder ID
19695             * @param status the status
19696             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19697             * @return the last matching journal article
19698             * @throws NoSuchArticleException if a matching journal article could not be found
19699             */
19700            @Override
19701            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
19702                    int status, OrderByComparator<JournalArticle> orderByComparator)
19703                    throws NoSuchArticleException {
19704                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
19705                                    status, orderByComparator);
19706    
19707                    if (journalArticle != null) {
19708                            return journalArticle;
19709                    }
19710    
19711                    StringBundler msg = new StringBundler(8);
19712    
19713                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19714    
19715                    msg.append("groupId=");
19716                    msg.append(groupId);
19717    
19718                    msg.append(", folderId=");
19719                    msg.append(folderId);
19720    
19721                    msg.append(", status=");
19722                    msg.append(status);
19723    
19724                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19725    
19726                    throw new NoSuchArticleException(msg.toString());
19727            }
19728    
19729            /**
19730             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19731             *
19732             * @param groupId the group ID
19733             * @param folderId the folder ID
19734             * @param status the status
19735             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19736             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19737             */
19738            @Override
19739            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
19740                    int status, OrderByComparator<JournalArticle> orderByComparator) {
19741                    int count = countByG_F_ST(groupId, folderId, status);
19742    
19743                    if (count == 0) {
19744                            return null;
19745                    }
19746    
19747                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
19748                                    count - 1, count, orderByComparator);
19749    
19750                    if (!list.isEmpty()) {
19751                            return list.get(0);
19752                    }
19753    
19754                    return null;
19755            }
19756    
19757            /**
19758             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
19759             *
19760             * @param id the primary key of the current journal article
19761             * @param groupId the group ID
19762             * @param folderId the folder ID
19763             * @param status the status
19764             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19765             * @return the previous, current, and next journal article
19766             * @throws NoSuchArticleException if a journal article with the primary key could not be found
19767             */
19768            @Override
19769            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
19770                    long folderId, int status,
19771                    OrderByComparator<JournalArticle> orderByComparator)
19772                    throws NoSuchArticleException {
19773                    JournalArticle journalArticle = findByPrimaryKey(id);
19774    
19775                    Session session = null;
19776    
19777                    try {
19778                            session = openSession();
19779    
19780                            JournalArticle[] array = new JournalArticleImpl[3];
19781    
19782                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
19783                                            groupId, folderId, status, orderByComparator, true);
19784    
19785                            array[1] = journalArticle;
19786    
19787                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
19788                                            groupId, folderId, status, orderByComparator, false);
19789    
19790                            return array;
19791                    }
19792                    catch (Exception e) {
19793                            throw processException(e);
19794                    }
19795                    finally {
19796                            closeSession(session);
19797                    }
19798            }
19799    
19800            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
19801                    JournalArticle journalArticle, long groupId, long folderId, int status,
19802                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
19803                    StringBundler query = null;
19804    
19805                    if (orderByComparator != null) {
19806                            query = new StringBundler(6 +
19807                                            (orderByComparator.getOrderByFields().length * 6));
19808                    }
19809                    else {
19810                            query = new StringBundler(3);
19811                    }
19812    
19813                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19814    
19815                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
19816    
19817                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
19818    
19819                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
19820    
19821                    if (orderByComparator != null) {
19822                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19823    
19824                            if (orderByConditionFields.length > 0) {
19825                                    query.append(WHERE_AND);
19826                            }
19827    
19828                            for (int i = 0; i < orderByConditionFields.length; i++) {
19829                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19830                                    query.append(orderByConditionFields[i]);
19831    
19832                                    if ((i + 1) < orderByConditionFields.length) {
19833                                            if (orderByComparator.isAscending() ^ previous) {
19834                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19835                                            }
19836                                            else {
19837                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19838                                            }
19839                                    }
19840                                    else {
19841                                            if (orderByComparator.isAscending() ^ previous) {
19842                                                    query.append(WHERE_GREATER_THAN);
19843                                            }
19844                                            else {
19845                                                    query.append(WHERE_LESSER_THAN);
19846                                            }
19847                                    }
19848                            }
19849    
19850                            query.append(ORDER_BY_CLAUSE);
19851    
19852                            String[] orderByFields = orderByComparator.getOrderByFields();
19853    
19854                            for (int i = 0; i < orderByFields.length; i++) {
19855                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19856                                    query.append(orderByFields[i]);
19857    
19858                                    if ((i + 1) < orderByFields.length) {
19859                                            if (orderByComparator.isAscending() ^ previous) {
19860                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19861                                            }
19862                                            else {
19863                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19864                                            }
19865                                    }
19866                                    else {
19867                                            if (orderByComparator.isAscending() ^ previous) {
19868                                                    query.append(ORDER_BY_ASC);
19869                                            }
19870                                            else {
19871                                                    query.append(ORDER_BY_DESC);
19872                                            }
19873                                    }
19874                            }
19875                    }
19876                    else {
19877                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19878                    }
19879    
19880                    String sql = query.toString();
19881    
19882                    Query q = session.createQuery(sql);
19883    
19884                    q.setFirstResult(0);
19885                    q.setMaxResults(2);
19886    
19887                    QueryPos qPos = QueryPos.getInstance(q);
19888    
19889                    qPos.add(groupId);
19890    
19891                    qPos.add(folderId);
19892    
19893                    qPos.add(status);
19894    
19895                    if (orderByComparator != null) {
19896                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19897    
19898                            for (Object value : values) {
19899                                    qPos.add(value);
19900                            }
19901                    }
19902    
19903                    List<JournalArticle> list = q.list();
19904    
19905                    if (list.size() == 2) {
19906                            return list.get(1);
19907                    }
19908                    else {
19909                            return null;
19910                    }
19911            }
19912    
19913            /**
19914             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
19915             *
19916             * @param groupId the group ID
19917             * @param folderId the folder ID
19918             * @param status the status
19919             * @return the matching journal articles that the user has permission to view
19920             */
19921            @Override
19922            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19923                    int status) {
19924                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
19925                            QueryUtil.ALL_POS, null);
19926            }
19927    
19928            /**
19929             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
19930             *
19931             * <p>
19932             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19933             * </p>
19934             *
19935             * @param groupId the group ID
19936             * @param folderId the folder ID
19937             * @param status the status
19938             * @param start the lower bound of the range of journal articles
19939             * @param end the upper bound of the range of journal articles (not inclusive)
19940             * @return the range of matching journal articles that the user has permission to view
19941             */
19942            @Override
19943            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19944                    int status, int start, int end) {
19945                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
19946            }
19947    
19948            /**
19949             * 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;.
19950             *
19951             * <p>
19952             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19953             * </p>
19954             *
19955             * @param groupId the group ID
19956             * @param folderId the folder ID
19957             * @param status the status
19958             * @param start the lower bound of the range of journal articles
19959             * @param end the upper bound of the range of journal articles (not inclusive)
19960             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19961             * @return the ordered range of matching journal articles that the user has permission to view
19962             */
19963            @Override
19964            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
19965                    int status, int start, int end,
19966                    OrderByComparator<JournalArticle> orderByComparator) {
19967                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19968                            return findByG_F_ST(groupId, folderId, status, start, end,
19969                                    orderByComparator);
19970                    }
19971    
19972                    StringBundler query = null;
19973    
19974                    if (orderByComparator != null) {
19975                            query = new StringBundler(5 +
19976                                            (orderByComparator.getOrderByFields().length * 3));
19977                    }
19978                    else {
19979                            query = new StringBundler(5);
19980                    }
19981    
19982                    if (getDB().isSupportsInlineDistinct()) {
19983                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19984                    }
19985                    else {
19986                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19987                    }
19988    
19989                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
19990    
19991                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
19992    
19993                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
19994    
19995                    if (!getDB().isSupportsInlineDistinct()) {
19996                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19997                    }
19998    
19999                    if (orderByComparator != null) {
20000                            if (getDB().isSupportsInlineDistinct()) {
20001                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20002                                            orderByComparator, true);
20003                            }
20004                            else {
20005                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20006                                            orderByComparator, true);
20007                            }
20008                    }
20009                    else {
20010                            if (getDB().isSupportsInlineDistinct()) {
20011                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20012                            }
20013                            else {
20014                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20015                            }
20016                    }
20017    
20018                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20019                                    JournalArticle.class.getName(),
20020                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20021    
20022                    Session session = null;
20023    
20024                    try {
20025                            session = openSession();
20026    
20027                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
20028    
20029                            if (getDB().isSupportsInlineDistinct()) {
20030                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20031                            }
20032                            else {
20033                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20034                            }
20035    
20036                            QueryPos qPos = QueryPos.getInstance(q);
20037    
20038                            qPos.add(groupId);
20039    
20040                            qPos.add(folderId);
20041    
20042                            qPos.add(status);
20043    
20044                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20045                                    end);
20046                    }
20047                    catch (Exception e) {
20048                            throw processException(e);
20049                    }
20050                    finally {
20051                            closeSession(session);
20052                    }
20053            }
20054    
20055            /**
20056             * 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;.
20057             *
20058             * @param id the primary key of the current journal article
20059             * @param groupId the group ID
20060             * @param folderId the folder ID
20061             * @param status the status
20062             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
20063             * @return the previous, current, and next journal article
20064             * @throws NoSuchArticleException if a journal article with the primary key could not be found
20065             */
20066            @Override
20067            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
20068                    long groupId, long folderId, int status,
20069                    OrderByComparator<JournalArticle> orderByComparator)
20070                    throws NoSuchArticleException {
20071                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20072                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
20073                                    orderByComparator);
20074                    }
20075    
20076                    JournalArticle journalArticle = findByPrimaryKey(id);
20077    
20078                    Session session = null;
20079    
20080                    try {
20081                            session = openSession();
20082    
20083                            JournalArticle[] array = new JournalArticleImpl[3];
20084    
20085                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
20086                                            groupId, folderId, status, orderByComparator, true);
20087    
20088                            array[1] = journalArticle;
20089    
20090                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
20091                                            groupId, folderId, status, orderByComparator, false);
20092    
20093                            return array;
20094                    }
20095                    catch (Exception e) {
20096                            throw processException(e);
20097                    }
20098                    finally {
20099                            closeSession(session);
20100                    }
20101            }
20102    
20103            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
20104                    JournalArticle journalArticle, long groupId, long folderId, int status,
20105                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
20106                    StringBundler query = null;
20107    
20108                    if (orderByComparator != null) {
20109                            query = new StringBundler(6 +
20110                                            (orderByComparator.getOrderByFields().length * 6));
20111                    }
20112                    else {
20113                            query = new StringBundler(3);
20114                    }
20115    
20116                    if (getDB().isSupportsInlineDistinct()) {
20117                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20118                    }
20119                    else {
20120                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20121                    }
20122    
20123                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20124    
20125                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20126    
20127                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20128    
20129                    if (!getDB().isSupportsInlineDistinct()) {
20130                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20131                    }
20132    
20133                    if (orderByComparator != null) {
20134                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
20135    
20136                            if (orderByConditionFields.length > 0) {
20137                                    query.append(WHERE_AND);
20138                            }
20139    
20140                            for (int i = 0; i < orderByConditionFields.length; i++) {
20141                                    if (getDB().isSupportsInlineDistinct()) {
20142                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20143                                    }
20144                                    else {
20145                                            query.append(_ORDER_BY_ENTITY_TABLE);
20146                                    }
20147    
20148                                    query.append(orderByConditionFields[i]);
20149    
20150                                    if ((i + 1) < orderByConditionFields.length) {
20151                                            if (orderByComparator.isAscending() ^ previous) {
20152                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
20153                                            }
20154                                            else {
20155                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
20156                                            }
20157                                    }
20158                                    else {
20159                                            if (orderByComparator.isAscending() ^ previous) {
20160                                                    query.append(WHERE_GREATER_THAN);
20161                                            }
20162                                            else {
20163                                                    query.append(WHERE_LESSER_THAN);
20164                                            }
20165                                    }
20166                            }
20167    
20168                            query.append(ORDER_BY_CLAUSE);
20169    
20170                            String[] orderByFields = orderByComparator.getOrderByFields();
20171    
20172                            for (int i = 0; i < orderByFields.length; i++) {
20173                                    if (getDB().isSupportsInlineDistinct()) {
20174                                            query.append(_ORDER_BY_ENTITY_ALIAS);
20175                                    }
20176                                    else {
20177                                            query.append(_ORDER_BY_ENTITY_TABLE);
20178                                    }
20179    
20180                                    query.append(orderByFields[i]);
20181    
20182                                    if ((i + 1) < orderByFields.length) {
20183                                            if (orderByComparator.isAscending() ^ previous) {
20184                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
20185                                            }
20186                                            else {
20187                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20188                                            }
20189                                    }
20190                                    else {
20191                                            if (orderByComparator.isAscending() ^ previous) {
20192                                                    query.append(ORDER_BY_ASC);
20193                                            }
20194                                            else {
20195                                                    query.append(ORDER_BY_DESC);
20196                                            }
20197                                    }
20198                            }
20199                    }
20200                    else {
20201                            if (getDB().isSupportsInlineDistinct()) {
20202                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20203                            }
20204                            else {
20205                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20206                            }
20207                    }
20208    
20209                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20210                                    JournalArticle.class.getName(),
20211                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20212    
20213                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
20214    
20215                    q.setFirstResult(0);
20216                    q.setMaxResults(2);
20217    
20218                    if (getDB().isSupportsInlineDistinct()) {
20219                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20220                    }
20221                    else {
20222                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20223                    }
20224    
20225                    QueryPos qPos = QueryPos.getInstance(q);
20226    
20227                    qPos.add(groupId);
20228    
20229                    qPos.add(folderId);
20230    
20231                    qPos.add(status);
20232    
20233                    if (orderByComparator != null) {
20234                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20235    
20236                            for (Object value : values) {
20237                                    qPos.add(value);
20238                            }
20239                    }
20240    
20241                    List<JournalArticle> list = q.list();
20242    
20243                    if (list.size() == 2) {
20244                            return list.get(1);
20245                    }
20246                    else {
20247                            return null;
20248                    }
20249            }
20250    
20251            /**
20252             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
20253             *
20254             * @param groupId the group ID
20255             * @param folderId the folder ID
20256             * @param statuses the statuses
20257             * @return the matching journal articles that the user has permission to view
20258             */
20259            @Override
20260            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20261                    int[] statuses) {
20262                    return filterFindByG_F_ST(groupId, folderId, statuses,
20263                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20264            }
20265    
20266            /**
20267             * 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;.
20268             *
20269             * <p>
20270             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20271             * </p>
20272             *
20273             * @param groupId the group ID
20274             * @param folderId the folder ID
20275             * @param statuses the statuses
20276             * @param start the lower bound of the range of journal articles
20277             * @param end the upper bound of the range of journal articles (not inclusive)
20278             * @return the range of matching journal articles that the user has permission to view
20279             */
20280            @Override
20281            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20282                    int[] statuses, int start, int end) {
20283                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
20284            }
20285    
20286            /**
20287             * 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;.
20288             *
20289             * <p>
20290             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20291             * </p>
20292             *
20293             * @param groupId the group ID
20294             * @param folderId the folder ID
20295             * @param statuses the statuses
20296             * @param start the lower bound of the range of journal articles
20297             * @param end the upper bound of the range of journal articles (not inclusive)
20298             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20299             * @return the ordered range of matching journal articles that the user has permission to view
20300             */
20301            @Override
20302            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
20303                    int[] statuses, int start, int end,
20304                    OrderByComparator<JournalArticle> orderByComparator) {
20305                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20306                            return findByG_F_ST(groupId, folderId, statuses, start, end,
20307                                    orderByComparator);
20308                    }
20309    
20310                    if (statuses == null) {
20311                            statuses = new int[0];
20312                    }
20313                    else {
20314                            statuses = ArrayUtil.unique(statuses);
20315                    }
20316    
20317                    StringBundler query = new StringBundler();
20318    
20319                    if (getDB().isSupportsInlineDistinct()) {
20320                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
20321                    }
20322                    else {
20323                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
20324                    }
20325    
20326                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20327    
20328                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20329    
20330                    if (statuses.length > 0) {
20331                            query.append(StringPool.OPEN_PARENTHESIS);
20332    
20333                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_7);
20334    
20335                            query.append(StringUtil.merge(statuses));
20336    
20337                            query.append(StringPool.CLOSE_PARENTHESIS);
20338    
20339                            query.append(StringPool.CLOSE_PARENTHESIS);
20340                    }
20341    
20342                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
20343                            query.index() - 1);
20344    
20345                    if (!getDB().isSupportsInlineDistinct()) {
20346                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
20347                    }
20348    
20349                    if (orderByComparator != null) {
20350                            if (getDB().isSupportsInlineDistinct()) {
20351                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20352                                            orderByComparator, true);
20353                            }
20354                            else {
20355                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
20356                                            orderByComparator, true);
20357                            }
20358                    }
20359                    else {
20360                            if (getDB().isSupportsInlineDistinct()) {
20361                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20362                            }
20363                            else {
20364                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
20365                            }
20366                    }
20367    
20368                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20369                                    JournalArticle.class.getName(),
20370                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20371    
20372                    Session session = null;
20373    
20374                    try {
20375                            session = openSession();
20376    
20377                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
20378    
20379                            if (getDB().isSupportsInlineDistinct()) {
20380                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
20381                            }
20382                            else {
20383                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
20384                            }
20385    
20386                            QueryPos qPos = QueryPos.getInstance(q);
20387    
20388                            qPos.add(groupId);
20389    
20390                            qPos.add(folderId);
20391    
20392                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
20393                                    end);
20394                    }
20395                    catch (Exception e) {
20396                            throw processException(e);
20397                    }
20398                    finally {
20399                            closeSession(session);
20400                    }
20401            }
20402    
20403            /**
20404             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20405             *
20406             * <p>
20407             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20408             * </p>
20409             *
20410             * @param groupId the group ID
20411             * @param folderId the folder ID
20412             * @param statuses the statuses
20413             * @return the matching journal articles
20414             */
20415            @Override
20416            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20417                    int[] statuses) {
20418                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
20419                            QueryUtil.ALL_POS, null);
20420            }
20421    
20422            /**
20423             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20424             *
20425             * <p>
20426             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20427             * </p>
20428             *
20429             * @param groupId the group ID
20430             * @param folderId the folder ID
20431             * @param statuses the statuses
20432             * @param start the lower bound of the range of journal articles
20433             * @param end the upper bound of the range of journal articles (not inclusive)
20434             * @return the range of matching journal articles
20435             */
20436            @Override
20437            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20438                    int[] statuses, int start, int end) {
20439                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
20440            }
20441    
20442            /**
20443             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20444             *
20445             * <p>
20446             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20447             * </p>
20448             *
20449             * @param groupId the group ID
20450             * @param folderId the folder ID
20451             * @param statuses the statuses
20452             * @param start the lower bound of the range of journal articles
20453             * @param end the upper bound of the range of journal articles (not inclusive)
20454             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20455             * @return the ordered range of matching journal articles
20456             */
20457            @Override
20458            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
20459                    int[] statuses, int start, int end,
20460                    OrderByComparator<JournalArticle> orderByComparator) {
20461                    if (statuses == null) {
20462                            statuses = new int[0];
20463                    }
20464                    else {
20465                            statuses = ArrayUtil.unique(statuses);
20466                    }
20467    
20468                    if (statuses.length == 1) {
20469                            return findByG_F_ST(groupId, folderId, statuses[0], start, end,
20470                                    orderByComparator);
20471                    }
20472    
20473                    boolean pagination = true;
20474                    Object[] finderArgs = null;
20475    
20476                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20477                                    (orderByComparator == null)) {
20478                            pagination = false;
20479                            finderArgs = new Object[] {
20480                                            groupId, folderId, StringUtil.merge(statuses)
20481                                    };
20482                    }
20483                    else {
20484                            finderArgs = new Object[] {
20485                                            groupId, folderId, StringUtil.merge(statuses),
20486                                            
20487                                            start, end, orderByComparator
20488                                    };
20489                    }
20490    
20491                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
20492                                    finderArgs, this);
20493    
20494                    if ((list != null) && !list.isEmpty()) {
20495                            for (JournalArticle journalArticle : list) {
20496                                    if ((groupId != journalArticle.getGroupId()) ||
20497                                                    (folderId != journalArticle.getFolderId()) ||
20498                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
20499                                            list = null;
20500    
20501                                            break;
20502                                    }
20503                            }
20504                    }
20505    
20506                    if (list == null) {
20507                            StringBundler query = new StringBundler();
20508    
20509                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
20510    
20511                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20512    
20513                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20514    
20515                            if (statuses.length > 0) {
20516                                    query.append(StringPool.OPEN_PARENTHESIS);
20517    
20518                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_7);
20519    
20520                                    query.append(StringUtil.merge(statuses));
20521    
20522                                    query.append(StringPool.CLOSE_PARENTHESIS);
20523    
20524                                    query.append(StringPool.CLOSE_PARENTHESIS);
20525                            }
20526    
20527                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
20528                                                    1)), query.index() - 1);
20529    
20530                            if (orderByComparator != null) {
20531                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20532                                            orderByComparator);
20533                            }
20534                            else
20535                             if (pagination) {
20536                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20537                            }
20538    
20539                            String sql = query.toString();
20540    
20541                            Session session = null;
20542    
20543                            try {
20544                                    session = openSession();
20545    
20546                                    Query q = session.createQuery(sql);
20547    
20548                                    QueryPos qPos = QueryPos.getInstance(q);
20549    
20550                                    qPos.add(groupId);
20551    
20552                                    qPos.add(folderId);
20553    
20554                                    if (!pagination) {
20555                                            list = (List<JournalArticle>)QueryUtil.list(q,
20556                                                            getDialect(), start, end, false);
20557    
20558                                            Collections.sort(list);
20559    
20560                                            list = Collections.unmodifiableList(list);
20561                                    }
20562                                    else {
20563                                            list = (List<JournalArticle>)QueryUtil.list(q,
20564                                                            getDialect(), start, end);
20565                                    }
20566    
20567                                    cacheResult(list);
20568    
20569                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
20570                                            finderArgs, list);
20571                            }
20572                            catch (Exception e) {
20573                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST,
20574                                            finderArgs);
20575    
20576                                    throw processException(e);
20577                            }
20578                            finally {
20579                                    closeSession(session);
20580                            }
20581                    }
20582    
20583                    return list;
20584            }
20585    
20586            /**
20587             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
20588             *
20589             * @param groupId the group ID
20590             * @param folderId the folder ID
20591             * @param status the status
20592             */
20593            @Override
20594            public void removeByG_F_ST(long groupId, long folderId, int status) {
20595                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
20596                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
20597                            remove(journalArticle);
20598                    }
20599            }
20600    
20601            /**
20602             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
20603             *
20604             * @param groupId the group ID
20605             * @param folderId the folder ID
20606             * @param status the status
20607             * @return the number of matching journal articles
20608             */
20609            @Override
20610            public int countByG_F_ST(long groupId, long folderId, int status) {
20611                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_ST;
20612    
20613                    Object[] finderArgs = new Object[] { groupId, folderId, status };
20614    
20615                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
20616                                    this);
20617    
20618                    if (count == null) {
20619                            StringBundler query = new StringBundler(4);
20620    
20621                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20622    
20623                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20624    
20625                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20626    
20627                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20628    
20629                            String sql = query.toString();
20630    
20631                            Session session = null;
20632    
20633                            try {
20634                                    session = openSession();
20635    
20636                                    Query q = session.createQuery(sql);
20637    
20638                                    QueryPos qPos = QueryPos.getInstance(q);
20639    
20640                                    qPos.add(groupId);
20641    
20642                                    qPos.add(folderId);
20643    
20644                                    qPos.add(status);
20645    
20646                                    count = (Long)q.uniqueResult();
20647    
20648                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
20649                            }
20650                            catch (Exception e) {
20651                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
20652    
20653                                    throw processException(e);
20654                            }
20655                            finally {
20656                                    closeSession(session);
20657                            }
20658                    }
20659    
20660                    return count.intValue();
20661            }
20662    
20663            /**
20664             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
20665             *
20666             * @param groupId the group ID
20667             * @param folderId the folder ID
20668             * @param statuses the statuses
20669             * @return the number of matching journal articles
20670             */
20671            @Override
20672            public int countByG_F_ST(long groupId, long folderId, int[] statuses) {
20673                    if (statuses == null) {
20674                            statuses = new int[0];
20675                    }
20676                    else {
20677                            statuses = ArrayUtil.unique(statuses);
20678                    }
20679    
20680                    Object[] finderArgs = new Object[] {
20681                                    groupId, folderId, StringUtil.merge(statuses)
20682                            };
20683    
20684                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
20685                                    finderArgs, this);
20686    
20687                    if (count == null) {
20688                            StringBundler query = new StringBundler();
20689    
20690                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20691    
20692                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20693    
20694                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20695    
20696                            if (statuses.length > 0) {
20697                                    query.append(StringPool.OPEN_PARENTHESIS);
20698    
20699                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_7);
20700    
20701                                    query.append(StringUtil.merge(statuses));
20702    
20703                                    query.append(StringPool.CLOSE_PARENTHESIS);
20704    
20705                                    query.append(StringPool.CLOSE_PARENTHESIS);
20706                            }
20707    
20708                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
20709                                                    1)), query.index() - 1);
20710    
20711                            String sql = query.toString();
20712    
20713                            Session session = null;
20714    
20715                            try {
20716                                    session = openSession();
20717    
20718                                    Query q = session.createQuery(sql);
20719    
20720                                    QueryPos qPos = QueryPos.getInstance(q);
20721    
20722                                    qPos.add(groupId);
20723    
20724                                    qPos.add(folderId);
20725    
20726                                    count = (Long)q.uniqueResult();
20727    
20728                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
20729                                            finderArgs, count);
20730                            }
20731                            catch (Exception e) {
20732                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
20733                                            finderArgs);
20734    
20735                                    throw processException(e);
20736                            }
20737                            finally {
20738                                    closeSession(session);
20739                            }
20740                    }
20741    
20742                    return count.intValue();
20743            }
20744    
20745            /**
20746             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
20747             *
20748             * @param groupId the group ID
20749             * @param folderId the folder ID
20750             * @param status the status
20751             * @return the number of matching journal articles that the user has permission to view
20752             */
20753            @Override
20754            public int filterCountByG_F_ST(long groupId, long folderId, int status) {
20755                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20756                            return countByG_F_ST(groupId, folderId, status);
20757                    }
20758    
20759                    StringBundler query = new StringBundler(4);
20760    
20761                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20762    
20763                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20764    
20765                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20766    
20767                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
20768    
20769                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20770                                    JournalArticle.class.getName(),
20771                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20772    
20773                    Session session = null;
20774    
20775                    try {
20776                            session = openSession();
20777    
20778                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
20779    
20780                            q.addScalar(COUNT_COLUMN_NAME,
20781                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20782    
20783                            QueryPos qPos = QueryPos.getInstance(q);
20784    
20785                            qPos.add(groupId);
20786    
20787                            qPos.add(folderId);
20788    
20789                            qPos.add(status);
20790    
20791                            Long count = (Long)q.uniqueResult();
20792    
20793                            return count.intValue();
20794                    }
20795                    catch (Exception e) {
20796                            throw processException(e);
20797                    }
20798                    finally {
20799                            closeSession(session);
20800                    }
20801            }
20802    
20803            /**
20804             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
20805             *
20806             * @param groupId the group ID
20807             * @param folderId the folder ID
20808             * @param statuses the statuses
20809             * @return the number of matching journal articles that the user has permission to view
20810             */
20811            @Override
20812            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses) {
20813                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20814                            return countByG_F_ST(groupId, folderId, statuses);
20815                    }
20816    
20817                    if (statuses == null) {
20818                            statuses = new int[0];
20819                    }
20820                    else {
20821                            statuses = ArrayUtil.unique(statuses);
20822                    }
20823    
20824                    StringBundler query = new StringBundler();
20825    
20826                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20827    
20828                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
20829    
20830                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
20831    
20832                    if (statuses.length > 0) {
20833                            query.append(StringPool.OPEN_PARENTHESIS);
20834    
20835                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_7);
20836    
20837                            query.append(StringUtil.merge(statuses));
20838    
20839                            query.append(StringPool.CLOSE_PARENTHESIS);
20840    
20841                            query.append(StringPool.CLOSE_PARENTHESIS);
20842                    }
20843    
20844                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
20845                            query.index() - 1);
20846    
20847                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20848                                    JournalArticle.class.getName(),
20849                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20850    
20851                    Session session = null;
20852    
20853                    try {
20854                            session = openSession();
20855    
20856                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
20857    
20858                            q.addScalar(COUNT_COLUMN_NAME,
20859                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20860    
20861                            QueryPos qPos = QueryPos.getInstance(q);
20862    
20863                            qPos.add(groupId);
20864    
20865                            qPos.add(folderId);
20866    
20867                            Long count = (Long)q.uniqueResult();
20868    
20869                            return count.intValue();
20870                    }
20871                    catch (Exception e) {
20872                            throw processException(e);
20873                    }
20874                    finally {
20875                            closeSession(session);
20876                    }
20877            }
20878    
20879            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
20880            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
20881            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
20882            private static final String _FINDER_COLUMN_G_F_ST_STATUS_7 = "journalArticle.status IN (";
20883            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20884                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20885                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
20886                            "findByG_C_C",
20887                            new String[] {
20888                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
20889                                    
20890                            Integer.class.getName(), Integer.class.getName(),
20891                                    OrderByComparator.class.getName()
20892                            });
20893            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20894                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
20895                            JournalArticleImpl.class,
20896                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
20897                            new String[] {
20898                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20899                            },
20900                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
20901                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
20902                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK |
20903                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
20904                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
20905            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
20906                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
20907                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
20908                            new String[] {
20909                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
20910                            });
20911    
20912            /**
20913             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20914             *
20915             * @param groupId the group ID
20916             * @param classNameId the class name ID
20917             * @param classPK the class p k
20918             * @return the matching journal articles
20919             */
20920            @Override
20921            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
20922                    long classPK) {
20923                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
20924                            QueryUtil.ALL_POS, null);
20925            }
20926    
20927            /**
20928             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20929             *
20930             * <p>
20931             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20932             * </p>
20933             *
20934             * @param groupId the group ID
20935             * @param classNameId the class name ID
20936             * @param classPK the class p k
20937             * @param start the lower bound of the range of journal articles
20938             * @param end the upper bound of the range of journal articles (not inclusive)
20939             * @return the range of matching journal articles
20940             */
20941            @Override
20942            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
20943                    long classPK, int start, int end) {
20944                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
20945            }
20946    
20947            /**
20948             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
20949             *
20950             * <p>
20951             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
20952             * </p>
20953             *
20954             * @param groupId the group ID
20955             * @param classNameId the class name ID
20956             * @param classPK the class p k
20957             * @param start the lower bound of the range of journal articles
20958             * @param end the upper bound of the range of journal articles (not inclusive)
20959             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20960             * @return the ordered range of matching journal articles
20961             */
20962            @Override
20963            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
20964                    long classPK, int start, int end,
20965                    OrderByComparator<JournalArticle> orderByComparator) {
20966                    boolean pagination = true;
20967                    FinderPath finderPath = null;
20968                    Object[] finderArgs = null;
20969    
20970                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20971                                    (orderByComparator == null)) {
20972                            pagination = false;
20973                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
20974                            finderArgs = new Object[] { groupId, classNameId, classPK };
20975                    }
20976                    else {
20977                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
20978                            finderArgs = new Object[] {
20979                                            groupId, classNameId, classPK,
20980                                            
20981                                            start, end, orderByComparator
20982                                    };
20983                    }
20984    
20985                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
20986                                    finderArgs, this);
20987    
20988                    if ((list != null) && !list.isEmpty()) {
20989                            for (JournalArticle journalArticle : list) {
20990                                    if ((groupId != journalArticle.getGroupId()) ||
20991                                                    (classNameId != journalArticle.getClassNameId()) ||
20992                                                    (classPK != journalArticle.getClassPK())) {
20993                                            list = null;
20994    
20995                                            break;
20996                                    }
20997                            }
20998                    }
20999    
21000                    if (list == null) {
21001                            StringBundler query = null;
21002    
21003                            if (orderByComparator != null) {
21004                                    query = new StringBundler(5 +
21005                                                    (orderByComparator.getOrderByFields().length * 3));
21006                            }
21007                            else {
21008                                    query = new StringBundler(5);
21009                            }
21010    
21011                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21012    
21013                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21014    
21015                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21016    
21017                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21018    
21019                            if (orderByComparator != null) {
21020                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21021                                            orderByComparator);
21022                            }
21023                            else
21024                             if (pagination) {
21025                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21026                            }
21027    
21028                            String sql = query.toString();
21029    
21030                            Session session = null;
21031    
21032                            try {
21033                                    session = openSession();
21034    
21035                                    Query q = session.createQuery(sql);
21036    
21037                                    QueryPos qPos = QueryPos.getInstance(q);
21038    
21039                                    qPos.add(groupId);
21040    
21041                                    qPos.add(classNameId);
21042    
21043                                    qPos.add(classPK);
21044    
21045                                    if (!pagination) {
21046                                            list = (List<JournalArticle>)QueryUtil.list(q,
21047                                                            getDialect(), start, end, false);
21048    
21049                                            Collections.sort(list);
21050    
21051                                            list = Collections.unmodifiableList(list);
21052                                    }
21053                                    else {
21054                                            list = (List<JournalArticle>)QueryUtil.list(q,
21055                                                            getDialect(), start, end);
21056                                    }
21057    
21058                                    cacheResult(list);
21059    
21060                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
21061                            }
21062                            catch (Exception e) {
21063                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21064    
21065                                    throw processException(e);
21066                            }
21067                            finally {
21068                                    closeSession(session);
21069                            }
21070                    }
21071    
21072                    return list;
21073            }
21074    
21075            /**
21076             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21077             *
21078             * @param groupId the group ID
21079             * @param classNameId the class name ID
21080             * @param classPK the class p k
21081             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21082             * @return the first matching journal article
21083             * @throws NoSuchArticleException if a matching journal article could not be found
21084             */
21085            @Override
21086            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
21087                    long classPK, OrderByComparator<JournalArticle> orderByComparator)
21088                    throws NoSuchArticleException {
21089                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
21090                                    classNameId, classPK, orderByComparator);
21091    
21092                    if (journalArticle != null) {
21093                            return journalArticle;
21094                    }
21095    
21096                    StringBundler msg = new StringBundler(8);
21097    
21098                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21099    
21100                    msg.append("groupId=");
21101                    msg.append(groupId);
21102    
21103                    msg.append(", classNameId=");
21104                    msg.append(classNameId);
21105    
21106                    msg.append(", classPK=");
21107                    msg.append(classPK);
21108    
21109                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21110    
21111                    throw new NoSuchArticleException(msg.toString());
21112            }
21113    
21114            /**
21115             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21116             *
21117             * @param groupId the group ID
21118             * @param classNameId the class name ID
21119             * @param classPK the class p k
21120             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21121             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
21122             */
21123            @Override
21124            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
21125                    long classPK, OrderByComparator<JournalArticle> orderByComparator) {
21126                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
21127                                    0, 1, orderByComparator);
21128    
21129                    if (!list.isEmpty()) {
21130                            return list.get(0);
21131                    }
21132    
21133                    return null;
21134            }
21135    
21136            /**
21137             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21138             *
21139             * @param groupId the group ID
21140             * @param classNameId the class name ID
21141             * @param classPK the class p k
21142             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21143             * @return the last matching journal article
21144             * @throws NoSuchArticleException if a matching journal article could not be found
21145             */
21146            @Override
21147            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
21148                    long classPK, OrderByComparator<JournalArticle> orderByComparator)
21149                    throws NoSuchArticleException {
21150                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
21151                                    classPK, orderByComparator);
21152    
21153                    if (journalArticle != null) {
21154                            return journalArticle;
21155                    }
21156    
21157                    StringBundler msg = new StringBundler(8);
21158    
21159                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21160    
21161                    msg.append("groupId=");
21162                    msg.append(groupId);
21163    
21164                    msg.append(", classNameId=");
21165                    msg.append(classNameId);
21166    
21167                    msg.append(", classPK=");
21168                    msg.append(classPK);
21169    
21170                    msg.append(StringPool.CLOSE_CURLY_BRACE);
21171    
21172                    throw new NoSuchArticleException(msg.toString());
21173            }
21174    
21175            /**
21176             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21177             *
21178             * @param groupId the group ID
21179             * @param classNameId the class name ID
21180             * @param classPK the class p k
21181             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21182             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
21183             */
21184            @Override
21185            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
21186                    long classPK, OrderByComparator<JournalArticle> orderByComparator) {
21187                    int count = countByG_C_C(groupId, classNameId, classPK);
21188    
21189                    if (count == 0) {
21190                            return null;
21191                    }
21192    
21193                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
21194                                    count - 1, count, orderByComparator);
21195    
21196                    if (!list.isEmpty()) {
21197                            return list.get(0);
21198                    }
21199    
21200                    return null;
21201            }
21202    
21203            /**
21204             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21205             *
21206             * @param id the primary key of the current journal article
21207             * @param groupId the group ID
21208             * @param classNameId the class name ID
21209             * @param classPK the class p k
21210             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21211             * @return the previous, current, and next journal article
21212             * @throws NoSuchArticleException if a journal article with the primary key could not be found
21213             */
21214            @Override
21215            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
21216                    long classNameId, long classPK,
21217                    OrderByComparator<JournalArticle> orderByComparator)
21218                    throws NoSuchArticleException {
21219                    JournalArticle journalArticle = findByPrimaryKey(id);
21220    
21221                    Session session = null;
21222    
21223                    try {
21224                            session = openSession();
21225    
21226                            JournalArticle[] array = new JournalArticleImpl[3];
21227    
21228                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
21229                                            classNameId, classPK, orderByComparator, true);
21230    
21231                            array[1] = journalArticle;
21232    
21233                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
21234                                            classNameId, classPK, orderByComparator, false);
21235    
21236                            return array;
21237                    }
21238                    catch (Exception e) {
21239                            throw processException(e);
21240                    }
21241                    finally {
21242                            closeSession(session);
21243                    }
21244            }
21245    
21246            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
21247                    JournalArticle journalArticle, long groupId, long classNameId,
21248                    long classPK, OrderByComparator<JournalArticle> orderByComparator,
21249                    boolean previous) {
21250                    StringBundler query = null;
21251    
21252                    if (orderByComparator != null) {
21253                            query = new StringBundler(6 +
21254                                            (orderByComparator.getOrderByFields().length * 6));
21255                    }
21256                    else {
21257                            query = new StringBundler(3);
21258                    }
21259    
21260                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21261    
21262                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21263    
21264                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21265    
21266                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21267    
21268                    if (orderByComparator != null) {
21269                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21270    
21271                            if (orderByConditionFields.length > 0) {
21272                                    query.append(WHERE_AND);
21273                            }
21274    
21275                            for (int i = 0; i < orderByConditionFields.length; i++) {
21276                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21277                                    query.append(orderByConditionFields[i]);
21278    
21279                                    if ((i + 1) < orderByConditionFields.length) {
21280                                            if (orderByComparator.isAscending() ^ previous) {
21281                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21282                                            }
21283                                            else {
21284                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21285                                            }
21286                                    }
21287                                    else {
21288                                            if (orderByComparator.isAscending() ^ previous) {
21289                                                    query.append(WHERE_GREATER_THAN);
21290                                            }
21291                                            else {
21292                                                    query.append(WHERE_LESSER_THAN);
21293                                            }
21294                                    }
21295                            }
21296    
21297                            query.append(ORDER_BY_CLAUSE);
21298    
21299                            String[] orderByFields = orderByComparator.getOrderByFields();
21300    
21301                            for (int i = 0; i < orderByFields.length; i++) {
21302                                    query.append(_ORDER_BY_ENTITY_ALIAS);
21303                                    query.append(orderByFields[i]);
21304    
21305                                    if ((i + 1) < orderByFields.length) {
21306                                            if (orderByComparator.isAscending() ^ previous) {
21307                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21308                                            }
21309                                            else {
21310                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21311                                            }
21312                                    }
21313                                    else {
21314                                            if (orderByComparator.isAscending() ^ previous) {
21315                                                    query.append(ORDER_BY_ASC);
21316                                            }
21317                                            else {
21318                                                    query.append(ORDER_BY_DESC);
21319                                            }
21320                                    }
21321                            }
21322                    }
21323                    else {
21324                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21325                    }
21326    
21327                    String sql = query.toString();
21328    
21329                    Query q = session.createQuery(sql);
21330    
21331                    q.setFirstResult(0);
21332                    q.setMaxResults(2);
21333    
21334                    QueryPos qPos = QueryPos.getInstance(q);
21335    
21336                    qPos.add(groupId);
21337    
21338                    qPos.add(classNameId);
21339    
21340                    qPos.add(classPK);
21341    
21342                    if (orderByComparator != null) {
21343                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21344    
21345                            for (Object value : values) {
21346                                    qPos.add(value);
21347                            }
21348                    }
21349    
21350                    List<JournalArticle> list = q.list();
21351    
21352                    if (list.size() == 2) {
21353                            return list.get(1);
21354                    }
21355                    else {
21356                            return null;
21357                    }
21358            }
21359    
21360            /**
21361             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21362             *
21363             * @param groupId the group ID
21364             * @param classNameId the class name ID
21365             * @param classPK the class p k
21366             * @return the matching journal articles that the user has permission to view
21367             */
21368            @Override
21369            public List<JournalArticle> filterFindByG_C_C(long groupId,
21370                    long classNameId, long classPK) {
21371                    return filterFindByG_C_C(groupId, classNameId, classPK,
21372                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
21373            }
21374    
21375            /**
21376             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21377             *
21378             * <p>
21379             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21380             * </p>
21381             *
21382             * @param groupId the group ID
21383             * @param classNameId the class name ID
21384             * @param classPK the class p k
21385             * @param start the lower bound of the range of journal articles
21386             * @param end the upper bound of the range of journal articles (not inclusive)
21387             * @return the range of matching journal articles that the user has permission to view
21388             */
21389            @Override
21390            public List<JournalArticle> filterFindByG_C_C(long groupId,
21391                    long classNameId, long classPK, int start, int end) {
21392                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
21393            }
21394    
21395            /**
21396             * 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;.
21397             *
21398             * <p>
21399             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
21400             * </p>
21401             *
21402             * @param groupId the group ID
21403             * @param classNameId the class name ID
21404             * @param classPK the class p k
21405             * @param start the lower bound of the range of journal articles
21406             * @param end the upper bound of the range of journal articles (not inclusive)
21407             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
21408             * @return the ordered range of matching journal articles that the user has permission to view
21409             */
21410            @Override
21411            public List<JournalArticle> filterFindByG_C_C(long groupId,
21412                    long classNameId, long classPK, int start, int end,
21413                    OrderByComparator<JournalArticle> orderByComparator) {
21414                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21415                            return findByG_C_C(groupId, classNameId, classPK, start, end,
21416                                    orderByComparator);
21417                    }
21418    
21419                    StringBundler query = null;
21420    
21421                    if (orderByComparator != null) {
21422                            query = new StringBundler(5 +
21423                                            (orderByComparator.getOrderByFields().length * 3));
21424                    }
21425                    else {
21426                            query = new StringBundler(5);
21427                    }
21428    
21429                    if (getDB().isSupportsInlineDistinct()) {
21430                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21431                    }
21432                    else {
21433                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21434                    }
21435    
21436                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21437    
21438                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21439    
21440                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21441    
21442                    if (!getDB().isSupportsInlineDistinct()) {
21443                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21444                    }
21445    
21446                    if (orderByComparator != null) {
21447                            if (getDB().isSupportsInlineDistinct()) {
21448                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
21449                                            orderByComparator, true);
21450                            }
21451                            else {
21452                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
21453                                            orderByComparator, true);
21454                            }
21455                    }
21456                    else {
21457                            if (getDB().isSupportsInlineDistinct()) {
21458                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21459                            }
21460                            else {
21461                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21462                            }
21463                    }
21464    
21465                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21466                                    JournalArticle.class.getName(),
21467                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21468    
21469                    Session session = null;
21470    
21471                    try {
21472                            session = openSession();
21473    
21474                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
21475    
21476                            if (getDB().isSupportsInlineDistinct()) {
21477                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21478                            }
21479                            else {
21480                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21481                            }
21482    
21483                            QueryPos qPos = QueryPos.getInstance(q);
21484    
21485                            qPos.add(groupId);
21486    
21487                            qPos.add(classNameId);
21488    
21489                            qPos.add(classPK);
21490    
21491                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
21492                                    end);
21493                    }
21494                    catch (Exception e) {
21495                            throw processException(e);
21496                    }
21497                    finally {
21498                            closeSession(session);
21499                    }
21500            }
21501    
21502            /**
21503             * 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;.
21504             *
21505             * @param id the primary key of the current journal article
21506             * @param groupId the group ID
21507             * @param classNameId the class name ID
21508             * @param classPK the class p k
21509             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
21510             * @return the previous, current, and next journal article
21511             * @throws NoSuchArticleException if a journal article with the primary key could not be found
21512             */
21513            @Override
21514            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
21515                    long groupId, long classNameId, long classPK,
21516                    OrderByComparator<JournalArticle> orderByComparator)
21517                    throws NoSuchArticleException {
21518                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21519                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
21520                                    orderByComparator);
21521                    }
21522    
21523                    JournalArticle journalArticle = findByPrimaryKey(id);
21524    
21525                    Session session = null;
21526    
21527                    try {
21528                            session = openSession();
21529    
21530                            JournalArticle[] array = new JournalArticleImpl[3];
21531    
21532                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
21533                                            groupId, classNameId, classPK, orderByComparator, true);
21534    
21535                            array[1] = journalArticle;
21536    
21537                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
21538                                            groupId, classNameId, classPK, orderByComparator, false);
21539    
21540                            return array;
21541                    }
21542                    catch (Exception e) {
21543                            throw processException(e);
21544                    }
21545                    finally {
21546                            closeSession(session);
21547                    }
21548            }
21549    
21550            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
21551                    JournalArticle journalArticle, long groupId, long classNameId,
21552                    long classPK, OrderByComparator<JournalArticle> orderByComparator,
21553                    boolean previous) {
21554                    StringBundler query = null;
21555    
21556                    if (orderByComparator != null) {
21557                            query = new StringBundler(6 +
21558                                            (orderByComparator.getOrderByFields().length * 6));
21559                    }
21560                    else {
21561                            query = new StringBundler(3);
21562                    }
21563    
21564                    if (getDB().isSupportsInlineDistinct()) {
21565                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
21566                    }
21567                    else {
21568                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
21569                    }
21570    
21571                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21572    
21573                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21574    
21575                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21576    
21577                    if (!getDB().isSupportsInlineDistinct()) {
21578                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
21579                    }
21580    
21581                    if (orderByComparator != null) {
21582                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
21583    
21584                            if (orderByConditionFields.length > 0) {
21585                                    query.append(WHERE_AND);
21586                            }
21587    
21588                            for (int i = 0; i < orderByConditionFields.length; i++) {
21589                                    if (getDB().isSupportsInlineDistinct()) {
21590                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21591                                    }
21592                                    else {
21593                                            query.append(_ORDER_BY_ENTITY_TABLE);
21594                                    }
21595    
21596                                    query.append(orderByConditionFields[i]);
21597    
21598                                    if ((i + 1) < orderByConditionFields.length) {
21599                                            if (orderByComparator.isAscending() ^ previous) {
21600                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
21601                                            }
21602                                            else {
21603                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
21604                                            }
21605                                    }
21606                                    else {
21607                                            if (orderByComparator.isAscending() ^ previous) {
21608                                                    query.append(WHERE_GREATER_THAN);
21609                                            }
21610                                            else {
21611                                                    query.append(WHERE_LESSER_THAN);
21612                                            }
21613                                    }
21614                            }
21615    
21616                            query.append(ORDER_BY_CLAUSE);
21617    
21618                            String[] orderByFields = orderByComparator.getOrderByFields();
21619    
21620                            for (int i = 0; i < orderByFields.length; i++) {
21621                                    if (getDB().isSupportsInlineDistinct()) {
21622                                            query.append(_ORDER_BY_ENTITY_ALIAS);
21623                                    }
21624                                    else {
21625                                            query.append(_ORDER_BY_ENTITY_TABLE);
21626                                    }
21627    
21628                                    query.append(orderByFields[i]);
21629    
21630                                    if ((i + 1) < orderByFields.length) {
21631                                            if (orderByComparator.isAscending() ^ previous) {
21632                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
21633                                            }
21634                                            else {
21635                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
21636                                            }
21637                                    }
21638                                    else {
21639                                            if (orderByComparator.isAscending() ^ previous) {
21640                                                    query.append(ORDER_BY_ASC);
21641                                            }
21642                                            else {
21643                                                    query.append(ORDER_BY_DESC);
21644                                            }
21645                                    }
21646                            }
21647                    }
21648                    else {
21649                            if (getDB().isSupportsInlineDistinct()) {
21650                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
21651                            }
21652                            else {
21653                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
21654                            }
21655                    }
21656    
21657                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21658                                    JournalArticle.class.getName(),
21659                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21660    
21661                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
21662    
21663                    q.setFirstResult(0);
21664                    q.setMaxResults(2);
21665    
21666                    if (getDB().isSupportsInlineDistinct()) {
21667                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
21668                    }
21669                    else {
21670                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
21671                    }
21672    
21673                    QueryPos qPos = QueryPos.getInstance(q);
21674    
21675                    qPos.add(groupId);
21676    
21677                    qPos.add(classNameId);
21678    
21679                    qPos.add(classPK);
21680    
21681                    if (orderByComparator != null) {
21682                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
21683    
21684                            for (Object value : values) {
21685                                    qPos.add(value);
21686                            }
21687                    }
21688    
21689                    List<JournalArticle> list = q.list();
21690    
21691                    if (list.size() == 2) {
21692                            return list.get(1);
21693                    }
21694                    else {
21695                            return null;
21696                    }
21697            }
21698    
21699            /**
21700             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
21701             *
21702             * @param groupId the group ID
21703             * @param classNameId the class name ID
21704             * @param classPK the class p k
21705             */
21706            @Override
21707            public void removeByG_C_C(long groupId, long classNameId, long classPK) {
21708                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
21709                                    classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
21710                            remove(journalArticle);
21711                    }
21712            }
21713    
21714            /**
21715             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21716             *
21717             * @param groupId the group ID
21718             * @param classNameId the class name ID
21719             * @param classPK the class p k
21720             * @return the number of matching journal articles
21721             */
21722            @Override
21723            public int countByG_C_C(long groupId, long classNameId, long classPK) {
21724                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
21725    
21726                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
21727    
21728                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
21729                                    this);
21730    
21731                    if (count == null) {
21732                            StringBundler query = new StringBundler(4);
21733    
21734                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21735    
21736                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21737    
21738                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21739    
21740                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21741    
21742                            String sql = query.toString();
21743    
21744                            Session session = null;
21745    
21746                            try {
21747                                    session = openSession();
21748    
21749                                    Query q = session.createQuery(sql);
21750    
21751                                    QueryPos qPos = QueryPos.getInstance(q);
21752    
21753                                    qPos.add(groupId);
21754    
21755                                    qPos.add(classNameId);
21756    
21757                                    qPos.add(classPK);
21758    
21759                                    count = (Long)q.uniqueResult();
21760    
21761                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
21762                            }
21763                            catch (Exception e) {
21764                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
21765    
21766                                    throw processException(e);
21767                            }
21768                            finally {
21769                                    closeSession(session);
21770                            }
21771                    }
21772    
21773                    return count.intValue();
21774            }
21775    
21776            /**
21777             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
21778             *
21779             * @param groupId the group ID
21780             * @param classNameId the class name ID
21781             * @param classPK the class p k
21782             * @return the number of matching journal articles that the user has permission to view
21783             */
21784            @Override
21785            public int filterCountByG_C_C(long groupId, long classNameId, long classPK) {
21786                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21787                            return countByG_C_C(groupId, classNameId, classPK);
21788                    }
21789    
21790                    StringBundler query = new StringBundler(4);
21791    
21792                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21793    
21794                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
21795    
21796                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
21797    
21798                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
21799    
21800                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21801                                    JournalArticle.class.getName(),
21802                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21803    
21804                    Session session = null;
21805    
21806                    try {
21807                            session = openSession();
21808    
21809                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
21810    
21811                            q.addScalar(COUNT_COLUMN_NAME,
21812                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21813    
21814                            QueryPos qPos = QueryPos.getInstance(q);
21815    
21816                            qPos.add(groupId);
21817    
21818                            qPos.add(classNameId);
21819    
21820                            qPos.add(classPK);
21821    
21822                            Long count = (Long)q.uniqueResult();
21823    
21824                            return count.intValue();
21825                    }
21826                    catch (Exception e) {
21827                            throw processException(e);
21828                    }
21829                    finally {
21830                            closeSession(session);
21831                    }
21832            }
21833    
21834            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
21835            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
21836            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
21837            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_DDMSK = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21838                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
21839                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
21840                            "fetchByG_C_DDMSK",
21841                            new String[] {
21842                                    Long.class.getName(), Long.class.getName(),
21843                                    String.class.getName()
21844                            },
21845                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
21846                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
21847                            JournalArticleModelImpl.DDMSTRUCTUREKEY_COLUMN_BITMASK);
21848            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_DDMSK = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
21849                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
21850                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_DDMSK",
21851                            new String[] {
21852                                    Long.class.getName(), Long.class.getName(),
21853                                    String.class.getName()
21854                            });
21855    
21856            /**
21857             * Returns the journal article where groupId = &#63; and classNameId = &#63; and DDMStructureKey = &#63; or throws a {@link NoSuchArticleException} if it could not be found.
21858             *
21859             * @param groupId the group ID
21860             * @param classNameId the class name ID
21861             * @param DDMStructureKey the d d m structure key
21862             * @return the matching journal article
21863             * @throws NoSuchArticleException if a matching journal article could not be found
21864             */
21865            @Override
21866            public JournalArticle findByG_C_DDMSK(long groupId, long classNameId,
21867                    String DDMStructureKey) throws NoSuchArticleException {
21868                    JournalArticle journalArticle = fetchByG_C_DDMSK(groupId, classNameId,
21869                                    DDMStructureKey);
21870    
21871                    if (journalArticle == null) {
21872                            StringBundler msg = new StringBundler(8);
21873    
21874                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
21875    
21876                            msg.append("groupId=");
21877                            msg.append(groupId);
21878    
21879                            msg.append(", classNameId=");
21880                            msg.append(classNameId);
21881    
21882                            msg.append(", DDMStructureKey=");
21883                            msg.append(DDMStructureKey);
21884    
21885                            msg.append(StringPool.CLOSE_CURLY_BRACE);
21886    
21887                            if (_log.isWarnEnabled()) {
21888                                    _log.warn(msg.toString());
21889                            }
21890    
21891                            throw new NoSuchArticleException(msg.toString());
21892                    }
21893    
21894                    return journalArticle;
21895            }
21896    
21897            /**
21898             * Returns the journal article where groupId = &#63; and classNameId = &#63; and DDMStructureKey = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
21899             *
21900             * @param groupId the group ID
21901             * @param classNameId the class name ID
21902             * @param DDMStructureKey the d d m structure key
21903             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
21904             */
21905            @Override
21906            public JournalArticle fetchByG_C_DDMSK(long groupId, long classNameId,
21907                    String DDMStructureKey) {
21908                    return fetchByG_C_DDMSK(groupId, classNameId, DDMStructureKey, true);
21909            }
21910    
21911            /**
21912             * Returns the journal article where groupId = &#63; and classNameId = &#63; and DDMStructureKey = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
21913             *
21914             * @param groupId the group ID
21915             * @param classNameId the class name ID
21916             * @param DDMStructureKey the d d m structure key
21917             * @param retrieveFromCache whether to use the finder cache
21918             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
21919             */
21920            @Override
21921            public JournalArticle fetchByG_C_DDMSK(long groupId, long classNameId,
21922                    String DDMStructureKey, boolean retrieveFromCache) {
21923                    Object[] finderArgs = new Object[] { groupId, classNameId, DDMStructureKey };
21924    
21925                    Object result = null;
21926    
21927                    if (retrieveFromCache) {
21928                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_DDMSK,
21929                                            finderArgs, this);
21930                    }
21931    
21932                    if (result instanceof JournalArticle) {
21933                            JournalArticle journalArticle = (JournalArticle)result;
21934    
21935                            if ((groupId != journalArticle.getGroupId()) ||
21936                                            (classNameId != journalArticle.getClassNameId()) ||
21937                                            !Validator.equals(DDMStructureKey,
21938                                                    journalArticle.getDDMStructureKey())) {
21939                                    result = null;
21940                            }
21941                    }
21942    
21943                    if (result == null) {
21944                            StringBundler query = new StringBundler(5);
21945    
21946                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
21947    
21948                            query.append(_FINDER_COLUMN_G_C_DDMSK_GROUPID_2);
21949    
21950                            query.append(_FINDER_COLUMN_G_C_DDMSK_CLASSNAMEID_2);
21951    
21952                            boolean bindDDMStructureKey = false;
21953    
21954                            if (DDMStructureKey == null) {
21955                                    query.append(_FINDER_COLUMN_G_C_DDMSK_DDMSTRUCTUREKEY_1);
21956                            }
21957                            else if (DDMStructureKey.equals(StringPool.BLANK)) {
21958                                    query.append(_FINDER_COLUMN_G_C_DDMSK_DDMSTRUCTUREKEY_3);
21959                            }
21960                            else {
21961                                    bindDDMStructureKey = true;
21962    
21963                                    query.append(_FINDER_COLUMN_G_C_DDMSK_DDMSTRUCTUREKEY_2);
21964                            }
21965    
21966                            String sql = query.toString();
21967    
21968                            Session session = null;
21969    
21970                            try {
21971                                    session = openSession();
21972    
21973                                    Query q = session.createQuery(sql);
21974    
21975                                    QueryPos qPos = QueryPos.getInstance(q);
21976    
21977                                    qPos.add(groupId);
21978    
21979                                    qPos.add(classNameId);
21980    
21981                                    if (bindDDMStructureKey) {
21982                                            qPos.add(DDMStructureKey);
21983                                    }
21984    
21985                                    List<JournalArticle> list = q.list();
21986    
21987                                    if (list.isEmpty()) {
21988                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_DDMSK,
21989                                                    finderArgs, list);
21990                                    }
21991                                    else {
21992                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
21993                                                    _log.warn(
21994                                                            "JournalArticlePersistenceImpl.fetchByG_C_DDMSK(long, long, String, boolean) with parameters (" +
21995                                                            StringUtil.merge(finderArgs) +
21996                                                            ") 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.");
21997                                            }
21998    
21999                                            JournalArticle journalArticle = list.get(0);
22000    
22001                                            result = journalArticle;
22002    
22003                                            cacheResult(journalArticle);
22004    
22005                                            if ((journalArticle.getGroupId() != groupId) ||
22006                                                            (journalArticle.getClassNameId() != classNameId) ||
22007                                                            (journalArticle.getDDMStructureKey() == null) ||
22008                                                            !journalArticle.getDDMStructureKey()
22009                                                                                               .equals(DDMStructureKey)) {
22010                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_DDMSK,
22011                                                            finderArgs, journalArticle);
22012                                            }
22013                                    }
22014                            }
22015                            catch (Exception e) {
22016                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_DDMSK,
22017                                            finderArgs);
22018    
22019                                    throw processException(e);
22020                            }
22021                            finally {
22022                                    closeSession(session);
22023                            }
22024                    }
22025    
22026                    if (result instanceof List<?>) {
22027                            return null;
22028                    }
22029                    else {
22030                            return (JournalArticle)result;
22031                    }
22032            }
22033    
22034            /**
22035             * Removes the journal article where groupId = &#63; and classNameId = &#63; and DDMStructureKey = &#63; from the database.
22036             *
22037             * @param groupId the group ID
22038             * @param classNameId the class name ID
22039             * @param DDMStructureKey the d d m structure key
22040             * @return the journal article that was removed
22041             */
22042            @Override
22043            public JournalArticle removeByG_C_DDMSK(long groupId, long classNameId,
22044                    String DDMStructureKey) throws NoSuchArticleException {
22045                    JournalArticle journalArticle = findByG_C_DDMSK(groupId, classNameId,
22046                                    DDMStructureKey);
22047    
22048                    return remove(journalArticle);
22049            }
22050    
22051            /**
22052             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and DDMStructureKey = &#63;.
22053             *
22054             * @param groupId the group ID
22055             * @param classNameId the class name ID
22056             * @param DDMStructureKey the d d m structure key
22057             * @return the number of matching journal articles
22058             */
22059            @Override
22060            public int countByG_C_DDMSK(long groupId, long classNameId,
22061                    String DDMStructureKey) {
22062                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_DDMSK;
22063    
22064                    Object[] finderArgs = new Object[] { groupId, classNameId, DDMStructureKey };
22065    
22066                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
22067                                    this);
22068    
22069                    if (count == null) {
22070                            StringBundler query = new StringBundler(4);
22071    
22072                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22073    
22074                            query.append(_FINDER_COLUMN_G_C_DDMSK_GROUPID_2);
22075    
22076                            query.append(_FINDER_COLUMN_G_C_DDMSK_CLASSNAMEID_2);
22077    
22078                            boolean bindDDMStructureKey = false;
22079    
22080                            if (DDMStructureKey == null) {
22081                                    query.append(_FINDER_COLUMN_G_C_DDMSK_DDMSTRUCTUREKEY_1);
22082                            }
22083                            else if (DDMStructureKey.equals(StringPool.BLANK)) {
22084                                    query.append(_FINDER_COLUMN_G_C_DDMSK_DDMSTRUCTUREKEY_3);
22085                            }
22086                            else {
22087                                    bindDDMStructureKey = true;
22088    
22089                                    query.append(_FINDER_COLUMN_G_C_DDMSK_DDMSTRUCTUREKEY_2);
22090                            }
22091    
22092                            String sql = query.toString();
22093    
22094                            Session session = null;
22095    
22096                            try {
22097                                    session = openSession();
22098    
22099                                    Query q = session.createQuery(sql);
22100    
22101                                    QueryPos qPos = QueryPos.getInstance(q);
22102    
22103                                    qPos.add(groupId);
22104    
22105                                    qPos.add(classNameId);
22106    
22107                                    if (bindDDMStructureKey) {
22108                                            qPos.add(DDMStructureKey);
22109                                    }
22110    
22111                                    count = (Long)q.uniqueResult();
22112    
22113                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
22114                            }
22115                            catch (Exception e) {
22116                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22117    
22118                                    throw processException(e);
22119                            }
22120                            finally {
22121                                    closeSession(session);
22122                            }
22123                    }
22124    
22125                    return count.intValue();
22126            }
22127    
22128            private static final String _FINDER_COLUMN_G_C_DDMSK_GROUPID_2 = "journalArticle.groupId = ? AND ";
22129            private static final String _FINDER_COLUMN_G_C_DDMSK_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
22130            private static final String _FINDER_COLUMN_G_C_DDMSK_DDMSTRUCTUREKEY_1 = "journalArticle.DDMStructureKey IS NULL";
22131            private static final String _FINDER_COLUMN_G_C_DDMSK_DDMSTRUCTUREKEY_2 = "journalArticle.DDMStructureKey = ?";
22132            private static final String _FINDER_COLUMN_G_C_DDMSK_DDMSTRUCTUREKEY_3 = "(journalArticle.DDMStructureKey IS NULL OR journalArticle.DDMStructureKey = '')";
22133            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_DDMTK =
22134                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22135                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22136                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
22137                            "findByG_C_DDMTK",
22138                            new String[] {
22139                                    Long.class.getName(), Long.class.getName(),
22140                                    String.class.getName(),
22141                                    
22142                            Integer.class.getName(), Integer.class.getName(),
22143                                    OrderByComparator.class.getName()
22144                            });
22145            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_DDMTK =
22146                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22147                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
22148                            JournalArticleImpl.class,
22149                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_DDMTK",
22150                            new String[] {
22151                                    Long.class.getName(), Long.class.getName(),
22152                                    String.class.getName()
22153                            },
22154                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
22155                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
22156                            JournalArticleModelImpl.DDMTEMPLATEKEY_COLUMN_BITMASK |
22157                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
22158                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
22159            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_DDMTK = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
22160                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
22161                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_DDMTK",
22162                            new String[] {
22163                                    Long.class.getName(), Long.class.getName(),
22164                                    String.class.getName()
22165                            });
22166    
22167            /**
22168             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
22169             *
22170             * @param groupId the group ID
22171             * @param classNameId the class name ID
22172             * @param DDMTemplateKey the d d m template key
22173             * @return the matching journal articles
22174             */
22175            @Override
22176            public List<JournalArticle> findByG_C_DDMTK(long groupId, long classNameId,
22177                    String DDMTemplateKey) {
22178                    return findByG_C_DDMTK(groupId, classNameId, DDMTemplateKey,
22179                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
22180            }
22181    
22182            /**
22183             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
22184             *
22185             * <p>
22186             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22187             * </p>
22188             *
22189             * @param groupId the group ID
22190             * @param classNameId the class name ID
22191             * @param DDMTemplateKey the d d m template key
22192             * @param start the lower bound of the range of journal articles
22193             * @param end the upper bound of the range of journal articles (not inclusive)
22194             * @return the range of matching journal articles
22195             */
22196            @Override
22197            public List<JournalArticle> findByG_C_DDMTK(long groupId, long classNameId,
22198                    String DDMTemplateKey, int start, int end) {
22199                    return findByG_C_DDMTK(groupId, classNameId, DDMTemplateKey, start,
22200                            end, null);
22201            }
22202    
22203            /**
22204             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
22205             *
22206             * <p>
22207             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22208             * </p>
22209             *
22210             * @param groupId the group ID
22211             * @param classNameId the class name ID
22212             * @param DDMTemplateKey the d d m template key
22213             * @param start the lower bound of the range of journal articles
22214             * @param end the upper bound of the range of journal articles (not inclusive)
22215             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22216             * @return the ordered range of matching journal articles
22217             */
22218            @Override
22219            public List<JournalArticle> findByG_C_DDMTK(long groupId, long classNameId,
22220                    String DDMTemplateKey, int start, int end,
22221                    OrderByComparator<JournalArticle> orderByComparator) {
22222                    boolean pagination = true;
22223                    FinderPath finderPath = null;
22224                    Object[] finderArgs = null;
22225    
22226                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
22227                                    (orderByComparator == null)) {
22228                            pagination = false;
22229                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_DDMTK;
22230                            finderArgs = new Object[] { groupId, classNameId, DDMTemplateKey };
22231                    }
22232                    else {
22233                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_DDMTK;
22234                            finderArgs = new Object[] {
22235                                            groupId, classNameId, DDMTemplateKey,
22236                                            
22237                                            start, end, orderByComparator
22238                                    };
22239                    }
22240    
22241                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
22242                                    finderArgs, this);
22243    
22244                    if ((list != null) && !list.isEmpty()) {
22245                            for (JournalArticle journalArticle : list) {
22246                                    if ((groupId != journalArticle.getGroupId()) ||
22247                                                    (classNameId != journalArticle.getClassNameId()) ||
22248                                                    !Validator.equals(DDMTemplateKey,
22249                                                            journalArticle.getDDMTemplateKey())) {
22250                                            list = null;
22251    
22252                                            break;
22253                                    }
22254                            }
22255                    }
22256    
22257                    if (list == null) {
22258                            StringBundler query = null;
22259    
22260                            if (orderByComparator != null) {
22261                                    query = new StringBundler(5 +
22262                                                    (orderByComparator.getOrderByFields().length * 3));
22263                            }
22264                            else {
22265                                    query = new StringBundler(5);
22266                            }
22267    
22268                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22269    
22270                            query.append(_FINDER_COLUMN_G_C_DDMTK_GROUPID_2);
22271    
22272                            query.append(_FINDER_COLUMN_G_C_DDMTK_CLASSNAMEID_2);
22273    
22274                            boolean bindDDMTemplateKey = false;
22275    
22276                            if (DDMTemplateKey == null) {
22277                                    query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_1);
22278                            }
22279                            else if (DDMTemplateKey.equals(StringPool.BLANK)) {
22280                                    query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_3);
22281                            }
22282                            else {
22283                                    bindDDMTemplateKey = true;
22284    
22285                                    query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_2);
22286                            }
22287    
22288                            if (orderByComparator != null) {
22289                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22290                                            orderByComparator);
22291                            }
22292                            else
22293                             if (pagination) {
22294                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22295                            }
22296    
22297                            String sql = query.toString();
22298    
22299                            Session session = null;
22300    
22301                            try {
22302                                    session = openSession();
22303    
22304                                    Query q = session.createQuery(sql);
22305    
22306                                    QueryPos qPos = QueryPos.getInstance(q);
22307    
22308                                    qPos.add(groupId);
22309    
22310                                    qPos.add(classNameId);
22311    
22312                                    if (bindDDMTemplateKey) {
22313                                            qPos.add(DDMTemplateKey);
22314                                    }
22315    
22316                                    if (!pagination) {
22317                                            list = (List<JournalArticle>)QueryUtil.list(q,
22318                                                            getDialect(), start, end, false);
22319    
22320                                            Collections.sort(list);
22321    
22322                                            list = Collections.unmodifiableList(list);
22323                                    }
22324                                    else {
22325                                            list = (List<JournalArticle>)QueryUtil.list(q,
22326                                                            getDialect(), start, end);
22327                                    }
22328    
22329                                    cacheResult(list);
22330    
22331                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
22332                            }
22333                            catch (Exception e) {
22334                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
22335    
22336                                    throw processException(e);
22337                            }
22338                            finally {
22339                                    closeSession(session);
22340                            }
22341                    }
22342    
22343                    return list;
22344            }
22345    
22346            /**
22347             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
22348             *
22349             * @param groupId the group ID
22350             * @param classNameId the class name ID
22351             * @param DDMTemplateKey the d d m template key
22352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22353             * @return the first matching journal article
22354             * @throws NoSuchArticleException if a matching journal article could not be found
22355             */
22356            @Override
22357            public JournalArticle findByG_C_DDMTK_First(long groupId, long classNameId,
22358                    String DDMTemplateKey,
22359                    OrderByComparator<JournalArticle> orderByComparator)
22360                    throws NoSuchArticleException {
22361                    JournalArticle journalArticle = fetchByG_C_DDMTK_First(groupId,
22362                                    classNameId, DDMTemplateKey, orderByComparator);
22363    
22364                    if (journalArticle != null) {
22365                            return journalArticle;
22366                    }
22367    
22368                    StringBundler msg = new StringBundler(8);
22369    
22370                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22371    
22372                    msg.append("groupId=");
22373                    msg.append(groupId);
22374    
22375                    msg.append(", classNameId=");
22376                    msg.append(classNameId);
22377    
22378                    msg.append(", DDMTemplateKey=");
22379                    msg.append(DDMTemplateKey);
22380    
22381                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22382    
22383                    throw new NoSuchArticleException(msg.toString());
22384            }
22385    
22386            /**
22387             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
22388             *
22389             * @param groupId the group ID
22390             * @param classNameId the class name ID
22391             * @param DDMTemplateKey the d d m template key
22392             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22393             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
22394             */
22395            @Override
22396            public JournalArticle fetchByG_C_DDMTK_First(long groupId,
22397                    long classNameId, String DDMTemplateKey,
22398                    OrderByComparator<JournalArticle> orderByComparator) {
22399                    List<JournalArticle> list = findByG_C_DDMTK(groupId, classNameId,
22400                                    DDMTemplateKey, 0, 1, orderByComparator);
22401    
22402                    if (!list.isEmpty()) {
22403                            return list.get(0);
22404                    }
22405    
22406                    return null;
22407            }
22408    
22409            /**
22410             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
22411             *
22412             * @param groupId the group ID
22413             * @param classNameId the class name ID
22414             * @param DDMTemplateKey the d d m template key
22415             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22416             * @return the last matching journal article
22417             * @throws NoSuchArticleException if a matching journal article could not be found
22418             */
22419            @Override
22420            public JournalArticle findByG_C_DDMTK_Last(long groupId, long classNameId,
22421                    String DDMTemplateKey,
22422                    OrderByComparator<JournalArticle> orderByComparator)
22423                    throws NoSuchArticleException {
22424                    JournalArticle journalArticle = fetchByG_C_DDMTK_Last(groupId,
22425                                    classNameId, DDMTemplateKey, orderByComparator);
22426    
22427                    if (journalArticle != null) {
22428                            return journalArticle;
22429                    }
22430    
22431                    StringBundler msg = new StringBundler(8);
22432    
22433                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
22434    
22435                    msg.append("groupId=");
22436                    msg.append(groupId);
22437    
22438                    msg.append(", classNameId=");
22439                    msg.append(classNameId);
22440    
22441                    msg.append(", DDMTemplateKey=");
22442                    msg.append(DDMTemplateKey);
22443    
22444                    msg.append(StringPool.CLOSE_CURLY_BRACE);
22445    
22446                    throw new NoSuchArticleException(msg.toString());
22447            }
22448    
22449            /**
22450             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
22451             *
22452             * @param groupId the group ID
22453             * @param classNameId the class name ID
22454             * @param DDMTemplateKey the d d m template key
22455             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22456             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
22457             */
22458            @Override
22459            public JournalArticle fetchByG_C_DDMTK_Last(long groupId, long classNameId,
22460                    String DDMTemplateKey,
22461                    OrderByComparator<JournalArticle> orderByComparator) {
22462                    int count = countByG_C_DDMTK(groupId, classNameId, DDMTemplateKey);
22463    
22464                    if (count == 0) {
22465                            return null;
22466                    }
22467    
22468                    List<JournalArticle> list = findByG_C_DDMTK(groupId, classNameId,
22469                                    DDMTemplateKey, count - 1, count, orderByComparator);
22470    
22471                    if (!list.isEmpty()) {
22472                            return list.get(0);
22473                    }
22474    
22475                    return null;
22476            }
22477    
22478            /**
22479             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
22480             *
22481             * @param id the primary key of the current journal article
22482             * @param groupId the group ID
22483             * @param classNameId the class name ID
22484             * @param DDMTemplateKey the d d m template key
22485             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22486             * @return the previous, current, and next journal article
22487             * @throws NoSuchArticleException if a journal article with the primary key could not be found
22488             */
22489            @Override
22490            public JournalArticle[] findByG_C_DDMTK_PrevAndNext(long id, long groupId,
22491                    long classNameId, String DDMTemplateKey,
22492                    OrderByComparator<JournalArticle> orderByComparator)
22493                    throws NoSuchArticleException {
22494                    JournalArticle journalArticle = findByPrimaryKey(id);
22495    
22496                    Session session = null;
22497    
22498                    try {
22499                            session = openSession();
22500    
22501                            JournalArticle[] array = new JournalArticleImpl[3];
22502    
22503                            array[0] = getByG_C_DDMTK_PrevAndNext(session, journalArticle,
22504                                            groupId, classNameId, DDMTemplateKey, orderByComparator,
22505                                            true);
22506    
22507                            array[1] = journalArticle;
22508    
22509                            array[2] = getByG_C_DDMTK_PrevAndNext(session, journalArticle,
22510                                            groupId, classNameId, DDMTemplateKey, orderByComparator,
22511                                            false);
22512    
22513                            return array;
22514                    }
22515                    catch (Exception e) {
22516                            throw processException(e);
22517                    }
22518                    finally {
22519                            closeSession(session);
22520                    }
22521            }
22522    
22523            protected JournalArticle getByG_C_DDMTK_PrevAndNext(Session session,
22524                    JournalArticle journalArticle, long groupId, long classNameId,
22525                    String DDMTemplateKey,
22526                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
22527                    StringBundler query = null;
22528    
22529                    if (orderByComparator != null) {
22530                            query = new StringBundler(6 +
22531                                            (orderByComparator.getOrderByFields().length * 6));
22532                    }
22533                    else {
22534                            query = new StringBundler(3);
22535                    }
22536    
22537                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
22538    
22539                    query.append(_FINDER_COLUMN_G_C_DDMTK_GROUPID_2);
22540    
22541                    query.append(_FINDER_COLUMN_G_C_DDMTK_CLASSNAMEID_2);
22542    
22543                    boolean bindDDMTemplateKey = false;
22544    
22545                    if (DDMTemplateKey == null) {
22546                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_1);
22547                    }
22548                    else if (DDMTemplateKey.equals(StringPool.BLANK)) {
22549                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_3);
22550                    }
22551                    else {
22552                            bindDDMTemplateKey = true;
22553    
22554                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_2);
22555                    }
22556    
22557                    if (orderByComparator != null) {
22558                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22559    
22560                            if (orderByConditionFields.length > 0) {
22561                                    query.append(WHERE_AND);
22562                            }
22563    
22564                            for (int i = 0; i < orderByConditionFields.length; i++) {
22565                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22566                                    query.append(orderByConditionFields[i]);
22567    
22568                                    if ((i + 1) < orderByConditionFields.length) {
22569                                            if (orderByComparator.isAscending() ^ previous) {
22570                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22571                                            }
22572                                            else {
22573                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22574                                            }
22575                                    }
22576                                    else {
22577                                            if (orderByComparator.isAscending() ^ previous) {
22578                                                    query.append(WHERE_GREATER_THAN);
22579                                            }
22580                                            else {
22581                                                    query.append(WHERE_LESSER_THAN);
22582                                            }
22583                                    }
22584                            }
22585    
22586                            query.append(ORDER_BY_CLAUSE);
22587    
22588                            String[] orderByFields = orderByComparator.getOrderByFields();
22589    
22590                            for (int i = 0; i < orderByFields.length; i++) {
22591                                    query.append(_ORDER_BY_ENTITY_ALIAS);
22592                                    query.append(orderByFields[i]);
22593    
22594                                    if ((i + 1) < orderByFields.length) {
22595                                            if (orderByComparator.isAscending() ^ previous) {
22596                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22597                                            }
22598                                            else {
22599                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22600                                            }
22601                                    }
22602                                    else {
22603                                            if (orderByComparator.isAscending() ^ previous) {
22604                                                    query.append(ORDER_BY_ASC);
22605                                            }
22606                                            else {
22607                                                    query.append(ORDER_BY_DESC);
22608                                            }
22609                                    }
22610                            }
22611                    }
22612                    else {
22613                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22614                    }
22615    
22616                    String sql = query.toString();
22617    
22618                    Query q = session.createQuery(sql);
22619    
22620                    q.setFirstResult(0);
22621                    q.setMaxResults(2);
22622    
22623                    QueryPos qPos = QueryPos.getInstance(q);
22624    
22625                    qPos.add(groupId);
22626    
22627                    qPos.add(classNameId);
22628    
22629                    if (bindDDMTemplateKey) {
22630                            qPos.add(DDMTemplateKey);
22631                    }
22632    
22633                    if (orderByComparator != null) {
22634                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
22635    
22636                            for (Object value : values) {
22637                                    qPos.add(value);
22638                            }
22639                    }
22640    
22641                    List<JournalArticle> list = q.list();
22642    
22643                    if (list.size() == 2) {
22644                            return list.get(1);
22645                    }
22646                    else {
22647                            return null;
22648                    }
22649            }
22650    
22651            /**
22652             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
22653             *
22654             * @param groupId the group ID
22655             * @param classNameId the class name ID
22656             * @param DDMTemplateKey the d d m template key
22657             * @return the matching journal articles that the user has permission to view
22658             */
22659            @Override
22660            public List<JournalArticle> filterFindByG_C_DDMTK(long groupId,
22661                    long classNameId, String DDMTemplateKey) {
22662                    return filterFindByG_C_DDMTK(groupId, classNameId, DDMTemplateKey,
22663                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
22664            }
22665    
22666            /**
22667             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
22668             *
22669             * <p>
22670             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22671             * </p>
22672             *
22673             * @param groupId the group ID
22674             * @param classNameId the class name ID
22675             * @param DDMTemplateKey the d d m template key
22676             * @param start the lower bound of the range of journal articles
22677             * @param end the upper bound of the range of journal articles (not inclusive)
22678             * @return the range of matching journal articles that the user has permission to view
22679             */
22680            @Override
22681            public List<JournalArticle> filterFindByG_C_DDMTK(long groupId,
22682                    long classNameId, String DDMTemplateKey, int start, int end) {
22683                    return filterFindByG_C_DDMTK(groupId, classNameId, DDMTemplateKey,
22684                            start, end, null);
22685            }
22686    
22687            /**
22688             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
22689             *
22690             * <p>
22691             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
22692             * </p>
22693             *
22694             * @param groupId the group ID
22695             * @param classNameId the class name ID
22696             * @param DDMTemplateKey the d d m template key
22697             * @param start the lower bound of the range of journal articles
22698             * @param end the upper bound of the range of journal articles (not inclusive)
22699             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
22700             * @return the ordered range of matching journal articles that the user has permission to view
22701             */
22702            @Override
22703            public List<JournalArticle> filterFindByG_C_DDMTK(long groupId,
22704                    long classNameId, String DDMTemplateKey, int start, int end,
22705                    OrderByComparator<JournalArticle> orderByComparator) {
22706                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22707                            return findByG_C_DDMTK(groupId, classNameId, DDMTemplateKey, start,
22708                                    end, orderByComparator);
22709                    }
22710    
22711                    StringBundler query = null;
22712    
22713                    if (orderByComparator != null) {
22714                            query = new StringBundler(5 +
22715                                            (orderByComparator.getOrderByFields().length * 3));
22716                    }
22717                    else {
22718                            query = new StringBundler(5);
22719                    }
22720    
22721                    if (getDB().isSupportsInlineDistinct()) {
22722                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22723                    }
22724                    else {
22725                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22726                    }
22727    
22728                    query.append(_FINDER_COLUMN_G_C_DDMTK_GROUPID_2);
22729    
22730                    query.append(_FINDER_COLUMN_G_C_DDMTK_CLASSNAMEID_2);
22731    
22732                    boolean bindDDMTemplateKey = false;
22733    
22734                    if (DDMTemplateKey == null) {
22735                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_1);
22736                    }
22737                    else if (DDMTemplateKey.equals(StringPool.BLANK)) {
22738                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_3);
22739                    }
22740                    else {
22741                            bindDDMTemplateKey = true;
22742    
22743                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_2);
22744                    }
22745    
22746                    if (!getDB().isSupportsInlineDistinct()) {
22747                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22748                    }
22749    
22750                    if (orderByComparator != null) {
22751                            if (getDB().isSupportsInlineDistinct()) {
22752                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
22753                                            orderByComparator, true);
22754                            }
22755                            else {
22756                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
22757                                            orderByComparator, true);
22758                            }
22759                    }
22760                    else {
22761                            if (getDB().isSupportsInlineDistinct()) {
22762                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22763                            }
22764                            else {
22765                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22766                            }
22767                    }
22768    
22769                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22770                                    JournalArticle.class.getName(),
22771                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22772    
22773                    Session session = null;
22774    
22775                    try {
22776                            session = openSession();
22777    
22778                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
22779    
22780                            if (getDB().isSupportsInlineDistinct()) {
22781                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22782                            }
22783                            else {
22784                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22785                            }
22786    
22787                            QueryPos qPos = QueryPos.getInstance(q);
22788    
22789                            qPos.add(groupId);
22790    
22791                            qPos.add(classNameId);
22792    
22793                            if (bindDDMTemplateKey) {
22794                                    qPos.add(DDMTemplateKey);
22795                            }
22796    
22797                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
22798                                    end);
22799                    }
22800                    catch (Exception e) {
22801                            throw processException(e);
22802                    }
22803                    finally {
22804                            closeSession(session);
22805                    }
22806            }
22807    
22808            /**
22809             * 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 DDMTemplateKey = &#63;.
22810             *
22811             * @param id the primary key of the current journal article
22812             * @param groupId the group ID
22813             * @param classNameId the class name ID
22814             * @param DDMTemplateKey the d d m template key
22815             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
22816             * @return the previous, current, and next journal article
22817             * @throws NoSuchArticleException if a journal article with the primary key could not be found
22818             */
22819            @Override
22820            public JournalArticle[] filterFindByG_C_DDMTK_PrevAndNext(long id,
22821                    long groupId, long classNameId, String DDMTemplateKey,
22822                    OrderByComparator<JournalArticle> orderByComparator)
22823                    throws NoSuchArticleException {
22824                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22825                            return findByG_C_DDMTK_PrevAndNext(id, groupId, classNameId,
22826                                    DDMTemplateKey, orderByComparator);
22827                    }
22828    
22829                    JournalArticle journalArticle = findByPrimaryKey(id);
22830    
22831                    Session session = null;
22832    
22833                    try {
22834                            session = openSession();
22835    
22836                            JournalArticle[] array = new JournalArticleImpl[3];
22837    
22838                            array[0] = filterGetByG_C_DDMTK_PrevAndNext(session,
22839                                            journalArticle, groupId, classNameId, DDMTemplateKey,
22840                                            orderByComparator, true);
22841    
22842                            array[1] = journalArticle;
22843    
22844                            array[2] = filterGetByG_C_DDMTK_PrevAndNext(session,
22845                                            journalArticle, groupId, classNameId, DDMTemplateKey,
22846                                            orderByComparator, false);
22847    
22848                            return array;
22849                    }
22850                    catch (Exception e) {
22851                            throw processException(e);
22852                    }
22853                    finally {
22854                            closeSession(session);
22855                    }
22856            }
22857    
22858            protected JournalArticle filterGetByG_C_DDMTK_PrevAndNext(Session session,
22859                    JournalArticle journalArticle, long groupId, long classNameId,
22860                    String DDMTemplateKey,
22861                    OrderByComparator<JournalArticle> orderByComparator, boolean previous) {
22862                    StringBundler query = null;
22863    
22864                    if (orderByComparator != null) {
22865                            query = new StringBundler(6 +
22866                                            (orderByComparator.getOrderByFields().length * 6));
22867                    }
22868                    else {
22869                            query = new StringBundler(3);
22870                    }
22871    
22872                    if (getDB().isSupportsInlineDistinct()) {
22873                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
22874                    }
22875                    else {
22876                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
22877                    }
22878    
22879                    query.append(_FINDER_COLUMN_G_C_DDMTK_GROUPID_2);
22880    
22881                    query.append(_FINDER_COLUMN_G_C_DDMTK_CLASSNAMEID_2);
22882    
22883                    boolean bindDDMTemplateKey = false;
22884    
22885                    if (DDMTemplateKey == null) {
22886                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_1);
22887                    }
22888                    else if (DDMTemplateKey.equals(StringPool.BLANK)) {
22889                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_3);
22890                    }
22891                    else {
22892                            bindDDMTemplateKey = true;
22893    
22894                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_2);
22895                    }
22896    
22897                    if (!getDB().isSupportsInlineDistinct()) {
22898                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
22899                    }
22900    
22901                    if (orderByComparator != null) {
22902                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
22903    
22904                            if (orderByConditionFields.length > 0) {
22905                                    query.append(WHERE_AND);
22906                            }
22907    
22908                            for (int i = 0; i < orderByConditionFields.length; i++) {
22909                                    if (getDB().isSupportsInlineDistinct()) {
22910                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22911                                    }
22912                                    else {
22913                                            query.append(_ORDER_BY_ENTITY_TABLE);
22914                                    }
22915    
22916                                    query.append(orderByConditionFields[i]);
22917    
22918                                    if ((i + 1) < orderByConditionFields.length) {
22919                                            if (orderByComparator.isAscending() ^ previous) {
22920                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
22921                                            }
22922                                            else {
22923                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
22924                                            }
22925                                    }
22926                                    else {
22927                                            if (orderByComparator.isAscending() ^ previous) {
22928                                                    query.append(WHERE_GREATER_THAN);
22929                                            }
22930                                            else {
22931                                                    query.append(WHERE_LESSER_THAN);
22932                                            }
22933                                    }
22934                            }
22935    
22936                            query.append(ORDER_BY_CLAUSE);
22937    
22938                            String[] orderByFields = orderByComparator.getOrderByFields();
22939    
22940                            for (int i = 0; i < orderByFields.length; i++) {
22941                                    if (getDB().isSupportsInlineDistinct()) {
22942                                            query.append(_ORDER_BY_ENTITY_ALIAS);
22943                                    }
22944                                    else {
22945                                            query.append(_ORDER_BY_ENTITY_TABLE);
22946                                    }
22947    
22948                                    query.append(orderByFields[i]);
22949    
22950                                    if ((i + 1) < orderByFields.length) {
22951                                            if (orderByComparator.isAscending() ^ previous) {
22952                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
22953                                            }
22954                                            else {
22955                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
22956                                            }
22957                                    }
22958                                    else {
22959                                            if (orderByComparator.isAscending() ^ previous) {
22960                                                    query.append(ORDER_BY_ASC);
22961                                            }
22962                                            else {
22963                                                    query.append(ORDER_BY_DESC);
22964                                            }
22965                                    }
22966                            }
22967                    }
22968                    else {
22969                            if (getDB().isSupportsInlineDistinct()) {
22970                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
22971                            }
22972                            else {
22973                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
22974                            }
22975                    }
22976    
22977                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22978                                    JournalArticle.class.getName(),
22979                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22980    
22981                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
22982    
22983                    q.setFirstResult(0);
22984                    q.setMaxResults(2);
22985    
22986                    if (getDB().isSupportsInlineDistinct()) {
22987                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
22988                    }
22989                    else {
22990                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
22991                    }
22992    
22993                    QueryPos qPos = QueryPos.getInstance(q);
22994    
22995                    qPos.add(groupId);
22996    
22997                    qPos.add(classNameId);
22998    
22999                    if (bindDDMTemplateKey) {
23000                            qPos.add(DDMTemplateKey);
23001                    }
23002    
23003                    if (orderByComparator != null) {
23004                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23005    
23006                            for (Object value : values) {
23007                                    qPos.add(value);
23008                            }
23009                    }
23010    
23011                    List<JournalArticle> list = q.list();
23012    
23013                    if (list.size() == 2) {
23014                            return list.get(1);
23015                    }
23016                    else {
23017                            return null;
23018                    }
23019            }
23020    
23021            /**
23022             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63; from the database.
23023             *
23024             * @param groupId the group ID
23025             * @param classNameId the class name ID
23026             * @param DDMTemplateKey the d d m template key
23027             */
23028            @Override
23029            public void removeByG_C_DDMTK(long groupId, long classNameId,
23030                    String DDMTemplateKey) {
23031                    for (JournalArticle journalArticle : findByG_C_DDMTK(groupId,
23032                                    classNameId, DDMTemplateKey, QueryUtil.ALL_POS,
23033                                    QueryUtil.ALL_POS, null)) {
23034                            remove(journalArticle);
23035                    }
23036            }
23037    
23038            /**
23039             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
23040             *
23041             * @param groupId the group ID
23042             * @param classNameId the class name ID
23043             * @param DDMTemplateKey the d d m template key
23044             * @return the number of matching journal articles
23045             */
23046            @Override
23047            public int countByG_C_DDMTK(long groupId, long classNameId,
23048                    String DDMTemplateKey) {
23049                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_DDMTK;
23050    
23051                    Object[] finderArgs = new Object[] { groupId, classNameId, DDMTemplateKey };
23052    
23053                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
23054                                    this);
23055    
23056                    if (count == null) {
23057                            StringBundler query = new StringBundler(4);
23058    
23059                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23060    
23061                            query.append(_FINDER_COLUMN_G_C_DDMTK_GROUPID_2);
23062    
23063                            query.append(_FINDER_COLUMN_G_C_DDMTK_CLASSNAMEID_2);
23064    
23065                            boolean bindDDMTemplateKey = false;
23066    
23067                            if (DDMTemplateKey == null) {
23068                                    query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_1);
23069                            }
23070                            else if (DDMTemplateKey.equals(StringPool.BLANK)) {
23071                                    query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_3);
23072                            }
23073                            else {
23074                                    bindDDMTemplateKey = true;
23075    
23076                                    query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_2);
23077                            }
23078    
23079                            String sql = query.toString();
23080    
23081                            Session session = null;
23082    
23083                            try {
23084                                    session = openSession();
23085    
23086                                    Query q = session.createQuery(sql);
23087    
23088                                    QueryPos qPos = QueryPos.getInstance(q);
23089    
23090                                    qPos.add(groupId);
23091    
23092                                    qPos.add(classNameId);
23093    
23094                                    if (bindDDMTemplateKey) {
23095                                            qPos.add(DDMTemplateKey);
23096                                    }
23097    
23098                                    count = (Long)q.uniqueResult();
23099    
23100                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
23101                            }
23102                            catch (Exception e) {
23103                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23104    
23105                                    throw processException(e);
23106                            }
23107                            finally {
23108                                    closeSession(session);
23109                            }
23110                    }
23111    
23112                    return count.intValue();
23113            }
23114    
23115            /**
23116             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and DDMTemplateKey = &#63;.
23117             *
23118             * @param groupId the group ID
23119             * @param classNameId the class name ID
23120             * @param DDMTemplateKey the d d m template key
23121             * @return the number of matching journal articles that the user has permission to view
23122             */
23123            @Override
23124            public int filterCountByG_C_DDMTK(long groupId, long classNameId,
23125                    String DDMTemplateKey) {
23126                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23127                            return countByG_C_DDMTK(groupId, classNameId, DDMTemplateKey);
23128                    }
23129    
23130                    StringBundler query = new StringBundler(4);
23131    
23132                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23133    
23134                    query.append(_FINDER_COLUMN_G_C_DDMTK_GROUPID_2);
23135    
23136                    query.append(_FINDER_COLUMN_G_C_DDMTK_CLASSNAMEID_2);
23137    
23138                    boolean bindDDMTemplateKey = false;
23139    
23140                    if (DDMTemplateKey == null) {
23141                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_1);
23142                    }
23143                    else if (DDMTemplateKey.equals(StringPool.BLANK)) {
23144                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_3);
23145                    }
23146                    else {
23147                            bindDDMTemplateKey = true;
23148    
23149                            query.append(_FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_2);
23150                    }
23151    
23152                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23153                                    JournalArticle.class.getName(),
23154                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23155    
23156                    Session session = null;
23157    
23158                    try {
23159                            session = openSession();
23160    
23161                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
23162    
23163                            q.addScalar(COUNT_COLUMN_NAME,
23164                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23165    
23166                            QueryPos qPos = QueryPos.getInstance(q);
23167    
23168                            qPos.add(groupId);
23169    
23170                            qPos.add(classNameId);
23171    
23172                            if (bindDDMTemplateKey) {
23173                                    qPos.add(DDMTemplateKey);
23174                            }
23175    
23176                            Long count = (Long)q.uniqueResult();
23177    
23178                            return count.intValue();
23179                    }
23180                    catch (Exception e) {
23181                            throw processException(e);
23182                    }
23183                    finally {
23184                            closeSession(session);
23185                    }
23186            }
23187    
23188            private static final String _FINDER_COLUMN_G_C_DDMTK_GROUPID_2 = "journalArticle.groupId = ? AND ";
23189            private static final String _FINDER_COLUMN_G_C_DDMTK_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
23190            private static final String _FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_1 = "journalArticle.DDMTemplateKey IS NULL";
23191            private static final String _FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_2 = "journalArticle.DDMTemplateKey = ?";
23192            private static final String _FINDER_COLUMN_G_C_DDMTK_DDMTEMPLATEKEY_3 = "(journalArticle.DDMTemplateKey IS NULL OR journalArticle.DDMTemplateKey = '')";
23193            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23194                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23195                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
23196                            "findByG_C_L",
23197                            new String[] {
23198                                    Long.class.getName(), Long.class.getName(),
23199                                    String.class.getName(),
23200                                    
23201                            Integer.class.getName(), Integer.class.getName(),
23202                                    OrderByComparator.class.getName()
23203                            });
23204            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23205                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
23206                            JournalArticleImpl.class,
23207                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
23208                            new String[] {
23209                                    Long.class.getName(), Long.class.getName(),
23210                                    String.class.getName()
23211                            },
23212                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
23213                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
23214                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK |
23215                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
23216                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
23217            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
23218                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
23219                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
23220                            new String[] {
23221                                    Long.class.getName(), Long.class.getName(),
23222                                    String.class.getName()
23223                            });
23224    
23225            /**
23226             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23227             *
23228             * @param groupId the group ID
23229             * @param classNameId the class name ID
23230             * @param layoutUuid the layout uuid
23231             * @return the matching journal articles
23232             */
23233            @Override
23234            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23235                    String layoutUuid) {
23236                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
23237                            QueryUtil.ALL_POS, null);
23238            }
23239    
23240            /**
23241             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23242             *
23243             * <p>
23244             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23245             * </p>
23246             *
23247             * @param groupId the group ID
23248             * @param classNameId the class name ID
23249             * @param layoutUuid the layout uuid
23250             * @param start the lower bound of the range of journal articles
23251             * @param end the upper bound of the range of journal articles (not inclusive)
23252             * @return the range of matching journal articles
23253             */
23254            @Override
23255            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23256                    String layoutUuid, int start, int end) {
23257                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
23258            }
23259    
23260            /**
23261             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23262             *
23263             * <p>
23264             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23265             * </p>
23266             *
23267             * @param groupId the group ID
23268             * @param classNameId the class name ID
23269             * @param layoutUuid the layout uuid
23270             * @param start the lower bound of the range of journal articles
23271             * @param end the upper bound of the range of journal articles (not inclusive)
23272             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23273             * @return the ordered range of matching journal articles
23274             */
23275            @Override
23276            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
23277                    String layoutUuid, int start, int end,
23278                    OrderByComparator<JournalArticle> orderByComparator) {
23279                    boolean pagination = true;
23280                    FinderPath finderPath = null;
23281                    Object[] finderArgs = null;
23282    
23283                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
23284                                    (orderByComparator == null)) {
23285                            pagination = false;
23286                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
23287                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
23288                    }
23289                    else {
23290                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
23291                            finderArgs = new Object[] {
23292                                            groupId, classNameId, layoutUuid,
23293                                            
23294                                            start, end, orderByComparator
23295                                    };
23296                    }
23297    
23298                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
23299                                    finderArgs, this);
23300    
23301                    if ((list != null) && !list.isEmpty()) {
23302                            for (JournalArticle journalArticle : list) {
23303                                    if ((groupId != journalArticle.getGroupId()) ||
23304                                                    (classNameId != journalArticle.getClassNameId()) ||
23305                                                    !Validator.equals(layoutUuid,
23306                                                            journalArticle.getLayoutUuid())) {
23307                                            list = null;
23308    
23309                                            break;
23310                                    }
23311                            }
23312                    }
23313    
23314                    if (list == null) {
23315                            StringBundler query = null;
23316    
23317                            if (orderByComparator != null) {
23318                                    query = new StringBundler(5 +
23319                                                    (orderByComparator.getOrderByFields().length * 3));
23320                            }
23321                            else {
23322                                    query = new StringBundler(5);
23323                            }
23324    
23325                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23326    
23327                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23328    
23329                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23330    
23331                            boolean bindLayoutUuid = false;
23332    
23333                            if (layoutUuid == null) {
23334                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23335                            }
23336                            else if (layoutUuid.equals(StringPool.BLANK)) {
23337                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23338                            }
23339                            else {
23340                                    bindLayoutUuid = true;
23341    
23342                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23343                            }
23344    
23345                            if (orderByComparator != null) {
23346                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23347                                            orderByComparator);
23348                            }
23349                            else
23350                             if (pagination) {
23351                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23352                            }
23353    
23354                            String sql = query.toString();
23355    
23356                            Session session = null;
23357    
23358                            try {
23359                                    session = openSession();
23360    
23361                                    Query q = session.createQuery(sql);
23362    
23363                                    QueryPos qPos = QueryPos.getInstance(q);
23364    
23365                                    qPos.add(groupId);
23366    
23367                                    qPos.add(classNameId);
23368    
23369                                    if (bindLayoutUuid) {
23370                                            qPos.add(layoutUuid);
23371                                    }
23372    
23373                                    if (!pagination) {
23374                                            list = (List<JournalArticle>)QueryUtil.list(q,
23375                                                            getDialect(), start, end, false);
23376    
23377                                            Collections.sort(list);
23378    
23379                                            list = Collections.unmodifiableList(list);
23380                                    }
23381                                    else {
23382                                            list = (List<JournalArticle>)QueryUtil.list(q,
23383                                                            getDialect(), start, end);
23384                                    }
23385    
23386                                    cacheResult(list);
23387    
23388                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
23389                            }
23390                            catch (Exception e) {
23391                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
23392    
23393                                    throw processException(e);
23394                            }
23395                            finally {
23396                                    closeSession(session);
23397                            }
23398                    }
23399    
23400                    return list;
23401            }
23402    
23403            /**
23404             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23405             *
23406             * @param groupId the group ID
23407             * @param classNameId the class name ID
23408             * @param layoutUuid the layout uuid
23409             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23410             * @return the first matching journal article
23411             * @throws NoSuchArticleException if a matching journal article could not be found
23412             */
23413            @Override
23414            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
23415                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator)
23416                    throws NoSuchArticleException {
23417                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
23418                                    classNameId, layoutUuid, orderByComparator);
23419    
23420                    if (journalArticle != null) {
23421                            return journalArticle;
23422                    }
23423    
23424                    StringBundler msg = new StringBundler(8);
23425    
23426                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23427    
23428                    msg.append("groupId=");
23429                    msg.append(groupId);
23430    
23431                    msg.append(", classNameId=");
23432                    msg.append(classNameId);
23433    
23434                    msg.append(", layoutUuid=");
23435                    msg.append(layoutUuid);
23436    
23437                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23438    
23439                    throw new NoSuchArticleException(msg.toString());
23440            }
23441    
23442            /**
23443             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23444             *
23445             * @param groupId the group ID
23446             * @param classNameId the class name ID
23447             * @param layoutUuid the layout uuid
23448             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23449             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
23450             */
23451            @Override
23452            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
23453                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator) {
23454                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
23455                                    layoutUuid, 0, 1, orderByComparator);
23456    
23457                    if (!list.isEmpty()) {
23458                            return list.get(0);
23459                    }
23460    
23461                    return null;
23462            }
23463    
23464            /**
23465             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23466             *
23467             * @param groupId the group ID
23468             * @param classNameId the class name ID
23469             * @param layoutUuid the layout uuid
23470             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23471             * @return the last matching journal article
23472             * @throws NoSuchArticleException if a matching journal article could not be found
23473             */
23474            @Override
23475            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
23476                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator)
23477                    throws NoSuchArticleException {
23478                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
23479                                    layoutUuid, orderByComparator);
23480    
23481                    if (journalArticle != null) {
23482                            return journalArticle;
23483                    }
23484    
23485                    StringBundler msg = new StringBundler(8);
23486    
23487                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
23488    
23489                    msg.append("groupId=");
23490                    msg.append(groupId);
23491    
23492                    msg.append(", classNameId=");
23493                    msg.append(classNameId);
23494    
23495                    msg.append(", layoutUuid=");
23496                    msg.append(layoutUuid);
23497    
23498                    msg.append(StringPool.CLOSE_CURLY_BRACE);
23499    
23500                    throw new NoSuchArticleException(msg.toString());
23501            }
23502    
23503            /**
23504             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23505             *
23506             * @param groupId the group ID
23507             * @param classNameId the class name ID
23508             * @param layoutUuid the layout uuid
23509             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23510             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
23511             */
23512            @Override
23513            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
23514                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator) {
23515                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
23516    
23517                    if (count == 0) {
23518                            return null;
23519                    }
23520    
23521                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
23522                                    layoutUuid, count - 1, count, orderByComparator);
23523    
23524                    if (!list.isEmpty()) {
23525                            return list.get(0);
23526                    }
23527    
23528                    return null;
23529            }
23530    
23531            /**
23532             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23533             *
23534             * @param id the primary key of the current journal article
23535             * @param groupId the group ID
23536             * @param classNameId the class name ID
23537             * @param layoutUuid the layout uuid
23538             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23539             * @return the previous, current, and next journal article
23540             * @throws NoSuchArticleException if a journal article with the primary key could not be found
23541             */
23542            @Override
23543            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
23544                    long classNameId, String layoutUuid,
23545                    OrderByComparator<JournalArticle> orderByComparator)
23546                    throws NoSuchArticleException {
23547                    JournalArticle journalArticle = findByPrimaryKey(id);
23548    
23549                    Session session = null;
23550    
23551                    try {
23552                            session = openSession();
23553    
23554                            JournalArticle[] array = new JournalArticleImpl[3];
23555    
23556                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
23557                                            classNameId, layoutUuid, orderByComparator, true);
23558    
23559                            array[1] = journalArticle;
23560    
23561                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
23562                                            classNameId, layoutUuid, orderByComparator, false);
23563    
23564                            return array;
23565                    }
23566                    catch (Exception e) {
23567                            throw processException(e);
23568                    }
23569                    finally {
23570                            closeSession(session);
23571                    }
23572            }
23573    
23574            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
23575                    JournalArticle journalArticle, long groupId, long classNameId,
23576                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator,
23577                    boolean previous) {
23578                    StringBundler query = null;
23579    
23580                    if (orderByComparator != null) {
23581                            query = new StringBundler(6 +
23582                                            (orderByComparator.getOrderByFields().length * 6));
23583                    }
23584                    else {
23585                            query = new StringBundler(3);
23586                    }
23587    
23588                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
23589    
23590                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23591    
23592                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23593    
23594                    boolean bindLayoutUuid = false;
23595    
23596                    if (layoutUuid == null) {
23597                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23598                    }
23599                    else if (layoutUuid.equals(StringPool.BLANK)) {
23600                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23601                    }
23602                    else {
23603                            bindLayoutUuid = true;
23604    
23605                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23606                    }
23607    
23608                    if (orderByComparator != null) {
23609                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23610    
23611                            if (orderByConditionFields.length > 0) {
23612                                    query.append(WHERE_AND);
23613                            }
23614    
23615                            for (int i = 0; i < orderByConditionFields.length; i++) {
23616                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23617                                    query.append(orderByConditionFields[i]);
23618    
23619                                    if ((i + 1) < orderByConditionFields.length) {
23620                                            if (orderByComparator.isAscending() ^ previous) {
23621                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23622                                            }
23623                                            else {
23624                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23625                                            }
23626                                    }
23627                                    else {
23628                                            if (orderByComparator.isAscending() ^ previous) {
23629                                                    query.append(WHERE_GREATER_THAN);
23630                                            }
23631                                            else {
23632                                                    query.append(WHERE_LESSER_THAN);
23633                                            }
23634                                    }
23635                            }
23636    
23637                            query.append(ORDER_BY_CLAUSE);
23638    
23639                            String[] orderByFields = orderByComparator.getOrderByFields();
23640    
23641                            for (int i = 0; i < orderByFields.length; i++) {
23642                                    query.append(_ORDER_BY_ENTITY_ALIAS);
23643                                    query.append(orderByFields[i]);
23644    
23645                                    if ((i + 1) < orderByFields.length) {
23646                                            if (orderByComparator.isAscending() ^ previous) {
23647                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
23648                                            }
23649                                            else {
23650                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
23651                                            }
23652                                    }
23653                                    else {
23654                                            if (orderByComparator.isAscending() ^ previous) {
23655                                                    query.append(ORDER_BY_ASC);
23656                                            }
23657                                            else {
23658                                                    query.append(ORDER_BY_DESC);
23659                                            }
23660                                    }
23661                            }
23662                    }
23663                    else {
23664                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23665                    }
23666    
23667                    String sql = query.toString();
23668    
23669                    Query q = session.createQuery(sql);
23670    
23671                    q.setFirstResult(0);
23672                    q.setMaxResults(2);
23673    
23674                    QueryPos qPos = QueryPos.getInstance(q);
23675    
23676                    qPos.add(groupId);
23677    
23678                    qPos.add(classNameId);
23679    
23680                    if (bindLayoutUuid) {
23681                            qPos.add(layoutUuid);
23682                    }
23683    
23684                    if (orderByComparator != null) {
23685                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
23686    
23687                            for (Object value : values) {
23688                                    qPos.add(value);
23689                            }
23690                    }
23691    
23692                    List<JournalArticle> list = q.list();
23693    
23694                    if (list.size() == 2) {
23695                            return list.get(1);
23696                    }
23697                    else {
23698                            return null;
23699                    }
23700            }
23701    
23702            /**
23703             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23704             *
23705             * @param groupId the group ID
23706             * @param classNameId the class name ID
23707             * @param layoutUuid the layout uuid
23708             * @return the matching journal articles that the user has permission to view
23709             */
23710            @Override
23711            public List<JournalArticle> filterFindByG_C_L(long groupId,
23712                    long classNameId, String layoutUuid) {
23713                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
23714                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
23715            }
23716    
23717            /**
23718             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23719             *
23720             * <p>
23721             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23722             * </p>
23723             *
23724             * @param groupId the group ID
23725             * @param classNameId the class name ID
23726             * @param layoutUuid the layout uuid
23727             * @param start the lower bound of the range of journal articles
23728             * @param end the upper bound of the range of journal articles (not inclusive)
23729             * @return the range of matching journal articles that the user has permission to view
23730             */
23731            @Override
23732            public List<JournalArticle> filterFindByG_C_L(long groupId,
23733                    long classNameId, String layoutUuid, int start, int end) {
23734                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
23735                            null);
23736            }
23737    
23738            /**
23739             * 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;.
23740             *
23741             * <p>
23742             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
23743             * </p>
23744             *
23745             * @param groupId the group ID
23746             * @param classNameId the class name ID
23747             * @param layoutUuid the layout uuid
23748             * @param start the lower bound of the range of journal articles
23749             * @param end the upper bound of the range of journal articles (not inclusive)
23750             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
23751             * @return the ordered range of matching journal articles that the user has permission to view
23752             */
23753            @Override
23754            public List<JournalArticle> filterFindByG_C_L(long groupId,
23755                    long classNameId, String layoutUuid, int start, int end,
23756                    OrderByComparator<JournalArticle> orderByComparator) {
23757                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23758                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
23759                                    orderByComparator);
23760                    }
23761    
23762                    StringBundler query = null;
23763    
23764                    if (orderByComparator != null) {
23765                            query = new StringBundler(5 +
23766                                            (orderByComparator.getOrderByFields().length * 3));
23767                    }
23768                    else {
23769                            query = new StringBundler(5);
23770                    }
23771    
23772                    if (getDB().isSupportsInlineDistinct()) {
23773                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23774                    }
23775                    else {
23776                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23777                    }
23778    
23779                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23780    
23781                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23782    
23783                    boolean bindLayoutUuid = false;
23784    
23785                    if (layoutUuid == null) {
23786                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23787                    }
23788                    else if (layoutUuid.equals(StringPool.BLANK)) {
23789                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23790                    }
23791                    else {
23792                            bindLayoutUuid = true;
23793    
23794                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23795                    }
23796    
23797                    if (!getDB().isSupportsInlineDistinct()) {
23798                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23799                    }
23800    
23801                    if (orderByComparator != null) {
23802                            if (getDB().isSupportsInlineDistinct()) {
23803                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
23804                                            orderByComparator, true);
23805                            }
23806                            else {
23807                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
23808                                            orderByComparator, true);
23809                            }
23810                    }
23811                    else {
23812                            if (getDB().isSupportsInlineDistinct()) {
23813                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
23814                            }
23815                            else {
23816                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
23817                            }
23818                    }
23819    
23820                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23821                                    JournalArticle.class.getName(),
23822                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23823    
23824                    Session session = null;
23825    
23826                    try {
23827                            session = openSession();
23828    
23829                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
23830    
23831                            if (getDB().isSupportsInlineDistinct()) {
23832                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
23833                            }
23834                            else {
23835                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
23836                            }
23837    
23838                            QueryPos qPos = QueryPos.getInstance(q);
23839    
23840                            qPos.add(groupId);
23841    
23842                            qPos.add(classNameId);
23843    
23844                            if (bindLayoutUuid) {
23845                                    qPos.add(layoutUuid);
23846                            }
23847    
23848                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
23849                                    end);
23850                    }
23851                    catch (Exception e) {
23852                            throw processException(e);
23853                    }
23854                    finally {
23855                            closeSession(session);
23856                    }
23857            }
23858    
23859            /**
23860             * 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;.
23861             *
23862             * @param id the primary key of the current journal article
23863             * @param groupId the group ID
23864             * @param classNameId the class name ID
23865             * @param layoutUuid the layout uuid
23866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
23867             * @return the previous, current, and next journal article
23868             * @throws NoSuchArticleException if a journal article with the primary key could not be found
23869             */
23870            @Override
23871            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
23872                    long groupId, long classNameId, String layoutUuid,
23873                    OrderByComparator<JournalArticle> orderByComparator)
23874                    throws NoSuchArticleException {
23875                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23876                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
23877                                    layoutUuid, orderByComparator);
23878                    }
23879    
23880                    JournalArticle journalArticle = findByPrimaryKey(id);
23881    
23882                    Session session = null;
23883    
23884                    try {
23885                            session = openSession();
23886    
23887                            JournalArticle[] array = new JournalArticleImpl[3];
23888    
23889                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
23890                                            groupId, classNameId, layoutUuid, orderByComparator, true);
23891    
23892                            array[1] = journalArticle;
23893    
23894                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
23895                                            groupId, classNameId, layoutUuid, orderByComparator, false);
23896    
23897                            return array;
23898                    }
23899                    catch (Exception e) {
23900                            throw processException(e);
23901                    }
23902                    finally {
23903                            closeSession(session);
23904                    }
23905            }
23906    
23907            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
23908                    JournalArticle journalArticle, long groupId, long classNameId,
23909                    String layoutUuid, OrderByComparator<JournalArticle> orderByComparator,
23910                    boolean previous) {
23911                    StringBundler query = null;
23912    
23913                    if (orderByComparator != null) {
23914                            query = new StringBundler(6 +
23915                                            (orderByComparator.getOrderByFields().length * 6));
23916                    }
23917                    else {
23918                            query = new StringBundler(3);
23919                    }
23920    
23921                    if (getDB().isSupportsInlineDistinct()) {
23922                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
23923                    }
23924                    else {
23925                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
23926                    }
23927    
23928                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23929    
23930                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23931    
23932                    boolean bindLayoutUuid = false;
23933    
23934                    if (layoutUuid == null) {
23935                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23936                    }
23937                    else if (layoutUuid.equals(StringPool.BLANK)) {
23938                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23939                    }
23940                    else {
23941                            bindLayoutUuid = true;
23942    
23943                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23944                    }
23945    
23946                    if (!getDB().isSupportsInlineDistinct()) {
23947                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
23948                    }
23949    
23950                    if (orderByComparator != null) {
23951                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
23952    
23953                            if (orderByConditionFields.length > 0) {
23954                                    query.append(WHERE_AND);
23955                            }
23956    
23957                            for (int i = 0; i < orderByConditionFields.length; i++) {
23958                                    if (getDB().isSupportsInlineDistinct()) {
23959                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23960                                    }
23961                                    else {
23962                                            query.append(_ORDER_BY_ENTITY_TABLE);
23963                                    }
23964    
23965                                    query.append(orderByConditionFields[i]);
23966    
23967                                    if ((i + 1) < orderByConditionFields.length) {
23968                                            if (orderByComparator.isAscending() ^ previous) {
23969                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
23970                                            }
23971                                            else {
23972                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
23973                                            }
23974                                    }
23975                                    else {
23976                                            if (orderByComparator.isAscending() ^ previous) {
23977                                                    query.append(WHERE_GREATER_THAN);
23978                                            }
23979                                            else {
23980                                                    query.append(WHERE_LESSER_THAN);
23981                                            }
23982                                    }
23983                            }
23984    
23985                            query.append(ORDER_BY_CLAUSE);
23986    
23987                            String[] orderByFields = orderByComparator.getOrderByFields();
23988    
23989                            for (int i = 0; i < orderByFields.length; i++) {
23990                                    if (getDB().isSupportsInlineDistinct()) {
23991                                            query.append(_ORDER_BY_ENTITY_ALIAS);
23992                                    }
23993                                    else {
23994                                            query.append(_ORDER_BY_ENTITY_TABLE);
23995                                    }
23996    
23997                                    query.append(orderByFields[i]);
23998    
23999                                    if ((i + 1) < orderByFields.length) {
24000                                            if (orderByComparator.isAscending() ^ previous) {
24001                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24002                                            }
24003                                            else {
24004                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24005                                            }
24006                                    }
24007                                    else {
24008                                            if (orderByComparator.isAscending() ^ previous) {
24009                                                    query.append(ORDER_BY_ASC);
24010                                            }
24011                                            else {
24012                                                    query.append(ORDER_BY_DESC);
24013                                            }
24014                                    }
24015                            }
24016                    }
24017                    else {
24018                            if (getDB().isSupportsInlineDistinct()) {
24019                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24020                            }
24021                            else {
24022                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
24023                            }
24024                    }
24025    
24026                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24027                                    JournalArticle.class.getName(),
24028                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24029    
24030                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
24031    
24032                    q.setFirstResult(0);
24033                    q.setMaxResults(2);
24034    
24035                    if (getDB().isSupportsInlineDistinct()) {
24036                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
24037                    }
24038                    else {
24039                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
24040                    }
24041    
24042                    QueryPos qPos = QueryPos.getInstance(q);
24043    
24044                    qPos.add(groupId);
24045    
24046                    qPos.add(classNameId);
24047    
24048                    if (bindLayoutUuid) {
24049                            qPos.add(layoutUuid);
24050                    }
24051    
24052                    if (orderByComparator != null) {
24053                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
24054    
24055                            for (Object value : values) {
24056                                    qPos.add(value);
24057                            }
24058                    }
24059    
24060                    List<JournalArticle> list = q.list();
24061    
24062                    if (list.size() == 2) {
24063                            return list.get(1);
24064                    }
24065                    else {
24066                            return null;
24067                    }
24068            }
24069    
24070            /**
24071             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
24072             *
24073             * @param groupId the group ID
24074             * @param classNameId the class name ID
24075             * @param layoutUuid the layout uuid
24076             */
24077            @Override
24078            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid) {
24079                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
24080                                    layoutUuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
24081                            remove(journalArticle);
24082                    }
24083            }
24084    
24085            /**
24086             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24087             *
24088             * @param groupId the group ID
24089             * @param classNameId the class name ID
24090             * @param layoutUuid the layout uuid
24091             * @return the number of matching journal articles
24092             */
24093            @Override
24094            public int countByG_C_L(long groupId, long classNameId, String layoutUuid) {
24095                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_L;
24096    
24097                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
24098    
24099                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24100                                    this);
24101    
24102                    if (count == null) {
24103                            StringBundler query = new StringBundler(4);
24104    
24105                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24106    
24107                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24108    
24109                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24110    
24111                            boolean bindLayoutUuid = false;
24112    
24113                            if (layoutUuid == null) {
24114                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24115                            }
24116                            else if (layoutUuid.equals(StringPool.BLANK)) {
24117                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24118                            }
24119                            else {
24120                                    bindLayoutUuid = true;
24121    
24122                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24123                            }
24124    
24125                            String sql = query.toString();
24126    
24127                            Session session = null;
24128    
24129                            try {
24130                                    session = openSession();
24131    
24132                                    Query q = session.createQuery(sql);
24133    
24134                                    QueryPos qPos = QueryPos.getInstance(q);
24135    
24136                                    qPos.add(groupId);
24137    
24138                                    qPos.add(classNameId);
24139    
24140                                    if (bindLayoutUuid) {
24141                                            qPos.add(layoutUuid);
24142                                    }
24143    
24144                                    count = (Long)q.uniqueResult();
24145    
24146                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24147                            }
24148                            catch (Exception e) {
24149                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24150    
24151                                    throw processException(e);
24152                            }
24153                            finally {
24154                                    closeSession(session);
24155                            }
24156                    }
24157    
24158                    return count.intValue();
24159            }
24160    
24161            /**
24162             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
24163             *
24164             * @param groupId the group ID
24165             * @param classNameId the class name ID
24166             * @param layoutUuid the layout uuid
24167             * @return the number of matching journal articles that the user has permission to view
24168             */
24169            @Override
24170            public int filterCountByG_C_L(long groupId, long classNameId,
24171                    String layoutUuid) {
24172                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
24173                            return countByG_C_L(groupId, classNameId, layoutUuid);
24174                    }
24175    
24176                    StringBundler query = new StringBundler(4);
24177    
24178                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
24179    
24180                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
24181    
24182                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
24183    
24184                    boolean bindLayoutUuid = false;
24185    
24186                    if (layoutUuid == null) {
24187                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
24188                    }
24189                    else if (layoutUuid.equals(StringPool.BLANK)) {
24190                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
24191                    }
24192                    else {
24193                            bindLayoutUuid = true;
24194    
24195                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
24196                    }
24197    
24198                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
24199                                    JournalArticle.class.getName(),
24200                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
24201    
24202                    Session session = null;
24203    
24204                    try {
24205                            session = openSession();
24206    
24207                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
24208    
24209                            q.addScalar(COUNT_COLUMN_NAME,
24210                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
24211    
24212                            QueryPos qPos = QueryPos.getInstance(q);
24213    
24214                            qPos.add(groupId);
24215    
24216                            qPos.add(classNameId);
24217    
24218                            if (bindLayoutUuid) {
24219                                    qPos.add(layoutUuid);
24220                            }
24221    
24222                            Long count = (Long)q.uniqueResult();
24223    
24224                            return count.intValue();
24225                    }
24226                    catch (Exception e) {
24227                            throw processException(e);
24228                    }
24229                    finally {
24230                            closeSession(session);
24231                    }
24232            }
24233    
24234            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
24235            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
24236            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
24237            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
24238            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = '')";
24239            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24240                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24241                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
24242                            new String[] {
24243                                    Long.class.getName(), String.class.getName(),
24244                                    Double.class.getName()
24245                            },
24246                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
24247                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
24248                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
24249            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24250                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24251                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
24252                            new String[] {
24253                                    Long.class.getName(), String.class.getName(),
24254                                    Double.class.getName()
24255                            });
24256    
24257            /**
24258             * Returns the journal article where groupId = &#63; and articleId = &#63; and version = &#63; or throws a {@link NoSuchArticleException} if it could not be found.
24259             *
24260             * @param groupId the group ID
24261             * @param articleId the article ID
24262             * @param version the version
24263             * @return the matching journal article
24264             * @throws NoSuchArticleException if a matching journal article could not be found
24265             */
24266            @Override
24267            public JournalArticle findByG_A_V(long groupId, String articleId,
24268                    double version) throws NoSuchArticleException {
24269                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
24270    
24271                    if (journalArticle == null) {
24272                            StringBundler msg = new StringBundler(8);
24273    
24274                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24275    
24276                            msg.append("groupId=");
24277                            msg.append(groupId);
24278    
24279                            msg.append(", articleId=");
24280                            msg.append(articleId);
24281    
24282                            msg.append(", version=");
24283                            msg.append(version);
24284    
24285                            msg.append(StringPool.CLOSE_CURLY_BRACE);
24286    
24287                            if (_log.isWarnEnabled()) {
24288                                    _log.warn(msg.toString());
24289                            }
24290    
24291                            throw new NoSuchArticleException(msg.toString());
24292                    }
24293    
24294                    return journalArticle;
24295            }
24296    
24297            /**
24298             * 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.
24299             *
24300             * @param groupId the group ID
24301             * @param articleId the article ID
24302             * @param version the version
24303             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24304             */
24305            @Override
24306            public JournalArticle fetchByG_A_V(long groupId, String articleId,
24307                    double version) {
24308                    return fetchByG_A_V(groupId, articleId, version, true);
24309            }
24310    
24311            /**
24312             * 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.
24313             *
24314             * @param groupId the group ID
24315             * @param articleId the article ID
24316             * @param version the version
24317             * @param retrieveFromCache whether to use the finder cache
24318             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
24319             */
24320            @Override
24321            public JournalArticle fetchByG_A_V(long groupId, String articleId,
24322                    double version, boolean retrieveFromCache) {
24323                    Object[] finderArgs = new Object[] { groupId, articleId, version };
24324    
24325                    Object result = null;
24326    
24327                    if (retrieveFromCache) {
24328                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
24329                                            finderArgs, this);
24330                    }
24331    
24332                    if (result instanceof JournalArticle) {
24333                            JournalArticle journalArticle = (JournalArticle)result;
24334    
24335                            if ((groupId != journalArticle.getGroupId()) ||
24336                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
24337                                            (version != journalArticle.getVersion())) {
24338                                    result = null;
24339                            }
24340                    }
24341    
24342                    if (result == null) {
24343                            StringBundler query = new StringBundler(5);
24344    
24345                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24346    
24347                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
24348    
24349                            boolean bindArticleId = false;
24350    
24351                            if (articleId == null) {
24352                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
24353                            }
24354                            else if (articleId.equals(StringPool.BLANK)) {
24355                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
24356                            }
24357                            else {
24358                                    bindArticleId = true;
24359    
24360                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
24361                            }
24362    
24363                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
24364    
24365                            String sql = query.toString();
24366    
24367                            Session session = null;
24368    
24369                            try {
24370                                    session = openSession();
24371    
24372                                    Query q = session.createQuery(sql);
24373    
24374                                    QueryPos qPos = QueryPos.getInstance(q);
24375    
24376                                    qPos.add(groupId);
24377    
24378                                    if (bindArticleId) {
24379                                            qPos.add(articleId);
24380                                    }
24381    
24382                                    qPos.add(version);
24383    
24384                                    List<JournalArticle> list = q.list();
24385    
24386                                    if (list.isEmpty()) {
24387                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
24388                                                    finderArgs, list);
24389                                    }
24390                                    else {
24391                                            JournalArticle journalArticle = list.get(0);
24392    
24393                                            result = journalArticle;
24394    
24395                                            cacheResult(journalArticle);
24396    
24397                                            if ((journalArticle.getGroupId() != groupId) ||
24398                                                            (journalArticle.getArticleId() == null) ||
24399                                                            !journalArticle.getArticleId().equals(articleId) ||
24400                                                            (journalArticle.getVersion() != version)) {
24401                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
24402                                                            finderArgs, journalArticle);
24403                                            }
24404                                    }
24405                            }
24406                            catch (Exception e) {
24407                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
24408                                            finderArgs);
24409    
24410                                    throw processException(e);
24411                            }
24412                            finally {
24413                                    closeSession(session);
24414                            }
24415                    }
24416    
24417                    if (result instanceof List<?>) {
24418                            return null;
24419                    }
24420                    else {
24421                            return (JournalArticle)result;
24422                    }
24423            }
24424    
24425            /**
24426             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
24427             *
24428             * @param groupId the group ID
24429             * @param articleId the article ID
24430             * @param version the version
24431             * @return the journal article that was removed
24432             */
24433            @Override
24434            public JournalArticle removeByG_A_V(long groupId, String articleId,
24435                    double version) throws NoSuchArticleException {
24436                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
24437    
24438                    return remove(journalArticle);
24439            }
24440    
24441            /**
24442             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
24443             *
24444             * @param groupId the group ID
24445             * @param articleId the article ID
24446             * @param version the version
24447             * @return the number of matching journal articles
24448             */
24449            @Override
24450            public int countByG_A_V(long groupId, String articleId, double version) {
24451                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_V;
24452    
24453                    Object[] finderArgs = new Object[] { groupId, articleId, version };
24454    
24455                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
24456                                    this);
24457    
24458                    if (count == null) {
24459                            StringBundler query = new StringBundler(4);
24460    
24461                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24462    
24463                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
24464    
24465                            boolean bindArticleId = false;
24466    
24467                            if (articleId == null) {
24468                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
24469                            }
24470                            else if (articleId.equals(StringPool.BLANK)) {
24471                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
24472                            }
24473                            else {
24474                                    bindArticleId = true;
24475    
24476                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
24477                            }
24478    
24479                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
24480    
24481                            String sql = query.toString();
24482    
24483                            Session session = null;
24484    
24485                            try {
24486                                    session = openSession();
24487    
24488                                    Query q = session.createQuery(sql);
24489    
24490                                    QueryPos qPos = QueryPos.getInstance(q);
24491    
24492                                    qPos.add(groupId);
24493    
24494                                    if (bindArticleId) {
24495                                            qPos.add(articleId);
24496                                    }
24497    
24498                                    qPos.add(version);
24499    
24500                                    count = (Long)q.uniqueResult();
24501    
24502                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
24503                            }
24504                            catch (Exception e) {
24505                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24506    
24507                                    throw processException(e);
24508                            }
24509                            finally {
24510                                    closeSession(session);
24511                            }
24512                    }
24513    
24514                    return count.intValue();
24515            }
24516    
24517            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
24518            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
24519            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
24520            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
24521            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
24522            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24523                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24524                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
24525                            "findByG_A_ST",
24526                            new String[] {
24527                                    Long.class.getName(), String.class.getName(),
24528                                    Integer.class.getName(),
24529                                    
24530                            Integer.class.getName(), Integer.class.getName(),
24531                                    OrderByComparator.class.getName()
24532                            });
24533            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
24534                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24535                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
24536                            JournalArticleImpl.class,
24537                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
24538                            new String[] {
24539                                    Long.class.getName(), String.class.getName(),
24540                                    Integer.class.getName()
24541                            },
24542                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
24543                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
24544                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
24545                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
24546            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24547                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24548                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
24549                            new String[] {
24550                                    Long.class.getName(), String.class.getName(),
24551                                    Integer.class.getName()
24552                            });
24553            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
24554                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
24555                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
24556                            new String[] {
24557                                    Long.class.getName(), String.class.getName(),
24558                                    Integer.class.getName()
24559                            });
24560    
24561            /**
24562             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
24563             *
24564             * @param groupId the group ID
24565             * @param articleId the article ID
24566             * @param status the status
24567             * @return the matching journal articles
24568             */
24569            @Override
24570            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24571                    int status) {
24572                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
24573                            QueryUtil.ALL_POS, null);
24574            }
24575    
24576            /**
24577             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
24578             *
24579             * <p>
24580             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24581             * </p>
24582             *
24583             * @param groupId the group ID
24584             * @param articleId the article ID
24585             * @param status the status
24586             * @param start the lower bound of the range of journal articles
24587             * @param end the upper bound of the range of journal articles (not inclusive)
24588             * @return the range of matching journal articles
24589             */
24590            @Override
24591            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24592                    int status, int start, int end) {
24593                    return findByG_A_ST(groupId, articleId, status, start, end, null);
24594            }
24595    
24596            /**
24597             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
24598             *
24599             * <p>
24600             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
24601             * </p>
24602             *
24603             * @param groupId the group ID
24604             * @param articleId the article ID
24605             * @param status the status
24606             * @param start the lower bound of the range of journal articles
24607             * @param end the upper bound of the range of journal articles (not inclusive)
24608             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
24609             * @return the ordered range of matching journal articles
24610             */
24611            @Override
24612            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
24613                    int status, int start, int end,
24614                    OrderByComparator<JournalArticle> orderByComparator) {
24615                    boolean pagination = true;
24616                    FinderPath finderPath = null;
24617                    Object[] finderArgs = null;
24618    
24619                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
24620                                    (orderByComparator == null)) {
24621                            pagination = false;
24622                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
24623                            finderArgs = new Object[] { groupId, articleId, status };
24624                    }
24625                    else {
24626                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
24627                            finderArgs = new Object[] {
24628                                            groupId, articleId, status,
24629                                            
24630                                            start, end, orderByComparator
24631                                    };
24632                    }
24633    
24634                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
24635                                    finderArgs, this);
24636    
24637                    if ((list != null) && !list.isEmpty()) {
24638                            for (JournalArticle journalArticle : list) {
24639                                    if ((groupId != journalArticle.getGroupId()) ||
24640                                                    !Validator.equals(articleId,
24641                                                            journalArticle.getArticleId()) ||
24642                                                    (status != journalArticle.getStatus())) {
24643                                            list = null;
24644    
24645                                            break;
24646                                    }
24647                            }
24648                    }
24649    
24650                    if (list == null) {
24651                            StringBundler query = null;
24652    
24653                            if (orderByComparator != null) {
24654                                    query = new StringBundler(5 +
24655                                                    (orderByComparator.getOrderByFields().length * 3));
24656                            }
24657                            else {
24658                                    query = new StringBundler(5);
24659                            }
24660    
24661                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24662    
24663                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24664    
24665                            boolean bindArticleId = false;
24666    
24667                            if (articleId == null) {
24668                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24669                            }
24670                            else if (articleId.equals(StringPool.BLANK)) {
24671                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24672                            }
24673                            else {
24674                                    bindArticleId = true;
24675    
24676                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24677                            }
24678    
24679                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24680    
24681                            if (orderByComparator != null) {
24682                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
24683                                            orderByComparator);
24684                            }
24685                            else
24686                             if (pagination) {
24687                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
24688                            }
24689    
24690                            String sql = query.toString();
24691    
24692                            Session session = null;
24693    
24694                            try {
24695                                    session = openSession();
24696    
24697                                    Query q = session.createQuery(sql);
24698    
24699                                    QueryPos qPos = QueryPos.getInstance(q);
24700    
24701                                    qPos.add(groupId);
24702    
24703                                    if (bindArticleId) {
24704                                            qPos.add(articleId);
24705                                    }
24706    
24707                                    qPos.add(status);
24708    
24709                                    if (!pagination) {
24710                                            list = (List<JournalArticle>)QueryUtil.list(q,
24711                                                            getDialect(), start, end, false);
24712    
24713                                            Collections.sort(list);
24714    
24715                                            list = Collections.unmodifiableList(list);
24716                                    }
24717                                    else {
24718                                            list = (List<JournalArticle>)QueryUtil.list(q,
24719                                                            getDialect(), start, end);
24720                                    }
24721    
24722                                    cacheResult(list);
24723    
24724                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
24725                            }
24726                            catch (Exception e) {
24727                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
24728    
24729                                    throw processException(e);
24730                            }
24731                            finally {
24732                                    closeSession(session);
24733                            }
24734                    }
24735    
24736                    return list;
24737            }
24738    
24739            /**
24740             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24741             *
24742             * @param groupId the group ID
24743             * @param articleId the article ID
24744             * @param status the status
24745             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24746             * @return the first matching journal article
24747             * @throws NoSuchArticleException if a matching journal article could not be found
24748             */
24749            @Override
24750            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
24751                    int status, OrderByComparator<JournalArticle> orderByComparator)
24752                    throws NoSuchArticleException {
24753                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
24754                                    status, orderByComparator);
24755    
24756                    if (journalArticle != null) {
24757                            return journalArticle;
24758                    }
24759    
24760                    StringBundler msg = new StringBundler(8);
24761    
24762                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24763    
24764                    msg.append("groupId=");
24765                    msg.append(groupId);
24766    
24767                    msg.append(", articleId=");
24768                    msg.append(articleId);
24769    
24770                    msg.append(", status=");
24771                    msg.append(status);
24772    
24773                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24774    
24775                    throw new NoSuchArticleException(msg.toString());
24776            }
24777    
24778            /**
24779             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24780             *
24781             * @param groupId the group ID
24782             * @param articleId the article ID
24783             * @param status the status
24784             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24785             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
24786             */
24787            @Override
24788            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
24789                    int status, OrderByComparator<JournalArticle> orderByComparator) {
24790                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
24791                                    1, orderByComparator);
24792    
24793                    if (!list.isEmpty()) {
24794                            return list.get(0);
24795                    }
24796    
24797                    return null;
24798            }
24799    
24800            /**
24801             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24802             *
24803             * @param groupId the group ID
24804             * @param articleId the article ID
24805             * @param status the status
24806             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24807             * @return the last matching journal article
24808             * @throws NoSuchArticleException if a matching journal article could not be found
24809             */
24810            @Override
24811            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
24812                    int status, OrderByComparator<JournalArticle> orderByComparator)
24813                    throws NoSuchArticleException {
24814                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
24815                                    status, orderByComparator);
24816    
24817                    if (journalArticle != null) {
24818                            return journalArticle;
24819                    }
24820    
24821                    StringBundler msg = new StringBundler(8);
24822    
24823                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
24824    
24825                    msg.append("groupId=");
24826                    msg.append(groupId);
24827    
24828                    msg.append(", articleId=");
24829                    msg.append(articleId);
24830    
24831                    msg.append(", status=");
24832                    msg.append(status);
24833    
24834                    msg.append(StringPool.CLOSE_CURLY_BRACE);
24835    
24836                    throw new NoSuchArticleException(msg.toString());
24837            }
24838    
24839            /**
24840             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24841             *
24842             * @param groupId the group ID
24843             * @param articleId the article ID
24844             * @param status the status
24845             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24846             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
24847             */
24848            @Override
24849            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
24850                    int status, OrderByComparator<JournalArticle> orderByComparator) {
24851                    int count = countByG_A_ST(groupId, articleId, status);
24852    
24853                    if (count == 0) {
24854                            return null;
24855                    }
24856    
24857                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
24858                                    count - 1, count, orderByComparator);
24859    
24860                    if (!list.isEmpty()) {
24861                            return list.get(0);
24862                    }
24863    
24864                    return null;
24865            }
24866    
24867            /**
24868             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
24869             *
24870             * @param id the primary key of the current journal article
24871             * @param groupId the group ID
24872             * @param articleId the article ID
24873             * @param status the status
24874             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
24875             * @return the previous, current, and next journal article
24876             * @throws NoSuchArticleException if a journal article with the primary key could not be found
24877             */
24878            @Override
24879            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
24880                    String articleId, int status,
24881                    OrderByComparator<JournalArticle> orderByComparator)
24882                    throws NoSuchArticleException {
24883                    JournalArticle journalArticle = findByPrimaryKey(id);
24884    
24885                    Session session = null;
24886    
24887                    try {
24888                            session = openSession();
24889    
24890                            JournalArticle[] array = new JournalArticleImpl[3];
24891    
24892                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
24893                                            groupId, articleId, status, orderByComparator, true);
24894    
24895                            array[1] = journalArticle;
24896    
24897                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
24898                                            groupId, articleId, status, orderByComparator, false);
24899    
24900                            return array;
24901                    }
24902                    catch (Exception e) {
24903                            throw processException(e);
24904                    }
24905                    finally {
24906                            closeSession(session);
24907                    }
24908            }
24909    
24910            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
24911                    JournalArticle journalArticle, long groupId, String articleId,
24912                    int status, OrderByComparator<JournalArticle> orderByComparator,
24913                    boolean previous) {
24914                    StringBundler query = null;
24915    
24916                    if (orderByComparator != null) {
24917                            query = new StringBundler(6 +
24918                                            (orderByComparator.getOrderByFields().length * 6));
24919                    }
24920                    else {
24921                            query = new StringBundler(3);
24922                    }
24923    
24924                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
24925    
24926                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
24927    
24928                    boolean bindArticleId = false;
24929    
24930                    if (articleId == null) {
24931                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
24932                    }
24933                    else if (articleId.equals(StringPool.BLANK)) {
24934                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
24935                    }
24936                    else {
24937                            bindArticleId = true;
24938    
24939                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
24940                    }
24941    
24942                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
24943    
24944                    if (orderByComparator != null) {
24945                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
24946    
24947                            if (orderByConditionFields.length > 0) {
24948                                    query.append(WHERE_AND);
24949                            }
24950    
24951                            for (int i = 0; i < orderByConditionFields.length; i++) {
24952                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24953                                    query.append(orderByConditionFields[i]);
24954    
24955                                    if ((i + 1) < orderByConditionFields.length) {
24956                                            if (orderByComparator.isAscending() ^ previous) {
24957                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
24958                                            }
24959                                            else {
24960                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
24961                                            }
24962                                    }
24963                                    else {
24964                                            if (orderByComparator.isAscending() ^ previous) {
24965                                                    query.append(WHERE_GREATER_THAN);
24966                                            }
24967                                            else {
24968                                                    query.append(WHERE_LESSER_THAN);
24969                                            }
24970                                    }
24971                            }
24972    
24973                            query.append(ORDER_BY_CLAUSE);
24974    
24975                            String[] orderByFields = orderByComparator.getOrderByFields();
24976    
24977                            for (int i = 0; i < orderByFields.length; i++) {
24978                                    query.append(_ORDER_BY_ENTITY_ALIAS);
24979                                    query.append(orderByFields[i]);
24980    
24981                                    if ((i + 1) < orderByFields.length) {
24982                                            if (orderByComparator.isAscending() ^ previous) {
24983                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
24984                                            }
24985                                            else {
24986                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
24987                                            }
24988                                    }
24989                                    else {
24990                                            if (orderByComparator.isAscending() ^ previous) {
24991                                                    query.append(ORDER_BY_ASC);
24992                                            }
24993                                            else {
24994                                                    query.append(ORDER_BY_DESC);
24995                                            }
24996                                    }
24997                            }
24998                    }
24999                    else {
25000                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25001                    }
25002    
25003                    String sql = query.toString();
25004    
25005                    Query q = session.createQuery(sql);
25006    
25007                    q.setFirstResult(0);
25008                    q.setMaxResults(2);
25009    
25010                    QueryPos qPos = QueryPos.getInstance(q);
25011    
25012                    qPos.add(groupId);
25013    
25014                    if (bindArticleId) {
25015                            qPos.add(articleId);
25016                    }
25017    
25018                    qPos.add(status);
25019    
25020                    if (orderByComparator != null) {
25021                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25022    
25023                            for (Object value : values) {
25024                                    qPos.add(value);
25025                            }
25026                    }
25027    
25028                    List<JournalArticle> list = q.list();
25029    
25030                    if (list.size() == 2) {
25031                            return list.get(1);
25032                    }
25033                    else {
25034                            return null;
25035                    }
25036            }
25037    
25038            /**
25039             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25040             *
25041             * @param groupId the group ID
25042             * @param articleId the article ID
25043             * @param status the status
25044             * @return the matching journal articles that the user has permission to view
25045             */
25046            @Override
25047            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25048                    String articleId, int status) {
25049                    return filterFindByG_A_ST(groupId, articleId, status,
25050                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
25051            }
25052    
25053            /**
25054             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25055             *
25056             * <p>
25057             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25058             * </p>
25059             *
25060             * @param groupId the group ID
25061             * @param articleId the article ID
25062             * @param status the status
25063             * @param start the lower bound of the range of journal articles
25064             * @param end the upper bound of the range of journal articles (not inclusive)
25065             * @return the range of matching journal articles that the user has permission to view
25066             */
25067            @Override
25068            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25069                    String articleId, int status, int start, int end) {
25070                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
25071            }
25072    
25073            /**
25074             * 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;.
25075             *
25076             * <p>
25077             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25078             * </p>
25079             *
25080             * @param groupId the group ID
25081             * @param articleId the article ID
25082             * @param status the status
25083             * @param start the lower bound of the range of journal articles
25084             * @param end the upper bound of the range of journal articles (not inclusive)
25085             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25086             * @return the ordered range of matching journal articles that the user has permission to view
25087             */
25088            @Override
25089            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25090                    String articleId, int status, int start, int end,
25091                    OrderByComparator<JournalArticle> orderByComparator) {
25092                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25093                            return findByG_A_ST(groupId, articleId, status, start, end,
25094                                    orderByComparator);
25095                    }
25096    
25097                    StringBundler query = null;
25098    
25099                    if (orderByComparator != null) {
25100                            query = new StringBundler(5 +
25101                                            (orderByComparator.getOrderByFields().length * 3));
25102                    }
25103                    else {
25104                            query = new StringBundler(5);
25105                    }
25106    
25107                    if (getDB().isSupportsInlineDistinct()) {
25108                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25109                    }
25110                    else {
25111                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25112                    }
25113    
25114                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25115    
25116                    boolean bindArticleId = false;
25117    
25118                    if (articleId == null) {
25119                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25120                    }
25121                    else if (articleId.equals(StringPool.BLANK)) {
25122                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25123                    }
25124                    else {
25125                            bindArticleId = true;
25126    
25127                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25128                    }
25129    
25130                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25131    
25132                    if (!getDB().isSupportsInlineDistinct()) {
25133                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25134                    }
25135    
25136                    if (orderByComparator != null) {
25137                            if (getDB().isSupportsInlineDistinct()) {
25138                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25139                                            orderByComparator, true);
25140                            }
25141                            else {
25142                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
25143                                            orderByComparator, true);
25144                            }
25145                    }
25146                    else {
25147                            if (getDB().isSupportsInlineDistinct()) {
25148                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25149                            }
25150                            else {
25151                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25152                            }
25153                    }
25154    
25155                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25156                                    JournalArticle.class.getName(),
25157                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25158    
25159                    Session session = null;
25160    
25161                    try {
25162                            session = openSession();
25163    
25164                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
25165    
25166                            if (getDB().isSupportsInlineDistinct()) {
25167                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25168                            }
25169                            else {
25170                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25171                            }
25172    
25173                            QueryPos qPos = QueryPos.getInstance(q);
25174    
25175                            qPos.add(groupId);
25176    
25177                            if (bindArticleId) {
25178                                    qPos.add(articleId);
25179                            }
25180    
25181                            qPos.add(status);
25182    
25183                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
25184                                    end);
25185                    }
25186                    catch (Exception e) {
25187                            throw processException(e);
25188                    }
25189                    finally {
25190                            closeSession(session);
25191                    }
25192            }
25193    
25194            /**
25195             * 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;.
25196             *
25197             * @param id the primary key of the current journal article
25198             * @param groupId the group ID
25199             * @param articleId the article ID
25200             * @param status the status
25201             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
25202             * @return the previous, current, and next journal article
25203             * @throws NoSuchArticleException if a journal article with the primary key could not be found
25204             */
25205            @Override
25206            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
25207                    long groupId, String articleId, int status,
25208                    OrderByComparator<JournalArticle> orderByComparator)
25209                    throws NoSuchArticleException {
25210                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25211                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
25212                                    orderByComparator);
25213                    }
25214    
25215                    JournalArticle journalArticle = findByPrimaryKey(id);
25216    
25217                    Session session = null;
25218    
25219                    try {
25220                            session = openSession();
25221    
25222                            JournalArticle[] array = new JournalArticleImpl[3];
25223    
25224                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
25225                                            groupId, articleId, status, orderByComparator, true);
25226    
25227                            array[1] = journalArticle;
25228    
25229                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
25230                                            groupId, articleId, status, orderByComparator, false);
25231    
25232                            return array;
25233                    }
25234                    catch (Exception e) {
25235                            throw processException(e);
25236                    }
25237                    finally {
25238                            closeSession(session);
25239                    }
25240            }
25241    
25242            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
25243                    JournalArticle journalArticle, long groupId, String articleId,
25244                    int status, OrderByComparator<JournalArticle> orderByComparator,
25245                    boolean previous) {
25246                    StringBundler query = null;
25247    
25248                    if (orderByComparator != null) {
25249                            query = new StringBundler(6 +
25250                                            (orderByComparator.getOrderByFields().length * 6));
25251                    }
25252                    else {
25253                            query = new StringBundler(3);
25254                    }
25255    
25256                    if (getDB().isSupportsInlineDistinct()) {
25257                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25258                    }
25259                    else {
25260                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25261                    }
25262    
25263                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25264    
25265                    boolean bindArticleId = false;
25266    
25267                    if (articleId == null) {
25268                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25269                    }
25270                    else if (articleId.equals(StringPool.BLANK)) {
25271                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25272                    }
25273                    else {
25274                            bindArticleId = true;
25275    
25276                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25277                    }
25278    
25279                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25280    
25281                    if (!getDB().isSupportsInlineDistinct()) {
25282                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25283                    }
25284    
25285                    if (orderByComparator != null) {
25286                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
25287    
25288                            if (orderByConditionFields.length > 0) {
25289                                    query.append(WHERE_AND);
25290                            }
25291    
25292                            for (int i = 0; i < orderByConditionFields.length; i++) {
25293                                    if (getDB().isSupportsInlineDistinct()) {
25294                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25295                                    }
25296                                    else {
25297                                            query.append(_ORDER_BY_ENTITY_TABLE);
25298                                    }
25299    
25300                                    query.append(orderByConditionFields[i]);
25301    
25302                                    if ((i + 1) < orderByConditionFields.length) {
25303                                            if (orderByComparator.isAscending() ^ previous) {
25304                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
25305                                            }
25306                                            else {
25307                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
25308                                            }
25309                                    }
25310                                    else {
25311                                            if (orderByComparator.isAscending() ^ previous) {
25312                                                    query.append(WHERE_GREATER_THAN);
25313                                            }
25314                                            else {
25315                                                    query.append(WHERE_LESSER_THAN);
25316                                            }
25317                                    }
25318                            }
25319    
25320                            query.append(ORDER_BY_CLAUSE);
25321    
25322                            String[] orderByFields = orderByComparator.getOrderByFields();
25323    
25324                            for (int i = 0; i < orderByFields.length; i++) {
25325                                    if (getDB().isSupportsInlineDistinct()) {
25326                                            query.append(_ORDER_BY_ENTITY_ALIAS);
25327                                    }
25328                                    else {
25329                                            query.append(_ORDER_BY_ENTITY_TABLE);
25330                                    }
25331    
25332                                    query.append(orderByFields[i]);
25333    
25334                                    if ((i + 1) < orderByFields.length) {
25335                                            if (orderByComparator.isAscending() ^ previous) {
25336                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
25337                                            }
25338                                            else {
25339                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
25340                                            }
25341                                    }
25342                                    else {
25343                                            if (orderByComparator.isAscending() ^ previous) {
25344                                                    query.append(ORDER_BY_ASC);
25345                                            }
25346                                            else {
25347                                                    query.append(ORDER_BY_DESC);
25348                                            }
25349                                    }
25350                            }
25351                    }
25352                    else {
25353                            if (getDB().isSupportsInlineDistinct()) {
25354                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25355                            }
25356                            else {
25357                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25358                            }
25359                    }
25360    
25361                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25362                                    JournalArticle.class.getName(),
25363                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25364    
25365                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
25366    
25367                    q.setFirstResult(0);
25368                    q.setMaxResults(2);
25369    
25370                    if (getDB().isSupportsInlineDistinct()) {
25371                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25372                    }
25373                    else {
25374                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25375                    }
25376    
25377                    QueryPos qPos = QueryPos.getInstance(q);
25378    
25379                    qPos.add(groupId);
25380    
25381                    if (bindArticleId) {
25382                            qPos.add(articleId);
25383                    }
25384    
25385                    qPos.add(status);
25386    
25387                    if (orderByComparator != null) {
25388                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
25389    
25390                            for (Object value : values) {
25391                                    qPos.add(value);
25392                            }
25393                    }
25394    
25395                    List<JournalArticle> list = q.list();
25396    
25397                    if (list.size() == 2) {
25398                            return list.get(1);
25399                    }
25400                    else {
25401                            return null;
25402                    }
25403            }
25404    
25405            /**
25406             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
25407             *
25408             * @param groupId the group ID
25409             * @param articleId the article ID
25410             * @param statuses the statuses
25411             * @return the matching journal articles that the user has permission to view
25412             */
25413            @Override
25414            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25415                    String articleId, int[] statuses) {
25416                    return filterFindByG_A_ST(groupId, articleId, statuses,
25417                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
25418            }
25419    
25420            /**
25421             * 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;.
25422             *
25423             * <p>
25424             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25425             * </p>
25426             *
25427             * @param groupId the group ID
25428             * @param articleId the article ID
25429             * @param statuses the statuses
25430             * @param start the lower bound of the range of journal articles
25431             * @param end the upper bound of the range of journal articles (not inclusive)
25432             * @return the range of matching journal articles that the user has permission to view
25433             */
25434            @Override
25435            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25436                    String articleId, int[] statuses, int start, int end) {
25437                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
25438            }
25439    
25440            /**
25441             * 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;.
25442             *
25443             * <p>
25444             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25445             * </p>
25446             *
25447             * @param groupId the group ID
25448             * @param articleId the article ID
25449             * @param statuses the statuses
25450             * @param start the lower bound of the range of journal articles
25451             * @param end the upper bound of the range of journal articles (not inclusive)
25452             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25453             * @return the ordered range of matching journal articles that the user has permission to view
25454             */
25455            @Override
25456            public List<JournalArticle> filterFindByG_A_ST(long groupId,
25457                    String articleId, int[] statuses, int start, int end,
25458                    OrderByComparator<JournalArticle> orderByComparator) {
25459                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25460                            return findByG_A_ST(groupId, articleId, statuses, start, end,
25461                                    orderByComparator);
25462                    }
25463    
25464                    if (statuses == null) {
25465                            statuses = new int[0];
25466                    }
25467                    else {
25468                            statuses = ArrayUtil.unique(statuses);
25469                    }
25470    
25471                    StringBundler query = new StringBundler();
25472    
25473                    if (getDB().isSupportsInlineDistinct()) {
25474                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
25475                    }
25476                    else {
25477                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
25478                    }
25479    
25480                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25481    
25482                    boolean bindArticleId = false;
25483    
25484                    if (articleId == null) {
25485                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25486                    }
25487                    else if (articleId.equals(StringPool.BLANK)) {
25488                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25489                    }
25490                    else {
25491                            bindArticleId = true;
25492    
25493                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25494                    }
25495    
25496                    if (statuses.length > 0) {
25497                            query.append(StringPool.OPEN_PARENTHESIS);
25498    
25499                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_7);
25500    
25501                            query.append(StringUtil.merge(statuses));
25502    
25503                            query.append(StringPool.CLOSE_PARENTHESIS);
25504    
25505                            query.append(StringPool.CLOSE_PARENTHESIS);
25506                    }
25507    
25508                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
25509                            query.index() - 1);
25510    
25511                    if (!getDB().isSupportsInlineDistinct()) {
25512                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
25513                    }
25514    
25515                    if (orderByComparator != null) {
25516                            if (getDB().isSupportsInlineDistinct()) {
25517                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25518                                            orderByComparator, true);
25519                            }
25520                            else {
25521                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
25522                                            orderByComparator, true);
25523                            }
25524                    }
25525                    else {
25526                            if (getDB().isSupportsInlineDistinct()) {
25527                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25528                            }
25529                            else {
25530                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
25531                            }
25532                    }
25533    
25534                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25535                                    JournalArticle.class.getName(),
25536                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25537    
25538                    Session session = null;
25539    
25540                    try {
25541                            session = openSession();
25542    
25543                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
25544    
25545                            if (getDB().isSupportsInlineDistinct()) {
25546                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
25547                            }
25548                            else {
25549                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
25550                            }
25551    
25552                            QueryPos qPos = QueryPos.getInstance(q);
25553    
25554                            qPos.add(groupId);
25555    
25556                            if (bindArticleId) {
25557                                    qPos.add(articleId);
25558                            }
25559    
25560                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
25561                                    end);
25562                    }
25563                    catch (Exception e) {
25564                            throw processException(e);
25565                    }
25566                    finally {
25567                            closeSession(session);
25568                    }
25569            }
25570    
25571            /**
25572             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25573             *
25574             * <p>
25575             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25576             * </p>
25577             *
25578             * @param groupId the group ID
25579             * @param articleId the article ID
25580             * @param statuses the statuses
25581             * @return the matching journal articles
25582             */
25583            @Override
25584            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25585                    int[] statuses) {
25586                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
25587                            QueryUtil.ALL_POS, null);
25588            }
25589    
25590            /**
25591             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25592             *
25593             * <p>
25594             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25595             * </p>
25596             *
25597             * @param groupId the group ID
25598             * @param articleId the article ID
25599             * @param statuses the statuses
25600             * @param start the lower bound of the range of journal articles
25601             * @param end the upper bound of the range of journal articles (not inclusive)
25602             * @return the range of matching journal articles
25603             */
25604            @Override
25605            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25606                    int[] statuses, int start, int end) {
25607                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
25608            }
25609    
25610            /**
25611             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25612             *
25613             * <p>
25614             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
25615             * </p>
25616             *
25617             * @param groupId the group ID
25618             * @param articleId the article ID
25619             * @param statuses the statuses
25620             * @param start the lower bound of the range of journal articles
25621             * @param end the upper bound of the range of journal articles (not inclusive)
25622             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
25623             * @return the ordered range of matching journal articles
25624             */
25625            @Override
25626            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
25627                    int[] statuses, int start, int end,
25628                    OrderByComparator<JournalArticle> orderByComparator) {
25629                    if (statuses == null) {
25630                            statuses = new int[0];
25631                    }
25632                    else {
25633                            statuses = ArrayUtil.unique(statuses);
25634                    }
25635    
25636                    if (statuses.length == 1) {
25637                            return findByG_A_ST(groupId, articleId, statuses[0], start, end,
25638                                    orderByComparator);
25639                    }
25640    
25641                    boolean pagination = true;
25642                    Object[] finderArgs = null;
25643    
25644                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
25645                                    (orderByComparator == null)) {
25646                            pagination = false;
25647                            finderArgs = new Object[] {
25648                                            groupId, articleId, StringUtil.merge(statuses)
25649                                    };
25650                    }
25651                    else {
25652                            finderArgs = new Object[] {
25653                                            groupId, articleId, StringUtil.merge(statuses),
25654                                            
25655                                            start, end, orderByComparator
25656                                    };
25657                    }
25658    
25659                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
25660                                    finderArgs, this);
25661    
25662                    if ((list != null) && !list.isEmpty()) {
25663                            for (JournalArticle journalArticle : list) {
25664                                    if ((groupId != journalArticle.getGroupId()) ||
25665                                                    !Validator.equals(articleId,
25666                                                            journalArticle.getArticleId()) ||
25667                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
25668                                            list = null;
25669    
25670                                            break;
25671                                    }
25672                            }
25673                    }
25674    
25675                    if (list == null) {
25676                            StringBundler query = new StringBundler();
25677    
25678                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
25679    
25680                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25681    
25682                            boolean bindArticleId = false;
25683    
25684                            if (articleId == null) {
25685                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25686                            }
25687                            else if (articleId.equals(StringPool.BLANK)) {
25688                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25689                            }
25690                            else {
25691                                    bindArticleId = true;
25692    
25693                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25694                            }
25695    
25696                            if (statuses.length > 0) {
25697                                    query.append(StringPool.OPEN_PARENTHESIS);
25698    
25699                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_7);
25700    
25701                                    query.append(StringUtil.merge(statuses));
25702    
25703                                    query.append(StringPool.CLOSE_PARENTHESIS);
25704    
25705                                    query.append(StringPool.CLOSE_PARENTHESIS);
25706                            }
25707    
25708                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
25709                                                    1)), query.index() - 1);
25710    
25711                            if (orderByComparator != null) {
25712                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
25713                                            orderByComparator);
25714                            }
25715                            else
25716                             if (pagination) {
25717                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
25718                            }
25719    
25720                            String sql = query.toString();
25721    
25722                            Session session = null;
25723    
25724                            try {
25725                                    session = openSession();
25726    
25727                                    Query q = session.createQuery(sql);
25728    
25729                                    QueryPos qPos = QueryPos.getInstance(q);
25730    
25731                                    qPos.add(groupId);
25732    
25733                                    if (bindArticleId) {
25734                                            qPos.add(articleId);
25735                                    }
25736    
25737                                    if (!pagination) {
25738                                            list = (List<JournalArticle>)QueryUtil.list(q,
25739                                                            getDialect(), start, end, false);
25740    
25741                                            Collections.sort(list);
25742    
25743                                            list = Collections.unmodifiableList(list);
25744                                    }
25745                                    else {
25746                                            list = (List<JournalArticle>)QueryUtil.list(q,
25747                                                            getDialect(), start, end);
25748                                    }
25749    
25750                                    cacheResult(list);
25751    
25752                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
25753                                            finderArgs, list);
25754                            }
25755                            catch (Exception e) {
25756                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST,
25757                                            finderArgs);
25758    
25759                                    throw processException(e);
25760                            }
25761                            finally {
25762                                    closeSession(session);
25763                            }
25764                    }
25765    
25766                    return list;
25767            }
25768    
25769            /**
25770             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
25771             *
25772             * @param groupId the group ID
25773             * @param articleId the article ID
25774             * @param status the status
25775             */
25776            @Override
25777            public void removeByG_A_ST(long groupId, String articleId, int status) {
25778                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
25779                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
25780                            remove(journalArticle);
25781                    }
25782            }
25783    
25784            /**
25785             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
25786             *
25787             * @param groupId the group ID
25788             * @param articleId the article ID
25789             * @param status the status
25790             * @return the number of matching journal articles
25791             */
25792            @Override
25793            public int countByG_A_ST(long groupId, String articleId, int status) {
25794                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_ST;
25795    
25796                    Object[] finderArgs = new Object[] { groupId, articleId, status };
25797    
25798                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
25799                                    this);
25800    
25801                    if (count == null) {
25802                            StringBundler query = new StringBundler(4);
25803    
25804                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25805    
25806                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25807    
25808                            boolean bindArticleId = false;
25809    
25810                            if (articleId == null) {
25811                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25812                            }
25813                            else if (articleId.equals(StringPool.BLANK)) {
25814                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25815                            }
25816                            else {
25817                                    bindArticleId = true;
25818    
25819                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25820                            }
25821    
25822                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25823    
25824                            String sql = query.toString();
25825    
25826                            Session session = null;
25827    
25828                            try {
25829                                    session = openSession();
25830    
25831                                    Query q = session.createQuery(sql);
25832    
25833                                    QueryPos qPos = QueryPos.getInstance(q);
25834    
25835                                    qPos.add(groupId);
25836    
25837                                    if (bindArticleId) {
25838                                            qPos.add(articleId);
25839                                    }
25840    
25841                                    qPos.add(status);
25842    
25843                                    count = (Long)q.uniqueResult();
25844    
25845                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
25846                            }
25847                            catch (Exception e) {
25848                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
25849    
25850                                    throw processException(e);
25851                            }
25852                            finally {
25853                                    closeSession(session);
25854                            }
25855                    }
25856    
25857                    return count.intValue();
25858            }
25859    
25860            /**
25861             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
25862             *
25863             * @param groupId the group ID
25864             * @param articleId the article ID
25865             * @param statuses the statuses
25866             * @return the number of matching journal articles
25867             */
25868            @Override
25869            public int countByG_A_ST(long groupId, String articleId, int[] statuses) {
25870                    if (statuses == null) {
25871                            statuses = new int[0];
25872                    }
25873                    else {
25874                            statuses = ArrayUtil.unique(statuses);
25875                    }
25876    
25877                    Object[] finderArgs = new Object[] {
25878                                    groupId, articleId, StringUtil.merge(statuses)
25879                            };
25880    
25881                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25882                                    finderArgs, this);
25883    
25884                    if (count == null) {
25885                            StringBundler query = new StringBundler();
25886    
25887                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
25888    
25889                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25890    
25891                            boolean bindArticleId = false;
25892    
25893                            if (articleId == null) {
25894                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25895                            }
25896                            else if (articleId.equals(StringPool.BLANK)) {
25897                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25898                            }
25899                            else {
25900                                    bindArticleId = true;
25901    
25902                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25903                            }
25904    
25905                            if (statuses.length > 0) {
25906                                    query.append(StringPool.OPEN_PARENTHESIS);
25907    
25908                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_7);
25909    
25910                                    query.append(StringUtil.merge(statuses));
25911    
25912                                    query.append(StringPool.CLOSE_PARENTHESIS);
25913    
25914                                    query.append(StringPool.CLOSE_PARENTHESIS);
25915                            }
25916    
25917                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
25918                                                    1)), query.index() - 1);
25919    
25920                            String sql = query.toString();
25921    
25922                            Session session = null;
25923    
25924                            try {
25925                                    session = openSession();
25926    
25927                                    Query q = session.createQuery(sql);
25928    
25929                                    QueryPos qPos = QueryPos.getInstance(q);
25930    
25931                                    qPos.add(groupId);
25932    
25933                                    if (bindArticleId) {
25934                                            qPos.add(articleId);
25935                                    }
25936    
25937                                    count = (Long)q.uniqueResult();
25938    
25939                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25940                                            finderArgs, count);
25941                            }
25942                            catch (Exception e) {
25943                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
25944                                            finderArgs);
25945    
25946                                    throw processException(e);
25947                            }
25948                            finally {
25949                                    closeSession(session);
25950                            }
25951                    }
25952    
25953                    return count.intValue();
25954            }
25955    
25956            /**
25957             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
25958             *
25959             * @param groupId the group ID
25960             * @param articleId the article ID
25961             * @param status the status
25962             * @return the number of matching journal articles that the user has permission to view
25963             */
25964            @Override
25965            public int filterCountByG_A_ST(long groupId, String articleId, int status) {
25966                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
25967                            return countByG_A_ST(groupId, articleId, status);
25968                    }
25969    
25970                    StringBundler query = new StringBundler(4);
25971    
25972                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
25973    
25974                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
25975    
25976                    boolean bindArticleId = false;
25977    
25978                    if (articleId == null) {
25979                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
25980                    }
25981                    else if (articleId.equals(StringPool.BLANK)) {
25982                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
25983                    }
25984                    else {
25985                            bindArticleId = true;
25986    
25987                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
25988                    }
25989    
25990                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
25991    
25992                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
25993                                    JournalArticle.class.getName(),
25994                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
25995    
25996                    Session session = null;
25997    
25998                    try {
25999                            session = openSession();
26000    
26001                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
26002    
26003                            q.addScalar(COUNT_COLUMN_NAME,
26004                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
26005    
26006                            QueryPos qPos = QueryPos.getInstance(q);
26007    
26008                            qPos.add(groupId);
26009    
26010                            if (bindArticleId) {
26011                                    qPos.add(articleId);
26012                            }
26013    
26014                            qPos.add(status);
26015    
26016                            Long count = (Long)q.uniqueResult();
26017    
26018                            return count.intValue();
26019                    }
26020                    catch (Exception e) {
26021                            throw processException(e);
26022                    }
26023                    finally {
26024                            closeSession(session);
26025                    }
26026            }
26027    
26028            /**
26029             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
26030             *
26031             * @param groupId the group ID
26032             * @param articleId the article ID
26033             * @param statuses the statuses
26034             * @return the number of matching journal articles that the user has permission to view
26035             */
26036            @Override
26037            public int filterCountByG_A_ST(long groupId, String articleId,
26038                    int[] statuses) {
26039                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26040                            return countByG_A_ST(groupId, articleId, statuses);
26041                    }
26042    
26043                    if (statuses == null) {
26044                            statuses = new int[0];
26045                    }
26046                    else {
26047                            statuses = ArrayUtil.unique(statuses);
26048                    }
26049    
26050                    StringBundler query = new StringBundler();
26051    
26052                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
26053    
26054                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
26055    
26056                    boolean bindArticleId = false;
26057    
26058                    if (articleId == null) {
26059                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
26060                    }
26061                    else if (articleId.equals(StringPool.BLANK)) {
26062                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
26063                    }
26064                    else {
26065                            bindArticleId = true;
26066    
26067                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
26068                    }
26069    
26070                    if (statuses.length > 0) {
26071                            query.append(StringPool.OPEN_PARENTHESIS);
26072    
26073                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_7);
26074    
26075                            query.append(StringUtil.merge(statuses));
26076    
26077                            query.append(StringPool.CLOSE_PARENTHESIS);
26078    
26079                            query.append(StringPool.CLOSE_PARENTHESIS);
26080                    }
26081    
26082                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
26083                            query.index() - 1);
26084    
26085                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26086                                    JournalArticle.class.getName(),
26087                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26088    
26089                    Session session = null;
26090    
26091                    try {
26092                            session = openSession();
26093    
26094                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
26095    
26096                            q.addScalar(COUNT_COLUMN_NAME,
26097                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
26098    
26099                            QueryPos qPos = QueryPos.getInstance(q);
26100    
26101                            qPos.add(groupId);
26102    
26103                            if (bindArticleId) {
26104                                    qPos.add(articleId);
26105                            }
26106    
26107                            Long count = (Long)q.uniqueResult();
26108    
26109                            return count.intValue();
26110                    }
26111                    catch (Exception e) {
26112                            throw processException(e);
26113                    }
26114                    finally {
26115                            closeSession(session);
26116                    }
26117            }
26118    
26119            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
26120            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
26121            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
26122            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
26123            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
26124            private static final String _FINDER_COLUMN_G_A_ST_STATUS_7 = "journalArticle.status IN (";
26125            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST =
26126                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26127                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
26128                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
26129                            "findByG_A_NotST",
26130                            new String[] {
26131                                    Long.class.getName(), String.class.getName(),
26132                                    Integer.class.getName(),
26133                                    
26134                            Integer.class.getName(), Integer.class.getName(),
26135                                    OrderByComparator.class.getName()
26136                            });
26137            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST =
26138                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
26139                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
26140                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_NotST",
26141                            new String[] {
26142                                    Long.class.getName(), String.class.getName(),
26143                                    Integer.class.getName()
26144                            });
26145    
26146            /**
26147             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26148             *
26149             * @param groupId the group ID
26150             * @param articleId the article ID
26151             * @param status the status
26152             * @return the matching journal articles
26153             */
26154            @Override
26155            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26156                    int status) {
26157                    return findByG_A_NotST(groupId, articleId, status, QueryUtil.ALL_POS,
26158                            QueryUtil.ALL_POS, null);
26159            }
26160    
26161            /**
26162             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26163             *
26164             * <p>
26165             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26166             * </p>
26167             *
26168             * @param groupId the group ID
26169             * @param articleId the article ID
26170             * @param status the status
26171             * @param start the lower bound of the range of journal articles
26172             * @param end the upper bound of the range of journal articles (not inclusive)
26173             * @return the range of matching journal articles
26174             */
26175            @Override
26176            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26177                    int status, int start, int end) {
26178                    return findByG_A_NotST(groupId, articleId, status, start, end, null);
26179            }
26180    
26181            /**
26182             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26183             *
26184             * <p>
26185             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26186             * </p>
26187             *
26188             * @param groupId the group ID
26189             * @param articleId the article ID
26190             * @param status the status
26191             * @param start the lower bound of the range of journal articles
26192             * @param end the upper bound of the range of journal articles (not inclusive)
26193             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26194             * @return the ordered range of matching journal articles
26195             */
26196            @Override
26197            public List<JournalArticle> findByG_A_NotST(long groupId, String articleId,
26198                    int status, int start, int end,
26199                    OrderByComparator<JournalArticle> orderByComparator) {
26200                    boolean pagination = true;
26201                    FinderPath finderPath = null;
26202                    Object[] finderArgs = null;
26203    
26204                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_NOTST;
26205                    finderArgs = new Object[] {
26206                                    groupId, articleId, status,
26207                                    
26208                                    start, end, orderByComparator
26209                            };
26210    
26211                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
26212                                    finderArgs, this);
26213    
26214                    if ((list != null) && !list.isEmpty()) {
26215                            for (JournalArticle journalArticle : list) {
26216                                    if ((groupId != journalArticle.getGroupId()) ||
26217                                                    !Validator.equals(articleId,
26218                                                            journalArticle.getArticleId()) ||
26219                                                    (status == journalArticle.getStatus())) {
26220                                            list = null;
26221    
26222                                            break;
26223                                    }
26224                            }
26225                    }
26226    
26227                    if (list == null) {
26228                            StringBundler query = null;
26229    
26230                            if (orderByComparator != null) {
26231                                    query = new StringBundler(5 +
26232                                                    (orderByComparator.getOrderByFields().length * 3));
26233                            }
26234                            else {
26235                                    query = new StringBundler(5);
26236                            }
26237    
26238                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26239    
26240                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26241    
26242                            boolean bindArticleId = false;
26243    
26244                            if (articleId == null) {
26245                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26246                            }
26247                            else if (articleId.equals(StringPool.BLANK)) {
26248                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26249                            }
26250                            else {
26251                                    bindArticleId = true;
26252    
26253                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26254                            }
26255    
26256                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26257    
26258                            if (orderByComparator != null) {
26259                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26260                                            orderByComparator);
26261                            }
26262                            else
26263                             if (pagination) {
26264                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26265                            }
26266    
26267                            String sql = query.toString();
26268    
26269                            Session session = null;
26270    
26271                            try {
26272                                    session = openSession();
26273    
26274                                    Query q = session.createQuery(sql);
26275    
26276                                    QueryPos qPos = QueryPos.getInstance(q);
26277    
26278                                    qPos.add(groupId);
26279    
26280                                    if (bindArticleId) {
26281                                            qPos.add(articleId);
26282                                    }
26283    
26284                                    qPos.add(status);
26285    
26286                                    if (!pagination) {
26287                                            list = (List<JournalArticle>)QueryUtil.list(q,
26288                                                            getDialect(), start, end, false);
26289    
26290                                            Collections.sort(list);
26291    
26292                                            list = Collections.unmodifiableList(list);
26293                                    }
26294                                    else {
26295                                            list = (List<JournalArticle>)QueryUtil.list(q,
26296                                                            getDialect(), start, end);
26297                                    }
26298    
26299                                    cacheResult(list);
26300    
26301                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
26302                            }
26303                            catch (Exception e) {
26304                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
26305    
26306                                    throw processException(e);
26307                            }
26308                            finally {
26309                                    closeSession(session);
26310                            }
26311                    }
26312    
26313                    return list;
26314            }
26315    
26316            /**
26317             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26318             *
26319             * @param groupId the group ID
26320             * @param articleId the article ID
26321             * @param status the status
26322             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26323             * @return the first matching journal article
26324             * @throws NoSuchArticleException if a matching journal article could not be found
26325             */
26326            @Override
26327            public JournalArticle findByG_A_NotST_First(long groupId, String articleId,
26328                    int status, OrderByComparator<JournalArticle> orderByComparator)
26329                    throws NoSuchArticleException {
26330                    JournalArticle journalArticle = fetchByG_A_NotST_First(groupId,
26331                                    articleId, status, orderByComparator);
26332    
26333                    if (journalArticle != null) {
26334                            return journalArticle;
26335                    }
26336    
26337                    StringBundler msg = new StringBundler(8);
26338    
26339                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26340    
26341                    msg.append("groupId=");
26342                    msg.append(groupId);
26343    
26344                    msg.append(", articleId=");
26345                    msg.append(articleId);
26346    
26347                    msg.append(", status=");
26348                    msg.append(status);
26349    
26350                    msg.append(StringPool.CLOSE_CURLY_BRACE);
26351    
26352                    throw new NoSuchArticleException(msg.toString());
26353            }
26354    
26355            /**
26356             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26357             *
26358             * @param groupId the group ID
26359             * @param articleId the article ID
26360             * @param status the status
26361             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26362             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
26363             */
26364            @Override
26365            public JournalArticle fetchByG_A_NotST_First(long groupId,
26366                    String articleId, int status,
26367                    OrderByComparator<JournalArticle> orderByComparator) {
26368                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
26369                                    0, 1, orderByComparator);
26370    
26371                    if (!list.isEmpty()) {
26372                            return list.get(0);
26373                    }
26374    
26375                    return null;
26376            }
26377    
26378            /**
26379             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26380             *
26381             * @param groupId the group ID
26382             * @param articleId the article ID
26383             * @param status the status
26384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26385             * @return the last matching journal article
26386             * @throws NoSuchArticleException if a matching journal article could not be found
26387             */
26388            @Override
26389            public JournalArticle findByG_A_NotST_Last(long groupId, String articleId,
26390                    int status, OrderByComparator<JournalArticle> orderByComparator)
26391                    throws NoSuchArticleException {
26392                    JournalArticle journalArticle = fetchByG_A_NotST_Last(groupId,
26393                                    articleId, status, orderByComparator);
26394    
26395                    if (journalArticle != null) {
26396                            return journalArticle;
26397                    }
26398    
26399                    StringBundler msg = new StringBundler(8);
26400    
26401                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
26402    
26403                    msg.append("groupId=");
26404                    msg.append(groupId);
26405    
26406                    msg.append(", articleId=");
26407                    msg.append(articleId);
26408    
26409                    msg.append(", status=");
26410                    msg.append(status);
26411    
26412                    msg.append(StringPool.CLOSE_CURLY_BRACE);
26413    
26414                    throw new NoSuchArticleException(msg.toString());
26415            }
26416    
26417            /**
26418             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26419             *
26420             * @param groupId the group ID
26421             * @param articleId the article ID
26422             * @param status the status
26423             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26424             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
26425             */
26426            @Override
26427            public JournalArticle fetchByG_A_NotST_Last(long groupId, String articleId,
26428                    int status, OrderByComparator<JournalArticle> orderByComparator) {
26429                    int count = countByG_A_NotST(groupId, articleId, status);
26430    
26431                    if (count == 0) {
26432                            return null;
26433                    }
26434    
26435                    List<JournalArticle> list = findByG_A_NotST(groupId, articleId, status,
26436                                    count - 1, count, orderByComparator);
26437    
26438                    if (!list.isEmpty()) {
26439                            return list.get(0);
26440                    }
26441    
26442                    return null;
26443            }
26444    
26445            /**
26446             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26447             *
26448             * @param id the primary key of the current journal article
26449             * @param groupId the group ID
26450             * @param articleId the article ID
26451             * @param status the status
26452             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26453             * @return the previous, current, and next journal article
26454             * @throws NoSuchArticleException if a journal article with the primary key could not be found
26455             */
26456            @Override
26457            public JournalArticle[] findByG_A_NotST_PrevAndNext(long id, long groupId,
26458                    String articleId, int status,
26459                    OrderByComparator<JournalArticle> orderByComparator)
26460                    throws NoSuchArticleException {
26461                    JournalArticle journalArticle = findByPrimaryKey(id);
26462    
26463                    Session session = null;
26464    
26465                    try {
26466                            session = openSession();
26467    
26468                            JournalArticle[] array = new JournalArticleImpl[3];
26469    
26470                            array[0] = getByG_A_NotST_PrevAndNext(session, journalArticle,
26471                                            groupId, articleId, status, orderByComparator, true);
26472    
26473                            array[1] = journalArticle;
26474    
26475                            array[2] = getByG_A_NotST_PrevAndNext(session, journalArticle,
26476                                            groupId, articleId, status, orderByComparator, false);
26477    
26478                            return array;
26479                    }
26480                    catch (Exception e) {
26481                            throw processException(e);
26482                    }
26483                    finally {
26484                            closeSession(session);
26485                    }
26486            }
26487    
26488            protected JournalArticle getByG_A_NotST_PrevAndNext(Session session,
26489                    JournalArticle journalArticle, long groupId, String articleId,
26490                    int status, OrderByComparator<JournalArticle> orderByComparator,
26491                    boolean previous) {
26492                    StringBundler query = null;
26493    
26494                    if (orderByComparator != null) {
26495                            query = new StringBundler(6 +
26496                                            (orderByComparator.getOrderByFields().length * 6));
26497                    }
26498                    else {
26499                            query = new StringBundler(3);
26500                    }
26501    
26502                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
26503    
26504                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26505    
26506                    boolean bindArticleId = false;
26507    
26508                    if (articleId == null) {
26509                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26510                    }
26511                    else if (articleId.equals(StringPool.BLANK)) {
26512                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26513                    }
26514                    else {
26515                            bindArticleId = true;
26516    
26517                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26518                    }
26519    
26520                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26521    
26522                    if (orderByComparator != null) {
26523                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
26524    
26525                            if (orderByConditionFields.length > 0) {
26526                                    query.append(WHERE_AND);
26527                            }
26528    
26529                            for (int i = 0; i < orderByConditionFields.length; i++) {
26530                                    query.append(_ORDER_BY_ENTITY_ALIAS);
26531                                    query.append(orderByConditionFields[i]);
26532    
26533                                    if ((i + 1) < orderByConditionFields.length) {
26534                                            if (orderByComparator.isAscending() ^ previous) {
26535                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
26536                                            }
26537                                            else {
26538                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
26539                                            }
26540                                    }
26541                                    else {
26542                                            if (orderByComparator.isAscending() ^ previous) {
26543                                                    query.append(WHERE_GREATER_THAN);
26544                                            }
26545                                            else {
26546                                                    query.append(WHERE_LESSER_THAN);
26547                                            }
26548                                    }
26549                            }
26550    
26551                            query.append(ORDER_BY_CLAUSE);
26552    
26553                            String[] orderByFields = orderByComparator.getOrderByFields();
26554    
26555                            for (int i = 0; i < orderByFields.length; i++) {
26556                                    query.append(_ORDER_BY_ENTITY_ALIAS);
26557                                    query.append(orderByFields[i]);
26558    
26559                                    if ((i + 1) < orderByFields.length) {
26560                                            if (orderByComparator.isAscending() ^ previous) {
26561                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
26562                                            }
26563                                            else {
26564                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
26565                                            }
26566                                    }
26567                                    else {
26568                                            if (orderByComparator.isAscending() ^ previous) {
26569                                                    query.append(ORDER_BY_ASC);
26570                                            }
26571                                            else {
26572                                                    query.append(ORDER_BY_DESC);
26573                                            }
26574                                    }
26575                            }
26576                    }
26577                    else {
26578                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26579                    }
26580    
26581                    String sql = query.toString();
26582    
26583                    Query q = session.createQuery(sql);
26584    
26585                    q.setFirstResult(0);
26586                    q.setMaxResults(2);
26587    
26588                    QueryPos qPos = QueryPos.getInstance(q);
26589    
26590                    qPos.add(groupId);
26591    
26592                    if (bindArticleId) {
26593                            qPos.add(articleId);
26594                    }
26595    
26596                    qPos.add(status);
26597    
26598                    if (orderByComparator != null) {
26599                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26600    
26601                            for (Object value : values) {
26602                                    qPos.add(value);
26603                            }
26604                    }
26605    
26606                    List<JournalArticle> list = q.list();
26607    
26608                    if (list.size() == 2) {
26609                            return list.get(1);
26610                    }
26611                    else {
26612                            return null;
26613                    }
26614            }
26615    
26616            /**
26617             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26618             *
26619             * @param groupId the group ID
26620             * @param articleId the article ID
26621             * @param status the status
26622             * @return the matching journal articles that the user has permission to view
26623             */
26624            @Override
26625            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
26626                    String articleId, int status) {
26627                    return filterFindByG_A_NotST(groupId, articleId, status,
26628                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
26629            }
26630    
26631            /**
26632             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26633             *
26634             * <p>
26635             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26636             * </p>
26637             *
26638             * @param groupId the group ID
26639             * @param articleId the article ID
26640             * @param status the status
26641             * @param start the lower bound of the range of journal articles
26642             * @param end the upper bound of the range of journal articles (not inclusive)
26643             * @return the range of matching journal articles that the user has permission to view
26644             */
26645            @Override
26646            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
26647                    String articleId, int status, int start, int end) {
26648                    return filterFindByG_A_NotST(groupId, articleId, status, start, end,
26649                            null);
26650            }
26651    
26652            /**
26653             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26654             *
26655             * <p>
26656             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
26657             * </p>
26658             *
26659             * @param groupId the group ID
26660             * @param articleId the article ID
26661             * @param status the status
26662             * @param start the lower bound of the range of journal articles
26663             * @param end the upper bound of the range of journal articles (not inclusive)
26664             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
26665             * @return the ordered range of matching journal articles that the user has permission to view
26666             */
26667            @Override
26668            public List<JournalArticle> filterFindByG_A_NotST(long groupId,
26669                    String articleId, int status, int start, int end,
26670                    OrderByComparator<JournalArticle> orderByComparator) {
26671                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26672                            return findByG_A_NotST(groupId, articleId, status, start, end,
26673                                    orderByComparator);
26674                    }
26675    
26676                    StringBundler query = null;
26677    
26678                    if (orderByComparator != null) {
26679                            query = new StringBundler(5 +
26680                                            (orderByComparator.getOrderByFields().length * 3));
26681                    }
26682                    else {
26683                            query = new StringBundler(5);
26684                    }
26685    
26686                    if (getDB().isSupportsInlineDistinct()) {
26687                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
26688                    }
26689                    else {
26690                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
26691                    }
26692    
26693                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26694    
26695                    boolean bindArticleId = false;
26696    
26697                    if (articleId == null) {
26698                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26699                    }
26700                    else if (articleId.equals(StringPool.BLANK)) {
26701                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26702                    }
26703                    else {
26704                            bindArticleId = true;
26705    
26706                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26707                    }
26708    
26709                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26710    
26711                    if (!getDB().isSupportsInlineDistinct()) {
26712                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26713                    }
26714    
26715                    if (orderByComparator != null) {
26716                            if (getDB().isSupportsInlineDistinct()) {
26717                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
26718                                            orderByComparator, true);
26719                            }
26720                            else {
26721                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
26722                                            orderByComparator, true);
26723                            }
26724                    }
26725                    else {
26726                            if (getDB().isSupportsInlineDistinct()) {
26727                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26728                            }
26729                            else {
26730                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26731                            }
26732                    }
26733    
26734                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26735                                    JournalArticle.class.getName(),
26736                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26737    
26738                    Session session = null;
26739    
26740                    try {
26741                            session = openSession();
26742    
26743                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
26744    
26745                            if (getDB().isSupportsInlineDistinct()) {
26746                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26747                            }
26748                            else {
26749                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26750                            }
26751    
26752                            QueryPos qPos = QueryPos.getInstance(q);
26753    
26754                            qPos.add(groupId);
26755    
26756                            if (bindArticleId) {
26757                                    qPos.add(articleId);
26758                            }
26759    
26760                            qPos.add(status);
26761    
26762                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
26763                                    end);
26764                    }
26765                    catch (Exception e) {
26766                            throw processException(e);
26767                    }
26768                    finally {
26769                            closeSession(session);
26770                    }
26771            }
26772    
26773            /**
26774             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
26775             *
26776             * @param id the primary key of the current journal article
26777             * @param groupId the group ID
26778             * @param articleId the article ID
26779             * @param status the status
26780             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
26781             * @return the previous, current, and next journal article
26782             * @throws NoSuchArticleException if a journal article with the primary key could not be found
26783             */
26784            @Override
26785            public JournalArticle[] filterFindByG_A_NotST_PrevAndNext(long id,
26786                    long groupId, String articleId, int status,
26787                    OrderByComparator<JournalArticle> orderByComparator)
26788                    throws NoSuchArticleException {
26789                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
26790                            return findByG_A_NotST_PrevAndNext(id, groupId, articleId, status,
26791                                    orderByComparator);
26792                    }
26793    
26794                    JournalArticle journalArticle = findByPrimaryKey(id);
26795    
26796                    Session session = null;
26797    
26798                    try {
26799                            session = openSession();
26800    
26801                            JournalArticle[] array = new JournalArticleImpl[3];
26802    
26803                            array[0] = filterGetByG_A_NotST_PrevAndNext(session,
26804                                            journalArticle, groupId, articleId, status,
26805                                            orderByComparator, true);
26806    
26807                            array[1] = journalArticle;
26808    
26809                            array[2] = filterGetByG_A_NotST_PrevAndNext(session,
26810                                            journalArticle, groupId, articleId, status,
26811                                            orderByComparator, false);
26812    
26813                            return array;
26814                    }
26815                    catch (Exception e) {
26816                            throw processException(e);
26817                    }
26818                    finally {
26819                            closeSession(session);
26820                    }
26821            }
26822    
26823            protected JournalArticle filterGetByG_A_NotST_PrevAndNext(Session session,
26824                    JournalArticle journalArticle, long groupId, String articleId,
26825                    int status, OrderByComparator<JournalArticle> orderByComparator,
26826                    boolean previous) {
26827                    StringBundler query = null;
26828    
26829                    if (orderByComparator != null) {
26830                            query = new StringBundler(6 +
26831                                            (orderByComparator.getOrderByFields().length * 6));
26832                    }
26833                    else {
26834                            query = new StringBundler(3);
26835                    }
26836    
26837                    if (getDB().isSupportsInlineDistinct()) {
26838                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
26839                    }
26840                    else {
26841                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
26842                    }
26843    
26844                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
26845    
26846                    boolean bindArticleId = false;
26847    
26848                    if (articleId == null) {
26849                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
26850                    }
26851                    else if (articleId.equals(StringPool.BLANK)) {
26852                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
26853                    }
26854                    else {
26855                            bindArticleId = true;
26856    
26857                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
26858                    }
26859    
26860                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
26861    
26862                    if (!getDB().isSupportsInlineDistinct()) {
26863                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
26864                    }
26865    
26866                    if (orderByComparator != null) {
26867                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
26868    
26869                            if (orderByConditionFields.length > 0) {
26870                                    query.append(WHERE_AND);
26871                            }
26872    
26873                            for (int i = 0; i < orderByConditionFields.length; i++) {
26874                                    if (getDB().isSupportsInlineDistinct()) {
26875                                            query.append(_ORDER_BY_ENTITY_ALIAS);
26876                                    }
26877                                    else {
26878                                            query.append(_ORDER_BY_ENTITY_TABLE);
26879                                    }
26880    
26881                                    query.append(orderByConditionFields[i]);
26882    
26883                                    if ((i + 1) < orderByConditionFields.length) {
26884                                            if (orderByComparator.isAscending() ^ previous) {
26885                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
26886                                            }
26887                                            else {
26888                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
26889                                            }
26890                                    }
26891                                    else {
26892                                            if (orderByComparator.isAscending() ^ previous) {
26893                                                    query.append(WHERE_GREATER_THAN);
26894                                            }
26895                                            else {
26896                                                    query.append(WHERE_LESSER_THAN);
26897                                            }
26898                                    }
26899                            }
26900    
26901                            query.append(ORDER_BY_CLAUSE);
26902    
26903                            String[] orderByFields = orderByComparator.getOrderByFields();
26904    
26905                            for (int i = 0; i < orderByFields.length; i++) {
26906                                    if (getDB().isSupportsInlineDistinct()) {
26907                                            query.append(_ORDER_BY_ENTITY_ALIAS);
26908                                    }
26909                                    else {
26910                                            query.append(_ORDER_BY_ENTITY_TABLE);
26911                                    }
26912    
26913                                    query.append(orderByFields[i]);
26914    
26915                                    if ((i + 1) < orderByFields.length) {
26916                                            if (orderByComparator.isAscending() ^ previous) {
26917                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
26918                                            }
26919                                            else {
26920                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
26921                                            }
26922                                    }
26923                                    else {
26924                                            if (orderByComparator.isAscending() ^ previous) {
26925                                                    query.append(ORDER_BY_ASC);
26926                                            }
26927                                            else {
26928                                                    query.append(ORDER_BY_DESC);
26929                                            }
26930                                    }
26931                            }
26932                    }
26933                    else {
26934                            if (getDB().isSupportsInlineDistinct()) {
26935                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
26936                            }
26937                            else {
26938                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
26939                            }
26940                    }
26941    
26942                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
26943                                    JournalArticle.class.getName(),
26944                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
26945    
26946                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
26947    
26948                    q.setFirstResult(0);
26949                    q.setMaxResults(2);
26950    
26951                    if (getDB().isSupportsInlineDistinct()) {
26952                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
26953                    }
26954                    else {
26955                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
26956                    }
26957    
26958                    QueryPos qPos = QueryPos.getInstance(q);
26959    
26960                    qPos.add(groupId);
26961    
26962                    if (bindArticleId) {
26963                            qPos.add(articleId);
26964                    }
26965    
26966                    qPos.add(status);
26967    
26968                    if (orderByComparator != null) {
26969                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
26970    
26971                            for (Object value : values) {
26972                                    qPos.add(value);
26973                            }
26974                    }
26975    
26976                    List<JournalArticle> list = q.list();
26977    
26978                    if (list.size() == 2) {
26979                            return list.get(1);
26980                    }
26981                    else {
26982                            return null;
26983                    }
26984            }
26985    
26986            /**
26987             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63; from the database.
26988             *
26989             * @param groupId the group ID
26990             * @param articleId the article ID
26991             * @param status the status
26992             */
26993            @Override
26994            public void removeByG_A_NotST(long groupId, String articleId, int status) {
26995                    for (JournalArticle journalArticle : findByG_A_NotST(groupId,
26996                                    articleId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
26997                            remove(journalArticle);
26998                    }
26999            }
27000    
27001            /**
27002             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27003             *
27004             * @param groupId the group ID
27005             * @param articleId the article ID
27006             * @param status the status
27007             * @return the number of matching journal articles
27008             */
27009            @Override
27010            public int countByG_A_NotST(long groupId, String articleId, int status) {
27011                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_NOTST;
27012    
27013                    Object[] finderArgs = new Object[] { groupId, articleId, status };
27014    
27015                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
27016                                    this);
27017    
27018                    if (count == null) {
27019                            StringBundler query = new StringBundler(4);
27020    
27021                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
27022    
27023                            query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27024    
27025                            boolean bindArticleId = false;
27026    
27027                            if (articleId == null) {
27028                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27029                            }
27030                            else if (articleId.equals(StringPool.BLANK)) {
27031                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27032                            }
27033                            else {
27034                                    bindArticleId = true;
27035    
27036                                    query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27037                            }
27038    
27039                            query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27040    
27041                            String sql = query.toString();
27042    
27043                            Session session = null;
27044    
27045                            try {
27046                                    session = openSession();
27047    
27048                                    Query q = session.createQuery(sql);
27049    
27050                                    QueryPos qPos = QueryPos.getInstance(q);
27051    
27052                                    qPos.add(groupId);
27053    
27054                                    if (bindArticleId) {
27055                                            qPos.add(articleId);
27056                                    }
27057    
27058                                    qPos.add(status);
27059    
27060                                    count = (Long)q.uniqueResult();
27061    
27062                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
27063                            }
27064                            catch (Exception e) {
27065                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
27066    
27067                                    throw processException(e);
27068                            }
27069                            finally {
27070                                    closeSession(session);
27071                            }
27072                    }
27073    
27074                    return count.intValue();
27075            }
27076    
27077            /**
27078             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status &ne; &#63;.
27079             *
27080             * @param groupId the group ID
27081             * @param articleId the article ID
27082             * @param status the status
27083             * @return the number of matching journal articles that the user has permission to view
27084             */
27085            @Override
27086            public int filterCountByG_A_NotST(long groupId, String articleId, int status) {
27087                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27088                            return countByG_A_NotST(groupId, articleId, status);
27089                    }
27090    
27091                    StringBundler query = new StringBundler(4);
27092    
27093                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
27094    
27095                    query.append(_FINDER_COLUMN_G_A_NOTST_GROUPID_2);
27096    
27097                    boolean bindArticleId = false;
27098    
27099                    if (articleId == null) {
27100                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_1);
27101                    }
27102                    else if (articleId.equals(StringPool.BLANK)) {
27103                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_3);
27104                    }
27105                    else {
27106                            bindArticleId = true;
27107    
27108                            query.append(_FINDER_COLUMN_G_A_NOTST_ARTICLEID_2);
27109                    }
27110    
27111                    query.append(_FINDER_COLUMN_G_A_NOTST_STATUS_2);
27112    
27113                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27114                                    JournalArticle.class.getName(),
27115                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27116    
27117                    Session session = null;
27118    
27119                    try {
27120                            session = openSession();
27121    
27122                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
27123    
27124                            q.addScalar(COUNT_COLUMN_NAME,
27125                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
27126    
27127                            QueryPos qPos = QueryPos.getInstance(q);
27128    
27129                            qPos.add(groupId);
27130    
27131                            if (bindArticleId) {
27132                                    qPos.add(articleId);
27133                            }
27134    
27135                            qPos.add(status);
27136    
27137                            Long count = (Long)q.uniqueResult();
27138    
27139                            return count.intValue();
27140                    }
27141                    catch (Exception e) {
27142                            throw processException(e);
27143                    }
27144                    finally {
27145                            closeSession(session);
27146                    }
27147            }
27148    
27149            private static final String _FINDER_COLUMN_G_A_NOTST_GROUPID_2 = "journalArticle.groupId = ? AND ";
27150            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
27151            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
27152            private static final String _FINDER_COLUMN_G_A_NOTST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = '') AND ";
27153            private static final String _FINDER_COLUMN_G_A_NOTST_STATUS_2 = "journalArticle.status != ?";
27154            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27155                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
27156                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
27157                            "findByG_UT_ST",
27158                            new String[] {
27159                                    Long.class.getName(), String.class.getName(),
27160                                    Integer.class.getName(),
27161                                    
27162                            Integer.class.getName(), Integer.class.getName(),
27163                                    OrderByComparator.class.getName()
27164                            });
27165            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
27166                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27167                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
27168                            JournalArticleImpl.class,
27169                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
27170                            new String[] {
27171                                    Long.class.getName(), String.class.getName(),
27172                                    Integer.class.getName()
27173                            },
27174                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
27175                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
27176                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
27177                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
27178                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
27179            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
27180                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
27181                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
27182                            new String[] {
27183                                    Long.class.getName(), String.class.getName(),
27184                                    Integer.class.getName()
27185                            });
27186    
27187            /**
27188             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27189             *
27190             * @param groupId the group ID
27191             * @param urlTitle the url title
27192             * @param status the status
27193             * @return the matching journal articles
27194             */
27195            @Override
27196            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27197                    int status) {
27198                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
27199                            QueryUtil.ALL_POS, null);
27200            }
27201    
27202            /**
27203             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27204             *
27205             * <p>
27206             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27207             * </p>
27208             *
27209             * @param groupId the group ID
27210             * @param urlTitle the url title
27211             * @param status the status
27212             * @param start the lower bound of the range of journal articles
27213             * @param end the upper bound of the range of journal articles (not inclusive)
27214             * @return the range of matching journal articles
27215             */
27216            @Override
27217            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27218                    int status, int start, int end) {
27219                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
27220            }
27221    
27222            /**
27223             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27224             *
27225             * <p>
27226             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27227             * </p>
27228             *
27229             * @param groupId the group ID
27230             * @param urlTitle the url title
27231             * @param status the status
27232             * @param start the lower bound of the range of journal articles
27233             * @param end the upper bound of the range of journal articles (not inclusive)
27234             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27235             * @return the ordered range of matching journal articles
27236             */
27237            @Override
27238            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
27239                    int status, int start, int end,
27240                    OrderByComparator<JournalArticle> orderByComparator) {
27241                    boolean pagination = true;
27242                    FinderPath finderPath = null;
27243                    Object[] finderArgs = null;
27244    
27245                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
27246                                    (orderByComparator == null)) {
27247                            pagination = false;
27248                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
27249                            finderArgs = new Object[] { groupId, urlTitle, status };
27250                    }
27251                    else {
27252                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
27253                            finderArgs = new Object[] {
27254                                            groupId, urlTitle, status,
27255                                            
27256                                            start, end, orderByComparator
27257                                    };
27258                    }
27259    
27260                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
27261                                    finderArgs, this);
27262    
27263                    if ((list != null) && !list.isEmpty()) {
27264                            for (JournalArticle journalArticle : list) {
27265                                    if ((groupId != journalArticle.getGroupId()) ||
27266                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
27267                                                    (status != journalArticle.getStatus())) {
27268                                            list = null;
27269    
27270                                            break;
27271                                    }
27272                            }
27273                    }
27274    
27275                    if (list == null) {
27276                            StringBundler query = null;
27277    
27278                            if (orderByComparator != null) {
27279                                    query = new StringBundler(5 +
27280                                                    (orderByComparator.getOrderByFields().length * 3));
27281                            }
27282                            else {
27283                                    query = new StringBundler(5);
27284                            }
27285    
27286                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
27287    
27288                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27289    
27290                            boolean bindUrlTitle = false;
27291    
27292                            if (urlTitle == null) {
27293                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27294                            }
27295                            else if (urlTitle.equals(StringPool.BLANK)) {
27296                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27297                            }
27298                            else {
27299                                    bindUrlTitle = true;
27300    
27301                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27302                            }
27303    
27304                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27305    
27306                            if (orderByComparator != null) {
27307                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27308                                            orderByComparator);
27309                            }
27310                            else
27311                             if (pagination) {
27312                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27313                            }
27314    
27315                            String sql = query.toString();
27316    
27317                            Session session = null;
27318    
27319                            try {
27320                                    session = openSession();
27321    
27322                                    Query q = session.createQuery(sql);
27323    
27324                                    QueryPos qPos = QueryPos.getInstance(q);
27325    
27326                                    qPos.add(groupId);
27327    
27328                                    if (bindUrlTitle) {
27329                                            qPos.add(urlTitle);
27330                                    }
27331    
27332                                    qPos.add(status);
27333    
27334                                    if (!pagination) {
27335                                            list = (List<JournalArticle>)QueryUtil.list(q,
27336                                                            getDialect(), start, end, false);
27337    
27338                                            Collections.sort(list);
27339    
27340                                            list = Collections.unmodifiableList(list);
27341                                    }
27342                                    else {
27343                                            list = (List<JournalArticle>)QueryUtil.list(q,
27344                                                            getDialect(), start, end);
27345                                    }
27346    
27347                                    cacheResult(list);
27348    
27349                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
27350                            }
27351                            catch (Exception e) {
27352                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
27353    
27354                                    throw processException(e);
27355                            }
27356                            finally {
27357                                    closeSession(session);
27358                            }
27359                    }
27360    
27361                    return list;
27362            }
27363    
27364            /**
27365             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27366             *
27367             * @param groupId the group ID
27368             * @param urlTitle the url title
27369             * @param status the status
27370             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27371             * @return the first matching journal article
27372             * @throws NoSuchArticleException if a matching journal article could not be found
27373             */
27374            @Override
27375            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
27376                    int status, OrderByComparator<JournalArticle> orderByComparator)
27377                    throws NoSuchArticleException {
27378                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
27379                                    status, orderByComparator);
27380    
27381                    if (journalArticle != null) {
27382                            return journalArticle;
27383                    }
27384    
27385                    StringBundler msg = new StringBundler(8);
27386    
27387                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
27388    
27389                    msg.append("groupId=");
27390                    msg.append(groupId);
27391    
27392                    msg.append(", urlTitle=");
27393                    msg.append(urlTitle);
27394    
27395                    msg.append(", status=");
27396                    msg.append(status);
27397    
27398                    msg.append(StringPool.CLOSE_CURLY_BRACE);
27399    
27400                    throw new NoSuchArticleException(msg.toString());
27401            }
27402    
27403            /**
27404             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27405             *
27406             * @param groupId the group ID
27407             * @param urlTitle the url title
27408             * @param status the status
27409             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27410             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
27411             */
27412            @Override
27413            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
27414                    int status, OrderByComparator<JournalArticle> orderByComparator) {
27415                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
27416                                    1, orderByComparator);
27417    
27418                    if (!list.isEmpty()) {
27419                            return list.get(0);
27420                    }
27421    
27422                    return null;
27423            }
27424    
27425            /**
27426             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27427             *
27428             * @param groupId the group ID
27429             * @param urlTitle the url title
27430             * @param status the status
27431             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27432             * @return the last matching journal article
27433             * @throws NoSuchArticleException if a matching journal article could not be found
27434             */
27435            @Override
27436            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
27437                    int status, OrderByComparator<JournalArticle> orderByComparator)
27438                    throws NoSuchArticleException {
27439                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
27440                                    status, orderByComparator);
27441    
27442                    if (journalArticle != null) {
27443                            return journalArticle;
27444                    }
27445    
27446                    StringBundler msg = new StringBundler(8);
27447    
27448                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
27449    
27450                    msg.append("groupId=");
27451                    msg.append(groupId);
27452    
27453                    msg.append(", urlTitle=");
27454                    msg.append(urlTitle);
27455    
27456                    msg.append(", status=");
27457                    msg.append(status);
27458    
27459                    msg.append(StringPool.CLOSE_CURLY_BRACE);
27460    
27461                    throw new NoSuchArticleException(msg.toString());
27462            }
27463    
27464            /**
27465             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27466             *
27467             * @param groupId the group ID
27468             * @param urlTitle the url title
27469             * @param status the status
27470             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27471             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
27472             */
27473            @Override
27474            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
27475                    int status, OrderByComparator<JournalArticle> orderByComparator) {
27476                    int count = countByG_UT_ST(groupId, urlTitle, status);
27477    
27478                    if (count == 0) {
27479                            return null;
27480                    }
27481    
27482                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
27483                                    count - 1, count, orderByComparator);
27484    
27485                    if (!list.isEmpty()) {
27486                            return list.get(0);
27487                    }
27488    
27489                    return null;
27490            }
27491    
27492            /**
27493             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27494             *
27495             * @param id the primary key of the current journal article
27496             * @param groupId the group ID
27497             * @param urlTitle the url title
27498             * @param status the status
27499             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27500             * @return the previous, current, and next journal article
27501             * @throws NoSuchArticleException if a journal article with the primary key could not be found
27502             */
27503            @Override
27504            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
27505                    String urlTitle, int status,
27506                    OrderByComparator<JournalArticle> orderByComparator)
27507                    throws NoSuchArticleException {
27508                    JournalArticle journalArticle = findByPrimaryKey(id);
27509    
27510                    Session session = null;
27511    
27512                    try {
27513                            session = openSession();
27514    
27515                            JournalArticle[] array = new JournalArticleImpl[3];
27516    
27517                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
27518                                            groupId, urlTitle, status, orderByComparator, true);
27519    
27520                            array[1] = journalArticle;
27521    
27522                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
27523                                            groupId, urlTitle, status, orderByComparator, false);
27524    
27525                            return array;
27526                    }
27527                    catch (Exception e) {
27528                            throw processException(e);
27529                    }
27530                    finally {
27531                            closeSession(session);
27532                    }
27533            }
27534    
27535            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
27536                    JournalArticle journalArticle, long groupId, String urlTitle,
27537                    int status, OrderByComparator<JournalArticle> orderByComparator,
27538                    boolean previous) {
27539                    StringBundler query = null;
27540    
27541                    if (orderByComparator != null) {
27542                            query = new StringBundler(6 +
27543                                            (orderByComparator.getOrderByFields().length * 6));
27544                    }
27545                    else {
27546                            query = new StringBundler(3);
27547                    }
27548    
27549                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
27550    
27551                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27552    
27553                    boolean bindUrlTitle = false;
27554    
27555                    if (urlTitle == null) {
27556                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27557                    }
27558                    else if (urlTitle.equals(StringPool.BLANK)) {
27559                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27560                    }
27561                    else {
27562                            bindUrlTitle = true;
27563    
27564                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27565                    }
27566    
27567                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27568    
27569                    if (orderByComparator != null) {
27570                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27571    
27572                            if (orderByConditionFields.length > 0) {
27573                                    query.append(WHERE_AND);
27574                            }
27575    
27576                            for (int i = 0; i < orderByConditionFields.length; i++) {
27577                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27578                                    query.append(orderByConditionFields[i]);
27579    
27580                                    if ((i + 1) < orderByConditionFields.length) {
27581                                            if (orderByComparator.isAscending() ^ previous) {
27582                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27583                                            }
27584                                            else {
27585                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27586                                            }
27587                                    }
27588                                    else {
27589                                            if (orderByComparator.isAscending() ^ previous) {
27590                                                    query.append(WHERE_GREATER_THAN);
27591                                            }
27592                                            else {
27593                                                    query.append(WHERE_LESSER_THAN);
27594                                            }
27595                                    }
27596                            }
27597    
27598                            query.append(ORDER_BY_CLAUSE);
27599    
27600                            String[] orderByFields = orderByComparator.getOrderByFields();
27601    
27602                            for (int i = 0; i < orderByFields.length; i++) {
27603                                    query.append(_ORDER_BY_ENTITY_ALIAS);
27604                                    query.append(orderByFields[i]);
27605    
27606                                    if ((i + 1) < orderByFields.length) {
27607                                            if (orderByComparator.isAscending() ^ previous) {
27608                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27609                                            }
27610                                            else {
27611                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27612                                            }
27613                                    }
27614                                    else {
27615                                            if (orderByComparator.isAscending() ^ previous) {
27616                                                    query.append(ORDER_BY_ASC);
27617                                            }
27618                                            else {
27619                                                    query.append(ORDER_BY_DESC);
27620                                            }
27621                                    }
27622                            }
27623                    }
27624                    else {
27625                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27626                    }
27627    
27628                    String sql = query.toString();
27629    
27630                    Query q = session.createQuery(sql);
27631    
27632                    q.setFirstResult(0);
27633                    q.setMaxResults(2);
27634    
27635                    QueryPos qPos = QueryPos.getInstance(q);
27636    
27637                    qPos.add(groupId);
27638    
27639                    if (bindUrlTitle) {
27640                            qPos.add(urlTitle);
27641                    }
27642    
27643                    qPos.add(status);
27644    
27645                    if (orderByComparator != null) {
27646                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
27647    
27648                            for (Object value : values) {
27649                                    qPos.add(value);
27650                            }
27651                    }
27652    
27653                    List<JournalArticle> list = q.list();
27654    
27655                    if (list.size() == 2) {
27656                            return list.get(1);
27657                    }
27658                    else {
27659                            return null;
27660                    }
27661            }
27662    
27663            /**
27664             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27665             *
27666             * @param groupId the group ID
27667             * @param urlTitle the url title
27668             * @param status the status
27669             * @return the matching journal articles that the user has permission to view
27670             */
27671            @Override
27672            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
27673                    String urlTitle, int status) {
27674                    return filterFindByG_UT_ST(groupId, urlTitle, status,
27675                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
27676            }
27677    
27678            /**
27679             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
27680             *
27681             * <p>
27682             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27683             * </p>
27684             *
27685             * @param groupId the group ID
27686             * @param urlTitle the url title
27687             * @param status the status
27688             * @param start the lower bound of the range of journal articles
27689             * @param end the upper bound of the range of journal articles (not inclusive)
27690             * @return the range of matching journal articles that the user has permission to view
27691             */
27692            @Override
27693            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
27694                    String urlTitle, int status, int start, int end) {
27695                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
27696            }
27697    
27698            /**
27699             * 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;.
27700             *
27701             * <p>
27702             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
27703             * </p>
27704             *
27705             * @param groupId the group ID
27706             * @param urlTitle the url title
27707             * @param status the status
27708             * @param start the lower bound of the range of journal articles
27709             * @param end the upper bound of the range of journal articles (not inclusive)
27710             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
27711             * @return the ordered range of matching journal articles that the user has permission to view
27712             */
27713            @Override
27714            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
27715                    String urlTitle, int status, int start, int end,
27716                    OrderByComparator<JournalArticle> orderByComparator) {
27717                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27718                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
27719                                    orderByComparator);
27720                    }
27721    
27722                    StringBundler query = null;
27723    
27724                    if (orderByComparator != null) {
27725                            query = new StringBundler(5 +
27726                                            (orderByComparator.getOrderByFields().length * 3));
27727                    }
27728                    else {
27729                            query = new StringBundler(5);
27730                    }
27731    
27732                    if (getDB().isSupportsInlineDistinct()) {
27733                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27734                    }
27735                    else {
27736                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27737                    }
27738    
27739                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27740    
27741                    boolean bindUrlTitle = false;
27742    
27743                    if (urlTitle == null) {
27744                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27745                    }
27746                    else if (urlTitle.equals(StringPool.BLANK)) {
27747                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27748                    }
27749                    else {
27750                            bindUrlTitle = true;
27751    
27752                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27753                    }
27754    
27755                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27756    
27757                    if (!getDB().isSupportsInlineDistinct()) {
27758                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27759                    }
27760    
27761                    if (orderByComparator != null) {
27762                            if (getDB().isSupportsInlineDistinct()) {
27763                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
27764                                            orderByComparator, true);
27765                            }
27766                            else {
27767                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
27768                                            orderByComparator, true);
27769                            }
27770                    }
27771                    else {
27772                            if (getDB().isSupportsInlineDistinct()) {
27773                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27774                            }
27775                            else {
27776                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27777                            }
27778                    }
27779    
27780                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27781                                    JournalArticle.class.getName(),
27782                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27783    
27784                    Session session = null;
27785    
27786                    try {
27787                            session = openSession();
27788    
27789                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
27790    
27791                            if (getDB().isSupportsInlineDistinct()) {
27792                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27793                            }
27794                            else {
27795                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
27796                            }
27797    
27798                            QueryPos qPos = QueryPos.getInstance(q);
27799    
27800                            qPos.add(groupId);
27801    
27802                            if (bindUrlTitle) {
27803                                    qPos.add(urlTitle);
27804                            }
27805    
27806                            qPos.add(status);
27807    
27808                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
27809                                    end);
27810                    }
27811                    catch (Exception e) {
27812                            throw processException(e);
27813                    }
27814                    finally {
27815                            closeSession(session);
27816                    }
27817            }
27818    
27819            /**
27820             * 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;.
27821             *
27822             * @param id the primary key of the current journal article
27823             * @param groupId the group ID
27824             * @param urlTitle the url title
27825             * @param status the status
27826             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
27827             * @return the previous, current, and next journal article
27828             * @throws NoSuchArticleException if a journal article with the primary key could not be found
27829             */
27830            @Override
27831            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
27832                    long groupId, String urlTitle, int status,
27833                    OrderByComparator<JournalArticle> orderByComparator)
27834                    throws NoSuchArticleException {
27835                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
27836                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
27837                                    orderByComparator);
27838                    }
27839    
27840                    JournalArticle journalArticle = findByPrimaryKey(id);
27841    
27842                    Session session = null;
27843    
27844                    try {
27845                            session = openSession();
27846    
27847                            JournalArticle[] array = new JournalArticleImpl[3];
27848    
27849                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
27850                                            groupId, urlTitle, status, orderByComparator, true);
27851    
27852                            array[1] = journalArticle;
27853    
27854                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
27855                                            groupId, urlTitle, status, orderByComparator, false);
27856    
27857                            return array;
27858                    }
27859                    catch (Exception e) {
27860                            throw processException(e);
27861                    }
27862                    finally {
27863                            closeSession(session);
27864                    }
27865            }
27866    
27867            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
27868                    JournalArticle journalArticle, long groupId, String urlTitle,
27869                    int status, OrderByComparator<JournalArticle> orderByComparator,
27870                    boolean previous) {
27871                    StringBundler query = null;
27872    
27873                    if (orderByComparator != null) {
27874                            query = new StringBundler(6 +
27875                                            (orderByComparator.getOrderByFields().length * 6));
27876                    }
27877                    else {
27878                            query = new StringBundler(3);
27879                    }
27880    
27881                    if (getDB().isSupportsInlineDistinct()) {
27882                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
27883                    }
27884                    else {
27885                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
27886                    }
27887    
27888                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
27889    
27890                    boolean bindUrlTitle = false;
27891    
27892                    if (urlTitle == null) {
27893                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
27894                    }
27895                    else if (urlTitle.equals(StringPool.BLANK)) {
27896                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
27897                    }
27898                    else {
27899                            bindUrlTitle = true;
27900    
27901                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
27902                    }
27903    
27904                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
27905    
27906                    if (!getDB().isSupportsInlineDistinct()) {
27907                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
27908                    }
27909    
27910                    if (orderByComparator != null) {
27911                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
27912    
27913                            if (orderByConditionFields.length > 0) {
27914                                    query.append(WHERE_AND);
27915                            }
27916    
27917                            for (int i = 0; i < orderByConditionFields.length; i++) {
27918                                    if (getDB().isSupportsInlineDistinct()) {
27919                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27920                                    }
27921                                    else {
27922                                            query.append(_ORDER_BY_ENTITY_TABLE);
27923                                    }
27924    
27925                                    query.append(orderByConditionFields[i]);
27926    
27927                                    if ((i + 1) < orderByConditionFields.length) {
27928                                            if (orderByComparator.isAscending() ^ previous) {
27929                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
27930                                            }
27931                                            else {
27932                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
27933                                            }
27934                                    }
27935                                    else {
27936                                            if (orderByComparator.isAscending() ^ previous) {
27937                                                    query.append(WHERE_GREATER_THAN);
27938                                            }
27939                                            else {
27940                                                    query.append(WHERE_LESSER_THAN);
27941                                            }
27942                                    }
27943                            }
27944    
27945                            query.append(ORDER_BY_CLAUSE);
27946    
27947                            String[] orderByFields = orderByComparator.getOrderByFields();
27948    
27949                            for (int i = 0; i < orderByFields.length; i++) {
27950                                    if (getDB().isSupportsInlineDistinct()) {
27951                                            query.append(_ORDER_BY_ENTITY_ALIAS);
27952                                    }
27953                                    else {
27954                                            query.append(_ORDER_BY_ENTITY_TABLE);
27955                                    }
27956    
27957                                    query.append(orderByFields[i]);
27958    
27959                                    if ((i + 1) < orderByFields.length) {
27960                                            if (orderByComparator.isAscending() ^ previous) {
27961                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
27962                                            }
27963                                            else {
27964                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
27965                                            }
27966                                    }
27967                                    else {
27968                                            if (orderByComparator.isAscending() ^ previous) {
27969                                                    query.append(ORDER_BY_ASC);
27970                                            }
27971                                            else {
27972                                                    query.append(ORDER_BY_DESC);
27973                                            }
27974                                    }
27975                            }
27976                    }
27977                    else {
27978                            if (getDB().isSupportsInlineDistinct()) {
27979                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
27980                            }
27981                            else {
27982                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
27983                            }
27984                    }
27985    
27986                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
27987                                    JournalArticle.class.getName(),
27988                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
27989    
27990                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
27991    
27992                    q.setFirstResult(0);
27993                    q.setMaxResults(2);
27994    
27995                    if (getDB().isSupportsInlineDistinct()) {
27996                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
27997                    }
27998                    else {
27999                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
28000                    }
28001    
28002                    QueryPos qPos = QueryPos.getInstance(q);
28003    
28004                    qPos.add(groupId);
28005    
28006                    if (bindUrlTitle) {
28007                            qPos.add(urlTitle);
28008                    }
28009    
28010                    qPos.add(status);
28011    
28012                    if (orderByComparator != null) {
28013                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
28014    
28015                            for (Object value : values) {
28016                                    qPos.add(value);
28017                            }
28018                    }
28019    
28020                    List<JournalArticle> list = q.list();
28021    
28022                    if (list.size() == 2) {
28023                            return list.get(1);
28024                    }
28025                    else {
28026                            return null;
28027                    }
28028            }
28029    
28030            /**
28031             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
28032             *
28033             * @param groupId the group ID
28034             * @param urlTitle the url title
28035             * @param status the status
28036             */
28037            @Override
28038            public void removeByG_UT_ST(long groupId, String urlTitle, int status) {
28039                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
28040                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
28041                            remove(journalArticle);
28042                    }
28043            }
28044    
28045            /**
28046             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28047             *
28048             * @param groupId the group ID
28049             * @param urlTitle the url title
28050             * @param status the status
28051             * @return the number of matching journal articles
28052             */
28053            @Override
28054            public int countByG_UT_ST(long groupId, String urlTitle, int status) {
28055                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT_ST;
28056    
28057                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
28058    
28059                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
28060                                    this);
28061    
28062                    if (count == null) {
28063                            StringBundler query = new StringBundler(4);
28064    
28065                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
28066    
28067                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28068    
28069                            boolean bindUrlTitle = false;
28070    
28071                            if (urlTitle == null) {
28072                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28073                            }
28074                            else if (urlTitle.equals(StringPool.BLANK)) {
28075                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28076                            }
28077                            else {
28078                                    bindUrlTitle = true;
28079    
28080                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28081                            }
28082    
28083                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28084    
28085                            String sql = query.toString();
28086    
28087                            Session session = null;
28088    
28089                            try {
28090                                    session = openSession();
28091    
28092                                    Query q = session.createQuery(sql);
28093    
28094                                    QueryPos qPos = QueryPos.getInstance(q);
28095    
28096                                    qPos.add(groupId);
28097    
28098                                    if (bindUrlTitle) {
28099                                            qPos.add(urlTitle);
28100                                    }
28101    
28102                                    qPos.add(status);
28103    
28104                                    count = (Long)q.uniqueResult();
28105    
28106                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
28107                            }
28108                            catch (Exception e) {
28109                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28110    
28111                                    throw processException(e);
28112                            }
28113                            finally {
28114                                    closeSession(session);
28115                            }
28116                    }
28117    
28118                    return count.intValue();
28119            }
28120    
28121            /**
28122             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
28123             *
28124             * @param groupId the group ID
28125             * @param urlTitle the url title
28126             * @param status the status
28127             * @return the number of matching journal articles that the user has permission to view
28128             */
28129            @Override
28130            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status) {
28131                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
28132                            return countByG_UT_ST(groupId, urlTitle, status);
28133                    }
28134    
28135                    StringBundler query = new StringBundler(4);
28136    
28137                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
28138    
28139                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
28140    
28141                    boolean bindUrlTitle = false;
28142    
28143                    if (urlTitle == null) {
28144                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
28145                    }
28146                    else if (urlTitle.equals(StringPool.BLANK)) {
28147                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
28148                    }
28149                    else {
28150                            bindUrlTitle = true;
28151    
28152                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
28153                    }
28154    
28155                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
28156    
28157                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
28158                                    JournalArticle.class.getName(),
28159                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
28160    
28161                    Session session = null;
28162    
28163                    try {
28164                            session = openSession();
28165    
28166                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
28167    
28168                            q.addScalar(COUNT_COLUMN_NAME,
28169                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
28170    
28171                            QueryPos qPos = QueryPos.getInstance(q);
28172    
28173                            qPos.add(groupId);
28174    
28175                            if (bindUrlTitle) {
28176                                    qPos.add(urlTitle);
28177                            }
28178    
28179                            qPos.add(status);
28180    
28181                            Long count = (Long)q.uniqueResult();
28182    
28183                            return count.intValue();
28184                    }
28185                    catch (Exception e) {
28186                            throw processException(e);
28187                    }
28188                    finally {
28189                            closeSession(session);
28190                    }
28191            }
28192    
28193            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
28194            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
28195            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
28196            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = '') AND ";
28197            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
28198            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28199                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
28200                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
28201                            "findByC_V_ST",
28202                            new String[] {
28203                                    Long.class.getName(), Double.class.getName(),
28204                                    Integer.class.getName(),
28205                                    
28206                            Integer.class.getName(), Integer.class.getName(),
28207                                    OrderByComparator.class.getName()
28208                            });
28209            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
28210                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28211                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
28212                            JournalArticleImpl.class,
28213                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
28214                            new String[] {
28215                                    Long.class.getName(), Double.class.getName(),
28216                                    Integer.class.getName()
28217                            },
28218                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
28219                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
28220                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK |
28221                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
28222            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28223                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
28224                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
28225                            new String[] {
28226                                    Long.class.getName(), Double.class.getName(),
28227                                    Integer.class.getName()
28228                            });
28229    
28230            /**
28231             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28232             *
28233             * @param companyId the company ID
28234             * @param version the version
28235             * @param status the status
28236             * @return the matching journal articles
28237             */
28238            @Override
28239            public List<JournalArticle> findByC_V_ST(long companyId, double version,
28240                    int status) {
28241                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
28242                            QueryUtil.ALL_POS, null);
28243            }
28244    
28245            /**
28246             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28247             *
28248             * <p>
28249             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
28250             * </p>
28251             *
28252             * @param companyId the company ID
28253             * @param version the version
28254             * @param status the status
28255             * @param start the lower bound of the range of journal articles
28256             * @param end the upper bound of the range of journal articles (not inclusive)
28257             * @return the range of matching journal articles
28258             */
28259            @Override
28260            public List<JournalArticle> findByC_V_ST(long companyId, double version,
28261                    int status, int start, int end) {
28262                    return findByC_V_ST(companyId, version, status, start, end, null);
28263            }
28264    
28265            /**
28266             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28267             *
28268             * <p>
28269             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
28270             * </p>
28271             *
28272             * @param companyId the company ID
28273             * @param version the version
28274             * @param status the status
28275             * @param start the lower bound of the range of journal articles
28276             * @param end the upper bound of the range of journal articles (not inclusive)
28277             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
28278             * @return the ordered range of matching journal articles
28279             */
28280            @Override
28281            public List<JournalArticle> findByC_V_ST(long companyId, double version,
28282                    int status, int start, int end,
28283                    OrderByComparator<JournalArticle> orderByComparator) {
28284                    boolean pagination = true;
28285                    FinderPath finderPath = null;
28286                    Object[] finderArgs = null;
28287    
28288                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
28289                                    (orderByComparator == null)) {
28290                            pagination = false;
28291                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
28292                            finderArgs = new Object[] { companyId, version, status };
28293                    }
28294                    else {
28295                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
28296                            finderArgs = new Object[] {
28297                                            companyId, version, status,
28298                                            
28299                                            start, end, orderByComparator
28300                                    };
28301                    }
28302    
28303                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
28304                                    finderArgs, this);
28305    
28306                    if ((list != null) && !list.isEmpty()) {
28307                            for (JournalArticle journalArticle : list) {
28308                                    if ((companyId != journalArticle.getCompanyId()) ||
28309                                                    (version != journalArticle.getVersion()) ||
28310                                                    (status != journalArticle.getStatus())) {
28311                                            list = null;
28312    
28313                                            break;
28314                                    }
28315                            }
28316                    }
28317    
28318                    if (list == null) {
28319                            StringBundler query = null;
28320    
28321                            if (orderByComparator != null) {
28322                                    query = new StringBundler(5 +
28323                                                    (orderByComparator.getOrderByFields().length * 3));
28324                            }
28325                            else {
28326                                    query = new StringBundler(5);
28327                            }
28328    
28329                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28330    
28331                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
28332    
28333                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
28334    
28335                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
28336    
28337                            if (orderByComparator != null) {
28338                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
28339                                            orderByComparator);
28340                            }
28341                            else
28342                             if (pagination) {
28343                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28344                            }
28345    
28346                            String sql = query.toString();
28347    
28348                            Session session = null;
28349    
28350                            try {
28351                                    session = openSession();
28352    
28353                                    Query q = session.createQuery(sql);
28354    
28355                                    QueryPos qPos = QueryPos.getInstance(q);
28356    
28357                                    qPos.add(companyId);
28358    
28359                                    qPos.add(version);
28360    
28361                                    qPos.add(status);
28362    
28363                                    if (!pagination) {
28364                                            list = (List<JournalArticle>)QueryUtil.list(q,
28365                                                            getDialect(), start, end, false);
28366    
28367                                            Collections.sort(list);
28368    
28369                                            list = Collections.unmodifiableList(list);
28370                                    }
28371                                    else {
28372                                            list = (List<JournalArticle>)QueryUtil.list(q,
28373                                                            getDialect(), start, end);
28374                                    }
28375    
28376                                    cacheResult(list);
28377    
28378                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
28379                            }
28380                            catch (Exception e) {
28381                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28382    
28383                                    throw processException(e);
28384                            }
28385                            finally {
28386                                    closeSession(session);
28387                            }
28388                    }
28389    
28390                    return list;
28391            }
28392    
28393            /**
28394             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28395             *
28396             * @param companyId the company ID
28397             * @param version the version
28398             * @param status the status
28399             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28400             * @return the first matching journal article
28401             * @throws NoSuchArticleException if a matching journal article could not be found
28402             */
28403            @Override
28404            public JournalArticle findByC_V_ST_First(long companyId, double version,
28405                    int status, OrderByComparator<JournalArticle> orderByComparator)
28406                    throws NoSuchArticleException {
28407                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
28408                                    status, orderByComparator);
28409    
28410                    if (journalArticle != null) {
28411                            return journalArticle;
28412                    }
28413    
28414                    StringBundler msg = new StringBundler(8);
28415    
28416                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28417    
28418                    msg.append("companyId=");
28419                    msg.append(companyId);
28420    
28421                    msg.append(", version=");
28422                    msg.append(version);
28423    
28424                    msg.append(", status=");
28425                    msg.append(status);
28426    
28427                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28428    
28429                    throw new NoSuchArticleException(msg.toString());
28430            }
28431    
28432            /**
28433             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28434             *
28435             * @param companyId the company ID
28436             * @param version the version
28437             * @param status the status
28438             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28439             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
28440             */
28441            @Override
28442            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
28443                    int status, OrderByComparator<JournalArticle> orderByComparator) {
28444                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
28445                                    1, orderByComparator);
28446    
28447                    if (!list.isEmpty()) {
28448                            return list.get(0);
28449                    }
28450    
28451                    return null;
28452            }
28453    
28454            /**
28455             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28456             *
28457             * @param companyId the company ID
28458             * @param version the version
28459             * @param status the status
28460             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28461             * @return the last matching journal article
28462             * @throws NoSuchArticleException if a matching journal article could not be found
28463             */
28464            @Override
28465            public JournalArticle findByC_V_ST_Last(long companyId, double version,
28466                    int status, OrderByComparator<JournalArticle> orderByComparator)
28467                    throws NoSuchArticleException {
28468                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
28469                                    status, orderByComparator);
28470    
28471                    if (journalArticle != null) {
28472                            return journalArticle;
28473                    }
28474    
28475                    StringBundler msg = new StringBundler(8);
28476    
28477                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
28478    
28479                    msg.append("companyId=");
28480                    msg.append(companyId);
28481    
28482                    msg.append(", version=");
28483                    msg.append(version);
28484    
28485                    msg.append(", status=");
28486                    msg.append(status);
28487    
28488                    msg.append(StringPool.CLOSE_CURLY_BRACE);
28489    
28490                    throw new NoSuchArticleException(msg.toString());
28491            }
28492    
28493            /**
28494             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28495             *
28496             * @param companyId the company ID
28497             * @param version the version
28498             * @param status the status
28499             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28500             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
28501             */
28502            @Override
28503            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
28504                    int status, OrderByComparator<JournalArticle> orderByComparator) {
28505                    int count = countByC_V_ST(companyId, version, status);
28506    
28507                    if (count == 0) {
28508                            return null;
28509                    }
28510    
28511                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
28512                                    count - 1, count, orderByComparator);
28513    
28514                    if (!list.isEmpty()) {
28515                            return list.get(0);
28516                    }
28517    
28518                    return null;
28519            }
28520    
28521            /**
28522             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
28523             *
28524             * @param id the primary key of the current journal article
28525             * @param companyId the company ID
28526             * @param version the version
28527             * @param status the status
28528             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
28529             * @return the previous, current, and next journal article
28530             * @throws NoSuchArticleException if a journal article with the primary key could not be found
28531             */
28532            @Override
28533            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
28534                    double version, int status,
28535                    OrderByComparator<JournalArticle> orderByComparator)
28536                    throws NoSuchArticleException {
28537                    JournalArticle journalArticle = findByPrimaryKey(id);
28538    
28539                    Session session = null;
28540    
28541                    try {
28542                            session = openSession();
28543    
28544                            JournalArticle[] array = new JournalArticleImpl[3];
28545    
28546                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
28547                                            companyId, version, status, orderByComparator, true);
28548    
28549                            array[1] = journalArticle;
28550    
28551                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
28552                                            companyId, version, status, orderByComparator, false);
28553    
28554                            return array;
28555                    }
28556                    catch (Exception e) {
28557                            throw processException(e);
28558                    }
28559                    finally {
28560                            closeSession(session);
28561                    }
28562            }
28563    
28564            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
28565                    JournalArticle journalArticle, long companyId, double version,
28566                    int status, OrderByComparator<JournalArticle> orderByComparator,
28567                    boolean previous) {
28568                    StringBundler query = null;
28569    
28570                    if (orderByComparator != null) {
28571                            query = new StringBundler(6 +
28572                                            (orderByComparator.getOrderByFields().length * 6));
28573                    }
28574                    else {
28575                            query = new StringBundler(3);
28576                    }
28577    
28578                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
28579    
28580                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
28581    
28582                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
28583    
28584                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
28585    
28586                    if (orderByComparator != null) {
28587                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
28588    
28589                            if (orderByConditionFields.length > 0) {
28590                                    query.append(WHERE_AND);
28591                            }
28592    
28593                            for (int i = 0; i < orderByConditionFields.length; i++) {
28594                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28595                                    query.append(orderByConditionFields[i]);
28596    
28597                                    if ((i + 1) < orderByConditionFields.length) {
28598                                            if (orderByComparator.isAscending() ^ previous) {
28599                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
28600                                            }
28601                                            else {
28602                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
28603                                            }
28604                                    }
28605                                    else {
28606                                            if (orderByComparator.isAscending() ^ previous) {
28607                                                    query.append(WHERE_GREATER_THAN);
28608                                            }
28609                                            else {
28610                                                    query.append(WHERE_LESSER_THAN);
28611                                            }
28612                                    }
28613                            }
28614    
28615                            query.append(ORDER_BY_CLAUSE);
28616    
28617                            String[] orderByFields = orderByComparator.getOrderByFields();
28618    
28619                            for (int i = 0; i < orderByFields.length; i++) {
28620                                    query.append(_ORDER_BY_ENTITY_ALIAS);
28621                                    query.append(orderByFields[i]);
28622    
28623                                    if ((i + 1) < orderByFields.length) {
28624                                            if (orderByComparator.isAscending() ^ previous) {
28625                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
28626                                            }
28627                                            else {
28628                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
28629                                            }
28630                                    }
28631                                    else {
28632                                            if (orderByComparator.isAscending() ^ previous) {
28633                                                    query.append(ORDER_BY_ASC);
28634                                            }
28635                                            else {
28636                                                    query.append(ORDER_BY_DESC);
28637                                            }
28638                                    }
28639                            }
28640                    }
28641                    else {
28642                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
28643                    }
28644    
28645                    String sql = query.toString();
28646    
28647                    Query q = session.createQuery(sql);
28648    
28649                    q.setFirstResult(0);
28650                    q.setMaxResults(2);
28651    
28652                    QueryPos qPos = QueryPos.getInstance(q);
28653    
28654                    qPos.add(companyId);
28655    
28656                    qPos.add(version);
28657    
28658                    qPos.add(status);
28659    
28660                    if (orderByComparator != null) {
28661                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
28662    
28663                            for (Object value : values) {
28664                                    qPos.add(value);
28665                            }
28666                    }
28667    
28668                    List<JournalArticle> list = q.list();
28669    
28670                    if (list.size() == 2) {
28671                            return list.get(1);
28672                    }
28673                    else {
28674                            return null;
28675                    }
28676            }
28677    
28678            /**
28679             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
28680             *
28681             * @param companyId the company ID
28682             * @param version the version
28683             * @param status the status
28684             */
28685            @Override
28686            public void removeByC_V_ST(long companyId, double version, int status) {
28687                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
28688                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
28689                            remove(journalArticle);
28690                    }
28691            }
28692    
28693            /**
28694             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
28695             *
28696             * @param companyId the company ID
28697             * @param version the version
28698             * @param status the status
28699             * @return the number of matching journal articles
28700             */
28701            @Override
28702            public int countByC_V_ST(long companyId, double version, int status) {
28703                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_V_ST;
28704    
28705                    Object[] finderArgs = new Object[] { companyId, version, status };
28706    
28707                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
28708                                    this);
28709    
28710                    if (count == null) {
28711                            StringBundler query = new StringBundler(4);
28712    
28713                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
28714    
28715                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
28716    
28717                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
28718    
28719                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
28720    
28721                            String sql = query.toString();
28722    
28723                            Session session = null;
28724    
28725                            try {
28726                                    session = openSession();
28727    
28728                                    Query q = session.createQuery(sql);
28729    
28730                                    QueryPos qPos = QueryPos.getInstance(q);
28731    
28732                                    qPos.add(companyId);
28733    
28734                                    qPos.add(version);
28735    
28736                                    qPos.add(status);
28737    
28738                                    count = (Long)q.uniqueResult();
28739    
28740                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
28741                            }
28742                            catch (Exception e) {
28743                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
28744    
28745                                    throw processException(e);
28746                            }
28747                            finally {
28748                                    closeSession(session);
28749                            }
28750                    }
28751    
28752                    return count.intValue();
28753            }
28754    
28755            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
28756            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
28757            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
28758    
28759            public JournalArticlePersistenceImpl() {
28760                    setModelClass(JournalArticle.class);
28761            }
28762    
28763            /**
28764             * Caches the journal article in the entity cache if it is enabled.
28765             *
28766             * @param journalArticle the journal article
28767             */
28768            @Override
28769            public void cacheResult(JournalArticle journalArticle) {
28770                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28771                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
28772                            journalArticle);
28773    
28774                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
28775                            new Object[] { journalArticle.getUuid(), journalArticle.getGroupId() },
28776                            journalArticle);
28777    
28778                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_DDMSK,
28779                            new Object[] {
28780                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
28781                                    journalArticle.getDDMStructureKey()
28782                            }, journalArticle);
28783    
28784                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
28785                            new Object[] {
28786                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
28787                                    journalArticle.getVersion()
28788                            }, journalArticle);
28789    
28790                    journalArticle.resetOriginalValues();
28791            }
28792    
28793            /**
28794             * Caches the journal articles in the entity cache if it is enabled.
28795             *
28796             * @param journalArticles the journal articles
28797             */
28798            @Override
28799            public void cacheResult(List<JournalArticle> journalArticles) {
28800                    for (JournalArticle journalArticle : journalArticles) {
28801                            if (EntityCacheUtil.getResult(
28802                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28803                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
28804                                    cacheResult(journalArticle);
28805                            }
28806                            else {
28807                                    journalArticle.resetOriginalValues();
28808                            }
28809                    }
28810            }
28811    
28812            /**
28813             * Clears the cache for all journal articles.
28814             *
28815             * <p>
28816             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
28817             * </p>
28818             */
28819            @Override
28820            public void clearCache() {
28821                    EntityCacheUtil.clearCache(JournalArticleImpl.class);
28822    
28823                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
28824                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
28825                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
28826            }
28827    
28828            /**
28829             * Clears the cache for the journal article.
28830             *
28831             * <p>
28832             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
28833             * </p>
28834             */
28835            @Override
28836            public void clearCache(JournalArticle journalArticle) {
28837                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28838                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
28839    
28840                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
28841                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
28842    
28843                    clearUniqueFindersCache(journalArticle);
28844            }
28845    
28846            @Override
28847            public void clearCache(List<JournalArticle> journalArticles) {
28848                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
28849                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
28850    
28851                    for (JournalArticle journalArticle : journalArticles) {
28852                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
28853                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
28854    
28855                            clearUniqueFindersCache(journalArticle);
28856                    }
28857            }
28858    
28859            protected void cacheUniqueFindersCache(JournalArticle journalArticle) {
28860                    if (journalArticle.isNew()) {
28861                            Object[] args = new Object[] {
28862                                            journalArticle.getUuid(), journalArticle.getGroupId()
28863                                    };
28864    
28865                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
28866                                    Long.valueOf(1));
28867                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
28868                                    journalArticle);
28869    
28870                            args = new Object[] {
28871                                            journalArticle.getGroupId(), journalArticle.getClassNameId(),
28872                                            journalArticle.getDDMStructureKey()
28873                                    };
28874    
28875                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_DDMSK, args,
28876                                    Long.valueOf(1));
28877                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_DDMSK, args,
28878                                    journalArticle);
28879    
28880                            args = new Object[] {
28881                                            journalArticle.getGroupId(), journalArticle.getArticleId(),
28882                                            journalArticle.getVersion()
28883                                    };
28884    
28885                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
28886                                    Long.valueOf(1));
28887                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
28888                                    journalArticle);
28889                    }
28890                    else {
28891                            JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
28892    
28893                            if ((journalArticleModelImpl.getColumnBitmask() &
28894                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
28895                                    Object[] args = new Object[] {
28896                                                    journalArticle.getUuid(), journalArticle.getGroupId()
28897                                            };
28898    
28899                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
28900                                            Long.valueOf(1));
28901                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
28902                                            journalArticle);
28903                            }
28904    
28905                            if ((journalArticleModelImpl.getColumnBitmask() &
28906                                            FINDER_PATH_FETCH_BY_G_C_DDMSK.getColumnBitmask()) != 0) {
28907                                    Object[] args = new Object[] {
28908                                                    journalArticle.getGroupId(),
28909                                                    journalArticle.getClassNameId(),
28910                                                    journalArticle.getDDMStructureKey()
28911                                            };
28912    
28913                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_DDMSK, args,
28914                                            Long.valueOf(1));
28915                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_DDMSK, args,
28916                                            journalArticle);
28917                            }
28918    
28919                            if ((journalArticleModelImpl.getColumnBitmask() &
28920                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
28921                                    Object[] args = new Object[] {
28922                                                    journalArticle.getGroupId(),
28923                                                    journalArticle.getArticleId(),
28924                                                    journalArticle.getVersion()
28925                                            };
28926    
28927                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V, args,
28928                                            Long.valueOf(1));
28929                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V, args,
28930                                            journalArticle);
28931                            }
28932                    }
28933            }
28934    
28935            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
28936                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
28937    
28938                    Object[] args = new Object[] {
28939                                    journalArticle.getUuid(), journalArticle.getGroupId()
28940                            };
28941    
28942                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
28943                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
28944    
28945                    if ((journalArticleModelImpl.getColumnBitmask() &
28946                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
28947                            args = new Object[] {
28948                                            journalArticleModelImpl.getOriginalUuid(),
28949                                            journalArticleModelImpl.getOriginalGroupId()
28950                                    };
28951    
28952                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
28953                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
28954                    }
28955    
28956                    args = new Object[] {
28957                                    journalArticle.getGroupId(), journalArticle.getClassNameId(),
28958                                    journalArticle.getDDMStructureKey()
28959                            };
28960    
28961                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_DDMSK, args);
28962                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_DDMSK, args);
28963    
28964                    if ((journalArticleModelImpl.getColumnBitmask() &
28965                                    FINDER_PATH_FETCH_BY_G_C_DDMSK.getColumnBitmask()) != 0) {
28966                            args = new Object[] {
28967                                            journalArticleModelImpl.getOriginalGroupId(),
28968                                            journalArticleModelImpl.getOriginalClassNameId(),
28969                                            journalArticleModelImpl.getOriginalDDMStructureKey()
28970                                    };
28971    
28972                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_DDMSK, args);
28973                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_DDMSK, args);
28974                    }
28975    
28976                    args = new Object[] {
28977                                    journalArticle.getGroupId(), journalArticle.getArticleId(),
28978                                    journalArticle.getVersion()
28979                            };
28980    
28981                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
28982                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
28983    
28984                    if ((journalArticleModelImpl.getColumnBitmask() &
28985                                    FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
28986                            args = new Object[] {
28987                                            journalArticleModelImpl.getOriginalGroupId(),
28988                                            journalArticleModelImpl.getOriginalArticleId(),
28989                                            journalArticleModelImpl.getOriginalVersion()
28990                                    };
28991    
28992                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
28993                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
28994                    }
28995            }
28996    
28997            /**
28998             * Creates a new journal article with the primary key. Does not add the journal article to the database.
28999             *
29000             * @param id the primary key for the new journal article
29001             * @return the new journal article
29002             */
29003            @Override
29004            public JournalArticle create(long id) {
29005                    JournalArticle journalArticle = new JournalArticleImpl();
29006    
29007                    journalArticle.setNew(true);
29008                    journalArticle.setPrimaryKey(id);
29009    
29010                    String uuid = PortalUUIDUtil.generate();
29011    
29012                    journalArticle.setUuid(uuid);
29013    
29014                    return journalArticle;
29015            }
29016    
29017            /**
29018             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
29019             *
29020             * @param id the primary key of the journal article
29021             * @return the journal article that was removed
29022             * @throws NoSuchArticleException if a journal article with the primary key could not be found
29023             */
29024            @Override
29025            public JournalArticle remove(long id) throws NoSuchArticleException {
29026                    return remove((Serializable)id);
29027            }
29028    
29029            /**
29030             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
29031             *
29032             * @param primaryKey the primary key of the journal article
29033             * @return the journal article that was removed
29034             * @throws NoSuchArticleException if a journal article with the primary key could not be found
29035             */
29036            @Override
29037            public JournalArticle remove(Serializable primaryKey)
29038                    throws NoSuchArticleException {
29039                    Session session = null;
29040    
29041                    try {
29042                            session = openSession();
29043    
29044                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
29045                                            primaryKey);
29046    
29047                            if (journalArticle == null) {
29048                                    if (_log.isWarnEnabled()) {
29049                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
29050                                    }
29051    
29052                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
29053                                            primaryKey);
29054                            }
29055    
29056                            return remove(journalArticle);
29057                    }
29058                    catch (NoSuchArticleException nsee) {
29059                            throw nsee;
29060                    }
29061                    catch (Exception e) {
29062                            throw processException(e);
29063                    }
29064                    finally {
29065                            closeSession(session);
29066                    }
29067            }
29068    
29069            @Override
29070            protected JournalArticle removeImpl(JournalArticle journalArticle) {
29071                    journalArticle = toUnwrappedModel(journalArticle);
29072    
29073                    Session session = null;
29074    
29075                    try {
29076                            session = openSession();
29077    
29078                            if (!session.contains(journalArticle)) {
29079                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
29080                                                    journalArticle.getPrimaryKeyObj());
29081                            }
29082    
29083                            if (journalArticle != null) {
29084                                    session.delete(journalArticle);
29085                            }
29086                    }
29087                    catch (Exception e) {
29088                            throw processException(e);
29089                    }
29090                    finally {
29091                            closeSession(session);
29092                    }
29093    
29094                    if (journalArticle != null) {
29095                            clearCache(journalArticle);
29096                    }
29097    
29098                    return journalArticle;
29099            }
29100    
29101            @Override
29102            public JournalArticle updateImpl(JournalArticle journalArticle) {
29103                    journalArticle = toUnwrappedModel(journalArticle);
29104    
29105                    boolean isNew = journalArticle.isNew();
29106    
29107                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
29108    
29109                    if (Validator.isNull(journalArticle.getUuid())) {
29110                            String uuid = PortalUUIDUtil.generate();
29111    
29112                            journalArticle.setUuid(uuid);
29113                    }
29114    
29115                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
29116    
29117                    Date now = new Date();
29118    
29119                    if (isNew && (journalArticle.getCreateDate() == null)) {
29120                            if (serviceContext == null) {
29121                                    journalArticle.setCreateDate(now);
29122                            }
29123                            else {
29124                                    journalArticle.setCreateDate(serviceContext.getCreateDate(now));
29125                            }
29126                    }
29127    
29128                    if (!journalArticleModelImpl.hasSetModifiedDate()) {
29129                            if (serviceContext == null) {
29130                                    journalArticle.setModifiedDate(now);
29131                            }
29132                            else {
29133                                    journalArticle.setModifiedDate(serviceContext.getModifiedDate(
29134                                                    now));
29135                            }
29136                    }
29137    
29138                    Session session = null;
29139    
29140                    try {
29141                            session = openSession();
29142    
29143                            if (journalArticle.isNew()) {
29144                                    session.save(journalArticle);
29145    
29146                                    journalArticle.setNew(false);
29147                            }
29148                            else {
29149                                    session.merge(journalArticle);
29150                            }
29151                    }
29152                    catch (Exception e) {
29153                            throw processException(e);
29154                    }
29155                    finally {
29156                            closeSession(session);
29157                    }
29158    
29159                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
29160    
29161                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
29162                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
29163                    }
29164    
29165                    else {
29166                            if ((journalArticleModelImpl.getColumnBitmask() &
29167                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
29168                                    Object[] args = new Object[] {
29169                                                    journalArticleModelImpl.getOriginalUuid()
29170                                            };
29171    
29172                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
29173                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
29174                                            args);
29175    
29176                                    args = new Object[] { journalArticleModelImpl.getUuid() };
29177    
29178                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
29179                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
29180                                            args);
29181                            }
29182    
29183                            if ((journalArticleModelImpl.getColumnBitmask() &
29184                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
29185                                    Object[] args = new Object[] {
29186                                                    journalArticleModelImpl.getOriginalUuid(),
29187                                                    journalArticleModelImpl.getOriginalCompanyId()
29188                                            };
29189    
29190                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
29191                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
29192                                            args);
29193    
29194                                    args = new Object[] {
29195                                                    journalArticleModelImpl.getUuid(),
29196                                                    journalArticleModelImpl.getCompanyId()
29197                                            };
29198    
29199                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
29200                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
29201                                            args);
29202                            }
29203    
29204                            if ((journalArticleModelImpl.getColumnBitmask() &
29205                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
29206                                    Object[] args = new Object[] {
29207                                                    journalArticleModelImpl.getOriginalResourcePrimKey()
29208                                            };
29209    
29210                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
29211                                            args);
29212                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
29213                                            args);
29214    
29215                                    args = new Object[] { journalArticleModelImpl.getResourcePrimKey() };
29216    
29217                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
29218                                            args);
29219                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
29220                                            args);
29221                            }
29222    
29223                            if ((journalArticleModelImpl.getColumnBitmask() &
29224                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
29225                                    Object[] args = new Object[] {
29226                                                    journalArticleModelImpl.getOriginalGroupId()
29227                                            };
29228    
29229                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
29230                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
29231                                            args);
29232    
29233                                    args = new Object[] { journalArticleModelImpl.getGroupId() };
29234    
29235                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
29236                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
29237                                            args);
29238                            }
29239    
29240                            if ((journalArticleModelImpl.getColumnBitmask() &
29241                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
29242                                    Object[] args = new Object[] {
29243                                                    journalArticleModelImpl.getOriginalCompanyId()
29244                                            };
29245    
29246                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
29247                                            args);
29248                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
29249                                            args);
29250    
29251                                    args = new Object[] { journalArticleModelImpl.getCompanyId() };
29252    
29253                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
29254                                            args);
29255                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
29256                                            args);
29257                            }
29258    
29259                            if ((journalArticleModelImpl.getColumnBitmask() &
29260                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DDMSTRUCTUREKEY.getColumnBitmask()) != 0) {
29261                                    Object[] args = new Object[] {
29262                                                    journalArticleModelImpl.getOriginalDDMStructureKey()
29263                                            };
29264    
29265                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_DDMSTRUCTUREKEY,
29266                                            args);
29267                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DDMSTRUCTUREKEY,
29268                                            args);
29269    
29270                                    args = new Object[] { journalArticleModelImpl.getDDMStructureKey() };
29271    
29272                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_DDMSTRUCTUREKEY,
29273                                            args);
29274                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DDMSTRUCTUREKEY,
29275                                            args);
29276                            }
29277    
29278                            if ((journalArticleModelImpl.getColumnBitmask() &
29279                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DDMTEMPLATEKEY.getColumnBitmask()) != 0) {
29280                                    Object[] args = new Object[] {
29281                                                    journalArticleModelImpl.getOriginalDDMTemplateKey()
29282                                            };
29283    
29284                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_DDMTEMPLATEKEY,
29285                                            args);
29286                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DDMTEMPLATEKEY,
29287                                            args);
29288    
29289                                    args = new Object[] { journalArticleModelImpl.getDDMTemplateKey() };
29290    
29291                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_DDMTEMPLATEKEY,
29292                                            args);
29293                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DDMTEMPLATEKEY,
29294                                            args);
29295                            }
29296    
29297                            if ((journalArticleModelImpl.getColumnBitmask() &
29298                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
29299                                    Object[] args = new Object[] {
29300                                                    journalArticleModelImpl.getOriginalLayoutUuid()
29301                                            };
29302    
29303                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
29304                                            args);
29305                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
29306                                            args);
29307    
29308                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
29309    
29310                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
29311                                            args);
29312                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
29313                                            args);
29314                            }
29315    
29316                            if ((journalArticleModelImpl.getColumnBitmask() &
29317                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
29318                                    Object[] args = new Object[] {
29319                                                    journalArticleModelImpl.getOriginalSmallImageId()
29320                                            };
29321    
29322                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
29323                                            args);
29324                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
29325                                            args);
29326    
29327                                    args = new Object[] { journalArticleModelImpl.getSmallImageId() };
29328    
29329                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
29330                                            args);
29331                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
29332                                            args);
29333                            }
29334    
29335                            if ((journalArticleModelImpl.getColumnBitmask() &
29336                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I.getColumnBitmask()) != 0) {
29337                                    Object[] args = new Object[] {
29338                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
29339                                                    journalArticleModelImpl.getOriginalIndexable()
29340                                            };
29341    
29342                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
29343                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
29344                                            args);
29345    
29346                                    args = new Object[] {
29347                                                    journalArticleModelImpl.getResourcePrimKey(),
29348                                                    journalArticleModelImpl.getIndexable()
29349                                            };
29350    
29351                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I, args);
29352                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I,
29353                                            args);
29354                            }
29355    
29356                            if ((journalArticleModelImpl.getColumnBitmask() &
29357                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
29358                                    Object[] args = new Object[] {
29359                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
29360                                                    journalArticleModelImpl.getOriginalStatus()
29361                                            };
29362    
29363                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
29364                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
29365                                            args);
29366    
29367                                    args = new Object[] {
29368                                                    journalArticleModelImpl.getResourcePrimKey(),
29369                                                    journalArticleModelImpl.getStatus()
29370                                            };
29371    
29372                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
29373                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
29374                                            args);
29375                            }
29376    
29377                            if ((journalArticleModelImpl.getColumnBitmask() &
29378                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
29379                                    Object[] args = new Object[] {
29380                                                    journalArticleModelImpl.getOriginalGroupId(),
29381                                                    journalArticleModelImpl.getOriginalUserId()
29382                                            };
29383    
29384                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
29385                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
29386                                            args);
29387    
29388                                    args = new Object[] {
29389                                                    journalArticleModelImpl.getGroupId(),
29390                                                    journalArticleModelImpl.getUserId()
29391                                            };
29392    
29393                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
29394                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
29395                                            args);
29396                            }
29397    
29398                            if ((journalArticleModelImpl.getColumnBitmask() &
29399                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
29400                                    Object[] args = new Object[] {
29401                                                    journalArticleModelImpl.getOriginalGroupId(),
29402                                                    journalArticleModelImpl.getOriginalFolderId()
29403                                            };
29404    
29405                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
29406                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
29407                                            args);
29408    
29409                                    args = new Object[] {
29410                                                    journalArticleModelImpl.getGroupId(),
29411                                                    journalArticleModelImpl.getFolderId()
29412                                            };
29413    
29414                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
29415                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
29416                                            args);
29417                            }
29418    
29419                            if ((journalArticleModelImpl.getColumnBitmask() &
29420                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
29421                                    Object[] args = new Object[] {
29422                                                    journalArticleModelImpl.getOriginalGroupId(),
29423                                                    journalArticleModelImpl.getOriginalArticleId()
29424                                            };
29425    
29426                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
29427                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
29428                                            args);
29429    
29430                                    args = new Object[] {
29431                                                    journalArticleModelImpl.getGroupId(),
29432                                                    journalArticleModelImpl.getArticleId()
29433                                            };
29434    
29435                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
29436                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
29437                                            args);
29438                            }
29439    
29440                            if ((journalArticleModelImpl.getColumnBitmask() &
29441                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
29442                                    Object[] args = new Object[] {
29443                                                    journalArticleModelImpl.getOriginalGroupId(),
29444                                                    journalArticleModelImpl.getOriginalUrlTitle()
29445                                            };
29446    
29447                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
29448                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
29449                                            args);
29450    
29451                                    args = new Object[] {
29452                                                    journalArticleModelImpl.getGroupId(),
29453                                                    journalArticleModelImpl.getUrlTitle()
29454                                            };
29455    
29456                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
29457                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
29458                                            args);
29459                            }
29460    
29461                            if ((journalArticleModelImpl.getColumnBitmask() &
29462                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_DDMSK.getColumnBitmask()) != 0) {
29463                                    Object[] args = new Object[] {
29464                                                    journalArticleModelImpl.getOriginalGroupId(),
29465                                                    journalArticleModelImpl.getOriginalDDMStructureKey()
29466                                            };
29467    
29468                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_DDMSK, args);
29469                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_DDMSK,
29470                                            args);
29471    
29472                                    args = new Object[] {
29473                                                    journalArticleModelImpl.getGroupId(),
29474                                                    journalArticleModelImpl.getDDMStructureKey()
29475                                            };
29476    
29477                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_DDMSK, args);
29478                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_DDMSK,
29479                                            args);
29480                            }
29481    
29482                            if ((journalArticleModelImpl.getColumnBitmask() &
29483                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_DDMTK.getColumnBitmask()) != 0) {
29484                                    Object[] args = new Object[] {
29485                                                    journalArticleModelImpl.getOriginalGroupId(),
29486                                                    journalArticleModelImpl.getOriginalDDMTemplateKey()
29487                                            };
29488    
29489                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_DDMTK, args);
29490                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_DDMTK,
29491                                            args);
29492    
29493                                    args = new Object[] {
29494                                                    journalArticleModelImpl.getGroupId(),
29495                                                    journalArticleModelImpl.getDDMTemplateKey()
29496                                            };
29497    
29498                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_DDMTK, args);
29499                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_DDMTK,
29500                                            args);
29501                            }
29502    
29503                            if ((journalArticleModelImpl.getColumnBitmask() &
29504                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
29505                                    Object[] args = new Object[] {
29506                                                    journalArticleModelImpl.getOriginalGroupId(),
29507                                                    journalArticleModelImpl.getOriginalLayoutUuid()
29508                                            };
29509    
29510                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
29511                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
29512                                            args);
29513    
29514                                    args = new Object[] {
29515                                                    journalArticleModelImpl.getGroupId(),
29516                                                    journalArticleModelImpl.getLayoutUuid()
29517                                            };
29518    
29519                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
29520                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
29521                                            args);
29522                            }
29523    
29524                            if ((journalArticleModelImpl.getColumnBitmask() &
29525                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
29526                                    Object[] args = new Object[] {
29527                                                    journalArticleModelImpl.getOriginalGroupId(),
29528                                                    journalArticleModelImpl.getOriginalStatus()
29529                                            };
29530    
29531                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
29532                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
29533                                            args);
29534    
29535                                    args = new Object[] {
29536                                                    journalArticleModelImpl.getGroupId(),
29537                                                    journalArticleModelImpl.getStatus()
29538                                            };
29539    
29540                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
29541                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
29542                                            args);
29543                            }
29544    
29545                            if ((journalArticleModelImpl.getColumnBitmask() &
29546                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
29547                                    Object[] args = new Object[] {
29548                                                    journalArticleModelImpl.getOriginalCompanyId(),
29549                                                    journalArticleModelImpl.getOriginalVersion()
29550                                            };
29551    
29552                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
29553                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
29554                                            args);
29555    
29556                                    args = new Object[] {
29557                                                    journalArticleModelImpl.getCompanyId(),
29558                                                    journalArticleModelImpl.getVersion()
29559                                            };
29560    
29561                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
29562                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
29563                                            args);
29564                            }
29565    
29566                            if ((journalArticleModelImpl.getColumnBitmask() &
29567                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
29568                                    Object[] args = new Object[] {
29569                                                    journalArticleModelImpl.getOriginalCompanyId(),
29570                                                    journalArticleModelImpl.getOriginalStatus()
29571                                            };
29572    
29573                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
29574                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
29575                                            args);
29576    
29577                                    args = new Object[] {
29578                                                    journalArticleModelImpl.getCompanyId(),
29579                                                    journalArticleModelImpl.getStatus()
29580                                            };
29581    
29582                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
29583                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
29584                                            args);
29585                            }
29586    
29587                            if ((journalArticleModelImpl.getColumnBitmask() &
29588                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_DDMTK.getColumnBitmask()) != 0) {
29589                                    Object[] args = new Object[] {
29590                                                    journalArticleModelImpl.getOriginalClassNameId(),
29591                                                    journalArticleModelImpl.getOriginalDDMTemplateKey()
29592                                            };
29593    
29594                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_DDMTK, args);
29595                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_DDMTK,
29596                                            args);
29597    
29598                                    args = new Object[] {
29599                                                    journalArticleModelImpl.getClassNameId(),
29600                                                    journalArticleModelImpl.getDDMTemplateKey()
29601                                            };
29602    
29603                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_DDMTK, args);
29604                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_DDMTK,
29605                                            args);
29606                            }
29607    
29608                            if ((journalArticleModelImpl.getColumnBitmask() &
29609                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S.getColumnBitmask()) != 0) {
29610                                    Object[] args = new Object[] {
29611                                                    journalArticleModelImpl.getOriginalResourcePrimKey(),
29612                                                    journalArticleModelImpl.getOriginalIndexable(),
29613                                                    journalArticleModelImpl.getOriginalStatus()
29614                                            };
29615    
29616                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
29617                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
29618                                            args);
29619    
29620                                    args = new Object[] {
29621                                                    journalArticleModelImpl.getResourcePrimKey(),
29622                                                    journalArticleModelImpl.getIndexable(),
29623                                                    journalArticleModelImpl.getStatus()
29624                                            };
29625    
29626                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_I_S, args);
29627                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_I_S,
29628                                            args);
29629                            }
29630    
29631                            if ((journalArticleModelImpl.getColumnBitmask() &
29632                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C.getColumnBitmask()) != 0) {
29633                                    Object[] args = new Object[] {
29634                                                    journalArticleModelImpl.getOriginalGroupId(),
29635                                                    journalArticleModelImpl.getOriginalUserId(),
29636                                                    journalArticleModelImpl.getOriginalClassNameId()
29637                                            };
29638    
29639                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
29640                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
29641                                            args);
29642    
29643                                    args = new Object[] {
29644                                                    journalArticleModelImpl.getGroupId(),
29645                                                    journalArticleModelImpl.getUserId(),
29646                                                    journalArticleModelImpl.getClassNameId()
29647                                            };
29648    
29649                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C, args);
29650                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C,
29651                                            args);
29652                            }
29653    
29654                            if ((journalArticleModelImpl.getColumnBitmask() &
29655                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
29656                                    Object[] args = new Object[] {
29657                                                    journalArticleModelImpl.getOriginalGroupId(),
29658                                                    journalArticleModelImpl.getOriginalFolderId(),
29659                                                    journalArticleModelImpl.getOriginalStatus()
29660                                            };
29661    
29662                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
29663                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
29664                                            args);
29665    
29666                                    args = new Object[] {
29667                                                    journalArticleModelImpl.getGroupId(),
29668                                                    journalArticleModelImpl.getFolderId(),
29669                                                    journalArticleModelImpl.getStatus()
29670                                            };
29671    
29672                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
29673                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
29674                                            args);
29675                            }
29676    
29677                            if ((journalArticleModelImpl.getColumnBitmask() &
29678                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
29679                                    Object[] args = new Object[] {
29680                                                    journalArticleModelImpl.getOriginalGroupId(),
29681                                                    journalArticleModelImpl.getOriginalClassNameId(),
29682                                                    journalArticleModelImpl.getOriginalClassPK()
29683                                            };
29684    
29685                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
29686                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
29687                                            args);
29688    
29689                                    args = new Object[] {
29690                                                    journalArticleModelImpl.getGroupId(),
29691                                                    journalArticleModelImpl.getClassNameId(),
29692                                                    journalArticleModelImpl.getClassPK()
29693                                            };
29694    
29695                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
29696                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
29697                                            args);
29698                            }
29699    
29700                            if ((journalArticleModelImpl.getColumnBitmask() &
29701                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_DDMTK.getColumnBitmask()) != 0) {
29702                                    Object[] args = new Object[] {
29703                                                    journalArticleModelImpl.getOriginalGroupId(),
29704                                                    journalArticleModelImpl.getOriginalClassNameId(),
29705                                                    journalArticleModelImpl.getOriginalDDMTemplateKey()
29706                                            };
29707    
29708                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_DDMTK,
29709                                            args);
29710                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_DDMTK,
29711                                            args);
29712    
29713                                    args = new Object[] {
29714                                                    journalArticleModelImpl.getGroupId(),
29715                                                    journalArticleModelImpl.getClassNameId(),
29716                                                    journalArticleModelImpl.getDDMTemplateKey()
29717                                            };
29718    
29719                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_DDMTK,
29720                                            args);
29721                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_DDMTK,
29722                                            args);
29723                            }
29724    
29725                            if ((journalArticleModelImpl.getColumnBitmask() &
29726                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
29727                                    Object[] args = new Object[] {
29728                                                    journalArticleModelImpl.getOriginalGroupId(),
29729                                                    journalArticleModelImpl.getOriginalClassNameId(),
29730                                                    journalArticleModelImpl.getOriginalLayoutUuid()
29731                                            };
29732    
29733                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
29734                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
29735                                            args);
29736    
29737                                    args = new Object[] {
29738                                                    journalArticleModelImpl.getGroupId(),
29739                                                    journalArticleModelImpl.getClassNameId(),
29740                                                    journalArticleModelImpl.getLayoutUuid()
29741                                            };
29742    
29743                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
29744                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
29745                                            args);
29746                            }
29747    
29748                            if ((journalArticleModelImpl.getColumnBitmask() &
29749                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
29750                                    Object[] args = new Object[] {
29751                                                    journalArticleModelImpl.getOriginalGroupId(),
29752                                                    journalArticleModelImpl.getOriginalArticleId(),
29753                                                    journalArticleModelImpl.getOriginalStatus()
29754                                            };
29755    
29756                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
29757                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
29758                                            args);
29759    
29760                                    args = new Object[] {
29761                                                    journalArticleModelImpl.getGroupId(),
29762                                                    journalArticleModelImpl.getArticleId(),
29763                                                    journalArticleModelImpl.getStatus()
29764                                            };
29765    
29766                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
29767                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
29768                                            args);
29769                            }
29770    
29771                            if ((journalArticleModelImpl.getColumnBitmask() &
29772                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
29773                                    Object[] args = new Object[] {
29774                                                    journalArticleModelImpl.getOriginalGroupId(),
29775                                                    journalArticleModelImpl.getOriginalUrlTitle(),
29776                                                    journalArticleModelImpl.getOriginalStatus()
29777                                            };
29778    
29779                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
29780                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
29781                                            args);
29782    
29783                                    args = new Object[] {
29784                                                    journalArticleModelImpl.getGroupId(),
29785                                                    journalArticleModelImpl.getUrlTitle(),
29786                                                    journalArticleModelImpl.getStatus()
29787                                            };
29788    
29789                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
29790                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
29791                                            args);
29792                            }
29793    
29794                            if ((journalArticleModelImpl.getColumnBitmask() &
29795                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
29796                                    Object[] args = new Object[] {
29797                                                    journalArticleModelImpl.getOriginalCompanyId(),
29798                                                    journalArticleModelImpl.getOriginalVersion(),
29799                                                    journalArticleModelImpl.getOriginalStatus()
29800                                            };
29801    
29802                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
29803                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
29804                                            args);
29805    
29806                                    args = new Object[] {
29807                                                    journalArticleModelImpl.getCompanyId(),
29808                                                    journalArticleModelImpl.getVersion(),
29809                                                    journalArticleModelImpl.getStatus()
29810                                            };
29811    
29812                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
29813                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
29814                                            args);
29815                            }
29816                    }
29817    
29818                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29819                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
29820                            journalArticle, false);
29821    
29822                    clearUniqueFindersCache(journalArticle);
29823                    cacheUniqueFindersCache(journalArticle);
29824    
29825                    journalArticle.resetOriginalValues();
29826    
29827                    return journalArticle;
29828            }
29829    
29830            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
29831                    if (journalArticle instanceof JournalArticleImpl) {
29832                            return journalArticle;
29833                    }
29834    
29835                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
29836    
29837                    journalArticleImpl.setNew(journalArticle.isNew());
29838                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
29839    
29840                    journalArticleImpl.setUuid(journalArticle.getUuid());
29841                    journalArticleImpl.setId(journalArticle.getId());
29842                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
29843                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
29844                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
29845                    journalArticleImpl.setUserId(journalArticle.getUserId());
29846                    journalArticleImpl.setUserName(journalArticle.getUserName());
29847                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
29848                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
29849                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
29850                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
29851                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
29852                    journalArticleImpl.setTreePath(journalArticle.getTreePath());
29853                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
29854                    journalArticleImpl.setVersion(journalArticle.getVersion());
29855                    journalArticleImpl.setTitle(journalArticle.getTitle());
29856                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
29857                    journalArticleImpl.setDescription(journalArticle.getDescription());
29858                    journalArticleImpl.setContent(journalArticle.getContent());
29859                    journalArticleImpl.setDDMStructureKey(journalArticle.getDDMStructureKey());
29860                    journalArticleImpl.setDDMTemplateKey(journalArticle.getDDMTemplateKey());
29861                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
29862                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
29863                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
29864                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
29865                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
29866                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
29867                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
29868                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
29869                    journalArticleImpl.setStatus(journalArticle.getStatus());
29870                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
29871                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
29872                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
29873    
29874                    return journalArticleImpl;
29875            }
29876    
29877            /**
29878             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
29879             *
29880             * @param primaryKey the primary key of the journal article
29881             * @return the journal article
29882             * @throws NoSuchArticleException if a journal article with the primary key could not be found
29883             */
29884            @Override
29885            public JournalArticle findByPrimaryKey(Serializable primaryKey)
29886                    throws NoSuchArticleException {
29887                    JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
29888    
29889                    if (journalArticle == null) {
29890                            if (_log.isWarnEnabled()) {
29891                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
29892                            }
29893    
29894                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
29895                                    primaryKey);
29896                    }
29897    
29898                    return journalArticle;
29899            }
29900    
29901            /**
29902             * Returns the journal article with the primary key or throws a {@link NoSuchArticleException} if it could not be found.
29903             *
29904             * @param id the primary key of the journal article
29905             * @return the journal article
29906             * @throws NoSuchArticleException if a journal article with the primary key could not be found
29907             */
29908            @Override
29909            public JournalArticle findByPrimaryKey(long id)
29910                    throws NoSuchArticleException {
29911                    return findByPrimaryKey((Serializable)id);
29912            }
29913    
29914            /**
29915             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
29916             *
29917             * @param primaryKey the primary key of the journal article
29918             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
29919             */
29920            @Override
29921            public JournalArticle fetchByPrimaryKey(Serializable primaryKey) {
29922                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29923                                    JournalArticleImpl.class, primaryKey);
29924    
29925                    if (journalArticle == _nullJournalArticle) {
29926                            return null;
29927                    }
29928    
29929                    if (journalArticle == null) {
29930                            Session session = null;
29931    
29932                            try {
29933                                    session = openSession();
29934    
29935                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
29936                                                    primaryKey);
29937    
29938                                    if (journalArticle != null) {
29939                                            cacheResult(journalArticle);
29940                                    }
29941                                    else {
29942                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29943                                                    JournalArticleImpl.class, primaryKey,
29944                                                    _nullJournalArticle);
29945                                    }
29946                            }
29947                            catch (Exception e) {
29948                                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29949                                            JournalArticleImpl.class, primaryKey);
29950    
29951                                    throw processException(e);
29952                            }
29953                            finally {
29954                                    closeSession(session);
29955                            }
29956                    }
29957    
29958                    return journalArticle;
29959            }
29960    
29961            /**
29962             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
29963             *
29964             * @param id the primary key of the journal article
29965             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
29966             */
29967            @Override
29968            public JournalArticle fetchByPrimaryKey(long id) {
29969                    return fetchByPrimaryKey((Serializable)id);
29970            }
29971    
29972            @Override
29973            public Map<Serializable, JournalArticle> fetchByPrimaryKeys(
29974                    Set<Serializable> primaryKeys) {
29975                    if (primaryKeys.isEmpty()) {
29976                            return Collections.emptyMap();
29977                    }
29978    
29979                    Map<Serializable, JournalArticle> map = new HashMap<Serializable, JournalArticle>();
29980    
29981                    if (primaryKeys.size() == 1) {
29982                            Iterator<Serializable> iterator = primaryKeys.iterator();
29983    
29984                            Serializable primaryKey = iterator.next();
29985    
29986                            JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);
29987    
29988                            if (journalArticle != null) {
29989                                    map.put(primaryKey, journalArticle);
29990                            }
29991    
29992                            return map;
29993                    }
29994    
29995                    Set<Serializable> uncachedPrimaryKeys = null;
29996    
29997                    for (Serializable primaryKey : primaryKeys) {
29998                            JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
29999                                            JournalArticleImpl.class, primaryKey);
30000    
30001                            if (journalArticle == null) {
30002                                    if (uncachedPrimaryKeys == null) {
30003                                            uncachedPrimaryKeys = new HashSet<Serializable>();
30004                                    }
30005    
30006                                    uncachedPrimaryKeys.add(primaryKey);
30007                            }
30008                            else {
30009                                    map.put(primaryKey, journalArticle);
30010                            }
30011                    }
30012    
30013                    if (uncachedPrimaryKeys == null) {
30014                            return map;
30015                    }
30016    
30017                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
30018                                    1);
30019    
30020                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE_PKS_IN);
30021    
30022                    for (Serializable primaryKey : uncachedPrimaryKeys) {
30023                            query.append(String.valueOf(primaryKey));
30024    
30025                            query.append(StringPool.COMMA);
30026                    }
30027    
30028                    query.setIndex(query.index() - 1);
30029    
30030                    query.append(StringPool.CLOSE_PARENTHESIS);
30031    
30032                    String sql = query.toString();
30033    
30034                    Session session = null;
30035    
30036                    try {
30037                            session = openSession();
30038    
30039                            Query q = session.createQuery(sql);
30040    
30041                            for (JournalArticle journalArticle : (List<JournalArticle>)q.list()) {
30042                                    map.put(journalArticle.getPrimaryKeyObj(), journalArticle);
30043    
30044                                    cacheResult(journalArticle);
30045    
30046                                    uncachedPrimaryKeys.remove(journalArticle.getPrimaryKeyObj());
30047                            }
30048    
30049                            for (Serializable primaryKey : uncachedPrimaryKeys) {
30050                                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
30051                                            JournalArticleImpl.class, primaryKey, _nullJournalArticle);
30052                            }
30053                    }
30054                    catch (Exception e) {
30055                            throw processException(e);
30056                    }
30057                    finally {
30058                            closeSession(session);
30059                    }
30060    
30061                    return map;
30062            }
30063    
30064            /**
30065             * Returns all the journal articles.
30066             *
30067             * @return the journal articles
30068             */
30069            @Override
30070            public List<JournalArticle> findAll() {
30071                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
30072            }
30073    
30074            /**
30075             * Returns a range of all the journal articles.
30076             *
30077             * <p>
30078             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
30079             * </p>
30080             *
30081             * @param start the lower bound of the range of journal articles
30082             * @param end the upper bound of the range of journal articles (not inclusive)
30083             * @return the range of journal articles
30084             */
30085            @Override
30086            public List<JournalArticle> findAll(int start, int end) {
30087                    return findAll(start, end, null);
30088            }
30089    
30090            /**
30091             * Returns an ordered range of all the journal articles.
30092             *
30093             * <p>
30094             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link JournalArticleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
30095             * </p>
30096             *
30097             * @param start the lower bound of the range of journal articles
30098             * @param end the upper bound of the range of journal articles (not inclusive)
30099             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
30100             * @return the ordered range of journal articles
30101             */
30102            @Override
30103            public List<JournalArticle> findAll(int start, int end,
30104                    OrderByComparator<JournalArticle> orderByComparator) {
30105                    boolean pagination = true;
30106                    FinderPath finderPath = null;
30107                    Object[] finderArgs = null;
30108    
30109                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
30110                                    (orderByComparator == null)) {
30111                            pagination = false;
30112                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
30113                            finderArgs = FINDER_ARGS_EMPTY;
30114                    }
30115                    else {
30116                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
30117                            finderArgs = new Object[] { start, end, orderByComparator };
30118                    }
30119    
30120                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
30121                                    finderArgs, this);
30122    
30123                    if (list == null) {
30124                            StringBundler query = null;
30125                            String sql = null;
30126    
30127                            if (orderByComparator != null) {
30128                                    query = new StringBundler(2 +
30129                                                    (orderByComparator.getOrderByFields().length * 3));
30130    
30131                                    query.append(_SQL_SELECT_JOURNALARTICLE);
30132    
30133                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
30134                                            orderByComparator);
30135    
30136                                    sql = query.toString();
30137                            }
30138                            else {
30139                                    sql = _SQL_SELECT_JOURNALARTICLE;
30140    
30141                                    if (pagination) {
30142                                            sql = sql.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
30143                                    }
30144                            }
30145    
30146                            Session session = null;
30147    
30148                            try {
30149                                    session = openSession();
30150    
30151                                    Query q = session.createQuery(sql);
30152    
30153                                    if (!pagination) {
30154                                            list = (List<JournalArticle>)QueryUtil.list(q,
30155                                                            getDialect(), start, end, false);
30156    
30157                                            Collections.sort(list);
30158    
30159                                            list = Collections.unmodifiableList(list);
30160                                    }
30161                                    else {
30162                                            list = (List<JournalArticle>)QueryUtil.list(q,
30163                                                            getDialect(), start, end);
30164                                    }
30165    
30166                                    cacheResult(list);
30167    
30168                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
30169                            }
30170                            catch (Exception e) {
30171                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
30172    
30173                                    throw processException(e);
30174                            }
30175                            finally {
30176                                    closeSession(session);
30177                            }
30178                    }
30179    
30180                    return list;
30181            }
30182    
30183            /**
30184             * Removes all the journal articles from the database.
30185             *
30186             */
30187            @Override
30188            public void removeAll() {
30189                    for (JournalArticle journalArticle : findAll()) {
30190                            remove(journalArticle);
30191                    }
30192            }
30193    
30194            /**
30195             * Returns the number of journal articles.
30196             *
30197             * @return the number of journal articles
30198             */
30199            @Override
30200            public int countAll() {
30201                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
30202                                    FINDER_ARGS_EMPTY, this);
30203    
30204                    if (count == null) {
30205                            Session session = null;
30206    
30207                            try {
30208                                    session = openSession();
30209    
30210                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
30211    
30212                                    count = (Long)q.uniqueResult();
30213    
30214                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
30215                                            FINDER_ARGS_EMPTY, count);
30216                            }
30217                            catch (Exception e) {
30218                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
30219                                            FINDER_ARGS_EMPTY);
30220    
30221                                    throw processException(e);
30222                            }
30223                            finally {
30224                                    closeSession(session);
30225                            }
30226                    }
30227    
30228                    return count.intValue();
30229            }
30230    
30231            @Override
30232            protected Set<String> getBadColumnNames() {
30233                    return _badColumnNames;
30234            }
30235    
30236            /**
30237             * Initializes the journal article persistence.
30238             */
30239            public void afterPropertiesSet() {
30240            }
30241    
30242            public void destroy() {
30243                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
30244                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
30245                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
30246                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
30247            }
30248    
30249            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
30250            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE_PKS_IN = "SELECT journalArticle FROM JournalArticle journalArticle WHERE id_ IN (";
30251            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
30252            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
30253            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
30254            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
30255            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
30256            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
30257                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
30258            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
30259                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
30260            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
30261            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
30262            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
30263            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
30264            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
30265            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
30266            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
30267            private static final Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
30268            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
30269                                    "uuid", "id"
30270                            });
30271            private static final JournalArticle _nullJournalArticle = new JournalArticleImpl() {
30272                            @Override
30273                            public Object clone() {
30274                                    return this;
30275                            }
30276    
30277                            @Override
30278                            public CacheModel<JournalArticle> toCacheModel() {
30279                                    return _nullJournalArticleCacheModel;
30280                            }
30281                    };
30282    
30283            private static final CacheModel<JournalArticle> _nullJournalArticleCacheModel =
30284                    new CacheModel<JournalArticle>() {
30285                            @Override
30286                            public JournalArticle toEntityModel() {
30287                                    return _nullJournalArticle;
30288                            }
30289                    };
30290    }