001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041    import com.liferay.portal.service.persistence.BatchSessionUtil;
042    import com.liferay.portal.service.persistence.CompanyPersistence;
043    import com.liferay.portal.service.persistence.GroupPersistence;
044    import com.liferay.portal.service.persistence.ImagePersistence;
045    import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
046    import com.liferay.portal.service.persistence.ResourcePersistence;
047    import com.liferay.portal.service.persistence.SubscriptionPersistence;
048    import com.liferay.portal.service.persistence.UserPersistence;
049    import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
050    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
051    
052    import com.liferay.portlet.asset.service.persistence.AssetCategoryPersistence;
053    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
054    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
055    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
056    import com.liferay.portlet.journal.NoSuchArticleException;
057    import com.liferay.portlet.journal.model.JournalArticle;
058    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
059    import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
060    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
061    import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
062    
063    import java.io.Serializable;
064    
065    import java.util.ArrayList;
066    import java.util.Collections;
067    import java.util.List;
068    
069    /**
070     * The persistence for the journal article service.
071     *
072     * <p>
073     * Never modify this class directly. Modify <code>service.xml</code> and rerun ServiceBuilder to regnerate this class.
074     * </p>
075     *
076     * <p>
077     * Caching information and settings can be found in <code>portal.properties</code>
078     * </p>
079     *
080     * @author Brian Wing Shun Chan
081     * @see JournalArticlePersistence
082     * @see JournalArticleUtil
083     * @generated
084     */
085    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
086            implements JournalArticlePersistence {
087            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
088            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
089                    ".List";
090            public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
091                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
092                            FINDER_CLASS_NAME_LIST, "findByUuid",
093                            new String[] {
094                                    String.class.getName(),
095                                    
096                            "java.lang.Integer", "java.lang.Integer",
097                                    "com.liferay.portal.kernel.util.OrderByComparator"
098                            });
099            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
100                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
101                            FINDER_CLASS_NAME_LIST, "countByUuid",
102                            new String[] { String.class.getName() });
103            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
104                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
105                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
106                            new String[] { String.class.getName(), Long.class.getName() });
107            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
108                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
109                            FINDER_CLASS_NAME_LIST, "countByUUID_G",
110                            new String[] { String.class.getName(), Long.class.getName() });
111            public static final FinderPath FINDER_PATH_FIND_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
112                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
113                            FINDER_CLASS_NAME_LIST, "findByResourcePrimKey",
114                            new String[] {
115                                    Long.class.getName(),
116                                    
117                            "java.lang.Integer", "java.lang.Integer",
118                                    "com.liferay.portal.kernel.util.OrderByComparator"
119                            });
120            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
121                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
122                            FINDER_CLASS_NAME_LIST, "countByResourcePrimKey",
123                            new String[] { Long.class.getName() });
124            public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
125                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
126                            FINDER_CLASS_NAME_LIST, "findByGroupId",
127                            new String[] {
128                                    Long.class.getName(),
129                                    
130                            "java.lang.Integer", "java.lang.Integer",
131                                    "com.liferay.portal.kernel.util.OrderByComparator"
132                            });
133            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
134                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
135                            FINDER_CLASS_NAME_LIST, "countByGroupId",
136                            new String[] { Long.class.getName() });
137            public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
138                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
139                            FINDER_CLASS_NAME_LIST, "findByCompanyId",
140                            new String[] {
141                                    Long.class.getName(),
142                                    
143                            "java.lang.Integer", "java.lang.Integer",
144                                    "com.liferay.portal.kernel.util.OrderByComparator"
145                            });
146            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
147                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
148                            FINDER_CLASS_NAME_LIST, "countByCompanyId",
149                            new String[] { Long.class.getName() });
150            public static final FinderPath FINDER_PATH_FIND_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
151                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
152                            FINDER_CLASS_NAME_LIST, "findBySmallImageId",
153                            new String[] {
154                                    Long.class.getName(),
155                                    
156                            "java.lang.Integer", "java.lang.Integer",
157                                    "com.liferay.portal.kernel.util.OrderByComparator"
158                            });
159            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
160                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
161                            FINDER_CLASS_NAME_LIST, "countBySmallImageId",
162                            new String[] { Long.class.getName() });
163            public static final FinderPath FINDER_PATH_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
164                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
165                            FINDER_CLASS_NAME_LIST, "findByR_ST",
166                            new String[] {
167                                    Long.class.getName(), Integer.class.getName(),
168                                    
169                            "java.lang.Integer", "java.lang.Integer",
170                                    "com.liferay.portal.kernel.util.OrderByComparator"
171                            });
172            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
173                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
174                            FINDER_CLASS_NAME_LIST, "countByR_ST",
175                            new String[] { Long.class.getName(), Integer.class.getName() });
176            public static final FinderPath FINDER_PATH_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
177                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
178                            FINDER_CLASS_NAME_LIST, "findByG_A",
179                            new String[] {
180                                    Long.class.getName(), String.class.getName(),
181                                    
182                            "java.lang.Integer", "java.lang.Integer",
183                                    "com.liferay.portal.kernel.util.OrderByComparator"
184                            });
185            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
186                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
187                            FINDER_CLASS_NAME_LIST, "countByG_A",
188                            new String[] { Long.class.getName(), String.class.getName() });
189            public static final FinderPath FINDER_PATH_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
190                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
191                            FINDER_CLASS_NAME_LIST, "findByG_S",
192                            new String[] {
193                                    Long.class.getName(), String.class.getName(),
194                                    
195                            "java.lang.Integer", "java.lang.Integer",
196                                    "com.liferay.portal.kernel.util.OrderByComparator"
197                            });
198            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
199                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
200                            FINDER_CLASS_NAME_LIST, "countByG_S",
201                            new String[] { Long.class.getName(), String.class.getName() });
202            public static final FinderPath FINDER_PATH_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
203                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
204                            FINDER_CLASS_NAME_LIST, "findByG_T",
205                            new String[] {
206                                    Long.class.getName(), String.class.getName(),
207                                    
208                            "java.lang.Integer", "java.lang.Integer",
209                                    "com.liferay.portal.kernel.util.OrderByComparator"
210                            });
211            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
212                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
213                            FINDER_CLASS_NAME_LIST, "countByG_T",
214                            new String[] { Long.class.getName(), String.class.getName() });
215            public static final FinderPath FINDER_PATH_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
216                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
217                            FINDER_CLASS_NAME_LIST, "findByG_UT",
218                            new String[] {
219                                    Long.class.getName(), String.class.getName(),
220                                    
221                            "java.lang.Integer", "java.lang.Integer",
222                                    "com.liferay.portal.kernel.util.OrderByComparator"
223                            });
224            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
225                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
226                            FINDER_CLASS_NAME_LIST, "countByG_UT",
227                            new String[] { Long.class.getName(), String.class.getName() });
228            public static final FinderPath FINDER_PATH_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
229                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
230                            FINDER_CLASS_NAME_LIST, "findByG_ST",
231                            new String[] {
232                                    Long.class.getName(), Integer.class.getName(),
233                                    
234                            "java.lang.Integer", "java.lang.Integer",
235                                    "com.liferay.portal.kernel.util.OrderByComparator"
236                            });
237            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
238                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
239                            FINDER_CLASS_NAME_LIST, "countByG_ST",
240                            new String[] { Long.class.getName(), Integer.class.getName() });
241            public static final FinderPath FINDER_PATH_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
242                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
243                            FINDER_CLASS_NAME_LIST, "findByC_ST",
244                            new String[] {
245                                    Long.class.getName(), Integer.class.getName(),
246                                    
247                            "java.lang.Integer", "java.lang.Integer",
248                                    "com.liferay.portal.kernel.util.OrderByComparator"
249                            });
250            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
251                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
252                            FINDER_CLASS_NAME_LIST, "countByC_ST",
253                            new String[] { Long.class.getName(), Integer.class.getName() });
254            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
255                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
256                            FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
257                            new String[] {
258                                    Long.class.getName(), String.class.getName(),
259                                    Double.class.getName()
260                            });
261            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
262                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
263                            FINDER_CLASS_NAME_LIST, "countByG_A_V",
264                            new String[] {
265                                    Long.class.getName(), String.class.getName(),
266                                    Double.class.getName()
267                            });
268            public static final FinderPath FINDER_PATH_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
269                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
270                            FINDER_CLASS_NAME_LIST, "findByG_A_ST",
271                            new String[] {
272                                    Long.class.getName(), String.class.getName(),
273                                    Integer.class.getName(),
274                                    
275                            "java.lang.Integer", "java.lang.Integer",
276                                    "com.liferay.portal.kernel.util.OrderByComparator"
277                            });
278            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
279                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
280                            FINDER_CLASS_NAME_LIST, "countByG_A_ST",
281                            new String[] {
282                                    Long.class.getName(), String.class.getName(),
283                                    Integer.class.getName()
284                            });
285            public static final FinderPath FINDER_PATH_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
286                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
287                            FINDER_CLASS_NAME_LIST, "findByG_UT_ST",
288                            new String[] {
289                                    Long.class.getName(), String.class.getName(),
290                                    Integer.class.getName(),
291                                    
292                            "java.lang.Integer", "java.lang.Integer",
293                                    "com.liferay.portal.kernel.util.OrderByComparator"
294                            });
295            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
296                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
297                            FINDER_CLASS_NAME_LIST, "countByG_UT_ST",
298                            new String[] {
299                                    Long.class.getName(), String.class.getName(),
300                                    Integer.class.getName()
301                            });
302            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
303                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
304                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
305            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
306                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
307                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
308    
309            /**
310             * Caches the journal article in the entity cache if it is enabled.
311             *
312             * @param journalArticle the journal article to cache
313             */
314            public void cacheResult(JournalArticle journalArticle) {
315                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
316                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
317                            journalArticle);
318    
319                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
320                            new Object[] {
321                                    journalArticle.getUuid(), new Long(journalArticle.getGroupId())
322                            }, journalArticle);
323    
324                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
325                            new Object[] {
326                                    new Long(journalArticle.getGroupId()),
327                                    
328                            journalArticle.getArticleId(),
329                                    new Double(journalArticle.getVersion())
330                            }, journalArticle);
331            }
332    
333            /**
334             * Caches the journal articles in the entity cache if it is enabled.
335             *
336             * @param journalArticles the journal articles to cache
337             */
338            public void cacheResult(List<JournalArticle> journalArticles) {
339                    for (JournalArticle journalArticle : journalArticles) {
340                            if (EntityCacheUtil.getResult(
341                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
342                                                    JournalArticleImpl.class,
343                                                    journalArticle.getPrimaryKey(), this) == null) {
344                                    cacheResult(journalArticle);
345                            }
346                    }
347            }
348    
349            /**
350             * Clears the cache for all journal articles.
351             *
352             * <p>
353             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
354             * </p>
355             */
356            public void clearCache() {
357                    CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
358                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
359                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
360                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
361            }
362    
363            /**
364             * Clears the cache for the journal article.
365             *
366             * <p>
367             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
368             * </p>
369             */
370            public void clearCache(JournalArticle journalArticle) {
371                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
372                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
373    
374                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
375                            new Object[] {
376                                    journalArticle.getUuid(), new Long(journalArticle.getGroupId())
377                            });
378    
379                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
380                            new Object[] {
381                                    new Long(journalArticle.getGroupId()),
382                                    
383                            journalArticle.getArticleId(),
384                                    new Double(journalArticle.getVersion())
385                            });
386            }
387    
388            /**
389             * Creates a new journal article with the primary key.
390             *
391             * @param id the primary key for the new journal article
392             * @return the new journal article
393             */
394            public JournalArticle create(long id) {
395                    JournalArticle journalArticle = new JournalArticleImpl();
396    
397                    journalArticle.setNew(true);
398                    journalArticle.setPrimaryKey(id);
399    
400                    String uuid = PortalUUIDUtil.generate();
401    
402                    journalArticle.setUuid(uuid);
403    
404                    return journalArticle;
405            }
406    
407            /**
408             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
409             *
410             * @param primaryKey the primary key of the journal article to remove
411             * @return the journal article that was removed
412             * @throws com.liferay.portal.NoSuchModelException if a journal article with the primary key could not be found
413             * @throws SystemException if a system exception occurred
414             */
415            public JournalArticle remove(Serializable primaryKey)
416                    throws NoSuchModelException, SystemException {
417                    return remove(((Long)primaryKey).longValue());
418            }
419    
420            /**
421             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
422             *
423             * @param id the primary key of the journal article to remove
424             * @return the journal article that was removed
425             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
426             * @throws SystemException if a system exception occurred
427             */
428            public JournalArticle remove(long id)
429                    throws NoSuchArticleException, SystemException {
430                    Session session = null;
431    
432                    try {
433                            session = openSession();
434    
435                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
436                                            new Long(id));
437    
438                            if (journalArticle == null) {
439                                    if (_log.isWarnEnabled()) {
440                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
441                                    }
442    
443                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
444                                            id);
445                            }
446    
447                            return remove(journalArticle);
448                    }
449                    catch (NoSuchArticleException nsee) {
450                            throw nsee;
451                    }
452                    catch (Exception e) {
453                            throw processException(e);
454                    }
455                    finally {
456                            closeSession(session);
457                    }
458            }
459    
460            protected JournalArticle removeImpl(JournalArticle journalArticle)
461                    throws SystemException {
462                    journalArticle = toUnwrappedModel(journalArticle);
463    
464                    Session session = null;
465    
466                    try {
467                            session = openSession();
468    
469                            if (journalArticle.isCachedModel() || BatchSessionUtil.isEnabled()) {
470                                    Object staleObject = session.get(JournalArticleImpl.class,
471                                                    journalArticle.getPrimaryKeyObj());
472    
473                                    if (staleObject != null) {
474                                            session.evict(staleObject);
475                                    }
476                            }
477    
478                            session.delete(journalArticle);
479    
480                            session.flush();
481                    }
482                    catch (Exception e) {
483                            throw processException(e);
484                    }
485                    finally {
486                            closeSession(session);
487                    }
488    
489                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
490    
491                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
492    
493                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
494                            new Object[] {
495                                    journalArticleModelImpl.getOriginalUuid(),
496                                    new Long(journalArticleModelImpl.getOriginalGroupId())
497                            });
498    
499                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
500                            new Object[] {
501                                    new Long(journalArticleModelImpl.getOriginalGroupId()),
502                                    
503                            journalArticleModelImpl.getOriginalArticleId(),
504                                    new Double(journalArticleModelImpl.getOriginalVersion())
505                            });
506    
507                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
508                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
509    
510                    return journalArticle;
511            }
512    
513            public JournalArticle updateImpl(
514                    com.liferay.portlet.journal.model.JournalArticle journalArticle,
515                    boolean merge) throws SystemException {
516                    journalArticle = toUnwrappedModel(journalArticle);
517    
518                    boolean isNew = journalArticle.isNew();
519    
520                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
521    
522                    if (Validator.isNull(journalArticle.getUuid())) {
523                            String uuid = PortalUUIDUtil.generate();
524    
525                            journalArticle.setUuid(uuid);
526                    }
527    
528                    Session session = null;
529    
530                    try {
531                            session = openSession();
532    
533                            BatchSessionUtil.update(session, journalArticle, merge);
534    
535                            journalArticle.setNew(false);
536                    }
537                    catch (Exception e) {
538                            throw processException(e);
539                    }
540                    finally {
541                            closeSession(session);
542                    }
543    
544                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
545    
546                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
547                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
548                            journalArticle);
549    
550                    if (!isNew &&
551                                    (!Validator.equals(journalArticle.getUuid(),
552                                            journalArticleModelImpl.getOriginalUuid()) ||
553                                    (journalArticle.getGroupId() != journalArticleModelImpl.getOriginalGroupId()))) {
554                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
555                                    new Object[] {
556                                            journalArticleModelImpl.getOriginalUuid(),
557                                            new Long(journalArticleModelImpl.getOriginalGroupId())
558                                    });
559                    }
560    
561                    if (isNew ||
562                                    (!Validator.equals(journalArticle.getUuid(),
563                                            journalArticleModelImpl.getOriginalUuid()) ||
564                                    (journalArticle.getGroupId() != journalArticleModelImpl.getOriginalGroupId()))) {
565                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
566                                    new Object[] {
567                                            journalArticle.getUuid(),
568                                            new Long(journalArticle.getGroupId())
569                                    }, journalArticle);
570                    }
571    
572                    if (!isNew &&
573                                    ((journalArticle.getGroupId() != journalArticleModelImpl.getOriginalGroupId()) ||
574                                    !Validator.equals(journalArticle.getArticleId(),
575                                            journalArticleModelImpl.getOriginalArticleId()) ||
576                                    (journalArticle.getVersion() != journalArticleModelImpl.getOriginalVersion()))) {
577                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
578                                    new Object[] {
579                                            new Long(journalArticleModelImpl.getOriginalGroupId()),
580                                            
581                                    journalArticleModelImpl.getOriginalArticleId(),
582                                            new Double(journalArticleModelImpl.getOriginalVersion())
583                                    });
584                    }
585    
586                    if (isNew ||
587                                    ((journalArticle.getGroupId() != journalArticleModelImpl.getOriginalGroupId()) ||
588                                    !Validator.equals(journalArticle.getArticleId(),
589                                            journalArticleModelImpl.getOriginalArticleId()) ||
590                                    (journalArticle.getVersion() != journalArticleModelImpl.getOriginalVersion()))) {
591                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
592                                    new Object[] {
593                                            new Long(journalArticle.getGroupId()),
594                                            
595                                    journalArticle.getArticleId(),
596                                            new Double(journalArticle.getVersion())
597                                    }, journalArticle);
598                    }
599    
600                    return journalArticle;
601            }
602    
603            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
604                    if (journalArticle instanceof JournalArticleImpl) {
605                            return journalArticle;
606                    }
607    
608                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
609    
610                    journalArticleImpl.setNew(journalArticle.isNew());
611                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
612    
613                    journalArticleImpl.setUuid(journalArticle.getUuid());
614                    journalArticleImpl.setId(journalArticle.getId());
615                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
616                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
617                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
618                    journalArticleImpl.setUserId(journalArticle.getUserId());
619                    journalArticleImpl.setUserName(journalArticle.getUserName());
620                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
621                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
622                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
623                    journalArticleImpl.setVersion(journalArticle.getVersion());
624                    journalArticleImpl.setTitle(journalArticle.getTitle());
625                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
626                    journalArticleImpl.setDescription(journalArticle.getDescription());
627                    journalArticleImpl.setContent(journalArticle.getContent());
628                    journalArticleImpl.setType(journalArticle.getType());
629                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
630                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
631                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
632                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
633                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
634                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
635                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
636                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
637                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
638                    journalArticleImpl.setStatus(journalArticle.getStatus());
639                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
640                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
641                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
642    
643                    return journalArticleImpl;
644            }
645    
646            /**
647             * Finds the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
648             *
649             * @param primaryKey the primary key of the journal article to find
650             * @return the journal article
651             * @throws com.liferay.portal.NoSuchModelException if a journal article with the primary key could not be found
652             * @throws SystemException if a system exception occurred
653             */
654            public JournalArticle findByPrimaryKey(Serializable primaryKey)
655                    throws NoSuchModelException, SystemException {
656                    return findByPrimaryKey(((Long)primaryKey).longValue());
657            }
658    
659            /**
660             * Finds the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
661             *
662             * @param id the primary key of the journal article to find
663             * @return the journal article
664             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
665             * @throws SystemException if a system exception occurred
666             */
667            public JournalArticle findByPrimaryKey(long id)
668                    throws NoSuchArticleException, SystemException {
669                    JournalArticle journalArticle = fetchByPrimaryKey(id);
670    
671                    if (journalArticle == null) {
672                            if (_log.isWarnEnabled()) {
673                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
674                            }
675    
676                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
677                                    id);
678                    }
679    
680                    return journalArticle;
681            }
682    
683            /**
684             * Finds the journal article with the primary key or returns <code>null</code> if it could not be found.
685             *
686             * @param primaryKey the primary key of the journal article to find
687             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
688             * @throws SystemException if a system exception occurred
689             */
690            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
691                    throws SystemException {
692                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
693            }
694    
695            /**
696             * Finds the journal article with the primary key or returns <code>null</code> if it could not be found.
697             *
698             * @param id the primary key of the journal article to find
699             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
700             * @throws SystemException if a system exception occurred
701             */
702            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
703                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
704                                    JournalArticleImpl.class, id, this);
705    
706                    if (journalArticle == null) {
707                            Session session = null;
708    
709                            try {
710                                    session = openSession();
711    
712                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
713                                                    new Long(id));
714                            }
715                            catch (Exception e) {
716                                    throw processException(e);
717                            }
718                            finally {
719                                    if (journalArticle != null) {
720                                            cacheResult(journalArticle);
721                                    }
722    
723                                    closeSession(session);
724                            }
725                    }
726    
727                    return journalArticle;
728            }
729    
730            /**
731             * Finds all the journal articles where uuid = &#63;.
732             *
733             * @param uuid the uuid to search with
734             * @return the matching journal articles
735             * @throws SystemException if a system exception occurred
736             */
737            public List<JournalArticle> findByUuid(String uuid)
738                    throws SystemException {
739                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
740            }
741    
742            /**
743             * Finds a range of all the journal articles where uuid = &#63;.
744             *
745             * <p>
746             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
747             * </p>
748             *
749             * @param uuid the uuid to search with
750             * @param start the lower bound of the range of journal articles to return
751             * @param end the upper bound of the range of journal articles to return (not inclusive)
752             * @return the range of matching journal articles
753             * @throws SystemException if a system exception occurred
754             */
755            public List<JournalArticle> findByUuid(String uuid, int start, int end)
756                    throws SystemException {
757                    return findByUuid(uuid, start, end, null);
758            }
759    
760            /**
761             * Finds an ordered range of all the journal articles where uuid = &#63;.
762             *
763             * <p>
764             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
765             * </p>
766             *
767             * @param uuid the uuid to search with
768             * @param start the lower bound of the range of journal articles to return
769             * @param end the upper bound of the range of journal articles to return (not inclusive)
770             * @param orderByComparator the comparator to order the results by
771             * @return the ordered range of matching journal articles
772             * @throws SystemException if a system exception occurred
773             */
774            public List<JournalArticle> findByUuid(String uuid, int start, int end,
775                    OrderByComparator orderByComparator) throws SystemException {
776                    Object[] finderArgs = new Object[] {
777                                    uuid,
778                                    
779                                    String.valueOf(start), String.valueOf(end),
780                                    String.valueOf(orderByComparator)
781                            };
782    
783                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
784                                    finderArgs, this);
785    
786                    if (list == null) {
787                            Session session = null;
788    
789                            try {
790                                    session = openSession();
791    
792                                    StringBundler query = null;
793    
794                                    if (orderByComparator != null) {
795                                            query = new StringBundler(3 +
796                                                            (orderByComparator.getOrderByFields().length * 3));
797                                    }
798                                    else {
799                                            query = new StringBundler(3);
800                                    }
801    
802                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
803    
804                                    if (uuid == null) {
805                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
806                                    }
807                                    else {
808                                            if (uuid.equals(StringPool.BLANK)) {
809                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
810                                            }
811                                            else {
812                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
813                                            }
814                                    }
815    
816                                    if (orderByComparator != null) {
817                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
818                                                    orderByComparator);
819                                    }
820    
821                                    else {
822                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
823                                    }
824    
825                                    String sql = query.toString();
826    
827                                    Query q = session.createQuery(sql);
828    
829                                    QueryPos qPos = QueryPos.getInstance(q);
830    
831                                    if (uuid != null) {
832                                            qPos.add(uuid);
833                                    }
834    
835                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
836                                                    start, end);
837                            }
838                            catch (Exception e) {
839                                    throw processException(e);
840                            }
841                            finally {
842                                    if (list == null) {
843                                            list = new ArrayList<JournalArticle>();
844                                    }
845    
846                                    cacheResult(list);
847    
848                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
849                                            list);
850    
851                                    closeSession(session);
852                            }
853                    }
854    
855                    return list;
856            }
857    
858            /**
859             * Finds the first journal article in the ordered set where uuid = &#63;.
860             *
861             * <p>
862             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
863             * </p>
864             *
865             * @param uuid the uuid to search with
866             * @param orderByComparator the comparator to order the set by
867             * @return the first matching journal article
868             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
869             * @throws SystemException if a system exception occurred
870             */
871            public JournalArticle findByUuid_First(String uuid,
872                    OrderByComparator orderByComparator)
873                    throws NoSuchArticleException, SystemException {
874                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
875    
876                    if (list.isEmpty()) {
877                            StringBundler msg = new StringBundler(4);
878    
879                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
880    
881                            msg.append("uuid=");
882                            msg.append(uuid);
883    
884                            msg.append(StringPool.CLOSE_CURLY_BRACE);
885    
886                            throw new NoSuchArticleException(msg.toString());
887                    }
888                    else {
889                            return list.get(0);
890                    }
891            }
892    
893            /**
894             * Finds the last journal article in the ordered set where uuid = &#63;.
895             *
896             * <p>
897             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
898             * </p>
899             *
900             * @param uuid the uuid to search with
901             * @param orderByComparator the comparator to order the set by
902             * @return the last matching journal article
903             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
904             * @throws SystemException if a system exception occurred
905             */
906            public JournalArticle findByUuid_Last(String uuid,
907                    OrderByComparator orderByComparator)
908                    throws NoSuchArticleException, SystemException {
909                    int count = countByUuid(uuid);
910    
911                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
912                                    orderByComparator);
913    
914                    if (list.isEmpty()) {
915                            StringBundler msg = new StringBundler(4);
916    
917                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
918    
919                            msg.append("uuid=");
920                            msg.append(uuid);
921    
922                            msg.append(StringPool.CLOSE_CURLY_BRACE);
923    
924                            throw new NoSuchArticleException(msg.toString());
925                    }
926                    else {
927                            return list.get(0);
928                    }
929            }
930    
931            /**
932             * Finds the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
933             *
934             * <p>
935             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
936             * </p>
937             *
938             * @param id the primary key of the current journal article
939             * @param uuid the uuid to search with
940             * @param orderByComparator the comparator to order the set by
941             * @return the previous, current, and next journal article
942             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
943             * @throws SystemException if a system exception occurred
944             */
945            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
946                    OrderByComparator orderByComparator)
947                    throws NoSuchArticleException, SystemException {
948                    JournalArticle journalArticle = findByPrimaryKey(id);
949    
950                    Session session = null;
951    
952                    try {
953                            session = openSession();
954    
955                            JournalArticle[] array = new JournalArticleImpl[3];
956    
957                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
958                                            orderByComparator, true);
959    
960                            array[1] = journalArticle;
961    
962                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
963                                            orderByComparator, false);
964    
965                            return array;
966                    }
967                    catch (Exception e) {
968                            throw processException(e);
969                    }
970                    finally {
971                            closeSession(session);
972                    }
973            }
974    
975            protected JournalArticle getByUuid_PrevAndNext(Session session,
976                    JournalArticle journalArticle, String uuid,
977                    OrderByComparator orderByComparator, boolean previous) {
978                    StringBundler query = null;
979    
980                    if (orderByComparator != null) {
981                            query = new StringBundler(6 +
982                                            (orderByComparator.getOrderByFields().length * 6));
983                    }
984                    else {
985                            query = new StringBundler(3);
986                    }
987    
988                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
989    
990                    if (uuid == null) {
991                            query.append(_FINDER_COLUMN_UUID_UUID_1);
992                    }
993                    else {
994                            if (uuid.equals(StringPool.BLANK)) {
995                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
996                            }
997                            else {
998                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
999                            }
1000                    }
1001    
1002                    if (orderByComparator != null) {
1003                            String[] orderByFields = orderByComparator.getOrderByFields();
1004    
1005                            if (orderByFields.length > 0) {
1006                                    query.append(WHERE_AND);
1007                            }
1008    
1009                            for (int i = 0; i < orderByFields.length; i++) {
1010                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1011                                    query.append(orderByFields[i]);
1012    
1013                                    if ((i + 1) < orderByFields.length) {
1014                                            if (orderByComparator.isAscending() ^ previous) {
1015                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1016                                            }
1017                                            else {
1018                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1019                                            }
1020                                    }
1021                                    else {
1022                                            if (orderByComparator.isAscending() ^ previous) {
1023                                                    query.append(WHERE_GREATER_THAN);
1024                                            }
1025                                            else {
1026                                                    query.append(WHERE_LESSER_THAN);
1027                                            }
1028                                    }
1029                            }
1030    
1031                            query.append(ORDER_BY_CLAUSE);
1032    
1033                            for (int i = 0; i < orderByFields.length; i++) {
1034                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1035                                    query.append(orderByFields[i]);
1036    
1037                                    if ((i + 1) < orderByFields.length) {
1038                                            if (orderByComparator.isAscending() ^ previous) {
1039                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1040                                            }
1041                                            else {
1042                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1043                                            }
1044                                    }
1045                                    else {
1046                                            if (orderByComparator.isAscending() ^ previous) {
1047                                                    query.append(ORDER_BY_ASC);
1048                                            }
1049                                            else {
1050                                                    query.append(ORDER_BY_DESC);
1051                                            }
1052                                    }
1053                            }
1054                    }
1055    
1056                    else {
1057                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1058                    }
1059    
1060                    String sql = query.toString();
1061    
1062                    Query q = session.createQuery(sql);
1063    
1064                    q.setFirstResult(0);
1065                    q.setMaxResults(2);
1066    
1067                    QueryPos qPos = QueryPos.getInstance(q);
1068    
1069                    if (uuid != null) {
1070                            qPos.add(uuid);
1071                    }
1072    
1073                    if (orderByComparator != null) {
1074                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
1075    
1076                            for (Object value : values) {
1077                                    qPos.add(value);
1078                            }
1079                    }
1080    
1081                    List<JournalArticle> list = q.list();
1082    
1083                    if (list.size() == 2) {
1084                            return list.get(1);
1085                    }
1086                    else {
1087                            return null;
1088                    }
1089            }
1090    
1091            /**
1092             * Finds the journal article where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
1093             *
1094             * @param uuid the uuid to search with
1095             * @param groupId the group id to search with
1096             * @return the matching journal article
1097             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1098             * @throws SystemException if a system exception occurred
1099             */
1100            public JournalArticle findByUUID_G(String uuid, long groupId)
1101                    throws NoSuchArticleException, SystemException {
1102                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
1103    
1104                    if (journalArticle == null) {
1105                            StringBundler msg = new StringBundler(6);
1106    
1107                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1108    
1109                            msg.append("uuid=");
1110                            msg.append(uuid);
1111    
1112                            msg.append(", groupId=");
1113                            msg.append(groupId);
1114    
1115                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1116    
1117                            if (_log.isWarnEnabled()) {
1118                                    _log.warn(msg.toString());
1119                            }
1120    
1121                            throw new NoSuchArticleException(msg.toString());
1122                    }
1123    
1124                    return journalArticle;
1125            }
1126    
1127            /**
1128             * Finds the journal article where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1129             *
1130             * @param uuid the uuid to search with
1131             * @param groupId the group id to search with
1132             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
1133             * @throws SystemException if a system exception occurred
1134             */
1135            public JournalArticle fetchByUUID_G(String uuid, long groupId)
1136                    throws SystemException {
1137                    return fetchByUUID_G(uuid, groupId, true);
1138            }
1139    
1140            /**
1141             * Finds 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.
1142             *
1143             * @param uuid the uuid to search with
1144             * @param groupId the group id to search with
1145             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
1146             * @throws SystemException if a system exception occurred
1147             */
1148            public JournalArticle fetchByUUID_G(String uuid, long groupId,
1149                    boolean retrieveFromCache) throws SystemException {
1150                    Object[] finderArgs = new Object[] { uuid, groupId };
1151    
1152                    Object result = null;
1153    
1154                    if (retrieveFromCache) {
1155                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1156                                            finderArgs, this);
1157                    }
1158    
1159                    if (result == null) {
1160                            Session session = null;
1161    
1162                            try {
1163                                    session = openSession();
1164    
1165                                    StringBundler query = new StringBundler(4);
1166    
1167                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1168    
1169                                    if (uuid == null) {
1170                                            query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1171                                    }
1172                                    else {
1173                                            if (uuid.equals(StringPool.BLANK)) {
1174                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1175                                            }
1176                                            else {
1177                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1178                                            }
1179                                    }
1180    
1181                                    query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1182    
1183                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1184    
1185                                    String sql = query.toString();
1186    
1187                                    Query q = session.createQuery(sql);
1188    
1189                                    QueryPos qPos = QueryPos.getInstance(q);
1190    
1191                                    if (uuid != null) {
1192                                            qPos.add(uuid);
1193                                    }
1194    
1195                                    qPos.add(groupId);
1196    
1197                                    List<JournalArticle> list = q.list();
1198    
1199                                    result = list;
1200    
1201                                    JournalArticle journalArticle = null;
1202    
1203                                    if (list.isEmpty()) {
1204                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1205                                                    finderArgs, list);
1206                                    }
1207                                    else {
1208                                            journalArticle = list.get(0);
1209    
1210                                            cacheResult(journalArticle);
1211    
1212                                            if ((journalArticle.getUuid() == null) ||
1213                                                            !journalArticle.getUuid().equals(uuid) ||
1214                                                            (journalArticle.getGroupId() != groupId)) {
1215                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1216                                                            finderArgs, journalArticle);
1217                                            }
1218                                    }
1219    
1220                                    return journalArticle;
1221                            }
1222                            catch (Exception e) {
1223                                    throw processException(e);
1224                            }
1225                            finally {
1226                                    if (result == null) {
1227                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1228                                                    finderArgs, new ArrayList<JournalArticle>());
1229                                    }
1230    
1231                                    closeSession(session);
1232                            }
1233                    }
1234                    else {
1235                            if (result instanceof List<?>) {
1236                                    return null;
1237                            }
1238                            else {
1239                                    return (JournalArticle)result;
1240                            }
1241                    }
1242            }
1243    
1244            /**
1245             * Finds all the journal articles where resourcePrimKey = &#63;.
1246             *
1247             * @param resourcePrimKey the resource prim key to search with
1248             * @return the matching journal articles
1249             * @throws SystemException if a system exception occurred
1250             */
1251            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
1252                    throws SystemException {
1253                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
1254                            QueryUtil.ALL_POS, null);
1255            }
1256    
1257            /**
1258             * Finds a range of all the journal articles where resourcePrimKey = &#63;.
1259             *
1260             * <p>
1261             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1262             * </p>
1263             *
1264             * @param resourcePrimKey the resource prim key to search with
1265             * @param start the lower bound of the range of journal articles to return
1266             * @param end the upper bound of the range of journal articles to return (not inclusive)
1267             * @return the range of matching journal articles
1268             * @throws SystemException if a system exception occurred
1269             */
1270            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1271                    int start, int end) throws SystemException {
1272                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
1273            }
1274    
1275            /**
1276             * Finds an ordered range of all the journal articles where resourcePrimKey = &#63;.
1277             *
1278             * <p>
1279             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1280             * </p>
1281             *
1282             * @param resourcePrimKey the resource prim key to search with
1283             * @param start the lower bound of the range of journal articles to return
1284             * @param end the upper bound of the range of journal articles to return (not inclusive)
1285             * @param orderByComparator the comparator to order the results by
1286             * @return the ordered range of matching journal articles
1287             * @throws SystemException if a system exception occurred
1288             */
1289            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
1290                    int start, int end, OrderByComparator orderByComparator)
1291                    throws SystemException {
1292                    Object[] finderArgs = new Object[] {
1293                                    resourcePrimKey,
1294                                    
1295                                    String.valueOf(start), String.valueOf(end),
1296                                    String.valueOf(orderByComparator)
1297                            };
1298    
1299                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_RESOURCEPRIMKEY,
1300                                    finderArgs, this);
1301    
1302                    if (list == null) {
1303                            Session session = null;
1304    
1305                            try {
1306                                    session = openSession();
1307    
1308                                    StringBundler query = null;
1309    
1310                                    if (orderByComparator != null) {
1311                                            query = new StringBundler(3 +
1312                                                            (orderByComparator.getOrderByFields().length * 3));
1313                                    }
1314                                    else {
1315                                            query = new StringBundler(3);
1316                                    }
1317    
1318                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1319    
1320                                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1321    
1322                                    if (orderByComparator != null) {
1323                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1324                                                    orderByComparator);
1325                                    }
1326    
1327                                    else {
1328                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1329                                    }
1330    
1331                                    String sql = query.toString();
1332    
1333                                    Query q = session.createQuery(sql);
1334    
1335                                    QueryPos qPos = QueryPos.getInstance(q);
1336    
1337                                    qPos.add(resourcePrimKey);
1338    
1339                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
1340                                                    start, end);
1341                            }
1342                            catch (Exception e) {
1343                                    throw processException(e);
1344                            }
1345                            finally {
1346                                    if (list == null) {
1347                                            list = new ArrayList<JournalArticle>();
1348                                    }
1349    
1350                                    cacheResult(list);
1351    
1352                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_RESOURCEPRIMKEY,
1353                                            finderArgs, list);
1354    
1355                                    closeSession(session);
1356                            }
1357                    }
1358    
1359                    return list;
1360            }
1361    
1362            /**
1363             * Finds the first journal article in the ordered set where resourcePrimKey = &#63;.
1364             *
1365             * <p>
1366             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1367             * </p>
1368             *
1369             * @param resourcePrimKey the resource prim key to search with
1370             * @param orderByComparator the comparator to order the set by
1371             * @return the first matching journal article
1372             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1373             * @throws SystemException if a system exception occurred
1374             */
1375            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
1376                    OrderByComparator orderByComparator)
1377                    throws NoSuchArticleException, SystemException {
1378                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
1379                                    1, orderByComparator);
1380    
1381                    if (list.isEmpty()) {
1382                            StringBundler msg = new StringBundler(4);
1383    
1384                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1385    
1386                            msg.append("resourcePrimKey=");
1387                            msg.append(resourcePrimKey);
1388    
1389                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1390    
1391                            throw new NoSuchArticleException(msg.toString());
1392                    }
1393                    else {
1394                            return list.get(0);
1395                    }
1396            }
1397    
1398            /**
1399             * Finds the last journal article in the ordered set where resourcePrimKey = &#63;.
1400             *
1401             * <p>
1402             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1403             * </p>
1404             *
1405             * @param resourcePrimKey the resource prim key to search with
1406             * @param orderByComparator the comparator to order the set by
1407             * @return the last matching journal article
1408             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1409             * @throws SystemException if a system exception occurred
1410             */
1411            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
1412                    OrderByComparator orderByComparator)
1413                    throws NoSuchArticleException, SystemException {
1414                    int count = countByResourcePrimKey(resourcePrimKey);
1415    
1416                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
1417                                    count - 1, count, orderByComparator);
1418    
1419                    if (list.isEmpty()) {
1420                            StringBundler msg = new StringBundler(4);
1421    
1422                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1423    
1424                            msg.append("resourcePrimKey=");
1425                            msg.append(resourcePrimKey);
1426    
1427                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1428    
1429                            throw new NoSuchArticleException(msg.toString());
1430                    }
1431                    else {
1432                            return list.get(0);
1433                    }
1434            }
1435    
1436            /**
1437             * Finds the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
1438             *
1439             * <p>
1440             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1441             * </p>
1442             *
1443             * @param id the primary key of the current journal article
1444             * @param resourcePrimKey the resource prim key to search with
1445             * @param orderByComparator the comparator to order the set by
1446             * @return the previous, current, and next journal article
1447             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1448             * @throws SystemException if a system exception occurred
1449             */
1450            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
1451                    long resourcePrimKey, OrderByComparator orderByComparator)
1452                    throws NoSuchArticleException, SystemException {
1453                    JournalArticle journalArticle = findByPrimaryKey(id);
1454    
1455                    Session session = null;
1456    
1457                    try {
1458                            session = openSession();
1459    
1460                            JournalArticle[] array = new JournalArticleImpl[3];
1461    
1462                            array[0] = getByResourcePrimKey_PrevAndNext(session,
1463                                            journalArticle, resourcePrimKey, orderByComparator, true);
1464    
1465                            array[1] = journalArticle;
1466    
1467                            array[2] = getByResourcePrimKey_PrevAndNext(session,
1468                                            journalArticle, resourcePrimKey, orderByComparator, false);
1469    
1470                            return array;
1471                    }
1472                    catch (Exception e) {
1473                            throw processException(e);
1474                    }
1475                    finally {
1476                            closeSession(session);
1477                    }
1478            }
1479    
1480            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
1481                    JournalArticle journalArticle, long resourcePrimKey,
1482                    OrderByComparator orderByComparator, boolean previous) {
1483                    StringBundler query = null;
1484    
1485                    if (orderByComparator != null) {
1486                            query = new StringBundler(6 +
1487                                            (orderByComparator.getOrderByFields().length * 6));
1488                    }
1489                    else {
1490                            query = new StringBundler(3);
1491                    }
1492    
1493                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1494    
1495                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
1496    
1497                    if (orderByComparator != null) {
1498                            String[] orderByFields = orderByComparator.getOrderByFields();
1499    
1500                            if (orderByFields.length > 0) {
1501                                    query.append(WHERE_AND);
1502                            }
1503    
1504                            for (int i = 0; i < orderByFields.length; i++) {
1505                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1506                                    query.append(orderByFields[i]);
1507    
1508                                    if ((i + 1) < orderByFields.length) {
1509                                            if (orderByComparator.isAscending() ^ previous) {
1510                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1511                                            }
1512                                            else {
1513                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1514                                            }
1515                                    }
1516                                    else {
1517                                            if (orderByComparator.isAscending() ^ previous) {
1518                                                    query.append(WHERE_GREATER_THAN);
1519                                            }
1520                                            else {
1521                                                    query.append(WHERE_LESSER_THAN);
1522                                            }
1523                                    }
1524                            }
1525    
1526                            query.append(ORDER_BY_CLAUSE);
1527    
1528                            for (int i = 0; i < orderByFields.length; i++) {
1529                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1530                                    query.append(orderByFields[i]);
1531    
1532                                    if ((i + 1) < orderByFields.length) {
1533                                            if (orderByComparator.isAscending() ^ previous) {
1534                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1535                                            }
1536                                            else {
1537                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1538                                            }
1539                                    }
1540                                    else {
1541                                            if (orderByComparator.isAscending() ^ previous) {
1542                                                    query.append(ORDER_BY_ASC);
1543                                            }
1544                                            else {
1545                                                    query.append(ORDER_BY_DESC);
1546                                            }
1547                                    }
1548                            }
1549                    }
1550    
1551                    else {
1552                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1553                    }
1554    
1555                    String sql = query.toString();
1556    
1557                    Query q = session.createQuery(sql);
1558    
1559                    q.setFirstResult(0);
1560                    q.setMaxResults(2);
1561    
1562                    QueryPos qPos = QueryPos.getInstance(q);
1563    
1564                    qPos.add(resourcePrimKey);
1565    
1566                    if (orderByComparator != null) {
1567                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
1568    
1569                            for (Object value : values) {
1570                                    qPos.add(value);
1571                            }
1572                    }
1573    
1574                    List<JournalArticle> list = q.list();
1575    
1576                    if (list.size() == 2) {
1577                            return list.get(1);
1578                    }
1579                    else {
1580                            return null;
1581                    }
1582            }
1583    
1584            /**
1585             * Finds all the journal articles where groupId = &#63;.
1586             *
1587             * @param groupId the group id to search with
1588             * @return the matching journal articles
1589             * @throws SystemException if a system exception occurred
1590             */
1591            public List<JournalArticle> findByGroupId(long groupId)
1592                    throws SystemException {
1593                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1594            }
1595    
1596            /**
1597             * Finds a range of all the journal articles where groupId = &#63;.
1598             *
1599             * <p>
1600             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1601             * </p>
1602             *
1603             * @param groupId the group id to search with
1604             * @param start the lower bound of the range of journal articles to return
1605             * @param end the upper bound of the range of journal articles to return (not inclusive)
1606             * @return the range of matching journal articles
1607             * @throws SystemException if a system exception occurred
1608             */
1609            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
1610                    throws SystemException {
1611                    return findByGroupId(groupId, start, end, null);
1612            }
1613    
1614            /**
1615             * Finds an ordered range of all the journal articles where groupId = &#63;.
1616             *
1617             * <p>
1618             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1619             * </p>
1620             *
1621             * @param groupId the group id to search with
1622             * @param start the lower bound of the range of journal articles to return
1623             * @param end the upper bound of the range of journal articles to return (not inclusive)
1624             * @param orderByComparator the comparator to order the results by
1625             * @return the ordered range of matching journal articles
1626             * @throws SystemException if a system exception occurred
1627             */
1628            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
1629                    OrderByComparator orderByComparator) throws SystemException {
1630                    Object[] finderArgs = new Object[] {
1631                                    groupId,
1632                                    
1633                                    String.valueOf(start), String.valueOf(end),
1634                                    String.valueOf(orderByComparator)
1635                            };
1636    
1637                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1638                                    finderArgs, this);
1639    
1640                    if (list == null) {
1641                            Session session = null;
1642    
1643                            try {
1644                                    session = openSession();
1645    
1646                                    StringBundler query = null;
1647    
1648                                    if (orderByComparator != null) {
1649                                            query = new StringBundler(3 +
1650                                                            (orderByComparator.getOrderByFields().length * 3));
1651                                    }
1652                                    else {
1653                                            query = new StringBundler(3);
1654                                    }
1655    
1656                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1657    
1658                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1659    
1660                                    if (orderByComparator != null) {
1661                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1662                                                    orderByComparator);
1663                                    }
1664    
1665                                    else {
1666                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1667                                    }
1668    
1669                                    String sql = query.toString();
1670    
1671                                    Query q = session.createQuery(sql);
1672    
1673                                    QueryPos qPos = QueryPos.getInstance(q);
1674    
1675                                    qPos.add(groupId);
1676    
1677                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
1678                                                    start, end);
1679                            }
1680                            catch (Exception e) {
1681                                    throw processException(e);
1682                            }
1683                            finally {
1684                                    if (list == null) {
1685                                            list = new ArrayList<JournalArticle>();
1686                                    }
1687    
1688                                    cacheResult(list);
1689    
1690                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1691                                            finderArgs, list);
1692    
1693                                    closeSession(session);
1694                            }
1695                    }
1696    
1697                    return list;
1698            }
1699    
1700            /**
1701             * Finds the first journal article in the ordered set where groupId = &#63;.
1702             *
1703             * <p>
1704             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1705             * </p>
1706             *
1707             * @param groupId the group id to search with
1708             * @param orderByComparator the comparator to order the set by
1709             * @return the first matching journal article
1710             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1711             * @throws SystemException if a system exception occurred
1712             */
1713            public JournalArticle findByGroupId_First(long groupId,
1714                    OrderByComparator orderByComparator)
1715                    throws NoSuchArticleException, SystemException {
1716                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
1717                                    orderByComparator);
1718    
1719                    if (list.isEmpty()) {
1720                            StringBundler msg = new StringBundler(4);
1721    
1722                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1723    
1724                            msg.append("groupId=");
1725                            msg.append(groupId);
1726    
1727                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1728    
1729                            throw new NoSuchArticleException(msg.toString());
1730                    }
1731                    else {
1732                            return list.get(0);
1733                    }
1734            }
1735    
1736            /**
1737             * Finds the last journal article in the ordered set where groupId = &#63;.
1738             *
1739             * <p>
1740             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1741             * </p>
1742             *
1743             * @param groupId the group id to search with
1744             * @param orderByComparator the comparator to order the set by
1745             * @return the last matching journal article
1746             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1747             * @throws SystemException if a system exception occurred
1748             */
1749            public JournalArticle findByGroupId_Last(long groupId,
1750                    OrderByComparator orderByComparator)
1751                    throws NoSuchArticleException, SystemException {
1752                    int count = countByGroupId(groupId);
1753    
1754                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
1755                                    orderByComparator);
1756    
1757                    if (list.isEmpty()) {
1758                            StringBundler msg = new StringBundler(4);
1759    
1760                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1761    
1762                            msg.append("groupId=");
1763                            msg.append(groupId);
1764    
1765                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1766    
1767                            throw new NoSuchArticleException(msg.toString());
1768                    }
1769                    else {
1770                            return list.get(0);
1771                    }
1772            }
1773    
1774            /**
1775             * Finds the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
1776             *
1777             * <p>
1778             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1779             * </p>
1780             *
1781             * @param id the primary key of the current journal article
1782             * @param groupId the group id to search with
1783             * @param orderByComparator the comparator to order the set by
1784             * @return the previous, current, and next journal article
1785             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1786             * @throws SystemException if a system exception occurred
1787             */
1788            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
1789                    OrderByComparator orderByComparator)
1790                    throws NoSuchArticleException, SystemException {
1791                    JournalArticle journalArticle = findByPrimaryKey(id);
1792    
1793                    Session session = null;
1794    
1795                    try {
1796                            session = openSession();
1797    
1798                            JournalArticle[] array = new JournalArticleImpl[3];
1799    
1800                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
1801                                            groupId, orderByComparator, true);
1802    
1803                            array[1] = journalArticle;
1804    
1805                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
1806                                            groupId, orderByComparator, false);
1807    
1808                            return array;
1809                    }
1810                    catch (Exception e) {
1811                            throw processException(e);
1812                    }
1813                    finally {
1814                            closeSession(session);
1815                    }
1816            }
1817    
1818            protected JournalArticle getByGroupId_PrevAndNext(Session session,
1819                    JournalArticle journalArticle, long groupId,
1820                    OrderByComparator orderByComparator, boolean previous) {
1821                    StringBundler query = null;
1822    
1823                    if (orderByComparator != null) {
1824                            query = new StringBundler(6 +
1825                                            (orderByComparator.getOrderByFields().length * 6));
1826                    }
1827                    else {
1828                            query = new StringBundler(3);
1829                    }
1830    
1831                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1832    
1833                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1834    
1835                    if (orderByComparator != null) {
1836                            String[] orderByFields = orderByComparator.getOrderByFields();
1837    
1838                            if (orderByFields.length > 0) {
1839                                    query.append(WHERE_AND);
1840                            }
1841    
1842                            for (int i = 0; i < orderByFields.length; i++) {
1843                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1844                                    query.append(orderByFields[i]);
1845    
1846                                    if ((i + 1) < orderByFields.length) {
1847                                            if (orderByComparator.isAscending() ^ previous) {
1848                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1849                                            }
1850                                            else {
1851                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1852                                            }
1853                                    }
1854                                    else {
1855                                            if (orderByComparator.isAscending() ^ previous) {
1856                                                    query.append(WHERE_GREATER_THAN);
1857                                            }
1858                                            else {
1859                                                    query.append(WHERE_LESSER_THAN);
1860                                            }
1861                                    }
1862                            }
1863    
1864                            query.append(ORDER_BY_CLAUSE);
1865    
1866                            for (int i = 0; i < orderByFields.length; i++) {
1867                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1868                                    query.append(orderByFields[i]);
1869    
1870                                    if ((i + 1) < orderByFields.length) {
1871                                            if (orderByComparator.isAscending() ^ previous) {
1872                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1873                                            }
1874                                            else {
1875                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1876                                            }
1877                                    }
1878                                    else {
1879                                            if (orderByComparator.isAscending() ^ previous) {
1880                                                    query.append(ORDER_BY_ASC);
1881                                            }
1882                                            else {
1883                                                    query.append(ORDER_BY_DESC);
1884                                            }
1885                                    }
1886                            }
1887                    }
1888    
1889                    else {
1890                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1891                    }
1892    
1893                    String sql = query.toString();
1894    
1895                    Query q = session.createQuery(sql);
1896    
1897                    q.setFirstResult(0);
1898                    q.setMaxResults(2);
1899    
1900                    QueryPos qPos = QueryPos.getInstance(q);
1901    
1902                    qPos.add(groupId);
1903    
1904                    if (orderByComparator != null) {
1905                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
1906    
1907                            for (Object value : values) {
1908                                    qPos.add(value);
1909                            }
1910                    }
1911    
1912                    List<JournalArticle> list = q.list();
1913    
1914                    if (list.size() == 2) {
1915                            return list.get(1);
1916                    }
1917                    else {
1918                            return null;
1919                    }
1920            }
1921    
1922            /**
1923             * Filters by the user's permissions and finds all the journal articles where groupId = &#63;.
1924             *
1925             * @param groupId the group id to search with
1926             * @return the matching journal articles that the user has permission to view
1927             * @throws SystemException if a system exception occurred
1928             */
1929            public List<JournalArticle> filterFindByGroupId(long groupId)
1930                    throws SystemException {
1931                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1932                            QueryUtil.ALL_POS, null);
1933            }
1934    
1935            /**
1936             * Filters by the user's permissions and finds a range of all the journal articles where groupId = &#63;.
1937             *
1938             * <p>
1939             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1940             * </p>
1941             *
1942             * @param groupId the group id to search with
1943             * @param start the lower bound of the range of journal articles to return
1944             * @param end the upper bound of the range of journal articles to return (not inclusive)
1945             * @return the range of matching journal articles that the user has permission to view
1946             * @throws SystemException if a system exception occurred
1947             */
1948            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
1949                    int end) throws SystemException {
1950                    return filterFindByGroupId(groupId, start, end, null);
1951            }
1952    
1953            /**
1954             * Filters by the user's permissions and finds an ordered range of all the journal articles where groupId = &#63;.
1955             *
1956             * <p>
1957             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1958             * </p>
1959             *
1960             * @param groupId the group id to search with
1961             * @param start the lower bound of the range of journal articles to return
1962             * @param end the upper bound of the range of journal articles to return (not inclusive)
1963             * @param orderByComparator the comparator to order the results by
1964             * @return the ordered range of matching journal articles that the user has permission to view
1965             * @throws SystemException if a system exception occurred
1966             */
1967            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
1968                    int end, OrderByComparator orderByComparator) throws SystemException {
1969                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1970                            return findByGroupId(groupId, start, end, orderByComparator);
1971                    }
1972    
1973                    Session session = null;
1974    
1975                    try {
1976                            session = openSession();
1977    
1978                            StringBundler query = null;
1979    
1980                            if (orderByComparator != null) {
1981                                    query = new StringBundler(3 +
1982                                                    (orderByComparator.getOrderByFields().length * 3));
1983                            }
1984                            else {
1985                                    query = new StringBundler(3);
1986                            }
1987    
1988                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
1989    
1990                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1991    
1992                            if (orderByComparator != null) {
1993                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1994                                            orderByComparator);
1995                            }
1996    
1997                            else {
1998                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1999                            }
2000    
2001                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2002                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
2003                                            _FILTER_COLUMN_USERID, groupId);
2004    
2005                            SQLQuery q = session.createSQLQuery(sql);
2006    
2007                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2008    
2009                            QueryPos qPos = QueryPos.getInstance(q);
2010    
2011                            qPos.add(groupId);
2012    
2013                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
2014                                    end);
2015                    }
2016                    catch (Exception e) {
2017                            throw processException(e);
2018                    }
2019                    finally {
2020                            closeSession(session);
2021                    }
2022            }
2023    
2024            /**
2025             * Finds all the journal articles where companyId = &#63;.
2026             *
2027             * @param companyId the company id to search with
2028             * @return the matching journal articles
2029             * @throws SystemException if a system exception occurred
2030             */
2031            public List<JournalArticle> findByCompanyId(long companyId)
2032                    throws SystemException {
2033                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2034                            null);
2035            }
2036    
2037            /**
2038             * Finds a range of all the journal articles where companyId = &#63;.
2039             *
2040             * <p>
2041             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2042             * </p>
2043             *
2044             * @param companyId the company id to search with
2045             * @param start the lower bound of the range of journal articles to return
2046             * @param end the upper bound of the range of journal articles to return (not inclusive)
2047             * @return the range of matching journal articles
2048             * @throws SystemException if a system exception occurred
2049             */
2050            public List<JournalArticle> findByCompanyId(long companyId, int start,
2051                    int end) throws SystemException {
2052                    return findByCompanyId(companyId, start, end, null);
2053            }
2054    
2055            /**
2056             * Finds an ordered range of all the journal articles where companyId = &#63;.
2057             *
2058             * <p>
2059             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2060             * </p>
2061             *
2062             * @param companyId the company id to search with
2063             * @param start the lower bound of the range of journal articles to return
2064             * @param end the upper bound of the range of journal articles to return (not inclusive)
2065             * @param orderByComparator the comparator to order the results by
2066             * @return the ordered range of matching journal articles
2067             * @throws SystemException if a system exception occurred
2068             */
2069            public List<JournalArticle> findByCompanyId(long companyId, int start,
2070                    int end, OrderByComparator orderByComparator) throws SystemException {
2071                    Object[] finderArgs = new Object[] {
2072                                    companyId,
2073                                    
2074                                    String.valueOf(start), String.valueOf(end),
2075                                    String.valueOf(orderByComparator)
2076                            };
2077    
2078                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
2079                                    finderArgs, this);
2080    
2081                    if (list == null) {
2082                            Session session = null;
2083    
2084                            try {
2085                                    session = openSession();
2086    
2087                                    StringBundler query = null;
2088    
2089                                    if (orderByComparator != null) {
2090                                            query = new StringBundler(3 +
2091                                                            (orderByComparator.getOrderByFields().length * 3));
2092                                    }
2093                                    else {
2094                                            query = new StringBundler(3);
2095                                    }
2096    
2097                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2098    
2099                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2100    
2101                                    if (orderByComparator != null) {
2102                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2103                                                    orderByComparator);
2104                                    }
2105    
2106                                    else {
2107                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2108                                    }
2109    
2110                                    String sql = query.toString();
2111    
2112                                    Query q = session.createQuery(sql);
2113    
2114                                    QueryPos qPos = QueryPos.getInstance(q);
2115    
2116                                    qPos.add(companyId);
2117    
2118                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2119                                                    start, end);
2120                            }
2121                            catch (Exception e) {
2122                                    throw processException(e);
2123                            }
2124                            finally {
2125                                    if (list == null) {
2126                                            list = new ArrayList<JournalArticle>();
2127                                    }
2128    
2129                                    cacheResult(list);
2130    
2131                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
2132                                            finderArgs, list);
2133    
2134                                    closeSession(session);
2135                            }
2136                    }
2137    
2138                    return list;
2139            }
2140    
2141            /**
2142             * Finds the first journal article in the ordered set where companyId = &#63;.
2143             *
2144             * <p>
2145             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2146             * </p>
2147             *
2148             * @param companyId the company id to search with
2149             * @param orderByComparator the comparator to order the set by
2150             * @return the first matching journal article
2151             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2152             * @throws SystemException if a system exception occurred
2153             */
2154            public JournalArticle findByCompanyId_First(long companyId,
2155                    OrderByComparator orderByComparator)
2156                    throws NoSuchArticleException, SystemException {
2157                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
2158                                    orderByComparator);
2159    
2160                    if (list.isEmpty()) {
2161                            StringBundler msg = new StringBundler(4);
2162    
2163                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2164    
2165                            msg.append("companyId=");
2166                            msg.append(companyId);
2167    
2168                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2169    
2170                            throw new NoSuchArticleException(msg.toString());
2171                    }
2172                    else {
2173                            return list.get(0);
2174                    }
2175            }
2176    
2177            /**
2178             * Finds the last journal article in the ordered set where companyId = &#63;.
2179             *
2180             * <p>
2181             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2182             * </p>
2183             *
2184             * @param companyId the company id to search with
2185             * @param orderByComparator the comparator to order the set by
2186             * @return the last matching journal article
2187             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2188             * @throws SystemException if a system exception occurred
2189             */
2190            public JournalArticle findByCompanyId_Last(long companyId,
2191                    OrderByComparator orderByComparator)
2192                    throws NoSuchArticleException, SystemException {
2193                    int count = countByCompanyId(companyId);
2194    
2195                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
2196                                    count, orderByComparator);
2197    
2198                    if (list.isEmpty()) {
2199                            StringBundler msg = new StringBundler(4);
2200    
2201                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2202    
2203                            msg.append("companyId=");
2204                            msg.append(companyId);
2205    
2206                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2207    
2208                            throw new NoSuchArticleException(msg.toString());
2209                    }
2210                    else {
2211                            return list.get(0);
2212                    }
2213            }
2214    
2215            /**
2216             * Finds the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
2217             *
2218             * <p>
2219             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2220             * </p>
2221             *
2222             * @param id the primary key of the current journal article
2223             * @param companyId the company id to search with
2224             * @param orderByComparator the comparator to order the set by
2225             * @return the previous, current, and next journal article
2226             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2227             * @throws SystemException if a system exception occurred
2228             */
2229            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
2230                    long companyId, OrderByComparator orderByComparator)
2231                    throws NoSuchArticleException, SystemException {
2232                    JournalArticle journalArticle = findByPrimaryKey(id);
2233    
2234                    Session session = null;
2235    
2236                    try {
2237                            session = openSession();
2238    
2239                            JournalArticle[] array = new JournalArticleImpl[3];
2240    
2241                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
2242                                            companyId, orderByComparator, true);
2243    
2244                            array[1] = journalArticle;
2245    
2246                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
2247                                            companyId, orderByComparator, false);
2248    
2249                            return array;
2250                    }
2251                    catch (Exception e) {
2252                            throw processException(e);
2253                    }
2254                    finally {
2255                            closeSession(session);
2256                    }
2257            }
2258    
2259            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
2260                    JournalArticle journalArticle, long companyId,
2261                    OrderByComparator orderByComparator, boolean previous) {
2262                    StringBundler query = null;
2263    
2264                    if (orderByComparator != null) {
2265                            query = new StringBundler(6 +
2266                                            (orderByComparator.getOrderByFields().length * 6));
2267                    }
2268                    else {
2269                            query = new StringBundler(3);
2270                    }
2271    
2272                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2273    
2274                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2275    
2276                    if (orderByComparator != null) {
2277                            String[] orderByFields = orderByComparator.getOrderByFields();
2278    
2279                            if (orderByFields.length > 0) {
2280                                    query.append(WHERE_AND);
2281                            }
2282    
2283                            for (int i = 0; i < orderByFields.length; i++) {
2284                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2285                                    query.append(orderByFields[i]);
2286    
2287                                    if ((i + 1) < orderByFields.length) {
2288                                            if (orderByComparator.isAscending() ^ previous) {
2289                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2290                                            }
2291                                            else {
2292                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2293                                            }
2294                                    }
2295                                    else {
2296                                            if (orderByComparator.isAscending() ^ previous) {
2297                                                    query.append(WHERE_GREATER_THAN);
2298                                            }
2299                                            else {
2300                                                    query.append(WHERE_LESSER_THAN);
2301                                            }
2302                                    }
2303                            }
2304    
2305                            query.append(ORDER_BY_CLAUSE);
2306    
2307                            for (int i = 0; i < orderByFields.length; i++) {
2308                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2309                                    query.append(orderByFields[i]);
2310    
2311                                    if ((i + 1) < orderByFields.length) {
2312                                            if (orderByComparator.isAscending() ^ previous) {
2313                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2314                                            }
2315                                            else {
2316                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2317                                            }
2318                                    }
2319                                    else {
2320                                            if (orderByComparator.isAscending() ^ previous) {
2321                                                    query.append(ORDER_BY_ASC);
2322                                            }
2323                                            else {
2324                                                    query.append(ORDER_BY_DESC);
2325                                            }
2326                                    }
2327                            }
2328                    }
2329    
2330                    else {
2331                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2332                    }
2333    
2334                    String sql = query.toString();
2335    
2336                    Query q = session.createQuery(sql);
2337    
2338                    q.setFirstResult(0);
2339                    q.setMaxResults(2);
2340    
2341                    QueryPos qPos = QueryPos.getInstance(q);
2342    
2343                    qPos.add(companyId);
2344    
2345                    if (orderByComparator != null) {
2346                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
2347    
2348                            for (Object value : values) {
2349                                    qPos.add(value);
2350                            }
2351                    }
2352    
2353                    List<JournalArticle> list = q.list();
2354    
2355                    if (list.size() == 2) {
2356                            return list.get(1);
2357                    }
2358                    else {
2359                            return null;
2360                    }
2361            }
2362    
2363            /**
2364             * Finds all the journal articles where smallImageId = &#63;.
2365             *
2366             * @param smallImageId the small image id to search with
2367             * @return the matching journal articles
2368             * @throws SystemException if a system exception occurred
2369             */
2370            public List<JournalArticle> findBySmallImageId(long smallImageId)
2371                    throws SystemException {
2372                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
2373                            QueryUtil.ALL_POS, null);
2374            }
2375    
2376            /**
2377             * Finds a range of all the journal articles where smallImageId = &#63;.
2378             *
2379             * <p>
2380             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2381             * </p>
2382             *
2383             * @param smallImageId the small image id to search with
2384             * @param start the lower bound of the range of journal articles to return
2385             * @param end the upper bound of the range of journal articles to return (not inclusive)
2386             * @return the range of matching journal articles
2387             * @throws SystemException if a system exception occurred
2388             */
2389            public List<JournalArticle> findBySmallImageId(long smallImageId,
2390                    int start, int end) throws SystemException {
2391                    return findBySmallImageId(smallImageId, start, end, null);
2392            }
2393    
2394            /**
2395             * Finds an ordered range of all the journal articles where smallImageId = &#63;.
2396             *
2397             * <p>
2398             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2399             * </p>
2400             *
2401             * @param smallImageId the small image id to search with
2402             * @param start the lower bound of the range of journal articles to return
2403             * @param end the upper bound of the range of journal articles to return (not inclusive)
2404             * @param orderByComparator the comparator to order the results by
2405             * @return the ordered range of matching journal articles
2406             * @throws SystemException if a system exception occurred
2407             */
2408            public List<JournalArticle> findBySmallImageId(long smallImageId,
2409                    int start, int end, OrderByComparator orderByComparator)
2410                    throws SystemException {
2411                    Object[] finderArgs = new Object[] {
2412                                    smallImageId,
2413                                    
2414                                    String.valueOf(start), String.valueOf(end),
2415                                    String.valueOf(orderByComparator)
2416                            };
2417    
2418                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_SMALLIMAGEID,
2419                                    finderArgs, this);
2420    
2421                    if (list == null) {
2422                            Session session = null;
2423    
2424                            try {
2425                                    session = openSession();
2426    
2427                                    StringBundler query = null;
2428    
2429                                    if (orderByComparator != null) {
2430                                            query = new StringBundler(3 +
2431                                                            (orderByComparator.getOrderByFields().length * 3));
2432                                    }
2433                                    else {
2434                                            query = new StringBundler(3);
2435                                    }
2436    
2437                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2438    
2439                                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
2440    
2441                                    if (orderByComparator != null) {
2442                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2443                                                    orderByComparator);
2444                                    }
2445    
2446                                    else {
2447                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2448                                    }
2449    
2450                                    String sql = query.toString();
2451    
2452                                    Query q = session.createQuery(sql);
2453    
2454                                    QueryPos qPos = QueryPos.getInstance(q);
2455    
2456                                    qPos.add(smallImageId);
2457    
2458                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2459                                                    start, end);
2460                            }
2461                            catch (Exception e) {
2462                                    throw processException(e);
2463                            }
2464                            finally {
2465                                    if (list == null) {
2466                                            list = new ArrayList<JournalArticle>();
2467                                    }
2468    
2469                                    cacheResult(list);
2470    
2471                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_SMALLIMAGEID,
2472                                            finderArgs, list);
2473    
2474                                    closeSession(session);
2475                            }
2476                    }
2477    
2478                    return list;
2479            }
2480    
2481            /**
2482             * Finds the first journal article in the ordered set where smallImageId = &#63;.
2483             *
2484             * <p>
2485             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2486             * </p>
2487             *
2488             * @param smallImageId the small image id to search with
2489             * @param orderByComparator the comparator to order the set by
2490             * @return the first matching journal article
2491             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2492             * @throws SystemException if a system exception occurred
2493             */
2494            public JournalArticle findBySmallImageId_First(long smallImageId,
2495                    OrderByComparator orderByComparator)
2496                    throws NoSuchArticleException, SystemException {
2497                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
2498                                    orderByComparator);
2499    
2500                    if (list.isEmpty()) {
2501                            StringBundler msg = new StringBundler(4);
2502    
2503                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2504    
2505                            msg.append("smallImageId=");
2506                            msg.append(smallImageId);
2507    
2508                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2509    
2510                            throw new NoSuchArticleException(msg.toString());
2511                    }
2512                    else {
2513                            return list.get(0);
2514                    }
2515            }
2516    
2517            /**
2518             * Finds the last journal article in the ordered set where smallImageId = &#63;.
2519             *
2520             * <p>
2521             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2522             * </p>
2523             *
2524             * @param smallImageId the small image id to search with
2525             * @param orderByComparator the comparator to order the set by
2526             * @return the last matching journal article
2527             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2528             * @throws SystemException if a system exception occurred
2529             */
2530            public JournalArticle findBySmallImageId_Last(long smallImageId,
2531                    OrderByComparator orderByComparator)
2532                    throws NoSuchArticleException, SystemException {
2533                    int count = countBySmallImageId(smallImageId);
2534    
2535                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
2536                                    count, orderByComparator);
2537    
2538                    if (list.isEmpty()) {
2539                            StringBundler msg = new StringBundler(4);
2540    
2541                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2542    
2543                            msg.append("smallImageId=");
2544                            msg.append(smallImageId);
2545    
2546                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2547    
2548                            throw new NoSuchArticleException(msg.toString());
2549                    }
2550                    else {
2551                            return list.get(0);
2552                    }
2553            }
2554    
2555            /**
2556             * Finds the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
2557             *
2558             * <p>
2559             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2560             * </p>
2561             *
2562             * @param id the primary key of the current journal article
2563             * @param smallImageId the small image id to search with
2564             * @param orderByComparator the comparator to order the set by
2565             * @return the previous, current, and next journal article
2566             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2567             * @throws SystemException if a system exception occurred
2568             */
2569            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
2570                    long smallImageId, OrderByComparator orderByComparator)
2571                    throws NoSuchArticleException, SystemException {
2572                    JournalArticle journalArticle = findByPrimaryKey(id);
2573    
2574                    Session session = null;
2575    
2576                    try {
2577                            session = openSession();
2578    
2579                            JournalArticle[] array = new JournalArticleImpl[3];
2580    
2581                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
2582                                            smallImageId, orderByComparator, true);
2583    
2584                            array[1] = journalArticle;
2585    
2586                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
2587                                            smallImageId, orderByComparator, false);
2588    
2589                            return array;
2590                    }
2591                    catch (Exception e) {
2592                            throw processException(e);
2593                    }
2594                    finally {
2595                            closeSession(session);
2596                    }
2597            }
2598    
2599            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
2600                    JournalArticle journalArticle, long smallImageId,
2601                    OrderByComparator orderByComparator, boolean previous) {
2602                    StringBundler query = null;
2603    
2604                    if (orderByComparator != null) {
2605                            query = new StringBundler(6 +
2606                                            (orderByComparator.getOrderByFields().length * 6));
2607                    }
2608                    else {
2609                            query = new StringBundler(3);
2610                    }
2611    
2612                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2613    
2614                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
2615    
2616                    if (orderByComparator != null) {
2617                            String[] orderByFields = orderByComparator.getOrderByFields();
2618    
2619                            if (orderByFields.length > 0) {
2620                                    query.append(WHERE_AND);
2621                            }
2622    
2623                            for (int i = 0; i < orderByFields.length; i++) {
2624                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2625                                    query.append(orderByFields[i]);
2626    
2627                                    if ((i + 1) < orderByFields.length) {
2628                                            if (orderByComparator.isAscending() ^ previous) {
2629                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2630                                            }
2631                                            else {
2632                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2633                                            }
2634                                    }
2635                                    else {
2636                                            if (orderByComparator.isAscending() ^ previous) {
2637                                                    query.append(WHERE_GREATER_THAN);
2638                                            }
2639                                            else {
2640                                                    query.append(WHERE_LESSER_THAN);
2641                                            }
2642                                    }
2643                            }
2644    
2645                            query.append(ORDER_BY_CLAUSE);
2646    
2647                            for (int i = 0; i < orderByFields.length; i++) {
2648                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2649                                    query.append(orderByFields[i]);
2650    
2651                                    if ((i + 1) < orderByFields.length) {
2652                                            if (orderByComparator.isAscending() ^ previous) {
2653                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2654                                            }
2655                                            else {
2656                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2657                                            }
2658                                    }
2659                                    else {
2660                                            if (orderByComparator.isAscending() ^ previous) {
2661                                                    query.append(ORDER_BY_ASC);
2662                                            }
2663                                            else {
2664                                                    query.append(ORDER_BY_DESC);
2665                                            }
2666                                    }
2667                            }
2668                    }
2669    
2670                    else {
2671                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2672                    }
2673    
2674                    String sql = query.toString();
2675    
2676                    Query q = session.createQuery(sql);
2677    
2678                    q.setFirstResult(0);
2679                    q.setMaxResults(2);
2680    
2681                    QueryPos qPos = QueryPos.getInstance(q);
2682    
2683                    qPos.add(smallImageId);
2684    
2685                    if (orderByComparator != null) {
2686                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
2687    
2688                            for (Object value : values) {
2689                                    qPos.add(value);
2690                            }
2691                    }
2692    
2693                    List<JournalArticle> list = q.list();
2694    
2695                    if (list.size() == 2) {
2696                            return list.get(1);
2697                    }
2698                    else {
2699                            return null;
2700                    }
2701            }
2702    
2703            /**
2704             * Finds all the journal articles where resourcePrimKey = &#63; and status = &#63;.
2705             *
2706             * @param resourcePrimKey the resource prim key to search with
2707             * @param status the status to search with
2708             * @return the matching journal articles
2709             * @throws SystemException if a system exception occurred
2710             */
2711            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
2712                    throws SystemException {
2713                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
2714                            QueryUtil.ALL_POS, null);
2715            }
2716    
2717            /**
2718             * Finds a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
2719             *
2720             * <p>
2721             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2722             * </p>
2723             *
2724             * @param resourcePrimKey the resource prim key to search with
2725             * @param status the status to search with
2726             * @param start the lower bound of the range of journal articles to return
2727             * @param end the upper bound of the range of journal articles to return (not inclusive)
2728             * @return the range of matching journal articles
2729             * @throws SystemException if a system exception occurred
2730             */
2731            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
2732                    int start, int end) throws SystemException {
2733                    return findByR_ST(resourcePrimKey, status, start, end, null);
2734            }
2735    
2736            /**
2737             * Finds an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
2738             *
2739             * <p>
2740             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2741             * </p>
2742             *
2743             * @param resourcePrimKey the resource prim key to search with
2744             * @param status the status to search with
2745             * @param start the lower bound of the range of journal articles to return
2746             * @param end the upper bound of the range of journal articles to return (not inclusive)
2747             * @param orderByComparator the comparator to order the results by
2748             * @return the ordered range of matching journal articles
2749             * @throws SystemException if a system exception occurred
2750             */
2751            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
2752                    int start, int end, OrderByComparator orderByComparator)
2753                    throws SystemException {
2754                    Object[] finderArgs = new Object[] {
2755                                    resourcePrimKey, status,
2756                                    
2757                                    String.valueOf(start), String.valueOf(end),
2758                                    String.valueOf(orderByComparator)
2759                            };
2760    
2761                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_R_ST,
2762                                    finderArgs, this);
2763    
2764                    if (list == null) {
2765                            Session session = null;
2766    
2767                            try {
2768                                    session = openSession();
2769    
2770                                    StringBundler query = null;
2771    
2772                                    if (orderByComparator != null) {
2773                                            query = new StringBundler(4 +
2774                                                            (orderByComparator.getOrderByFields().length * 3));
2775                                    }
2776                                    else {
2777                                            query = new StringBundler(4);
2778                                    }
2779    
2780                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2781    
2782                                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
2783    
2784                                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
2785    
2786                                    if (orderByComparator != null) {
2787                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2788                                                    orderByComparator);
2789                                    }
2790    
2791                                    else {
2792                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2793                                    }
2794    
2795                                    String sql = query.toString();
2796    
2797                                    Query q = session.createQuery(sql);
2798    
2799                                    QueryPos qPos = QueryPos.getInstance(q);
2800    
2801                                    qPos.add(resourcePrimKey);
2802    
2803                                    qPos.add(status);
2804    
2805                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2806                                                    start, end);
2807                            }
2808                            catch (Exception e) {
2809                                    throw processException(e);
2810                            }
2811                            finally {
2812                                    if (list == null) {
2813                                            list = new ArrayList<JournalArticle>();
2814                                    }
2815    
2816                                    cacheResult(list);
2817    
2818                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_R_ST, finderArgs,
2819                                            list);
2820    
2821                                    closeSession(session);
2822                            }
2823                    }
2824    
2825                    return list;
2826            }
2827    
2828            /**
2829             * Finds the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
2830             *
2831             * <p>
2832             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2833             * </p>
2834             *
2835             * @param resourcePrimKey the resource prim key to search with
2836             * @param status the status to search with
2837             * @param orderByComparator the comparator to order the set by
2838             * @return the first matching journal article
2839             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2840             * @throws SystemException if a system exception occurred
2841             */
2842            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
2843                    OrderByComparator orderByComparator)
2844                    throws NoSuchArticleException, SystemException {
2845                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
2846                                    orderByComparator);
2847    
2848                    if (list.isEmpty()) {
2849                            StringBundler msg = new StringBundler(6);
2850    
2851                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2852    
2853                            msg.append("resourcePrimKey=");
2854                            msg.append(resourcePrimKey);
2855    
2856                            msg.append(", status=");
2857                            msg.append(status);
2858    
2859                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2860    
2861                            throw new NoSuchArticleException(msg.toString());
2862                    }
2863                    else {
2864                            return list.get(0);
2865                    }
2866            }
2867    
2868            /**
2869             * Finds the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
2870             *
2871             * <p>
2872             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2873             * </p>
2874             *
2875             * @param resourcePrimKey the resource prim key to search with
2876             * @param status the status to search with
2877             * @param orderByComparator the comparator to order the set by
2878             * @return the last matching journal article
2879             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2880             * @throws SystemException if a system exception occurred
2881             */
2882            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
2883                    OrderByComparator orderByComparator)
2884                    throws NoSuchArticleException, SystemException {
2885                    int count = countByR_ST(resourcePrimKey, status);
2886    
2887                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
2888                                    count - 1, count, orderByComparator);
2889    
2890                    if (list.isEmpty()) {
2891                            StringBundler msg = new StringBundler(6);
2892    
2893                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2894    
2895                            msg.append("resourcePrimKey=");
2896                            msg.append(resourcePrimKey);
2897    
2898                            msg.append(", status=");
2899                            msg.append(status);
2900    
2901                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2902    
2903                            throw new NoSuchArticleException(msg.toString());
2904                    }
2905                    else {
2906                            return list.get(0);
2907                    }
2908            }
2909    
2910            /**
2911             * Finds the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
2912             *
2913             * <p>
2914             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2915             * </p>
2916             *
2917             * @param id the primary key of the current journal article
2918             * @param resourcePrimKey the resource prim key to search with
2919             * @param status the status to search with
2920             * @param orderByComparator the comparator to order the set by
2921             * @return the previous, current, and next journal article
2922             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2923             * @throws SystemException if a system exception occurred
2924             */
2925            public JournalArticle[] findByR_ST_PrevAndNext(long id,
2926                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
2927                    throws NoSuchArticleException, SystemException {
2928                    JournalArticle journalArticle = findByPrimaryKey(id);
2929    
2930                    Session session = null;
2931    
2932                    try {
2933                            session = openSession();
2934    
2935                            JournalArticle[] array = new JournalArticleImpl[3];
2936    
2937                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
2938                                            resourcePrimKey, status, orderByComparator, true);
2939    
2940                            array[1] = journalArticle;
2941    
2942                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
2943                                            resourcePrimKey, status, orderByComparator, false);
2944    
2945                            return array;
2946                    }
2947                    catch (Exception e) {
2948                            throw processException(e);
2949                    }
2950                    finally {
2951                            closeSession(session);
2952                    }
2953            }
2954    
2955            protected JournalArticle getByR_ST_PrevAndNext(Session session,
2956                    JournalArticle journalArticle, long resourcePrimKey, int status,
2957                    OrderByComparator orderByComparator, boolean previous) {
2958                    StringBundler query = null;
2959    
2960                    if (orderByComparator != null) {
2961                            query = new StringBundler(6 +
2962                                            (orderByComparator.getOrderByFields().length * 6));
2963                    }
2964                    else {
2965                            query = new StringBundler(3);
2966                    }
2967    
2968                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2969    
2970                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
2971    
2972                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
2973    
2974                    if (orderByComparator != null) {
2975                            String[] orderByFields = orderByComparator.getOrderByFields();
2976    
2977                            if (orderByFields.length > 0) {
2978                                    query.append(WHERE_AND);
2979                            }
2980    
2981                            for (int i = 0; i < orderByFields.length; i++) {
2982                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2983                                    query.append(orderByFields[i]);
2984    
2985                                    if ((i + 1) < orderByFields.length) {
2986                                            if (orderByComparator.isAscending() ^ previous) {
2987                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2988                                            }
2989                                            else {
2990                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2991                                            }
2992                                    }
2993                                    else {
2994                                            if (orderByComparator.isAscending() ^ previous) {
2995                                                    query.append(WHERE_GREATER_THAN);
2996                                            }
2997                                            else {
2998                                                    query.append(WHERE_LESSER_THAN);
2999                                            }
3000                                    }
3001                            }
3002    
3003                            query.append(ORDER_BY_CLAUSE);
3004    
3005                            for (int i = 0; i < orderByFields.length; i++) {
3006                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3007                                    query.append(orderByFields[i]);
3008    
3009                                    if ((i + 1) < orderByFields.length) {
3010                                            if (orderByComparator.isAscending() ^ previous) {
3011                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3012                                            }
3013                                            else {
3014                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3015                                            }
3016                                    }
3017                                    else {
3018                                            if (orderByComparator.isAscending() ^ previous) {
3019                                                    query.append(ORDER_BY_ASC);
3020                                            }
3021                                            else {
3022                                                    query.append(ORDER_BY_DESC);
3023                                            }
3024                                    }
3025                            }
3026                    }
3027    
3028                    else {
3029                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3030                    }
3031    
3032                    String sql = query.toString();
3033    
3034                    Query q = session.createQuery(sql);
3035    
3036                    q.setFirstResult(0);
3037                    q.setMaxResults(2);
3038    
3039                    QueryPos qPos = QueryPos.getInstance(q);
3040    
3041                    qPos.add(resourcePrimKey);
3042    
3043                    qPos.add(status);
3044    
3045                    if (orderByComparator != null) {
3046                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
3047    
3048                            for (Object value : values) {
3049                                    qPos.add(value);
3050                            }
3051                    }
3052    
3053                    List<JournalArticle> list = q.list();
3054    
3055                    if (list.size() == 2) {
3056                            return list.get(1);
3057                    }
3058                    else {
3059                            return null;
3060                    }
3061            }
3062    
3063            /**
3064             * Finds all the journal articles where groupId = &#63; and articleId = &#63;.
3065             *
3066             * @param groupId the group id to search with
3067             * @param articleId the article id to search with
3068             * @return the matching journal articles
3069             * @throws SystemException if a system exception occurred
3070             */
3071            public List<JournalArticle> findByG_A(long groupId, String articleId)
3072                    throws SystemException {
3073                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
3074                            QueryUtil.ALL_POS, null);
3075            }
3076    
3077            /**
3078             * Finds a range of all the journal articles where groupId = &#63; and articleId = &#63;.
3079             *
3080             * <p>
3081             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3082             * </p>
3083             *
3084             * @param groupId the group id to search with
3085             * @param articleId the article id to search with
3086             * @param start the lower bound of the range of journal articles to return
3087             * @param end the upper bound of the range of journal articles to return (not inclusive)
3088             * @return the range of matching journal articles
3089             * @throws SystemException if a system exception occurred
3090             */
3091            public List<JournalArticle> findByG_A(long groupId, String articleId,
3092                    int start, int end) throws SystemException {
3093                    return findByG_A(groupId, articleId, start, end, null);
3094            }
3095    
3096            /**
3097             * Finds an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
3098             *
3099             * <p>
3100             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3101             * </p>
3102             *
3103             * @param groupId the group id to search with
3104             * @param articleId the article id to search with
3105             * @param start the lower bound of the range of journal articles to return
3106             * @param end the upper bound of the range of journal articles to return (not inclusive)
3107             * @param orderByComparator the comparator to order the results by
3108             * @return the ordered range of matching journal articles
3109             * @throws SystemException if a system exception occurred
3110             */
3111            public List<JournalArticle> findByG_A(long groupId, String articleId,
3112                    int start, int end, OrderByComparator orderByComparator)
3113                    throws SystemException {
3114                    Object[] finderArgs = new Object[] {
3115                                    groupId, articleId,
3116                                    
3117                                    String.valueOf(start), String.valueOf(end),
3118                                    String.valueOf(orderByComparator)
3119                            };
3120    
3121                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_A,
3122                                    finderArgs, this);
3123    
3124                    if (list == null) {
3125                            Session session = null;
3126    
3127                            try {
3128                                    session = openSession();
3129    
3130                                    StringBundler query = null;
3131    
3132                                    if (orderByComparator != null) {
3133                                            query = new StringBundler(4 +
3134                                                            (orderByComparator.getOrderByFields().length * 3));
3135                                    }
3136                                    else {
3137                                            query = new StringBundler(4);
3138                                    }
3139    
3140                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3141    
3142                                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
3143    
3144                                    if (articleId == null) {
3145                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
3146                                    }
3147                                    else {
3148                                            if (articleId.equals(StringPool.BLANK)) {
3149                                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
3150                                            }
3151                                            else {
3152                                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
3153                                            }
3154                                    }
3155    
3156                                    if (orderByComparator != null) {
3157                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3158                                                    orderByComparator);
3159                                    }
3160    
3161                                    else {
3162                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3163                                    }
3164    
3165                                    String sql = query.toString();
3166    
3167                                    Query q = session.createQuery(sql);
3168    
3169                                    QueryPos qPos = QueryPos.getInstance(q);
3170    
3171                                    qPos.add(groupId);
3172    
3173                                    if (articleId != null) {
3174                                            qPos.add(articleId);
3175                                    }
3176    
3177                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3178                                                    start, end);
3179                            }
3180                            catch (Exception e) {
3181                                    throw processException(e);
3182                            }
3183                            finally {
3184                                    if (list == null) {
3185                                            list = new ArrayList<JournalArticle>();
3186                                    }
3187    
3188                                    cacheResult(list);
3189    
3190                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_A, finderArgs,
3191                                            list);
3192    
3193                                    closeSession(session);
3194                            }
3195                    }
3196    
3197                    return list;
3198            }
3199    
3200            /**
3201             * Finds the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
3202             *
3203             * <p>
3204             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3205             * </p>
3206             *
3207             * @param groupId the group id to search with
3208             * @param articleId the article id to search with
3209             * @param orderByComparator the comparator to order the set by
3210             * @return the first matching journal article
3211             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3212             * @throws SystemException if a system exception occurred
3213             */
3214            public JournalArticle findByG_A_First(long groupId, String articleId,
3215                    OrderByComparator orderByComparator)
3216                    throws NoSuchArticleException, SystemException {
3217                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
3218                                    orderByComparator);
3219    
3220                    if (list.isEmpty()) {
3221                            StringBundler msg = new StringBundler(6);
3222    
3223                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3224    
3225                            msg.append("groupId=");
3226                            msg.append(groupId);
3227    
3228                            msg.append(", articleId=");
3229                            msg.append(articleId);
3230    
3231                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3232    
3233                            throw new NoSuchArticleException(msg.toString());
3234                    }
3235                    else {
3236                            return list.get(0);
3237                    }
3238            }
3239    
3240            /**
3241             * Finds the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
3242             *
3243             * <p>
3244             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3245             * </p>
3246             *
3247             * @param groupId the group id to search with
3248             * @param articleId the article id to search with
3249             * @param orderByComparator the comparator to order the set by
3250             * @return the last matching journal article
3251             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3252             * @throws SystemException if a system exception occurred
3253             */
3254            public JournalArticle findByG_A_Last(long groupId, String articleId,
3255                    OrderByComparator orderByComparator)
3256                    throws NoSuchArticleException, SystemException {
3257                    int count = countByG_A(groupId, articleId);
3258    
3259                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
3260                                    count, orderByComparator);
3261    
3262                    if (list.isEmpty()) {
3263                            StringBundler msg = new StringBundler(6);
3264    
3265                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3266    
3267                            msg.append("groupId=");
3268                            msg.append(groupId);
3269    
3270                            msg.append(", articleId=");
3271                            msg.append(articleId);
3272    
3273                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3274    
3275                            throw new NoSuchArticleException(msg.toString());
3276                    }
3277                    else {
3278                            return list.get(0);
3279                    }
3280            }
3281    
3282            /**
3283             * Finds the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
3284             *
3285             * <p>
3286             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3287             * </p>
3288             *
3289             * @param id the primary key of the current journal article
3290             * @param groupId the group id to search with
3291             * @param articleId the article id to search with
3292             * @param orderByComparator the comparator to order the set by
3293             * @return the previous, current, and next journal article
3294             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3295             * @throws SystemException if a system exception occurred
3296             */
3297            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
3298                    String articleId, OrderByComparator orderByComparator)
3299                    throws NoSuchArticleException, SystemException {
3300                    JournalArticle journalArticle = findByPrimaryKey(id);
3301    
3302                    Session session = null;
3303    
3304                    try {
3305                            session = openSession();
3306    
3307                            JournalArticle[] array = new JournalArticleImpl[3];
3308    
3309                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
3310                                            articleId, orderByComparator, true);
3311    
3312                            array[1] = journalArticle;
3313    
3314                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
3315                                            articleId, orderByComparator, false);
3316    
3317                            return array;
3318                    }
3319                    catch (Exception e) {
3320                            throw processException(e);
3321                    }
3322                    finally {
3323                            closeSession(session);
3324                    }
3325            }
3326    
3327            protected JournalArticle getByG_A_PrevAndNext(Session session,
3328                    JournalArticle journalArticle, long groupId, String articleId,
3329                    OrderByComparator orderByComparator, boolean previous) {
3330                    StringBundler query = null;
3331    
3332                    if (orderByComparator != null) {
3333                            query = new StringBundler(6 +
3334                                            (orderByComparator.getOrderByFields().length * 6));
3335                    }
3336                    else {
3337                            query = new StringBundler(3);
3338                    }
3339    
3340                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3341    
3342                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
3343    
3344                    if (articleId == null) {
3345                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
3346                    }
3347                    else {
3348                            if (articleId.equals(StringPool.BLANK)) {
3349                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
3350                            }
3351                            else {
3352                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
3353                            }
3354                    }
3355    
3356                    if (orderByComparator != null) {
3357                            String[] orderByFields = orderByComparator.getOrderByFields();
3358    
3359                            if (orderByFields.length > 0) {
3360                                    query.append(WHERE_AND);
3361                            }
3362    
3363                            for (int i = 0; i < orderByFields.length; i++) {
3364                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3365                                    query.append(orderByFields[i]);
3366    
3367                                    if ((i + 1) < orderByFields.length) {
3368                                            if (orderByComparator.isAscending() ^ previous) {
3369                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3370                                            }
3371                                            else {
3372                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3373                                            }
3374                                    }
3375                                    else {
3376                                            if (orderByComparator.isAscending() ^ previous) {
3377                                                    query.append(WHERE_GREATER_THAN);
3378                                            }
3379                                            else {
3380                                                    query.append(WHERE_LESSER_THAN);
3381                                            }
3382                                    }
3383                            }
3384    
3385                            query.append(ORDER_BY_CLAUSE);
3386    
3387                            for (int i = 0; i < orderByFields.length; i++) {
3388                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3389                                    query.append(orderByFields[i]);
3390    
3391                                    if ((i + 1) < orderByFields.length) {
3392                                            if (orderByComparator.isAscending() ^ previous) {
3393                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3394                                            }
3395                                            else {
3396                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3397                                            }
3398                                    }
3399                                    else {
3400                                            if (orderByComparator.isAscending() ^ previous) {
3401                                                    query.append(ORDER_BY_ASC);
3402                                            }
3403                                            else {
3404                                                    query.append(ORDER_BY_DESC);
3405                                            }
3406                                    }
3407                            }
3408                    }
3409    
3410                    else {
3411                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3412                    }
3413    
3414                    String sql = query.toString();
3415    
3416                    Query q = session.createQuery(sql);
3417    
3418                    q.setFirstResult(0);
3419                    q.setMaxResults(2);
3420    
3421                    QueryPos qPos = QueryPos.getInstance(q);
3422    
3423                    qPos.add(groupId);
3424    
3425                    if (articleId != null) {
3426                            qPos.add(articleId);
3427                    }
3428    
3429                    if (orderByComparator != null) {
3430                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
3431    
3432                            for (Object value : values) {
3433                                    qPos.add(value);
3434                            }
3435                    }
3436    
3437                    List<JournalArticle> list = q.list();
3438    
3439                    if (list.size() == 2) {
3440                            return list.get(1);
3441                    }
3442                    else {
3443                            return null;
3444                    }
3445            }
3446    
3447            /**
3448             * Filters by the user's permissions and finds all the journal articles where groupId = &#63; and articleId = &#63;.
3449             *
3450             * @param groupId the group id to search with
3451             * @param articleId the article id to search with
3452             * @return the matching journal articles that the user has permission to view
3453             * @throws SystemException if a system exception occurred
3454             */
3455            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
3456                    throws SystemException {
3457                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
3458                            QueryUtil.ALL_POS, null);
3459            }
3460    
3461            /**
3462             * Filters by the user's permissions and finds a range of all the journal articles where groupId = &#63; and articleId = &#63;.
3463             *
3464             * <p>
3465             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3466             * </p>
3467             *
3468             * @param groupId the group id to search with
3469             * @param articleId the article id to search with
3470             * @param start the lower bound of the range of journal articles to return
3471             * @param end the upper bound of the range of journal articles to return (not inclusive)
3472             * @return the range of matching journal articles that the user has permission to view
3473             * @throws SystemException if a system exception occurred
3474             */
3475            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
3476                    int start, int end) throws SystemException {
3477                    return filterFindByG_A(groupId, articleId, start, end, null);
3478            }
3479    
3480            /**
3481             * Filters by the user's permissions and finds an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
3482             *
3483             * <p>
3484             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3485             * </p>
3486             *
3487             * @param groupId the group id to search with
3488             * @param articleId the article id to search with
3489             * @param start the lower bound of the range of journal articles to return
3490             * @param end the upper bound of the range of journal articles to return (not inclusive)
3491             * @param orderByComparator the comparator to order the results by
3492             * @return the ordered range of matching journal articles that the user has permission to view
3493             * @throws SystemException if a system exception occurred
3494             */
3495            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
3496                    int start, int end, OrderByComparator orderByComparator)
3497                    throws SystemException {
3498                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3499                            return findByG_A(groupId, articleId, start, end, orderByComparator);
3500                    }
3501    
3502                    Session session = null;
3503    
3504                    try {
3505                            session = openSession();
3506    
3507                            StringBundler query = null;
3508    
3509                            if (orderByComparator != null) {
3510                                    query = new StringBundler(4 +
3511                                                    (orderByComparator.getOrderByFields().length * 3));
3512                            }
3513                            else {
3514                                    query = new StringBundler(4);
3515                            }
3516    
3517                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
3518    
3519                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
3520    
3521                            if (articleId == null) {
3522                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
3523                            }
3524                            else {
3525                                    if (articleId.equals(StringPool.BLANK)) {
3526                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
3527                                    }
3528                                    else {
3529                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
3530                                    }
3531                            }
3532    
3533                            if (orderByComparator != null) {
3534                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3535                                            orderByComparator);
3536                            }
3537    
3538                            else {
3539                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3540                            }
3541    
3542                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3543                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
3544                                            _FILTER_COLUMN_USERID, groupId);
3545    
3546                            SQLQuery q = session.createSQLQuery(sql);
3547    
3548                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
3549    
3550                            QueryPos qPos = QueryPos.getInstance(q);
3551    
3552                            qPos.add(groupId);
3553    
3554                            if (articleId != null) {
3555                                    qPos.add(articleId);
3556                            }
3557    
3558                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
3559                                    end);
3560                    }
3561                    catch (Exception e) {
3562                            throw processException(e);
3563                    }
3564                    finally {
3565                            closeSession(session);
3566                    }
3567            }
3568    
3569            /**
3570             * Finds all the journal articles where groupId = &#63; and structureId = &#63;.
3571             *
3572             * @param groupId the group id to search with
3573             * @param structureId the structure id to search with
3574             * @return the matching journal articles
3575             * @throws SystemException if a system exception occurred
3576             */
3577            public List<JournalArticle> findByG_S(long groupId, String structureId)
3578                    throws SystemException {
3579                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
3580                            QueryUtil.ALL_POS, null);
3581            }
3582    
3583            /**
3584             * Finds a range of all the journal articles where groupId = &#63; and structureId = &#63;.
3585             *
3586             * <p>
3587             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3588             * </p>
3589             *
3590             * @param groupId the group id to search with
3591             * @param structureId the structure id to search with
3592             * @param start the lower bound of the range of journal articles to return
3593             * @param end the upper bound of the range of journal articles to return (not inclusive)
3594             * @return the range of matching journal articles
3595             * @throws SystemException if a system exception occurred
3596             */
3597            public List<JournalArticle> findByG_S(long groupId, String structureId,
3598                    int start, int end) throws SystemException {
3599                    return findByG_S(groupId, structureId, start, end, null);
3600            }
3601    
3602            /**
3603             * Finds an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
3604             *
3605             * <p>
3606             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3607             * </p>
3608             *
3609             * @param groupId the group id to search with
3610             * @param structureId the structure id to search with
3611             * @param start the lower bound of the range of journal articles to return
3612             * @param end the upper bound of the range of journal articles to return (not inclusive)
3613             * @param orderByComparator the comparator to order the results by
3614             * @return the ordered range of matching journal articles
3615             * @throws SystemException if a system exception occurred
3616             */
3617            public List<JournalArticle> findByG_S(long groupId, String structureId,
3618                    int start, int end, OrderByComparator orderByComparator)
3619                    throws SystemException {
3620                    Object[] finderArgs = new Object[] {
3621                                    groupId, structureId,
3622                                    
3623                                    String.valueOf(start), String.valueOf(end),
3624                                    String.valueOf(orderByComparator)
3625                            };
3626    
3627                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_S,
3628                                    finderArgs, this);
3629    
3630                    if (list == null) {
3631                            Session session = null;
3632    
3633                            try {
3634                                    session = openSession();
3635    
3636                                    StringBundler query = null;
3637    
3638                                    if (orderByComparator != null) {
3639                                            query = new StringBundler(4 +
3640                                                            (orderByComparator.getOrderByFields().length * 3));
3641                                    }
3642                                    else {
3643                                            query = new StringBundler(4);
3644                                    }
3645    
3646                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3647    
3648                                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3649    
3650                                    if (structureId == null) {
3651                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
3652                                    }
3653                                    else {
3654                                            if (structureId.equals(StringPool.BLANK)) {
3655                                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
3656                                            }
3657                                            else {
3658                                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
3659                                            }
3660                                    }
3661    
3662                                    if (orderByComparator != null) {
3663                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3664                                                    orderByComparator);
3665                                    }
3666    
3667                                    else {
3668                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3669                                    }
3670    
3671                                    String sql = query.toString();
3672    
3673                                    Query q = session.createQuery(sql);
3674    
3675                                    QueryPos qPos = QueryPos.getInstance(q);
3676    
3677                                    qPos.add(groupId);
3678    
3679                                    if (structureId != null) {
3680                                            qPos.add(structureId);
3681                                    }
3682    
3683                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3684                                                    start, end);
3685                            }
3686                            catch (Exception e) {
3687                                    throw processException(e);
3688                            }
3689                            finally {
3690                                    if (list == null) {
3691                                            list = new ArrayList<JournalArticle>();
3692                                    }
3693    
3694                                    cacheResult(list);
3695    
3696                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_S, finderArgs,
3697                                            list);
3698    
3699                                    closeSession(session);
3700                            }
3701                    }
3702    
3703                    return list;
3704            }
3705    
3706            /**
3707             * Finds the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
3708             *
3709             * <p>
3710             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3711             * </p>
3712             *
3713             * @param groupId the group id to search with
3714             * @param structureId the structure id to search with
3715             * @param orderByComparator the comparator to order the set by
3716             * @return the first matching journal article
3717             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3718             * @throws SystemException if a system exception occurred
3719             */
3720            public JournalArticle findByG_S_First(long groupId, String structureId,
3721                    OrderByComparator orderByComparator)
3722                    throws NoSuchArticleException, SystemException {
3723                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
3724                                    orderByComparator);
3725    
3726                    if (list.isEmpty()) {
3727                            StringBundler msg = new StringBundler(6);
3728    
3729                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3730    
3731                            msg.append("groupId=");
3732                            msg.append(groupId);
3733    
3734                            msg.append(", structureId=");
3735                            msg.append(structureId);
3736    
3737                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3738    
3739                            throw new NoSuchArticleException(msg.toString());
3740                    }
3741                    else {
3742                            return list.get(0);
3743                    }
3744            }
3745    
3746            /**
3747             * Finds the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
3748             *
3749             * <p>
3750             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3751             * </p>
3752             *
3753             * @param groupId the group id to search with
3754             * @param structureId the structure id to search with
3755             * @param orderByComparator the comparator to order the set by
3756             * @return the last matching journal article
3757             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3758             * @throws SystemException if a system exception occurred
3759             */
3760            public JournalArticle findByG_S_Last(long groupId, String structureId,
3761                    OrderByComparator orderByComparator)
3762                    throws NoSuchArticleException, SystemException {
3763                    int count = countByG_S(groupId, structureId);
3764    
3765                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
3766                                    count, orderByComparator);
3767    
3768                    if (list.isEmpty()) {
3769                            StringBundler msg = new StringBundler(6);
3770    
3771                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3772    
3773                            msg.append("groupId=");
3774                            msg.append(groupId);
3775    
3776                            msg.append(", structureId=");
3777                            msg.append(structureId);
3778    
3779                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3780    
3781                            throw new NoSuchArticleException(msg.toString());
3782                    }
3783                    else {
3784                            return list.get(0);
3785                    }
3786            }
3787    
3788            /**
3789             * Finds the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
3790             *
3791             * <p>
3792             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3793             * </p>
3794             *
3795             * @param id the primary key of the current journal article
3796             * @param groupId the group id to search with
3797             * @param structureId the structure id to search with
3798             * @param orderByComparator the comparator to order the set by
3799             * @return the previous, current, and next journal article
3800             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3801             * @throws SystemException if a system exception occurred
3802             */
3803            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
3804                    String structureId, OrderByComparator orderByComparator)
3805                    throws NoSuchArticleException, SystemException {
3806                    JournalArticle journalArticle = findByPrimaryKey(id);
3807    
3808                    Session session = null;
3809    
3810                    try {
3811                            session = openSession();
3812    
3813                            JournalArticle[] array = new JournalArticleImpl[3];
3814    
3815                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
3816                                            structureId, orderByComparator, true);
3817    
3818                            array[1] = journalArticle;
3819    
3820                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
3821                                            structureId, orderByComparator, false);
3822    
3823                            return array;
3824                    }
3825                    catch (Exception e) {
3826                            throw processException(e);
3827                    }
3828                    finally {
3829                            closeSession(session);
3830                    }
3831            }
3832    
3833            protected JournalArticle getByG_S_PrevAndNext(Session session,
3834                    JournalArticle journalArticle, long groupId, String structureId,
3835                    OrderByComparator orderByComparator, boolean previous) {
3836                    StringBundler query = null;
3837    
3838                    if (orderByComparator != null) {
3839                            query = new StringBundler(6 +
3840                                            (orderByComparator.getOrderByFields().length * 6));
3841                    }
3842                    else {
3843                            query = new StringBundler(3);
3844                    }
3845    
3846                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3847    
3848                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3849    
3850                    if (structureId == null) {
3851                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
3852                    }
3853                    else {
3854                            if (structureId.equals(StringPool.BLANK)) {
3855                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
3856                            }
3857                            else {
3858                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
3859                            }
3860                    }
3861    
3862                    if (orderByComparator != null) {
3863                            String[] orderByFields = orderByComparator.getOrderByFields();
3864    
3865                            if (orderByFields.length > 0) {
3866                                    query.append(WHERE_AND);
3867                            }
3868    
3869                            for (int i = 0; i < orderByFields.length; i++) {
3870                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3871                                    query.append(orderByFields[i]);
3872    
3873                                    if ((i + 1) < orderByFields.length) {
3874                                            if (orderByComparator.isAscending() ^ previous) {
3875                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3876                                            }
3877                                            else {
3878                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3879                                            }
3880                                    }
3881                                    else {
3882                                            if (orderByComparator.isAscending() ^ previous) {
3883                                                    query.append(WHERE_GREATER_THAN);
3884                                            }
3885                                            else {
3886                                                    query.append(WHERE_LESSER_THAN);
3887                                            }
3888                                    }
3889                            }
3890    
3891                            query.append(ORDER_BY_CLAUSE);
3892    
3893                            for (int i = 0; i < orderByFields.length; i++) {
3894                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3895                                    query.append(orderByFields[i]);
3896    
3897                                    if ((i + 1) < orderByFields.length) {
3898                                            if (orderByComparator.isAscending() ^ previous) {
3899                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3900                                            }
3901                                            else {
3902                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3903                                            }
3904                                    }
3905                                    else {
3906                                            if (orderByComparator.isAscending() ^ previous) {
3907                                                    query.append(ORDER_BY_ASC);
3908                                            }
3909                                            else {
3910                                                    query.append(ORDER_BY_DESC);
3911                                            }
3912                                    }
3913                            }
3914                    }
3915    
3916                    else {
3917                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3918                    }
3919    
3920                    String sql = query.toString();
3921    
3922                    Query q = session.createQuery(sql);
3923    
3924                    q.setFirstResult(0);
3925                    q.setMaxResults(2);
3926    
3927                    QueryPos qPos = QueryPos.getInstance(q);
3928    
3929                    qPos.add(groupId);
3930    
3931                    if (structureId != null) {
3932                            qPos.add(structureId);
3933                    }
3934    
3935                    if (orderByComparator != null) {
3936                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
3937    
3938                            for (Object value : values) {
3939                                    qPos.add(value);
3940                            }
3941                    }
3942    
3943                    List<JournalArticle> list = q.list();
3944    
3945                    if (list.size() == 2) {
3946                            return list.get(1);
3947                    }
3948                    else {
3949                            return null;
3950                    }
3951            }
3952    
3953            /**
3954             * Filters by the user's permissions and finds all the journal articles where groupId = &#63; and structureId = &#63;.
3955             *
3956             * @param groupId the group id to search with
3957             * @param structureId the structure id to search with
3958             * @return the matching journal articles that the user has permission to view
3959             * @throws SystemException if a system exception occurred
3960             */
3961            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
3962                    throws SystemException {
3963                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
3964                            QueryUtil.ALL_POS, null);
3965            }
3966    
3967            /**
3968             * Filters by the user's permissions and finds a range of all the journal articles where groupId = &#63; and structureId = &#63;.
3969             *
3970             * <p>
3971             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3972             * </p>
3973             *
3974             * @param groupId the group id to search with
3975             * @param structureId the structure id to search with
3976             * @param start the lower bound of the range of journal articles to return
3977             * @param end the upper bound of the range of journal articles to return (not inclusive)
3978             * @return the range of matching journal articles that the user has permission to view
3979             * @throws SystemException if a system exception occurred
3980             */
3981            public List<JournalArticle> filterFindByG_S(long groupId,
3982                    String structureId, int start, int end) throws SystemException {
3983                    return filterFindByG_S(groupId, structureId, start, end, null);
3984            }
3985    
3986            /**
3987             * Filters by the user's permissions and finds an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
3988             *
3989             * <p>
3990             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3991             * </p>
3992             *
3993             * @param groupId the group id to search with
3994             * @param structureId the structure id to search with
3995             * @param start the lower bound of the range of journal articles to return
3996             * @param end the upper bound of the range of journal articles to return (not inclusive)
3997             * @param orderByComparator the comparator to order the results by
3998             * @return the ordered range of matching journal articles that the user has permission to view
3999             * @throws SystemException if a system exception occurred
4000             */
4001            public List<JournalArticle> filterFindByG_S(long groupId,
4002                    String structureId, int start, int end,
4003                    OrderByComparator orderByComparator) throws SystemException {
4004                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4005                            return findByG_S(groupId, structureId, start, end, orderByComparator);
4006                    }
4007    
4008                    Session session = null;
4009    
4010                    try {
4011                            session = openSession();
4012    
4013                            StringBundler query = null;
4014    
4015                            if (orderByComparator != null) {
4016                                    query = new StringBundler(4 +
4017                                                    (orderByComparator.getOrderByFields().length * 3));
4018                            }
4019                            else {
4020                                    query = new StringBundler(4);
4021                            }
4022    
4023                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
4024    
4025                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4026    
4027                            if (structureId == null) {
4028                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
4029                            }
4030                            else {
4031                                    if (structureId.equals(StringPool.BLANK)) {
4032                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
4033                                    }
4034                                    else {
4035                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
4036                                    }
4037                            }
4038    
4039                            if (orderByComparator != null) {
4040                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4041                                            orderByComparator);
4042                            }
4043    
4044                            else {
4045                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4046                            }
4047    
4048                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4049                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
4050                                            _FILTER_COLUMN_USERID, groupId);
4051    
4052                            SQLQuery q = session.createSQLQuery(sql);
4053    
4054                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
4055    
4056                            QueryPos qPos = QueryPos.getInstance(q);
4057    
4058                            qPos.add(groupId);
4059    
4060                            if (structureId != null) {
4061                                    qPos.add(structureId);
4062                            }
4063    
4064                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
4065                                    end);
4066                    }
4067                    catch (Exception e) {
4068                            throw processException(e);
4069                    }
4070                    finally {
4071                            closeSession(session);
4072                    }
4073            }
4074    
4075            /**
4076             * Finds all the journal articles where groupId = &#63; and templateId = &#63;.
4077             *
4078             * @param groupId the group id to search with
4079             * @param templateId the template id to search with
4080             * @return the matching journal articles
4081             * @throws SystemException if a system exception occurred
4082             */
4083            public List<JournalArticle> findByG_T(long groupId, String templateId)
4084                    throws SystemException {
4085                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
4086                            QueryUtil.ALL_POS, null);
4087            }
4088    
4089            /**
4090             * Finds a range of all the journal articles where groupId = &#63; and templateId = &#63;.
4091             *
4092             * <p>
4093             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4094             * </p>
4095             *
4096             * @param groupId the group id to search with
4097             * @param templateId the template id to search with
4098             * @param start the lower bound of the range of journal articles to return
4099             * @param end the upper bound of the range of journal articles to return (not inclusive)
4100             * @return the range of matching journal articles
4101             * @throws SystemException if a system exception occurred
4102             */
4103            public List<JournalArticle> findByG_T(long groupId, String templateId,
4104                    int start, int end) throws SystemException {
4105                    return findByG_T(groupId, templateId, start, end, null);
4106            }
4107    
4108            /**
4109             * Finds an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
4110             *
4111             * <p>
4112             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4113             * </p>
4114             *
4115             * @param groupId the group id to search with
4116             * @param templateId the template id to search with
4117             * @param start the lower bound of the range of journal articles to return
4118             * @param end the upper bound of the range of journal articles to return (not inclusive)
4119             * @param orderByComparator the comparator to order the results by
4120             * @return the ordered range of matching journal articles
4121             * @throws SystemException if a system exception occurred
4122             */
4123            public List<JournalArticle> findByG_T(long groupId, String templateId,
4124                    int start, int end, OrderByComparator orderByComparator)
4125                    throws SystemException {
4126                    Object[] finderArgs = new Object[] {
4127                                    groupId, templateId,
4128                                    
4129                                    String.valueOf(start), String.valueOf(end),
4130                                    String.valueOf(orderByComparator)
4131                            };
4132    
4133                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_T,
4134                                    finderArgs, this);
4135    
4136                    if (list == null) {
4137                            Session session = null;
4138    
4139                            try {
4140                                    session = openSession();
4141    
4142                                    StringBundler query = null;
4143    
4144                                    if (orderByComparator != null) {
4145                                            query = new StringBundler(4 +
4146                                                            (orderByComparator.getOrderByFields().length * 3));
4147                                    }
4148                                    else {
4149                                            query = new StringBundler(4);
4150                                    }
4151    
4152                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4153    
4154                                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
4155    
4156                                    if (templateId == null) {
4157                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
4158                                    }
4159                                    else {
4160                                            if (templateId.equals(StringPool.BLANK)) {
4161                                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
4162                                            }
4163                                            else {
4164                                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
4165                                            }
4166                                    }
4167    
4168                                    if (orderByComparator != null) {
4169                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4170                                                    orderByComparator);
4171                                    }
4172    
4173                                    else {
4174                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4175                                    }
4176    
4177                                    String sql = query.toString();
4178    
4179                                    Query q = session.createQuery(sql);
4180    
4181                                    QueryPos qPos = QueryPos.getInstance(q);
4182    
4183                                    qPos.add(groupId);
4184    
4185                                    if (templateId != null) {
4186                                            qPos.add(templateId);
4187                                    }
4188    
4189                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4190                                                    start, end);
4191                            }
4192                            catch (Exception e) {
4193                                    throw processException(e);
4194                            }
4195                            finally {
4196                                    if (list == null) {
4197                                            list = new ArrayList<JournalArticle>();
4198                                    }
4199    
4200                                    cacheResult(list);
4201    
4202                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_T, finderArgs,
4203                                            list);
4204    
4205                                    closeSession(session);
4206                            }
4207                    }
4208    
4209                    return list;
4210            }
4211    
4212            /**
4213             * Finds the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
4214             *
4215             * <p>
4216             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4217             * </p>
4218             *
4219             * @param groupId the group id to search with
4220             * @param templateId the template id to search with
4221             * @param orderByComparator the comparator to order the set by
4222             * @return the first matching journal article
4223             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4224             * @throws SystemException if a system exception occurred
4225             */
4226            public JournalArticle findByG_T_First(long groupId, String templateId,
4227                    OrderByComparator orderByComparator)
4228                    throws NoSuchArticleException, SystemException {
4229                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
4230                                    orderByComparator);
4231    
4232                    if (list.isEmpty()) {
4233                            StringBundler msg = new StringBundler(6);
4234    
4235                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4236    
4237                            msg.append("groupId=");
4238                            msg.append(groupId);
4239    
4240                            msg.append(", templateId=");
4241                            msg.append(templateId);
4242    
4243                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4244    
4245                            throw new NoSuchArticleException(msg.toString());
4246                    }
4247                    else {
4248                            return list.get(0);
4249                    }
4250            }
4251    
4252            /**
4253             * Finds the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
4254             *
4255             * <p>
4256             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4257             * </p>
4258             *
4259             * @param groupId the group id to search with
4260             * @param templateId the template id to search with
4261             * @param orderByComparator the comparator to order the set by
4262             * @return the last matching journal article
4263             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4264             * @throws SystemException if a system exception occurred
4265             */
4266            public JournalArticle findByG_T_Last(long groupId, String templateId,
4267                    OrderByComparator orderByComparator)
4268                    throws NoSuchArticleException, SystemException {
4269                    int count = countByG_T(groupId, templateId);
4270    
4271                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
4272                                    count, orderByComparator);
4273    
4274                    if (list.isEmpty()) {
4275                            StringBundler msg = new StringBundler(6);
4276    
4277                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4278    
4279                            msg.append("groupId=");
4280                            msg.append(groupId);
4281    
4282                            msg.append(", templateId=");
4283                            msg.append(templateId);
4284    
4285                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4286    
4287                            throw new NoSuchArticleException(msg.toString());
4288                    }
4289                    else {
4290                            return list.get(0);
4291                    }
4292            }
4293    
4294            /**
4295             * Finds the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
4296             *
4297             * <p>
4298             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4299             * </p>
4300             *
4301             * @param id the primary key of the current journal article
4302             * @param groupId the group id to search with
4303             * @param templateId the template id to search with
4304             * @param orderByComparator the comparator to order the set by
4305             * @return the previous, current, and next journal article
4306             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4307             * @throws SystemException if a system exception occurred
4308             */
4309            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
4310                    String templateId, OrderByComparator orderByComparator)
4311                    throws NoSuchArticleException, SystemException {
4312                    JournalArticle journalArticle = findByPrimaryKey(id);
4313    
4314                    Session session = null;
4315    
4316                    try {
4317                            session = openSession();
4318    
4319                            JournalArticle[] array = new JournalArticleImpl[3];
4320    
4321                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
4322                                            templateId, orderByComparator, true);
4323    
4324                            array[1] = journalArticle;
4325    
4326                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
4327                                            templateId, orderByComparator, false);
4328    
4329                            return array;
4330                    }
4331                    catch (Exception e) {
4332                            throw processException(e);
4333                    }
4334                    finally {
4335                            closeSession(session);
4336                    }
4337            }
4338    
4339            protected JournalArticle getByG_T_PrevAndNext(Session session,
4340                    JournalArticle journalArticle, long groupId, String templateId,
4341                    OrderByComparator orderByComparator, boolean previous) {
4342                    StringBundler query = null;
4343    
4344                    if (orderByComparator != null) {
4345                            query = new StringBundler(6 +
4346                                            (orderByComparator.getOrderByFields().length * 6));
4347                    }
4348                    else {
4349                            query = new StringBundler(3);
4350                    }
4351    
4352                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4353    
4354                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
4355    
4356                    if (templateId == null) {
4357                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
4358                    }
4359                    else {
4360                            if (templateId.equals(StringPool.BLANK)) {
4361                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
4362                            }
4363                            else {
4364                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
4365                            }
4366                    }
4367    
4368                    if (orderByComparator != null) {
4369                            String[] orderByFields = orderByComparator.getOrderByFields();
4370    
4371                            if (orderByFields.length > 0) {
4372                                    query.append(WHERE_AND);
4373                            }
4374    
4375                            for (int i = 0; i < orderByFields.length; i++) {
4376                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4377                                    query.append(orderByFields[i]);
4378    
4379                                    if ((i + 1) < orderByFields.length) {
4380                                            if (orderByComparator.isAscending() ^ previous) {
4381                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4382                                            }
4383                                            else {
4384                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4385                                            }
4386                                    }
4387                                    else {
4388                                            if (orderByComparator.isAscending() ^ previous) {
4389                                                    query.append(WHERE_GREATER_THAN);
4390                                            }
4391                                            else {
4392                                                    query.append(WHERE_LESSER_THAN);
4393                                            }
4394                                    }
4395                            }
4396    
4397                            query.append(ORDER_BY_CLAUSE);
4398    
4399                            for (int i = 0; i < orderByFields.length; i++) {
4400                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4401                                    query.append(orderByFields[i]);
4402    
4403                                    if ((i + 1) < orderByFields.length) {
4404                                            if (orderByComparator.isAscending() ^ previous) {
4405                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4406                                            }
4407                                            else {
4408                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4409                                            }
4410                                    }
4411                                    else {
4412                                            if (orderByComparator.isAscending() ^ previous) {
4413                                                    query.append(ORDER_BY_ASC);
4414                                            }
4415                                            else {
4416                                                    query.append(ORDER_BY_DESC);
4417                                            }
4418                                    }
4419                            }
4420                    }
4421    
4422                    else {
4423                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4424                    }
4425    
4426                    String sql = query.toString();
4427    
4428                    Query q = session.createQuery(sql);
4429    
4430                    q.setFirstResult(0);
4431                    q.setMaxResults(2);
4432    
4433                    QueryPos qPos = QueryPos.getInstance(q);
4434    
4435                    qPos.add(groupId);
4436    
4437                    if (templateId != null) {
4438                            qPos.add(templateId);
4439                    }
4440    
4441                    if (orderByComparator != null) {
4442                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
4443    
4444                            for (Object value : values) {
4445                                    qPos.add(value);
4446                            }
4447                    }
4448    
4449                    List<JournalArticle> list = q.list();
4450    
4451                    if (list.size() == 2) {
4452                            return list.get(1);
4453                    }
4454                    else {
4455                            return null;
4456                    }
4457            }
4458    
4459            /**
4460             * Filters by the user's permissions and finds all the journal articles where groupId = &#63; and templateId = &#63;.
4461             *
4462             * @param groupId the group id to search with
4463             * @param templateId the template id to search with
4464             * @return the matching journal articles that the user has permission to view
4465             * @throws SystemException if a system exception occurred
4466             */
4467            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
4468                    throws SystemException {
4469                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
4470                            QueryUtil.ALL_POS, null);
4471            }
4472    
4473            /**
4474             * Filters by the user's permissions and finds a range of all the journal articles where groupId = &#63; and templateId = &#63;.
4475             *
4476             * <p>
4477             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4478             * </p>
4479             *
4480             * @param groupId the group id to search with
4481             * @param templateId the template id to search with
4482             * @param start the lower bound of the range of journal articles to return
4483             * @param end the upper bound of the range of journal articles to return (not inclusive)
4484             * @return the range of matching journal articles that the user has permission to view
4485             * @throws SystemException if a system exception occurred
4486             */
4487            public List<JournalArticle> filterFindByG_T(long groupId,
4488                    String templateId, int start, int end) throws SystemException {
4489                    return filterFindByG_T(groupId, templateId, start, end, null);
4490            }
4491    
4492            /**
4493             * Filters by the user's permissions and finds an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
4494             *
4495             * <p>
4496             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4497             * </p>
4498             *
4499             * @param groupId the group id to search with
4500             * @param templateId the template id to search with
4501             * @param start the lower bound of the range of journal articles to return
4502             * @param end the upper bound of the range of journal articles to return (not inclusive)
4503             * @param orderByComparator the comparator to order the results by
4504             * @return the ordered range of matching journal articles that the user has permission to view
4505             * @throws SystemException if a system exception occurred
4506             */
4507            public List<JournalArticle> filterFindByG_T(long groupId,
4508                    String templateId, int start, int end,
4509                    OrderByComparator orderByComparator) throws SystemException {
4510                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4511                            return findByG_T(groupId, templateId, start, end, orderByComparator);
4512                    }
4513    
4514                    Session session = null;
4515    
4516                    try {
4517                            session = openSession();
4518    
4519                            StringBundler query = null;
4520    
4521                            if (orderByComparator != null) {
4522                                    query = new StringBundler(4 +
4523                                                    (orderByComparator.getOrderByFields().length * 3));
4524                            }
4525                            else {
4526                                    query = new StringBundler(4);
4527                            }
4528    
4529                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
4530    
4531                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
4532    
4533                            if (templateId == null) {
4534                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
4535                            }
4536                            else {
4537                                    if (templateId.equals(StringPool.BLANK)) {
4538                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
4539                                    }
4540                                    else {
4541                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
4542                                    }
4543                            }
4544    
4545                            if (orderByComparator != null) {
4546                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4547                                            orderByComparator);
4548                            }
4549    
4550                            else {
4551                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4552                            }
4553    
4554                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4555                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
4556                                            _FILTER_COLUMN_USERID, groupId);
4557    
4558                            SQLQuery q = session.createSQLQuery(sql);
4559    
4560                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
4561    
4562                            QueryPos qPos = QueryPos.getInstance(q);
4563    
4564                            qPos.add(groupId);
4565    
4566                            if (templateId != null) {
4567                                    qPos.add(templateId);
4568                            }
4569    
4570                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
4571                                    end);
4572                    }
4573                    catch (Exception e) {
4574                            throw processException(e);
4575                    }
4576                    finally {
4577                            closeSession(session);
4578                    }
4579            }
4580    
4581            /**
4582             * Finds all the journal articles where groupId = &#63; and urlTitle = &#63;.
4583             *
4584             * @param groupId the group id to search with
4585             * @param urlTitle the url title to search with
4586             * @return the matching journal articles
4587             * @throws SystemException if a system exception occurred
4588             */
4589            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
4590                    throws SystemException {
4591                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
4592                            QueryUtil.ALL_POS, null);
4593            }
4594    
4595            /**
4596             * Finds a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
4597             *
4598             * <p>
4599             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4600             * </p>
4601             *
4602             * @param groupId the group id to search with
4603             * @param urlTitle the url title to search with
4604             * @param start the lower bound of the range of journal articles to return
4605             * @param end the upper bound of the range of journal articles to return (not inclusive)
4606             * @return the range of matching journal articles
4607             * @throws SystemException if a system exception occurred
4608             */
4609            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
4610                    int start, int end) throws SystemException {
4611                    return findByG_UT(groupId, urlTitle, start, end, null);
4612            }
4613    
4614            /**
4615             * Finds an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
4616             *
4617             * <p>
4618             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4619             * </p>
4620             *
4621             * @param groupId the group id to search with
4622             * @param urlTitle the url title to search with
4623             * @param start the lower bound of the range of journal articles to return
4624             * @param end the upper bound of the range of journal articles to return (not inclusive)
4625             * @param orderByComparator the comparator to order the results by
4626             * @return the ordered range of matching journal articles
4627             * @throws SystemException if a system exception occurred
4628             */
4629            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
4630                    int start, int end, OrderByComparator orderByComparator)
4631                    throws SystemException {
4632                    Object[] finderArgs = new Object[] {
4633                                    groupId, urlTitle,
4634                                    
4635                                    String.valueOf(start), String.valueOf(end),
4636                                    String.valueOf(orderByComparator)
4637                            };
4638    
4639                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_UT,
4640                                    finderArgs, this);
4641    
4642                    if (list == null) {
4643                            Session session = null;
4644    
4645                            try {
4646                                    session = openSession();
4647    
4648                                    StringBundler query = null;
4649    
4650                                    if (orderByComparator != null) {
4651                                            query = new StringBundler(4 +
4652                                                            (orderByComparator.getOrderByFields().length * 3));
4653                                    }
4654                                    else {
4655                                            query = new StringBundler(4);
4656                                    }
4657    
4658                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4659    
4660                                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
4661    
4662                                    if (urlTitle == null) {
4663                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
4664                                    }
4665                                    else {
4666                                            if (urlTitle.equals(StringPool.BLANK)) {
4667                                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
4668                                            }
4669                                            else {
4670                                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
4671                                            }
4672                                    }
4673    
4674                                    if (orderByComparator != null) {
4675                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4676                                                    orderByComparator);
4677                                    }
4678    
4679                                    else {
4680                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4681                                    }
4682    
4683                                    String sql = query.toString();
4684    
4685                                    Query q = session.createQuery(sql);
4686    
4687                                    QueryPos qPos = QueryPos.getInstance(q);
4688    
4689                                    qPos.add(groupId);
4690    
4691                                    if (urlTitle != null) {
4692                                            qPos.add(urlTitle);
4693                                    }
4694    
4695                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4696                                                    start, end);
4697                            }
4698                            catch (Exception e) {
4699                                    throw processException(e);
4700                            }
4701                            finally {
4702                                    if (list == null) {
4703                                            list = new ArrayList<JournalArticle>();
4704                                    }
4705    
4706                                    cacheResult(list);
4707    
4708                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_UT, finderArgs,
4709                                            list);
4710    
4711                                    closeSession(session);
4712                            }
4713                    }
4714    
4715                    return list;
4716            }
4717    
4718            /**
4719             * Finds the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
4720             *
4721             * <p>
4722             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4723             * </p>
4724             *
4725             * @param groupId the group id to search with
4726             * @param urlTitle the url title to search with
4727             * @param orderByComparator the comparator to order the set by
4728             * @return the first matching journal article
4729             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4730             * @throws SystemException if a system exception occurred
4731             */
4732            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
4733                    OrderByComparator orderByComparator)
4734                    throws NoSuchArticleException, SystemException {
4735                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
4736                                    orderByComparator);
4737    
4738                    if (list.isEmpty()) {
4739                            StringBundler msg = new StringBundler(6);
4740    
4741                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4742    
4743                            msg.append("groupId=");
4744                            msg.append(groupId);
4745    
4746                            msg.append(", urlTitle=");
4747                            msg.append(urlTitle);
4748    
4749                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4750    
4751                            throw new NoSuchArticleException(msg.toString());
4752                    }
4753                    else {
4754                            return list.get(0);
4755                    }
4756            }
4757    
4758            /**
4759             * Finds the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
4760             *
4761             * <p>
4762             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4763             * </p>
4764             *
4765             * @param groupId the group id to search with
4766             * @param urlTitle the url title to search with
4767             * @param orderByComparator the comparator to order the set by
4768             * @return the last matching journal article
4769             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4770             * @throws SystemException if a system exception occurred
4771             */
4772            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
4773                    OrderByComparator orderByComparator)
4774                    throws NoSuchArticleException, SystemException {
4775                    int count = countByG_UT(groupId, urlTitle);
4776    
4777                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
4778                                    count, orderByComparator);
4779    
4780                    if (list.isEmpty()) {
4781                            StringBundler msg = new StringBundler(6);
4782    
4783                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4784    
4785                            msg.append("groupId=");
4786                            msg.append(groupId);
4787    
4788                            msg.append(", urlTitle=");
4789                            msg.append(urlTitle);
4790    
4791                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4792    
4793                            throw new NoSuchArticleException(msg.toString());
4794                    }
4795                    else {
4796                            return list.get(0);
4797                    }
4798            }
4799    
4800            /**
4801             * Finds the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
4802             *
4803             * <p>
4804             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4805             * </p>
4806             *
4807             * @param id the primary key of the current journal article
4808             * @param groupId the group id to search with
4809             * @param urlTitle the url title to search with
4810             * @param orderByComparator the comparator to order the set by
4811             * @return the previous, current, and next journal article
4812             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4813             * @throws SystemException if a system exception occurred
4814             */
4815            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
4816                    String urlTitle, OrderByComparator orderByComparator)
4817                    throws NoSuchArticleException, SystemException {
4818                    JournalArticle journalArticle = findByPrimaryKey(id);
4819    
4820                    Session session = null;
4821    
4822                    try {
4823                            session = openSession();
4824    
4825                            JournalArticle[] array = new JournalArticleImpl[3];
4826    
4827                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
4828                                            urlTitle, orderByComparator, true);
4829    
4830                            array[1] = journalArticle;
4831    
4832                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
4833                                            urlTitle, orderByComparator, false);
4834    
4835                            return array;
4836                    }
4837                    catch (Exception e) {
4838                            throw processException(e);
4839                    }
4840                    finally {
4841                            closeSession(session);
4842                    }
4843            }
4844    
4845            protected JournalArticle getByG_UT_PrevAndNext(Session session,
4846                    JournalArticle journalArticle, long groupId, String urlTitle,
4847                    OrderByComparator orderByComparator, boolean previous) {
4848                    StringBundler query = null;
4849    
4850                    if (orderByComparator != null) {
4851                            query = new StringBundler(6 +
4852                                            (orderByComparator.getOrderByFields().length * 6));
4853                    }
4854                    else {
4855                            query = new StringBundler(3);
4856                    }
4857    
4858                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4859    
4860                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
4861    
4862                    if (urlTitle == null) {
4863                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
4864                    }
4865                    else {
4866                            if (urlTitle.equals(StringPool.BLANK)) {
4867                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
4868                            }
4869                            else {
4870                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
4871                            }
4872                    }
4873    
4874                    if (orderByComparator != null) {
4875                            String[] orderByFields = orderByComparator.getOrderByFields();
4876    
4877                            if (orderByFields.length > 0) {
4878                                    query.append(WHERE_AND);
4879                            }
4880    
4881                            for (int i = 0; i < orderByFields.length; i++) {
4882                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4883                                    query.append(orderByFields[i]);
4884    
4885                                    if ((i + 1) < orderByFields.length) {
4886                                            if (orderByComparator.isAscending() ^ previous) {
4887                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4888                                            }
4889                                            else {
4890                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4891                                            }
4892                                    }
4893                                    else {
4894                                            if (orderByComparator.isAscending() ^ previous) {
4895                                                    query.append(WHERE_GREATER_THAN);
4896                                            }
4897                                            else {
4898                                                    query.append(WHERE_LESSER_THAN);
4899                                            }
4900                                    }
4901                            }
4902    
4903                            query.append(ORDER_BY_CLAUSE);
4904    
4905                            for (int i = 0; i < orderByFields.length; i++) {
4906                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4907                                    query.append(orderByFields[i]);
4908    
4909                                    if ((i + 1) < orderByFields.length) {
4910                                            if (orderByComparator.isAscending() ^ previous) {
4911                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4912                                            }
4913                                            else {
4914                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4915                                            }
4916                                    }
4917                                    else {
4918                                            if (orderByComparator.isAscending() ^ previous) {
4919                                                    query.append(ORDER_BY_ASC);
4920                                            }
4921                                            else {
4922                                                    query.append(ORDER_BY_DESC);
4923                                            }
4924                                    }
4925                            }
4926                    }
4927    
4928                    else {
4929                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4930                    }
4931    
4932                    String sql = query.toString();
4933    
4934                    Query q = session.createQuery(sql);
4935    
4936                    q.setFirstResult(0);
4937                    q.setMaxResults(2);
4938    
4939                    QueryPos qPos = QueryPos.getInstance(q);
4940    
4941                    qPos.add(groupId);
4942    
4943                    if (urlTitle != null) {
4944                            qPos.add(urlTitle);
4945                    }
4946    
4947                    if (orderByComparator != null) {
4948                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
4949    
4950                            for (Object value : values) {
4951                                    qPos.add(value);
4952                            }
4953                    }
4954    
4955                    List<JournalArticle> list = q.list();
4956    
4957                    if (list.size() == 2) {
4958                            return list.get(1);
4959                    }
4960                    else {
4961                            return null;
4962                    }
4963            }
4964    
4965            /**
4966             * Filters by the user's permissions and finds all the journal articles where groupId = &#63; and urlTitle = &#63;.
4967             *
4968             * @param groupId the group id to search with
4969             * @param urlTitle the url title to search with
4970             * @return the matching journal articles that the user has permission to view
4971             * @throws SystemException if a system exception occurred
4972             */
4973            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
4974                    throws SystemException {
4975                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
4976                            QueryUtil.ALL_POS, null);
4977            }
4978    
4979            /**
4980             * Filters by the user's permissions and finds a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
4981             *
4982             * <p>
4983             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4984             * </p>
4985             *
4986             * @param groupId the group id to search with
4987             * @param urlTitle the url title to search with
4988             * @param start the lower bound of the range of journal articles to return
4989             * @param end the upper bound of the range of journal articles to return (not inclusive)
4990             * @return the range of matching journal articles that the user has permission to view
4991             * @throws SystemException if a system exception occurred
4992             */
4993            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
4994                    int start, int end) throws SystemException {
4995                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
4996            }
4997    
4998            /**
4999             * Filters by the user's permissions and finds an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
5000             *
5001             * <p>
5002             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5003             * </p>
5004             *
5005             * @param groupId the group id to search with
5006             * @param urlTitle the url title to search with
5007             * @param start the lower bound of the range of journal articles to return
5008             * @param end the upper bound of the range of journal articles to return (not inclusive)
5009             * @param orderByComparator the comparator to order the results by
5010             * @return the ordered range of matching journal articles that the user has permission to view
5011             * @throws SystemException if a system exception occurred
5012             */
5013            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
5014                    int start, int end, OrderByComparator orderByComparator)
5015                    throws SystemException {
5016                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5017                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
5018                    }
5019    
5020                    Session session = null;
5021    
5022                    try {
5023                            session = openSession();
5024    
5025                            StringBundler query = null;
5026    
5027                            if (orderByComparator != null) {
5028                                    query = new StringBundler(4 +
5029                                                    (orderByComparator.getOrderByFields().length * 3));
5030                            }
5031                            else {
5032                                    query = new StringBundler(4);
5033                            }
5034    
5035                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
5036    
5037                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5038    
5039                            if (urlTitle == null) {
5040                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5041                            }
5042                            else {
5043                                    if (urlTitle.equals(StringPool.BLANK)) {
5044                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5045                                    }
5046                                    else {
5047                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5048                                    }
5049                            }
5050    
5051                            if (orderByComparator != null) {
5052                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5053                                            orderByComparator);
5054                            }
5055    
5056                            else {
5057                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5058                            }
5059    
5060                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5061                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
5062                                            _FILTER_COLUMN_USERID, groupId);
5063    
5064                            SQLQuery q = session.createSQLQuery(sql);
5065    
5066                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
5067    
5068                            QueryPos qPos = QueryPos.getInstance(q);
5069    
5070                            qPos.add(groupId);
5071    
5072                            if (urlTitle != null) {
5073                                    qPos.add(urlTitle);
5074                            }
5075    
5076                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
5077                                    end);
5078                    }
5079                    catch (Exception e) {
5080                            throw processException(e);
5081                    }
5082                    finally {
5083                            closeSession(session);
5084                    }
5085            }
5086    
5087            /**
5088             * Finds all the journal articles where groupId = &#63; and status = &#63;.
5089             *
5090             * @param groupId the group id to search with
5091             * @param status the status to search with
5092             * @return the matching journal articles
5093             * @throws SystemException if a system exception occurred
5094             */
5095            public List<JournalArticle> findByG_ST(long groupId, int status)
5096                    throws SystemException {
5097                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
5098                            QueryUtil.ALL_POS, null);
5099            }
5100    
5101            /**
5102             * Finds a range of all the journal articles where groupId = &#63; and status = &#63;.
5103             *
5104             * <p>
5105             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5106             * </p>
5107             *
5108             * @param groupId the group id to search with
5109             * @param status the status to search with
5110             * @param start the lower bound of the range of journal articles to return
5111             * @param end the upper bound of the range of journal articles to return (not inclusive)
5112             * @return the range of matching journal articles
5113             * @throws SystemException if a system exception occurred
5114             */
5115            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
5116                    int end) throws SystemException {
5117                    return findByG_ST(groupId, status, start, end, null);
5118            }
5119    
5120            /**
5121             * Finds an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
5122             *
5123             * <p>
5124             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5125             * </p>
5126             *
5127             * @param groupId the group id to search with
5128             * @param status the status to search with
5129             * @param start the lower bound of the range of journal articles to return
5130             * @param end the upper bound of the range of journal articles to return (not inclusive)
5131             * @param orderByComparator the comparator to order the results by
5132             * @return the ordered range of matching journal articles
5133             * @throws SystemException if a system exception occurred
5134             */
5135            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
5136                    int end, OrderByComparator orderByComparator) throws SystemException {
5137                    Object[] finderArgs = new Object[] {
5138                                    groupId, status,
5139                                    
5140                                    String.valueOf(start), String.valueOf(end),
5141                                    String.valueOf(orderByComparator)
5142                            };
5143    
5144                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_ST,
5145                                    finderArgs, this);
5146    
5147                    if (list == null) {
5148                            Session session = null;
5149    
5150                            try {
5151                                    session = openSession();
5152    
5153                                    StringBundler query = null;
5154    
5155                                    if (orderByComparator != null) {
5156                                            query = new StringBundler(4 +
5157                                                            (orderByComparator.getOrderByFields().length * 3));
5158                                    }
5159                                    else {
5160                                            query = new StringBundler(4);
5161                                    }
5162    
5163                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5164    
5165                                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
5166    
5167                                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
5168    
5169                                    if (orderByComparator != null) {
5170                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5171                                                    orderByComparator);
5172                                    }
5173    
5174                                    else {
5175                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5176                                    }
5177    
5178                                    String sql = query.toString();
5179    
5180                                    Query q = session.createQuery(sql);
5181    
5182                                    QueryPos qPos = QueryPos.getInstance(q);
5183    
5184                                    qPos.add(groupId);
5185    
5186                                    qPos.add(status);
5187    
5188                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5189                                                    start, end);
5190                            }
5191                            catch (Exception e) {
5192                                    throw processException(e);
5193                            }
5194                            finally {
5195                                    if (list == null) {
5196                                            list = new ArrayList<JournalArticle>();
5197                                    }
5198    
5199                                    cacheResult(list);
5200    
5201                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_ST, finderArgs,
5202                                            list);
5203    
5204                                    closeSession(session);
5205                            }
5206                    }
5207    
5208                    return list;
5209            }
5210    
5211            /**
5212             * Finds the first journal article in the ordered set where groupId = &#63; and status = &#63;.
5213             *
5214             * <p>
5215             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5216             * </p>
5217             *
5218             * @param groupId the group id to search with
5219             * @param status the status to search with
5220             * @param orderByComparator the comparator to order the set by
5221             * @return the first matching journal article
5222             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5223             * @throws SystemException if a system exception occurred
5224             */
5225            public JournalArticle findByG_ST_First(long groupId, int status,
5226                    OrderByComparator orderByComparator)
5227                    throws NoSuchArticleException, SystemException {
5228                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
5229                                    orderByComparator);
5230    
5231                    if (list.isEmpty()) {
5232                            StringBundler msg = new StringBundler(6);
5233    
5234                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5235    
5236                            msg.append("groupId=");
5237                            msg.append(groupId);
5238    
5239                            msg.append(", status=");
5240                            msg.append(status);
5241    
5242                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5243    
5244                            throw new NoSuchArticleException(msg.toString());
5245                    }
5246                    else {
5247                            return list.get(0);
5248                    }
5249            }
5250    
5251            /**
5252             * Finds the last journal article in the ordered set where groupId = &#63; and status = &#63;.
5253             *
5254             * <p>
5255             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5256             * </p>
5257             *
5258             * @param groupId the group id to search with
5259             * @param status the status to search with
5260             * @param orderByComparator the comparator to order the set by
5261             * @return the last matching journal article
5262             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5263             * @throws SystemException if a system exception occurred
5264             */
5265            public JournalArticle findByG_ST_Last(long groupId, int status,
5266                    OrderByComparator orderByComparator)
5267                    throws NoSuchArticleException, SystemException {
5268                    int count = countByG_ST(groupId, status);
5269    
5270                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
5271                                    count, orderByComparator);
5272    
5273                    if (list.isEmpty()) {
5274                            StringBundler msg = new StringBundler(6);
5275    
5276                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5277    
5278                            msg.append("groupId=");
5279                            msg.append(groupId);
5280    
5281                            msg.append(", status=");
5282                            msg.append(status);
5283    
5284                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5285    
5286                            throw new NoSuchArticleException(msg.toString());
5287                    }
5288                    else {
5289                            return list.get(0);
5290                    }
5291            }
5292    
5293            /**
5294             * Finds the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
5295             *
5296             * <p>
5297             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5298             * </p>
5299             *
5300             * @param id the primary key of the current journal article
5301             * @param groupId the group id to search with
5302             * @param status the status to search with
5303             * @param orderByComparator the comparator to order the set by
5304             * @return the previous, current, and next journal article
5305             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5306             * @throws SystemException if a system exception occurred
5307             */
5308            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
5309                    int status, OrderByComparator orderByComparator)
5310                    throws NoSuchArticleException, SystemException {
5311                    JournalArticle journalArticle = findByPrimaryKey(id);
5312    
5313                    Session session = null;
5314    
5315                    try {
5316                            session = openSession();
5317    
5318                            JournalArticle[] array = new JournalArticleImpl[3];
5319    
5320                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
5321                                            status, orderByComparator, true);
5322    
5323                            array[1] = journalArticle;
5324    
5325                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
5326                                            status, orderByComparator, false);
5327    
5328                            return array;
5329                    }
5330                    catch (Exception e) {
5331                            throw processException(e);
5332                    }
5333                    finally {
5334                            closeSession(session);
5335                    }
5336            }
5337    
5338            protected JournalArticle getByG_ST_PrevAndNext(Session session,
5339                    JournalArticle journalArticle, long groupId, int status,
5340                    OrderByComparator orderByComparator, boolean previous) {
5341                    StringBundler query = null;
5342    
5343                    if (orderByComparator != null) {
5344                            query = new StringBundler(6 +
5345                                            (orderByComparator.getOrderByFields().length * 6));
5346                    }
5347                    else {
5348                            query = new StringBundler(3);
5349                    }
5350    
5351                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5352    
5353                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
5354    
5355                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
5356    
5357                    if (orderByComparator != null) {
5358                            String[] orderByFields = orderByComparator.getOrderByFields();
5359    
5360                            if (orderByFields.length > 0) {
5361                                    query.append(WHERE_AND);
5362                            }
5363    
5364                            for (int i = 0; i < orderByFields.length; i++) {
5365                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5366                                    query.append(orderByFields[i]);
5367    
5368                                    if ((i + 1) < orderByFields.length) {
5369                                            if (orderByComparator.isAscending() ^ previous) {
5370                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5371                                            }
5372                                            else {
5373                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5374                                            }
5375                                    }
5376                                    else {
5377                                            if (orderByComparator.isAscending() ^ previous) {
5378                                                    query.append(WHERE_GREATER_THAN);
5379                                            }
5380                                            else {
5381                                                    query.append(WHERE_LESSER_THAN);
5382                                            }
5383                                    }
5384                            }
5385    
5386                            query.append(ORDER_BY_CLAUSE);
5387    
5388                            for (int i = 0; i < orderByFields.length; i++) {
5389                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5390                                    query.append(orderByFields[i]);
5391    
5392                                    if ((i + 1) < orderByFields.length) {
5393                                            if (orderByComparator.isAscending() ^ previous) {
5394                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5395                                            }
5396                                            else {
5397                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5398                                            }
5399                                    }
5400                                    else {
5401                                            if (orderByComparator.isAscending() ^ previous) {
5402                                                    query.append(ORDER_BY_ASC);
5403                                            }
5404                                            else {
5405                                                    query.append(ORDER_BY_DESC);
5406                                            }
5407                                    }
5408                            }
5409                    }
5410    
5411                    else {
5412                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5413                    }
5414    
5415                    String sql = query.toString();
5416    
5417                    Query q = session.createQuery(sql);
5418    
5419                    q.setFirstResult(0);
5420                    q.setMaxResults(2);
5421    
5422                    QueryPos qPos = QueryPos.getInstance(q);
5423    
5424                    qPos.add(groupId);
5425    
5426                    qPos.add(status);
5427    
5428                    if (orderByComparator != null) {
5429                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
5430    
5431                            for (Object value : values) {
5432                                    qPos.add(value);
5433                            }
5434                    }
5435    
5436                    List<JournalArticle> list = q.list();
5437    
5438                    if (list.size() == 2) {
5439                            return list.get(1);
5440                    }
5441                    else {
5442                            return null;
5443                    }
5444            }
5445    
5446            /**
5447             * Filters by the user's permissions and finds all the journal articles where groupId = &#63; and status = &#63;.
5448             *
5449             * @param groupId the group id to search with
5450             * @param status the status to search with
5451             * @return the matching journal articles that the user has permission to view
5452             * @throws SystemException if a system exception occurred
5453             */
5454            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
5455                    throws SystemException {
5456                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
5457                            QueryUtil.ALL_POS, null);
5458            }
5459    
5460            /**
5461             * Filters by the user's permissions and finds a range of all the journal articles where groupId = &#63; and status = &#63;.
5462             *
5463             * <p>
5464             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5465             * </p>
5466             *
5467             * @param groupId the group id to search with
5468             * @param status the status to search with
5469             * @param start the lower bound of the range of journal articles to return
5470             * @param end the upper bound of the range of journal articles to return (not inclusive)
5471             * @return the range of matching journal articles that the user has permission to view
5472             * @throws SystemException if a system exception occurred
5473             */
5474            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
5475                    int start, int end) throws SystemException {
5476                    return filterFindByG_ST(groupId, status, start, end, null);
5477            }
5478    
5479            /**
5480             * Filters by the user's permissions and finds an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
5481             *
5482             * <p>
5483             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5484             * </p>
5485             *
5486             * @param groupId the group id to search with
5487             * @param status the status to search with
5488             * @param start the lower bound of the range of journal articles to return
5489             * @param end the upper bound of the range of journal articles to return (not inclusive)
5490             * @param orderByComparator the comparator to order the results by
5491             * @return the ordered range of matching journal articles that the user has permission to view
5492             * @throws SystemException if a system exception occurred
5493             */
5494            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
5495                    int start, int end, OrderByComparator orderByComparator)
5496                    throws SystemException {
5497                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5498                            return findByG_ST(groupId, status, start, end, orderByComparator);
5499                    }
5500    
5501                    Session session = null;
5502    
5503                    try {
5504                            session = openSession();
5505    
5506                            StringBundler query = null;
5507    
5508                            if (orderByComparator != null) {
5509                                    query = new StringBundler(4 +
5510                                                    (orderByComparator.getOrderByFields().length * 3));
5511                            }
5512                            else {
5513                                    query = new StringBundler(4);
5514                            }
5515    
5516                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
5517    
5518                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
5519    
5520                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
5521    
5522                            if (orderByComparator != null) {
5523                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5524                                            orderByComparator);
5525                            }
5526    
5527                            else {
5528                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5529                            }
5530    
5531                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5532                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
5533                                            _FILTER_COLUMN_USERID, groupId);
5534    
5535                            SQLQuery q = session.createSQLQuery(sql);
5536    
5537                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
5538    
5539                            QueryPos qPos = QueryPos.getInstance(q);
5540    
5541                            qPos.add(groupId);
5542    
5543                            qPos.add(status);
5544    
5545                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
5546                                    end);
5547                    }
5548                    catch (Exception e) {
5549                            throw processException(e);
5550                    }
5551                    finally {
5552                            closeSession(session);
5553                    }
5554            }
5555    
5556            /**
5557             * Finds all the journal articles where companyId = &#63; and status = &#63;.
5558             *
5559             * @param companyId the company id to search with
5560             * @param status the status to search with
5561             * @return the matching journal articles
5562             * @throws SystemException if a system exception occurred
5563             */
5564            public List<JournalArticle> findByC_ST(long companyId, int status)
5565                    throws SystemException {
5566                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
5567                            QueryUtil.ALL_POS, null);
5568            }
5569    
5570            /**
5571             * Finds a range of all the journal articles where companyId = &#63; and status = &#63;.
5572             *
5573             * <p>
5574             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5575             * </p>
5576             *
5577             * @param companyId the company id to search with
5578             * @param status the status to search with
5579             * @param start the lower bound of the range of journal articles to return
5580             * @param end the upper bound of the range of journal articles to return (not inclusive)
5581             * @return the range of matching journal articles
5582             * @throws SystemException if a system exception occurred
5583             */
5584            public List<JournalArticle> findByC_ST(long companyId, int status,
5585                    int start, int end) throws SystemException {
5586                    return findByC_ST(companyId, status, start, end, null);
5587            }
5588    
5589            /**
5590             * Finds an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
5591             *
5592             * <p>
5593             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5594             * </p>
5595             *
5596             * @param companyId the company id to search with
5597             * @param status the status to search with
5598             * @param start the lower bound of the range of journal articles to return
5599             * @param end the upper bound of the range of journal articles to return (not inclusive)
5600             * @param orderByComparator the comparator to order the results by
5601             * @return the ordered range of matching journal articles
5602             * @throws SystemException if a system exception occurred
5603             */
5604            public List<JournalArticle> findByC_ST(long companyId, int status,
5605                    int start, int end, OrderByComparator orderByComparator)
5606                    throws SystemException {
5607                    Object[] finderArgs = new Object[] {
5608                                    companyId, status,
5609                                    
5610                                    String.valueOf(start), String.valueOf(end),
5611                                    String.valueOf(orderByComparator)
5612                            };
5613    
5614                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_ST,
5615                                    finderArgs, this);
5616    
5617                    if (list == null) {
5618                            Session session = null;
5619    
5620                            try {
5621                                    session = openSession();
5622    
5623                                    StringBundler query = null;
5624    
5625                                    if (orderByComparator != null) {
5626                                            query = new StringBundler(4 +
5627                                                            (orderByComparator.getOrderByFields().length * 3));
5628                                    }
5629                                    else {
5630                                            query = new StringBundler(4);
5631                                    }
5632    
5633                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5634    
5635                                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
5636    
5637                                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
5638    
5639                                    if (orderByComparator != null) {
5640                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5641                                                    orderByComparator);
5642                                    }
5643    
5644                                    else {
5645                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5646                                    }
5647    
5648                                    String sql = query.toString();
5649    
5650                                    Query q = session.createQuery(sql);
5651    
5652                                    QueryPos qPos = QueryPos.getInstance(q);
5653    
5654                                    qPos.add(companyId);
5655    
5656                                    qPos.add(status);
5657    
5658                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5659                                                    start, end);
5660                            }
5661                            catch (Exception e) {
5662                                    throw processException(e);
5663                            }
5664                            finally {
5665                                    if (list == null) {
5666                                            list = new ArrayList<JournalArticle>();
5667                                    }
5668    
5669                                    cacheResult(list);
5670    
5671                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_ST, finderArgs,
5672                                            list);
5673    
5674                                    closeSession(session);
5675                            }
5676                    }
5677    
5678                    return list;
5679            }
5680    
5681            /**
5682             * Finds the first journal article in the ordered set where companyId = &#63; and status = &#63;.
5683             *
5684             * <p>
5685             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5686             * </p>
5687             *
5688             * @param companyId the company id to search with
5689             * @param status the status to search with
5690             * @param orderByComparator the comparator to order the set by
5691             * @return the first matching journal article
5692             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5693             * @throws SystemException if a system exception occurred
5694             */
5695            public JournalArticle findByC_ST_First(long companyId, int status,
5696                    OrderByComparator orderByComparator)
5697                    throws NoSuchArticleException, SystemException {
5698                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
5699                                    orderByComparator);
5700    
5701                    if (list.isEmpty()) {
5702                            StringBundler msg = new StringBundler(6);
5703    
5704                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5705    
5706                            msg.append("companyId=");
5707                            msg.append(companyId);
5708    
5709                            msg.append(", status=");
5710                            msg.append(status);
5711    
5712                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5713    
5714                            throw new NoSuchArticleException(msg.toString());
5715                    }
5716                    else {
5717                            return list.get(0);
5718                    }
5719            }
5720    
5721            /**
5722             * Finds the last journal article in the ordered set where companyId = &#63; and status = &#63;.
5723             *
5724             * <p>
5725             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5726             * </p>
5727             *
5728             * @param companyId the company id to search with
5729             * @param status the status to search with
5730             * @param orderByComparator the comparator to order the set by
5731             * @return the last matching journal article
5732             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5733             * @throws SystemException if a system exception occurred
5734             */
5735            public JournalArticle findByC_ST_Last(long companyId, int status,
5736                    OrderByComparator orderByComparator)
5737                    throws NoSuchArticleException, SystemException {
5738                    int count = countByC_ST(companyId, status);
5739    
5740                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
5741                                    count, orderByComparator);
5742    
5743                    if (list.isEmpty()) {
5744                            StringBundler msg = new StringBundler(6);
5745    
5746                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5747    
5748                            msg.append("companyId=");
5749                            msg.append(companyId);
5750    
5751                            msg.append(", status=");
5752                            msg.append(status);
5753    
5754                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5755    
5756                            throw new NoSuchArticleException(msg.toString());
5757                    }
5758                    else {
5759                            return list.get(0);
5760                    }
5761            }
5762    
5763            /**
5764             * Finds the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
5765             *
5766             * <p>
5767             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5768             * </p>
5769             *
5770             * @param id the primary key of the current journal article
5771             * @param companyId the company id to search with
5772             * @param status the status to search with
5773             * @param orderByComparator the comparator to order the set by
5774             * @return the previous, current, and next journal article
5775             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5776             * @throws SystemException if a system exception occurred
5777             */
5778            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
5779                    int status, OrderByComparator orderByComparator)
5780                    throws NoSuchArticleException, SystemException {
5781                    JournalArticle journalArticle = findByPrimaryKey(id);
5782    
5783                    Session session = null;
5784    
5785                    try {
5786                            session = openSession();
5787    
5788                            JournalArticle[] array = new JournalArticleImpl[3];
5789    
5790                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
5791                                            companyId, status, orderByComparator, true);
5792    
5793                            array[1] = journalArticle;
5794    
5795                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
5796                                            companyId, status, orderByComparator, false);
5797    
5798                            return array;
5799                    }
5800                    catch (Exception e) {
5801                            throw processException(e);
5802                    }
5803                    finally {
5804                            closeSession(session);
5805                    }
5806            }
5807    
5808            protected JournalArticle getByC_ST_PrevAndNext(Session session,
5809                    JournalArticle journalArticle, long companyId, int status,
5810                    OrderByComparator orderByComparator, boolean previous) {
5811                    StringBundler query = null;
5812    
5813                    if (orderByComparator != null) {
5814                            query = new StringBundler(6 +
5815                                            (orderByComparator.getOrderByFields().length * 6));
5816                    }
5817                    else {
5818                            query = new StringBundler(3);
5819                    }
5820    
5821                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5822    
5823                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
5824    
5825                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
5826    
5827                    if (orderByComparator != null) {
5828                            String[] orderByFields = orderByComparator.getOrderByFields();
5829    
5830                            if (orderByFields.length > 0) {
5831                                    query.append(WHERE_AND);
5832                            }
5833    
5834                            for (int i = 0; i < orderByFields.length; i++) {
5835                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5836                                    query.append(orderByFields[i]);
5837    
5838                                    if ((i + 1) < orderByFields.length) {
5839                                            if (orderByComparator.isAscending() ^ previous) {
5840                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5841                                            }
5842                                            else {
5843                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5844                                            }
5845                                    }
5846                                    else {
5847                                            if (orderByComparator.isAscending() ^ previous) {
5848                                                    query.append(WHERE_GREATER_THAN);
5849                                            }
5850                                            else {
5851                                                    query.append(WHERE_LESSER_THAN);
5852                                            }
5853                                    }
5854                            }
5855    
5856                            query.append(ORDER_BY_CLAUSE);
5857    
5858                            for (int i = 0; i < orderByFields.length; i++) {
5859                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5860                                    query.append(orderByFields[i]);
5861    
5862                                    if ((i + 1) < orderByFields.length) {
5863                                            if (orderByComparator.isAscending() ^ previous) {
5864                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5865                                            }
5866                                            else {
5867                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5868                                            }
5869                                    }
5870                                    else {
5871                                            if (orderByComparator.isAscending() ^ previous) {
5872                                                    query.append(ORDER_BY_ASC);
5873                                            }
5874                                            else {
5875                                                    query.append(ORDER_BY_DESC);
5876                                            }
5877                                    }
5878                            }
5879                    }
5880    
5881                    else {
5882                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5883                    }
5884    
5885                    String sql = query.toString();
5886    
5887                    Query q = session.createQuery(sql);
5888    
5889                    q.setFirstResult(0);
5890                    q.setMaxResults(2);
5891    
5892                    QueryPos qPos = QueryPos.getInstance(q);
5893    
5894                    qPos.add(companyId);
5895    
5896                    qPos.add(status);
5897    
5898                    if (orderByComparator != null) {
5899                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
5900    
5901                            for (Object value : values) {
5902                                    qPos.add(value);
5903                            }
5904                    }
5905    
5906                    List<JournalArticle> list = q.list();
5907    
5908                    if (list.size() == 2) {
5909                            return list.get(1);
5910                    }
5911                    else {
5912                            return null;
5913                    }
5914            }
5915    
5916            /**
5917             * Finds the journal article where groupId = &#63; and articleId = &#63; and version = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
5918             *
5919             * @param groupId the group id to search with
5920             * @param articleId the article id to search with
5921             * @param version the version to search with
5922             * @return the matching journal article
5923             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5924             * @throws SystemException if a system exception occurred
5925             */
5926            public JournalArticle findByG_A_V(long groupId, String articleId,
5927                    double version) throws NoSuchArticleException, SystemException {
5928                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
5929    
5930                    if (journalArticle == null) {
5931                            StringBundler msg = new StringBundler(8);
5932    
5933                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5934    
5935                            msg.append("groupId=");
5936                            msg.append(groupId);
5937    
5938                            msg.append(", articleId=");
5939                            msg.append(articleId);
5940    
5941                            msg.append(", version=");
5942                            msg.append(version);
5943    
5944                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5945    
5946                            if (_log.isWarnEnabled()) {
5947                                    _log.warn(msg.toString());
5948                            }
5949    
5950                            throw new NoSuchArticleException(msg.toString());
5951                    }
5952    
5953                    return journalArticle;
5954            }
5955    
5956            /**
5957             * Finds 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.
5958             *
5959             * @param groupId the group id to search with
5960             * @param articleId the article id to search with
5961             * @param version the version to search with
5962             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
5963             * @throws SystemException if a system exception occurred
5964             */
5965            public JournalArticle fetchByG_A_V(long groupId, String articleId,
5966                    double version) throws SystemException {
5967                    return fetchByG_A_V(groupId, articleId, version, true);
5968            }
5969    
5970            /**
5971             * Finds 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.
5972             *
5973             * @param groupId the group id to search with
5974             * @param articleId the article id to search with
5975             * @param version the version to search with
5976             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
5977             * @throws SystemException if a system exception occurred
5978             */
5979            public JournalArticle fetchByG_A_V(long groupId, String articleId,
5980                    double version, boolean retrieveFromCache) throws SystemException {
5981                    Object[] finderArgs = new Object[] { groupId, articleId, version };
5982    
5983                    Object result = null;
5984    
5985                    if (retrieveFromCache) {
5986                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
5987                                            finderArgs, this);
5988                    }
5989    
5990                    if (result == null) {
5991                            Session session = null;
5992    
5993                            try {
5994                                    session = openSession();
5995    
5996                                    StringBundler query = new StringBundler(5);
5997    
5998                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5999    
6000                                    query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
6001    
6002                                    if (articleId == null) {
6003                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
6004                                    }
6005                                    else {
6006                                            if (articleId.equals(StringPool.BLANK)) {
6007                                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
6008                                            }
6009                                            else {
6010                                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
6011                                            }
6012                                    }
6013    
6014                                    query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
6015    
6016                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6017    
6018                                    String sql = query.toString();
6019    
6020                                    Query q = session.createQuery(sql);
6021    
6022                                    QueryPos qPos = QueryPos.getInstance(q);
6023    
6024                                    qPos.add(groupId);
6025    
6026                                    if (articleId != null) {
6027                                            qPos.add(articleId);
6028                                    }
6029    
6030                                    qPos.add(version);
6031    
6032                                    List<JournalArticle> list = q.list();
6033    
6034                                    result = list;
6035    
6036                                    JournalArticle journalArticle = null;
6037    
6038                                    if (list.isEmpty()) {
6039                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
6040                                                    finderArgs, list);
6041                                    }
6042                                    else {
6043                                            journalArticle = list.get(0);
6044    
6045                                            cacheResult(journalArticle);
6046    
6047                                            if ((journalArticle.getGroupId() != groupId) ||
6048                                                            (journalArticle.getArticleId() == null) ||
6049                                                            !journalArticle.getArticleId().equals(articleId) ||
6050                                                            (journalArticle.getVersion() != version)) {
6051                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
6052                                                            finderArgs, journalArticle);
6053                                            }
6054                                    }
6055    
6056                                    return journalArticle;
6057                            }
6058                            catch (Exception e) {
6059                                    throw processException(e);
6060                            }
6061                            finally {
6062                                    if (result == null) {
6063                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
6064                                                    finderArgs, new ArrayList<JournalArticle>());
6065                                    }
6066    
6067                                    closeSession(session);
6068                            }
6069                    }
6070                    else {
6071                            if (result instanceof List<?>) {
6072                                    return null;
6073                            }
6074                            else {
6075                                    return (JournalArticle)result;
6076                            }
6077                    }
6078            }
6079    
6080            /**
6081             * Finds all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
6082             *
6083             * @param groupId the group id to search with
6084             * @param articleId the article id to search with
6085             * @param status the status to search with
6086             * @return the matching journal articles
6087             * @throws SystemException if a system exception occurred
6088             */
6089            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
6090                    int status) throws SystemException {
6091                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
6092                            QueryUtil.ALL_POS, null);
6093            }
6094    
6095            /**
6096             * Finds a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
6097             *
6098             * <p>
6099             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6100             * </p>
6101             *
6102             * @param groupId the group id to search with
6103             * @param articleId the article id to search with
6104             * @param status the status to search with
6105             * @param start the lower bound of the range of journal articles to return
6106             * @param end the upper bound of the range of journal articles to return (not inclusive)
6107             * @return the range of matching journal articles
6108             * @throws SystemException if a system exception occurred
6109             */
6110            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
6111                    int status, int start, int end) throws SystemException {
6112                    return findByG_A_ST(groupId, articleId, status, start, end, null);
6113            }
6114    
6115            /**
6116             * Finds an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
6117             *
6118             * <p>
6119             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6120             * </p>
6121             *
6122             * @param groupId the group id to search with
6123             * @param articleId the article id to search with
6124             * @param status the status to search with
6125             * @param start the lower bound of the range of journal articles to return
6126             * @param end the upper bound of the range of journal articles to return (not inclusive)
6127             * @param orderByComparator the comparator to order the results by
6128             * @return the ordered range of matching journal articles
6129             * @throws SystemException if a system exception occurred
6130             */
6131            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
6132                    int status, int start, int end, OrderByComparator orderByComparator)
6133                    throws SystemException {
6134                    Object[] finderArgs = new Object[] {
6135                                    groupId, articleId, status,
6136                                    
6137                                    String.valueOf(start), String.valueOf(end),
6138                                    String.valueOf(orderByComparator)
6139                            };
6140    
6141                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_A_ST,
6142                                    finderArgs, this);
6143    
6144                    if (list == null) {
6145                            Session session = null;
6146    
6147                            try {
6148                                    session = openSession();
6149    
6150                                    StringBundler query = null;
6151    
6152                                    if (orderByComparator != null) {
6153                                            query = new StringBundler(5 +
6154                                                            (orderByComparator.getOrderByFields().length * 3));
6155                                    }
6156                                    else {
6157                                            query = new StringBundler(5);
6158                                    }
6159    
6160                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6161    
6162                                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
6163    
6164                                    if (articleId == null) {
6165                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
6166                                    }
6167                                    else {
6168                                            if (articleId.equals(StringPool.BLANK)) {
6169                                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
6170                                            }
6171                                            else {
6172                                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
6173                                            }
6174                                    }
6175    
6176                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
6177    
6178                                    if (orderByComparator != null) {
6179                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6180                                                    orderByComparator);
6181                                    }
6182    
6183                                    else {
6184                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6185                                    }
6186    
6187                                    String sql = query.toString();
6188    
6189                                    Query q = session.createQuery(sql);
6190    
6191                                    QueryPos qPos = QueryPos.getInstance(q);
6192    
6193                                    qPos.add(groupId);
6194    
6195                                    if (articleId != null) {
6196                                            qPos.add(articleId);
6197                                    }
6198    
6199                                    qPos.add(status);
6200    
6201                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
6202                                                    start, end);
6203                            }
6204                            catch (Exception e) {
6205                                    throw processException(e);
6206                            }
6207                            finally {
6208                                    if (list == null) {
6209                                            list = new ArrayList<JournalArticle>();
6210                                    }
6211    
6212                                    cacheResult(list);
6213    
6214                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_A_ST,
6215                                            finderArgs, list);
6216    
6217                                    closeSession(session);
6218                            }
6219                    }
6220    
6221                    return list;
6222            }
6223    
6224            /**
6225             * Finds the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
6226             *
6227             * <p>
6228             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6229             * </p>
6230             *
6231             * @param groupId the group id to search with
6232             * @param articleId the article id to search with
6233             * @param status the status to search with
6234             * @param orderByComparator the comparator to order the set by
6235             * @return the first matching journal article
6236             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6237             * @throws SystemException if a system exception occurred
6238             */
6239            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
6240                    int status, OrderByComparator orderByComparator)
6241                    throws NoSuchArticleException, SystemException {
6242                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
6243                                    1, orderByComparator);
6244    
6245                    if (list.isEmpty()) {
6246                            StringBundler msg = new StringBundler(8);
6247    
6248                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6249    
6250                            msg.append("groupId=");
6251                            msg.append(groupId);
6252    
6253                            msg.append(", articleId=");
6254                            msg.append(articleId);
6255    
6256                            msg.append(", status=");
6257                            msg.append(status);
6258    
6259                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6260    
6261                            throw new NoSuchArticleException(msg.toString());
6262                    }
6263                    else {
6264                            return list.get(0);
6265                    }
6266            }
6267    
6268            /**
6269             * Finds the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
6270             *
6271             * <p>
6272             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6273             * </p>
6274             *
6275             * @param groupId the group id to search with
6276             * @param articleId the article id to search with
6277             * @param status the status to search with
6278             * @param orderByComparator the comparator to order the set by
6279             * @return the last matching journal article
6280             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6281             * @throws SystemException if a system exception occurred
6282             */
6283            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
6284                    int status, OrderByComparator orderByComparator)
6285                    throws NoSuchArticleException, SystemException {
6286                    int count = countByG_A_ST(groupId, articleId, status);
6287    
6288                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
6289                                    count - 1, count, orderByComparator);
6290    
6291                    if (list.isEmpty()) {
6292                            StringBundler msg = new StringBundler(8);
6293    
6294                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6295    
6296                            msg.append("groupId=");
6297                            msg.append(groupId);
6298    
6299                            msg.append(", articleId=");
6300                            msg.append(articleId);
6301    
6302                            msg.append(", status=");
6303                            msg.append(status);
6304    
6305                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6306    
6307                            throw new NoSuchArticleException(msg.toString());
6308                    }
6309                    else {
6310                            return list.get(0);
6311                    }
6312            }
6313    
6314            /**
6315             * Finds the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
6316             *
6317             * <p>
6318             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6319             * </p>
6320             *
6321             * @param id the primary key of the current journal article
6322             * @param groupId the group id to search with
6323             * @param articleId the article id to search with
6324             * @param status the status to search with
6325             * @param orderByComparator the comparator to order the set by
6326             * @return the previous, current, and next journal article
6327             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6328             * @throws SystemException if a system exception occurred
6329             */
6330            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
6331                    String articleId, int status, OrderByComparator orderByComparator)
6332                    throws NoSuchArticleException, SystemException {
6333                    JournalArticle journalArticle = findByPrimaryKey(id);
6334    
6335                    Session session = null;
6336    
6337                    try {
6338                            session = openSession();
6339    
6340                            JournalArticle[] array = new JournalArticleImpl[3];
6341    
6342                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
6343                                            groupId, articleId, status, orderByComparator, true);
6344    
6345                            array[1] = journalArticle;
6346    
6347                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
6348                                            groupId, articleId, status, orderByComparator, false);
6349    
6350                            return array;
6351                    }
6352                    catch (Exception e) {
6353                            throw processException(e);
6354                    }
6355                    finally {
6356                            closeSession(session);
6357                    }
6358            }
6359    
6360            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
6361                    JournalArticle journalArticle, long groupId, String articleId,
6362                    int status, OrderByComparator orderByComparator, boolean previous) {
6363                    StringBundler query = null;
6364    
6365                    if (orderByComparator != null) {
6366                            query = new StringBundler(6 +
6367                                            (orderByComparator.getOrderByFields().length * 6));
6368                    }
6369                    else {
6370                            query = new StringBundler(3);
6371                    }
6372    
6373                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6374    
6375                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
6376    
6377                    if (articleId == null) {
6378                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
6379                    }
6380                    else {
6381                            if (articleId.equals(StringPool.BLANK)) {
6382                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
6383                            }
6384                            else {
6385                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
6386                            }
6387                    }
6388    
6389                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
6390    
6391                    if (orderByComparator != null) {
6392                            String[] orderByFields = orderByComparator.getOrderByFields();
6393    
6394                            if (orderByFields.length > 0) {
6395                                    query.append(WHERE_AND);
6396                            }
6397    
6398                            for (int i = 0; i < orderByFields.length; i++) {
6399                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6400                                    query.append(orderByFields[i]);
6401    
6402                                    if ((i + 1) < orderByFields.length) {
6403                                            if (orderByComparator.isAscending() ^ previous) {
6404                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6405                                            }
6406                                            else {
6407                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6408                                            }
6409                                    }
6410                                    else {
6411                                            if (orderByComparator.isAscending() ^ previous) {
6412                                                    query.append(WHERE_GREATER_THAN);
6413                                            }
6414                                            else {
6415                                                    query.append(WHERE_LESSER_THAN);
6416                                            }
6417                                    }
6418                            }
6419    
6420                            query.append(ORDER_BY_CLAUSE);
6421    
6422                            for (int i = 0; i < orderByFields.length; i++) {
6423                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6424                                    query.append(orderByFields[i]);
6425    
6426                                    if ((i + 1) < orderByFields.length) {
6427                                            if (orderByComparator.isAscending() ^ previous) {
6428                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6429                                            }
6430                                            else {
6431                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6432                                            }
6433                                    }
6434                                    else {
6435                                            if (orderByComparator.isAscending() ^ previous) {
6436                                                    query.append(ORDER_BY_ASC);
6437                                            }
6438                                            else {
6439                                                    query.append(ORDER_BY_DESC);
6440                                            }
6441                                    }
6442                            }
6443                    }
6444    
6445                    else {
6446                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6447                    }
6448    
6449                    String sql = query.toString();
6450    
6451                    Query q = session.createQuery(sql);
6452    
6453                    q.setFirstResult(0);
6454                    q.setMaxResults(2);
6455    
6456                    QueryPos qPos = QueryPos.getInstance(q);
6457    
6458                    qPos.add(groupId);
6459    
6460                    if (articleId != null) {
6461                            qPos.add(articleId);
6462                    }
6463    
6464                    qPos.add(status);
6465    
6466                    if (orderByComparator != null) {
6467                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
6468    
6469                            for (Object value : values) {
6470                                    qPos.add(value);
6471                            }
6472                    }
6473    
6474                    List<JournalArticle> list = q.list();
6475    
6476                    if (list.size() == 2) {
6477                            return list.get(1);
6478                    }
6479                    else {
6480                            return null;
6481                    }
6482            }
6483    
6484            /**
6485             * Filters by the user's permissions and finds all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
6486             *
6487             * @param groupId the group id to search with
6488             * @param articleId the article id to search with
6489             * @param status the status to search with
6490             * @return the matching journal articles that the user has permission to view
6491             * @throws SystemException if a system exception occurred
6492             */
6493            public List<JournalArticle> filterFindByG_A_ST(long groupId,
6494                    String articleId, int status) throws SystemException {
6495                    return filterFindByG_A_ST(groupId, articleId, status,
6496                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6497            }
6498    
6499            /**
6500             * Filters by the user's permissions and finds a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
6501             *
6502             * <p>
6503             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6504             * </p>
6505             *
6506             * @param groupId the group id to search with
6507             * @param articleId the article id to search with
6508             * @param status the status to search with
6509             * @param start the lower bound of the range of journal articles to return
6510             * @param end the upper bound of the range of journal articles to return (not inclusive)
6511             * @return the range of matching journal articles that the user has permission to view
6512             * @throws SystemException if a system exception occurred
6513             */
6514            public List<JournalArticle> filterFindByG_A_ST(long groupId,
6515                    String articleId, int status, int start, int end)
6516                    throws SystemException {
6517                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
6518            }
6519    
6520            /**
6521             * Filters by the user's permissions and finds an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
6522             *
6523             * <p>
6524             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6525             * </p>
6526             *
6527             * @param groupId the group id to search with
6528             * @param articleId the article id to search with
6529             * @param status the status to search with
6530             * @param start the lower bound of the range of journal articles to return
6531             * @param end the upper bound of the range of journal articles to return (not inclusive)
6532             * @param orderByComparator the comparator to order the results by
6533             * @return the ordered range of matching journal articles that the user has permission to view
6534             * @throws SystemException if a system exception occurred
6535             */
6536            public List<JournalArticle> filterFindByG_A_ST(long groupId,
6537                    String articleId, int status, int start, int end,
6538                    OrderByComparator orderByComparator) throws SystemException {
6539                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6540                            return findByG_A_ST(groupId, articleId, status, start, end,
6541                                    orderByComparator);
6542                    }
6543    
6544                    Session session = null;
6545    
6546                    try {
6547                            session = openSession();
6548    
6549                            StringBundler query = null;
6550    
6551                            if (orderByComparator != null) {
6552                                    query = new StringBundler(5 +
6553                                                    (orderByComparator.getOrderByFields().length * 3));
6554                            }
6555                            else {
6556                                    query = new StringBundler(5);
6557                            }
6558    
6559                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6560    
6561                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
6562    
6563                            if (articleId == null) {
6564                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
6565                            }
6566                            else {
6567                                    if (articleId.equals(StringPool.BLANK)) {
6568                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
6569                                    }
6570                                    else {
6571                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
6572                                    }
6573                            }
6574    
6575                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
6576    
6577                            if (orderByComparator != null) {
6578                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6579                                            orderByComparator);
6580                            }
6581    
6582                            else {
6583                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6584                            }
6585    
6586                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6587                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
6588                                            _FILTER_COLUMN_USERID, groupId);
6589    
6590                            SQLQuery q = session.createSQLQuery(sql);
6591    
6592                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6593    
6594                            QueryPos qPos = QueryPos.getInstance(q);
6595    
6596                            qPos.add(groupId);
6597    
6598                            if (articleId != null) {
6599                                    qPos.add(articleId);
6600                            }
6601    
6602                            qPos.add(status);
6603    
6604                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6605                                    end);
6606                    }
6607                    catch (Exception e) {
6608                            throw processException(e);
6609                    }
6610                    finally {
6611                            closeSession(session);
6612                    }
6613            }
6614    
6615            /**
6616             * Finds all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
6617             *
6618             * @param groupId the group id to search with
6619             * @param urlTitle the url title to search with
6620             * @param status the status to search with
6621             * @return the matching journal articles
6622             * @throws SystemException if a system exception occurred
6623             */
6624            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
6625                    int status) throws SystemException {
6626                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
6627                            QueryUtil.ALL_POS, null);
6628            }
6629    
6630            /**
6631             * Finds a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
6632             *
6633             * <p>
6634             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6635             * </p>
6636             *
6637             * @param groupId the group id to search with
6638             * @param urlTitle the url title to search with
6639             * @param status the status to search with
6640             * @param start the lower bound of the range of journal articles to return
6641             * @param end the upper bound of the range of journal articles to return (not inclusive)
6642             * @return the range of matching journal articles
6643             * @throws SystemException if a system exception occurred
6644             */
6645            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
6646                    int status, int start, int end) throws SystemException {
6647                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
6648            }
6649    
6650            /**
6651             * Finds an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
6652             *
6653             * <p>
6654             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6655             * </p>
6656             *
6657             * @param groupId the group id to search with
6658             * @param urlTitle the url title to search with
6659             * @param status the status to search with
6660             * @param start the lower bound of the range of journal articles to return
6661             * @param end the upper bound of the range of journal articles to return (not inclusive)
6662             * @param orderByComparator the comparator to order the results by
6663             * @return the ordered range of matching journal articles
6664             * @throws SystemException if a system exception occurred
6665             */
6666            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
6667                    int status, int start, int end, OrderByComparator orderByComparator)
6668                    throws SystemException {
6669                    Object[] finderArgs = new Object[] {
6670                                    groupId, urlTitle, status,
6671                                    
6672                                    String.valueOf(start), String.valueOf(end),
6673                                    String.valueOf(orderByComparator)
6674                            };
6675    
6676                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_UT_ST,
6677                                    finderArgs, this);
6678    
6679                    if (list == null) {
6680                            Session session = null;
6681    
6682                            try {
6683                                    session = openSession();
6684    
6685                                    StringBundler query = null;
6686    
6687                                    if (orderByComparator != null) {
6688                                            query = new StringBundler(5 +
6689                                                            (orderByComparator.getOrderByFields().length * 3));
6690                                    }
6691                                    else {
6692                                            query = new StringBundler(5);
6693                                    }
6694    
6695                                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6696    
6697                                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
6698    
6699                                    if (urlTitle == null) {
6700                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
6701                                    }
6702                                    else {
6703                                            if (urlTitle.equals(StringPool.BLANK)) {
6704                                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
6705                                            }
6706                                            else {
6707                                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
6708                                            }
6709                                    }
6710    
6711                                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
6712    
6713                                    if (orderByComparator != null) {
6714                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6715                                                    orderByComparator);
6716                                    }
6717    
6718                                    else {
6719                                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6720                                    }
6721    
6722                                    String sql = query.toString();
6723    
6724                                    Query q = session.createQuery(sql);
6725    
6726                                    QueryPos qPos = QueryPos.getInstance(q);
6727    
6728                                    qPos.add(groupId);
6729    
6730                                    if (urlTitle != null) {
6731                                            qPos.add(urlTitle);
6732                                    }
6733    
6734                                    qPos.add(status);
6735    
6736                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
6737                                                    start, end);
6738                            }
6739                            catch (Exception e) {
6740                                    throw processException(e);
6741                            }
6742                            finally {
6743                                    if (list == null) {
6744                                            list = new ArrayList<JournalArticle>();
6745                                    }
6746    
6747                                    cacheResult(list);
6748    
6749                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_UT_ST,
6750                                            finderArgs, list);
6751    
6752                                    closeSession(session);
6753                            }
6754                    }
6755    
6756                    return list;
6757            }
6758    
6759            /**
6760             * Finds the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
6761             *
6762             * <p>
6763             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6764             * </p>
6765             *
6766             * @param groupId the group id to search with
6767             * @param urlTitle the url title to search with
6768             * @param status the status to search with
6769             * @param orderByComparator the comparator to order the set by
6770             * @return the first matching journal article
6771             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6772             * @throws SystemException if a system exception occurred
6773             */
6774            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
6775                    int status, OrderByComparator orderByComparator)
6776                    throws NoSuchArticleException, SystemException {
6777                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
6778                                    1, orderByComparator);
6779    
6780                    if (list.isEmpty()) {
6781                            StringBundler msg = new StringBundler(8);
6782    
6783                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6784    
6785                            msg.append("groupId=");
6786                            msg.append(groupId);
6787    
6788                            msg.append(", urlTitle=");
6789                            msg.append(urlTitle);
6790    
6791                            msg.append(", status=");
6792                            msg.append(status);
6793    
6794                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6795    
6796                            throw new NoSuchArticleException(msg.toString());
6797                    }
6798                    else {
6799                            return list.get(0);
6800                    }
6801            }
6802    
6803            /**
6804             * Finds the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
6805             *
6806             * <p>
6807             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6808             * </p>
6809             *
6810             * @param groupId the group id to search with
6811             * @param urlTitle the url title to search with
6812             * @param status the status to search with
6813             * @param orderByComparator the comparator to order the set by
6814             * @return the last matching journal article
6815             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6816             * @throws SystemException if a system exception occurred
6817             */
6818            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
6819                    int status, OrderByComparator orderByComparator)
6820                    throws NoSuchArticleException, SystemException {
6821                    int count = countByG_UT_ST(groupId, urlTitle, status);
6822    
6823                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
6824                                    count - 1, count, orderByComparator);
6825    
6826                    if (list.isEmpty()) {
6827                            StringBundler msg = new StringBundler(8);
6828    
6829                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6830    
6831                            msg.append("groupId=");
6832                            msg.append(groupId);
6833    
6834                            msg.append(", urlTitle=");
6835                            msg.append(urlTitle);
6836    
6837                            msg.append(", status=");
6838                            msg.append(status);
6839    
6840                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6841    
6842                            throw new NoSuchArticleException(msg.toString());
6843                    }
6844                    else {
6845                            return list.get(0);
6846                    }
6847            }
6848    
6849            /**
6850             * Finds the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
6851             *
6852             * <p>
6853             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6854             * </p>
6855             *
6856             * @param id the primary key of the current journal article
6857             * @param groupId the group id to search with
6858             * @param urlTitle the url title to search with
6859             * @param status the status to search with
6860             * @param orderByComparator the comparator to order the set by
6861             * @return the previous, current, and next journal article
6862             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6863             * @throws SystemException if a system exception occurred
6864             */
6865            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
6866                    String urlTitle, int status, OrderByComparator orderByComparator)
6867                    throws NoSuchArticleException, SystemException {
6868                    JournalArticle journalArticle = findByPrimaryKey(id);
6869    
6870                    Session session = null;
6871    
6872                    try {
6873                            session = openSession();
6874    
6875                            JournalArticle[] array = new JournalArticleImpl[3];
6876    
6877                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
6878                                            groupId, urlTitle, status, orderByComparator, true);
6879    
6880                            array[1] = journalArticle;
6881    
6882                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
6883                                            groupId, urlTitle, status, orderByComparator, false);
6884    
6885                            return array;
6886                    }
6887                    catch (Exception e) {
6888                            throw processException(e);
6889                    }
6890                    finally {
6891                            closeSession(session);
6892                    }
6893            }
6894    
6895            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
6896                    JournalArticle journalArticle, long groupId, String urlTitle,
6897                    int status, OrderByComparator orderByComparator, boolean previous) {
6898                    StringBundler query = null;
6899    
6900                    if (orderByComparator != null) {
6901                            query = new StringBundler(6 +
6902                                            (orderByComparator.getOrderByFields().length * 6));
6903                    }
6904                    else {
6905                            query = new StringBundler(3);
6906                    }
6907    
6908                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6909    
6910                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
6911    
6912                    if (urlTitle == null) {
6913                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
6914                    }
6915                    else {
6916                            if (urlTitle.equals(StringPool.BLANK)) {
6917                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
6918                            }
6919                            else {
6920                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
6921                            }
6922                    }
6923    
6924                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
6925    
6926                    if (orderByComparator != null) {
6927                            String[] orderByFields = orderByComparator.getOrderByFields();
6928    
6929                            if (orderByFields.length > 0) {
6930                                    query.append(WHERE_AND);
6931                            }
6932    
6933                            for (int i = 0; i < orderByFields.length; i++) {
6934                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6935                                    query.append(orderByFields[i]);
6936    
6937                                    if ((i + 1) < orderByFields.length) {
6938                                            if (orderByComparator.isAscending() ^ previous) {
6939                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6940                                            }
6941                                            else {
6942                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6943                                            }
6944                                    }
6945                                    else {
6946                                            if (orderByComparator.isAscending() ^ previous) {
6947                                                    query.append(WHERE_GREATER_THAN);
6948                                            }
6949                                            else {
6950                                                    query.append(WHERE_LESSER_THAN);
6951                                            }
6952                                    }
6953                            }
6954    
6955                            query.append(ORDER_BY_CLAUSE);
6956    
6957                            for (int i = 0; i < orderByFields.length; i++) {
6958                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6959                                    query.append(orderByFields[i]);
6960    
6961                                    if ((i + 1) < orderByFields.length) {
6962                                            if (orderByComparator.isAscending() ^ previous) {
6963                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6964                                            }
6965                                            else {
6966                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6967                                            }
6968                                    }
6969                                    else {
6970                                            if (orderByComparator.isAscending() ^ previous) {
6971                                                    query.append(ORDER_BY_ASC);
6972                                            }
6973                                            else {
6974                                                    query.append(ORDER_BY_DESC);
6975                                            }
6976                                    }
6977                            }
6978                    }
6979    
6980                    else {
6981                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6982                    }
6983    
6984                    String sql = query.toString();
6985    
6986                    Query q = session.createQuery(sql);
6987    
6988                    q.setFirstResult(0);
6989                    q.setMaxResults(2);
6990    
6991                    QueryPos qPos = QueryPos.getInstance(q);
6992    
6993                    qPos.add(groupId);
6994    
6995                    if (urlTitle != null) {
6996                            qPos.add(urlTitle);
6997                    }
6998    
6999                    qPos.add(status);
7000    
7001                    if (orderByComparator != null) {
7002                            Object[] values = orderByComparator.getOrderByValues(journalArticle);
7003    
7004                            for (Object value : values) {
7005                                    qPos.add(value);
7006                            }
7007                    }
7008    
7009                    List<JournalArticle> list = q.list();
7010    
7011                    if (list.size() == 2) {
7012                            return list.get(1);
7013                    }
7014                    else {
7015                            return null;
7016                    }
7017            }
7018    
7019            /**
7020             * Filters by the user's permissions and finds all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
7021             *
7022             * @param groupId the group id to search with
7023             * @param urlTitle the url title to search with
7024             * @param status the status to search with
7025             * @return the matching journal articles that the user has permission to view
7026             * @throws SystemException if a system exception occurred
7027             */
7028            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
7029                    String urlTitle, int status) throws SystemException {
7030                    return filterFindByG_UT_ST(groupId, urlTitle, status,
7031                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7032            }
7033    
7034            /**
7035             * Filters by the user's permissions and finds a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
7036             *
7037             * <p>
7038             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7039             * </p>
7040             *
7041             * @param groupId the group id to search with
7042             * @param urlTitle the url title to search with
7043             * @param status the status to search with
7044             * @param start the lower bound of the range of journal articles to return
7045             * @param end the upper bound of the range of journal articles to return (not inclusive)
7046             * @return the range of matching journal articles that the user has permission to view
7047             * @throws SystemException if a system exception occurred
7048             */
7049            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
7050                    String urlTitle, int status, int start, int end)
7051                    throws SystemException {
7052                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
7053            }
7054    
7055            /**
7056             * Filters by the user's permissions and finds an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
7057             *
7058             * <p>
7059             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7060             * </p>
7061             *
7062             * @param groupId the group id to search with
7063             * @param urlTitle the url title to search with
7064             * @param status the status to search with
7065             * @param start the lower bound of the range of journal articles to return
7066             * @param end the upper bound of the range of journal articles to return (not inclusive)
7067             * @param orderByComparator the comparator to order the results by
7068             * @return the ordered range of matching journal articles that the user has permission to view
7069             * @throws SystemException if a system exception occurred
7070             */
7071            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
7072                    String urlTitle, int status, int start, int end,
7073                    OrderByComparator orderByComparator) throws SystemException {
7074                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7075                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
7076                                    orderByComparator);
7077                    }
7078    
7079                    Session session = null;
7080    
7081                    try {
7082                            session = openSession();
7083    
7084                            StringBundler query = null;
7085    
7086                            if (orderByComparator != null) {
7087                                    query = new StringBundler(5 +
7088                                                    (orderByComparator.getOrderByFields().length * 3));
7089                            }
7090                            else {
7091                                    query = new StringBundler(5);
7092                            }
7093    
7094                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7095    
7096                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
7097    
7098                            if (urlTitle == null) {
7099                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
7100                            }
7101                            else {
7102                                    if (urlTitle.equals(StringPool.BLANK)) {
7103                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
7104                                    }
7105                                    else {
7106                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
7107                                    }
7108                            }
7109    
7110                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
7111    
7112                            if (orderByComparator != null) {
7113                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7114                                            orderByComparator);
7115                            }
7116    
7117                            else {
7118                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7119                            }
7120    
7121                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7122                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
7123                                            _FILTER_COLUMN_USERID, groupId);
7124    
7125                            SQLQuery q = session.createSQLQuery(sql);
7126    
7127                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7128    
7129                            QueryPos qPos = QueryPos.getInstance(q);
7130    
7131                            qPos.add(groupId);
7132    
7133                            if (urlTitle != null) {
7134                                    qPos.add(urlTitle);
7135                            }
7136    
7137                            qPos.add(status);
7138    
7139                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7140                                    end);
7141                    }
7142                    catch (Exception e) {
7143                            throw processException(e);
7144                    }
7145                    finally {
7146                            closeSession(session);
7147                    }
7148            }
7149    
7150            /**
7151             * Finds all the journal articles.
7152             *
7153             * @return the journal articles
7154             * @throws SystemException if a system exception occurred
7155             */
7156            public List<JournalArticle> findAll() throws SystemException {
7157                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7158            }
7159    
7160            /**
7161             * Finds a range of all the journal articles.
7162             *
7163             * <p>
7164             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7165             * </p>
7166             *
7167             * @param start the lower bound of the range of journal articles to return
7168             * @param end the upper bound of the range of journal articles to return (not inclusive)
7169             * @return the range of journal articles
7170             * @throws SystemException if a system exception occurred
7171             */
7172            public List<JournalArticle> findAll(int start, int end)
7173                    throws SystemException {
7174                    return findAll(start, end, null);
7175            }
7176    
7177            /**
7178             * Finds an ordered range of all the journal articles.
7179             *
7180             * <p>
7181             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7182             * </p>
7183             *
7184             * @param start the lower bound of the range of journal articles to return
7185             * @param end the upper bound of the range of journal articles to return (not inclusive)
7186             * @param orderByComparator the comparator to order the results by
7187             * @return the ordered range of journal articles
7188             * @throws SystemException if a system exception occurred
7189             */
7190            public List<JournalArticle> findAll(int start, int end,
7191                    OrderByComparator orderByComparator) throws SystemException {
7192                    Object[] finderArgs = new Object[] {
7193                                    String.valueOf(start), String.valueOf(end),
7194                                    String.valueOf(orderByComparator)
7195                            };
7196    
7197                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
7198                                    finderArgs, this);
7199    
7200                    if (list == null) {
7201                            Session session = null;
7202    
7203                            try {
7204                                    session = openSession();
7205    
7206                                    StringBundler query = null;
7207                                    String sql = null;
7208    
7209                                    if (orderByComparator != null) {
7210                                            query = new StringBundler(2 +
7211                                                            (orderByComparator.getOrderByFields().length * 3));
7212    
7213                                            query.append(_SQL_SELECT_JOURNALARTICLE);
7214    
7215                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7216                                                    orderByComparator);
7217    
7218                                            sql = query.toString();
7219                                    }
7220                                    else {
7221                                            sql = _SQL_SELECT_JOURNALARTICLE.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
7222                                    }
7223    
7224                                    Query q = session.createQuery(sql);
7225    
7226                                    if (orderByComparator == null) {
7227                                            list = (List<JournalArticle>)QueryUtil.list(q,
7228                                                            getDialect(), start, end, false);
7229    
7230                                            Collections.sort(list);
7231                                    }
7232                                    else {
7233                                            list = (List<JournalArticle>)QueryUtil.list(q,
7234                                                            getDialect(), start, end);
7235                                    }
7236                            }
7237                            catch (Exception e) {
7238                                    throw processException(e);
7239                            }
7240                            finally {
7241                                    if (list == null) {
7242                                            list = new ArrayList<JournalArticle>();
7243                                    }
7244    
7245                                    cacheResult(list);
7246    
7247                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
7248    
7249                                    closeSession(session);
7250                            }
7251                    }
7252    
7253                    return list;
7254            }
7255    
7256            /**
7257             * Removes all the journal articles where uuid = &#63; from the database.
7258             *
7259             * @param uuid the uuid to search with
7260             * @throws SystemException if a system exception occurred
7261             */
7262            public void removeByUuid(String uuid) throws SystemException {
7263                    for (JournalArticle journalArticle : findByUuid(uuid)) {
7264                            remove(journalArticle);
7265                    }
7266            }
7267    
7268            /**
7269             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
7270             *
7271             * @param uuid the uuid to search with
7272             * @param groupId the group id to search with
7273             * @throws SystemException if a system exception occurred
7274             */
7275            public void removeByUUID_G(String uuid, long groupId)
7276                    throws NoSuchArticleException, SystemException {
7277                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
7278    
7279                    remove(journalArticle);
7280            }
7281    
7282            /**
7283             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
7284             *
7285             * @param resourcePrimKey the resource prim key to search with
7286             * @throws SystemException if a system exception occurred
7287             */
7288            public void removeByResourcePrimKey(long resourcePrimKey)
7289                    throws SystemException {
7290                    for (JournalArticle journalArticle : findByResourcePrimKey(
7291                                    resourcePrimKey)) {
7292                            remove(journalArticle);
7293                    }
7294            }
7295    
7296            /**
7297             * Removes all the journal articles where groupId = &#63; from the database.
7298             *
7299             * @param groupId the group id to search with
7300             * @throws SystemException if a system exception occurred
7301             */
7302            public void removeByGroupId(long groupId) throws SystemException {
7303                    for (JournalArticle journalArticle : findByGroupId(groupId)) {
7304                            remove(journalArticle);
7305                    }
7306            }
7307    
7308            /**
7309             * Removes all the journal articles where companyId = &#63; from the database.
7310             *
7311             * @param companyId the company id to search with
7312             * @throws SystemException if a system exception occurred
7313             */
7314            public void removeByCompanyId(long companyId) throws SystemException {
7315                    for (JournalArticle journalArticle : findByCompanyId(companyId)) {
7316                            remove(journalArticle);
7317                    }
7318            }
7319    
7320            /**
7321             * Removes all the journal articles where smallImageId = &#63; from the database.
7322             *
7323             * @param smallImageId the small image id to search with
7324             * @throws SystemException if a system exception occurred
7325             */
7326            public void removeBySmallImageId(long smallImageId)
7327                    throws SystemException {
7328                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId)) {
7329                            remove(journalArticle);
7330                    }
7331            }
7332    
7333            /**
7334             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
7335             *
7336             * @param resourcePrimKey the resource prim key to search with
7337             * @param status the status to search with
7338             * @throws SystemException if a system exception occurred
7339             */
7340            public void removeByR_ST(long resourcePrimKey, int status)
7341                    throws SystemException {
7342                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey, status)) {
7343                            remove(journalArticle);
7344                    }
7345            }
7346    
7347            /**
7348             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
7349             *
7350             * @param groupId the group id to search with
7351             * @param articleId the article id to search with
7352             * @throws SystemException if a system exception occurred
7353             */
7354            public void removeByG_A(long groupId, String articleId)
7355                    throws SystemException {
7356                    for (JournalArticle journalArticle : findByG_A(groupId, articleId)) {
7357                            remove(journalArticle);
7358                    }
7359            }
7360    
7361            /**
7362             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
7363             *
7364             * @param groupId the group id to search with
7365             * @param structureId the structure id to search with
7366             * @throws SystemException if a system exception occurred
7367             */
7368            public void removeByG_S(long groupId, String structureId)
7369                    throws SystemException {
7370                    for (JournalArticle journalArticle : findByG_S(groupId, structureId)) {
7371                            remove(journalArticle);
7372                    }
7373            }
7374    
7375            /**
7376             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
7377             *
7378             * @param groupId the group id to search with
7379             * @param templateId the template id to search with
7380             * @throws SystemException if a system exception occurred
7381             */
7382            public void removeByG_T(long groupId, String templateId)
7383                    throws SystemException {
7384                    for (JournalArticle journalArticle : findByG_T(groupId, templateId)) {
7385                            remove(journalArticle);
7386                    }
7387            }
7388    
7389            /**
7390             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
7391             *
7392             * @param groupId the group id to search with
7393             * @param urlTitle the url title to search with
7394             * @throws SystemException if a system exception occurred
7395             */
7396            public void removeByG_UT(long groupId, String urlTitle)
7397                    throws SystemException {
7398                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle)) {
7399                            remove(journalArticle);
7400                    }
7401            }
7402    
7403            /**
7404             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
7405             *
7406             * @param groupId the group id to search with
7407             * @param status the status to search with
7408             * @throws SystemException if a system exception occurred
7409             */
7410            public void removeByG_ST(long groupId, int status)
7411                    throws SystemException {
7412                    for (JournalArticle journalArticle : findByG_ST(groupId, status)) {
7413                            remove(journalArticle);
7414                    }
7415            }
7416    
7417            /**
7418             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
7419             *
7420             * @param companyId the company id to search with
7421             * @param status the status to search with
7422             * @throws SystemException if a system exception occurred
7423             */
7424            public void removeByC_ST(long companyId, int status)
7425                    throws SystemException {
7426                    for (JournalArticle journalArticle : findByC_ST(companyId, status)) {
7427                            remove(journalArticle);
7428                    }
7429            }
7430    
7431            /**
7432             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
7433             *
7434             * @param groupId the group id to search with
7435             * @param articleId the article id to search with
7436             * @param version the version to search with
7437             * @throws SystemException if a system exception occurred
7438             */
7439            public void removeByG_A_V(long groupId, String articleId, double version)
7440                    throws NoSuchArticleException, SystemException {
7441                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
7442    
7443                    remove(journalArticle);
7444            }
7445    
7446            /**
7447             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
7448             *
7449             * @param groupId the group id to search with
7450             * @param articleId the article id to search with
7451             * @param status the status to search with
7452             * @throws SystemException if a system exception occurred
7453             */
7454            public void removeByG_A_ST(long groupId, String articleId, int status)
7455                    throws SystemException {
7456                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
7457                                    status)) {
7458                            remove(journalArticle);
7459                    }
7460            }
7461    
7462            /**
7463             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
7464             *
7465             * @param groupId the group id to search with
7466             * @param urlTitle the url title to search with
7467             * @param status the status to search with
7468             * @throws SystemException if a system exception occurred
7469             */
7470            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
7471                    throws SystemException {
7472                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
7473                                    status)) {
7474                            remove(journalArticle);
7475                    }
7476            }
7477    
7478            /**
7479             * Removes all the journal articles from the database.
7480             *
7481             * @throws SystemException if a system exception occurred
7482             */
7483            public void removeAll() throws SystemException {
7484                    for (JournalArticle journalArticle : findAll()) {
7485                            remove(journalArticle);
7486                    }
7487            }
7488    
7489            /**
7490             * Counts all the journal articles where uuid = &#63;.
7491             *
7492             * @param uuid the uuid to search with
7493             * @return the number of matching journal articles
7494             * @throws SystemException if a system exception occurred
7495             */
7496            public int countByUuid(String uuid) throws SystemException {
7497                    Object[] finderArgs = new Object[] { uuid };
7498    
7499                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
7500                                    finderArgs, this);
7501    
7502                    if (count == null) {
7503                            Session session = null;
7504    
7505                            try {
7506                                    session = openSession();
7507    
7508                                    StringBundler query = new StringBundler(2);
7509    
7510                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7511    
7512                                    if (uuid == null) {
7513                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
7514                                    }
7515                                    else {
7516                                            if (uuid.equals(StringPool.BLANK)) {
7517                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
7518                                            }
7519                                            else {
7520                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
7521                                            }
7522                                    }
7523    
7524                                    String sql = query.toString();
7525    
7526                                    Query q = session.createQuery(sql);
7527    
7528                                    QueryPos qPos = QueryPos.getInstance(q);
7529    
7530                                    if (uuid != null) {
7531                                            qPos.add(uuid);
7532                                    }
7533    
7534                                    count = (Long)q.uniqueResult();
7535                            }
7536                            catch (Exception e) {
7537                                    throw processException(e);
7538                            }
7539                            finally {
7540                                    if (count == null) {
7541                                            count = Long.valueOf(0);
7542                                    }
7543    
7544                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
7545                                            finderArgs, count);
7546    
7547                                    closeSession(session);
7548                            }
7549                    }
7550    
7551                    return count.intValue();
7552            }
7553    
7554            /**
7555             * Counts all the journal articles where uuid = &#63; and groupId = &#63;.
7556             *
7557             * @param uuid the uuid to search with
7558             * @param groupId the group id to search with
7559             * @return the number of matching journal articles
7560             * @throws SystemException if a system exception occurred
7561             */
7562            public int countByUUID_G(String uuid, long groupId)
7563                    throws SystemException {
7564                    Object[] finderArgs = new Object[] { uuid, groupId };
7565    
7566                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
7567                                    finderArgs, this);
7568    
7569                    if (count == null) {
7570                            Session session = null;
7571    
7572                            try {
7573                                    session = openSession();
7574    
7575                                    StringBundler query = new StringBundler(3);
7576    
7577                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7578    
7579                                    if (uuid == null) {
7580                                            query.append(_FINDER_COLUMN_UUID_G_UUID_1);
7581                                    }
7582                                    else {
7583                                            if (uuid.equals(StringPool.BLANK)) {
7584                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
7585                                            }
7586                                            else {
7587                                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
7588                                            }
7589                                    }
7590    
7591                                    query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
7592    
7593                                    String sql = query.toString();
7594    
7595                                    Query q = session.createQuery(sql);
7596    
7597                                    QueryPos qPos = QueryPos.getInstance(q);
7598    
7599                                    if (uuid != null) {
7600                                            qPos.add(uuid);
7601                                    }
7602    
7603                                    qPos.add(groupId);
7604    
7605                                    count = (Long)q.uniqueResult();
7606                            }
7607                            catch (Exception e) {
7608                                    throw processException(e);
7609                            }
7610                            finally {
7611                                    if (count == null) {
7612                                            count = Long.valueOf(0);
7613                                    }
7614    
7615                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
7616                                            finderArgs, count);
7617    
7618                                    closeSession(session);
7619                            }
7620                    }
7621    
7622                    return count.intValue();
7623            }
7624    
7625            /**
7626             * Counts all the journal articles where resourcePrimKey = &#63;.
7627             *
7628             * @param resourcePrimKey the resource prim key to search with
7629             * @return the number of matching journal articles
7630             * @throws SystemException if a system exception occurred
7631             */
7632            public int countByResourcePrimKey(long resourcePrimKey)
7633                    throws SystemException {
7634                    Object[] finderArgs = new Object[] { resourcePrimKey };
7635    
7636                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
7637                                    finderArgs, this);
7638    
7639                    if (count == null) {
7640                            Session session = null;
7641    
7642                            try {
7643                                    session = openSession();
7644    
7645                                    StringBundler query = new StringBundler(2);
7646    
7647                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7648    
7649                                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
7650    
7651                                    String sql = query.toString();
7652    
7653                                    Query q = session.createQuery(sql);
7654    
7655                                    QueryPos qPos = QueryPos.getInstance(q);
7656    
7657                                    qPos.add(resourcePrimKey);
7658    
7659                                    count = (Long)q.uniqueResult();
7660                            }
7661                            catch (Exception e) {
7662                                    throw processException(e);
7663                            }
7664                            finally {
7665                                    if (count == null) {
7666                                            count = Long.valueOf(0);
7667                                    }
7668    
7669                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
7670                                            finderArgs, count);
7671    
7672                                    closeSession(session);
7673                            }
7674                    }
7675    
7676                    return count.intValue();
7677            }
7678    
7679            /**
7680             * Counts all the journal articles where groupId = &#63;.
7681             *
7682             * @param groupId the group id to search with
7683             * @return the number of matching journal articles
7684             * @throws SystemException if a system exception occurred
7685             */
7686            public int countByGroupId(long groupId) throws SystemException {
7687                    Object[] finderArgs = new Object[] { groupId };
7688    
7689                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
7690                                    finderArgs, this);
7691    
7692                    if (count == null) {
7693                            Session session = null;
7694    
7695                            try {
7696                                    session = openSession();
7697    
7698                                    StringBundler query = new StringBundler(2);
7699    
7700                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7701    
7702                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
7703    
7704                                    String sql = query.toString();
7705    
7706                                    Query q = session.createQuery(sql);
7707    
7708                                    QueryPos qPos = QueryPos.getInstance(q);
7709    
7710                                    qPos.add(groupId);
7711    
7712                                    count = (Long)q.uniqueResult();
7713                            }
7714                            catch (Exception e) {
7715                                    throw processException(e);
7716                            }
7717                            finally {
7718                                    if (count == null) {
7719                                            count = Long.valueOf(0);
7720                                    }
7721    
7722                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
7723                                            finderArgs, count);
7724    
7725                                    closeSession(session);
7726                            }
7727                    }
7728    
7729                    return count.intValue();
7730            }
7731    
7732            /**
7733             * Filters by the user's permissions and counts all the journal articles where groupId = &#63;.
7734             *
7735             * @param groupId the group id to search with
7736             * @return the number of matching journal articles that the user has permission to view
7737             * @throws SystemException if a system exception occurred
7738             */
7739            public int filterCountByGroupId(long groupId) throws SystemException {
7740                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7741                            return countByGroupId(groupId);
7742                    }
7743    
7744                    Session session = null;
7745    
7746                    try {
7747                            session = openSession();
7748    
7749                            StringBundler query = new StringBundler(2);
7750    
7751                            query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
7752    
7753                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
7754    
7755                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7756                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
7757                                            _FILTER_COLUMN_USERID, groupId);
7758    
7759                            SQLQuery q = session.createSQLQuery(sql);
7760    
7761                            q.addScalar(COUNT_COLUMN_NAME,
7762                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7763    
7764                            QueryPos qPos = QueryPos.getInstance(q);
7765    
7766                            qPos.add(groupId);
7767    
7768                            Long count = (Long)q.uniqueResult();
7769    
7770                            return count.intValue();
7771                    }
7772                    catch (Exception e) {
7773                            throw processException(e);
7774                    }
7775                    finally {
7776                            closeSession(session);
7777                    }
7778            }
7779    
7780            /**
7781             * Counts all the journal articles where companyId = &#63;.
7782             *
7783             * @param companyId the company id to search with
7784             * @return the number of matching journal articles
7785             * @throws SystemException if a system exception occurred
7786             */
7787            public int countByCompanyId(long companyId) throws SystemException {
7788                    Object[] finderArgs = new Object[] { companyId };
7789    
7790                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
7791                                    finderArgs, this);
7792    
7793                    if (count == null) {
7794                            Session session = null;
7795    
7796                            try {
7797                                    session = openSession();
7798    
7799                                    StringBundler query = new StringBundler(2);
7800    
7801                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7802    
7803                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
7804    
7805                                    String sql = query.toString();
7806    
7807                                    Query q = session.createQuery(sql);
7808    
7809                                    QueryPos qPos = QueryPos.getInstance(q);
7810    
7811                                    qPos.add(companyId);
7812    
7813                                    count = (Long)q.uniqueResult();
7814                            }
7815                            catch (Exception e) {
7816                                    throw processException(e);
7817                            }
7818                            finally {
7819                                    if (count == null) {
7820                                            count = Long.valueOf(0);
7821                                    }
7822    
7823                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
7824                                            finderArgs, count);
7825    
7826                                    closeSession(session);
7827                            }
7828                    }
7829    
7830                    return count.intValue();
7831            }
7832    
7833            /**
7834             * Counts all the journal articles where smallImageId = &#63;.
7835             *
7836             * @param smallImageId the small image id to search with
7837             * @return the number of matching journal articles
7838             * @throws SystemException if a system exception occurred
7839             */
7840            public int countBySmallImageId(long smallImageId) throws SystemException {
7841                    Object[] finderArgs = new Object[] { smallImageId };
7842    
7843                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
7844                                    finderArgs, this);
7845    
7846                    if (count == null) {
7847                            Session session = null;
7848    
7849                            try {
7850                                    session = openSession();
7851    
7852                                    StringBundler query = new StringBundler(2);
7853    
7854                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7855    
7856                                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
7857    
7858                                    String sql = query.toString();
7859    
7860                                    Query q = session.createQuery(sql);
7861    
7862                                    QueryPos qPos = QueryPos.getInstance(q);
7863    
7864                                    qPos.add(smallImageId);
7865    
7866                                    count = (Long)q.uniqueResult();
7867                            }
7868                            catch (Exception e) {
7869                                    throw processException(e);
7870                            }
7871                            finally {
7872                                    if (count == null) {
7873                                            count = Long.valueOf(0);
7874                                    }
7875    
7876                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
7877                                            finderArgs, count);
7878    
7879                                    closeSession(session);
7880                            }
7881                    }
7882    
7883                    return count.intValue();
7884            }
7885    
7886            /**
7887             * Counts all the journal articles where resourcePrimKey = &#63; and status = &#63;.
7888             *
7889             * @param resourcePrimKey the resource prim key to search with
7890             * @param status the status to search with
7891             * @return the number of matching journal articles
7892             * @throws SystemException if a system exception occurred
7893             */
7894            public int countByR_ST(long resourcePrimKey, int status)
7895                    throws SystemException {
7896                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
7897    
7898                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_ST,
7899                                    finderArgs, this);
7900    
7901                    if (count == null) {
7902                            Session session = null;
7903    
7904                            try {
7905                                    session = openSession();
7906    
7907                                    StringBundler query = new StringBundler(3);
7908    
7909                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7910    
7911                                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
7912    
7913                                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
7914    
7915                                    String sql = query.toString();
7916    
7917                                    Query q = session.createQuery(sql);
7918    
7919                                    QueryPos qPos = QueryPos.getInstance(q);
7920    
7921                                    qPos.add(resourcePrimKey);
7922    
7923                                    qPos.add(status);
7924    
7925                                    count = (Long)q.uniqueResult();
7926                            }
7927                            catch (Exception e) {
7928                                    throw processException(e);
7929                            }
7930                            finally {
7931                                    if (count == null) {
7932                                            count = Long.valueOf(0);
7933                                    }
7934    
7935                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_ST,
7936                                            finderArgs, count);
7937    
7938                                    closeSession(session);
7939                            }
7940                    }
7941    
7942                    return count.intValue();
7943            }
7944    
7945            /**
7946             * Counts all the journal articles where groupId = &#63; and articleId = &#63;.
7947             *
7948             * @param groupId the group id to search with
7949             * @param articleId the article id to search with
7950             * @return the number of matching journal articles
7951             * @throws SystemException if a system exception occurred
7952             */
7953            public int countByG_A(long groupId, String articleId)
7954                    throws SystemException {
7955                    Object[] finderArgs = new Object[] { groupId, articleId };
7956    
7957                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
7958                                    finderArgs, this);
7959    
7960                    if (count == null) {
7961                            Session session = null;
7962    
7963                            try {
7964                                    session = openSession();
7965    
7966                                    StringBundler query = new StringBundler(3);
7967    
7968                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
7969    
7970                                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
7971    
7972                                    if (articleId == null) {
7973                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
7974                                    }
7975                                    else {
7976                                            if (articleId.equals(StringPool.BLANK)) {
7977                                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
7978                                            }
7979                                            else {
7980                                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
7981                                            }
7982                                    }
7983    
7984                                    String sql = query.toString();
7985    
7986                                    Query q = session.createQuery(sql);
7987    
7988                                    QueryPos qPos = QueryPos.getInstance(q);
7989    
7990                                    qPos.add(groupId);
7991    
7992                                    if (articleId != null) {
7993                                            qPos.add(articleId);
7994                                    }
7995    
7996                                    count = (Long)q.uniqueResult();
7997                            }
7998                            catch (Exception e) {
7999                                    throw processException(e);
8000                            }
8001                            finally {
8002                                    if (count == null) {
8003                                            count = Long.valueOf(0);
8004                                    }
8005    
8006                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
8007                                            count);
8008    
8009                                    closeSession(session);
8010                            }
8011                    }
8012    
8013                    return count.intValue();
8014            }
8015    
8016            /**
8017             * Filters by the user's permissions and counts all the journal articles where groupId = &#63; and articleId = &#63;.
8018             *
8019             * @param groupId the group id to search with
8020             * @param articleId the article id to search with
8021             * @return the number of matching journal articles that the user has permission to view
8022             * @throws SystemException if a system exception occurred
8023             */
8024            public int filterCountByG_A(long groupId, String articleId)
8025                    throws SystemException {
8026                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8027                            return countByG_A(groupId, articleId);
8028                    }
8029    
8030                    Session session = null;
8031    
8032                    try {
8033                            session = openSession();
8034    
8035                            StringBundler query = new StringBundler(3);
8036    
8037                            query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8038    
8039                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8040    
8041                            if (articleId == null) {
8042                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8043                            }
8044                            else {
8045                                    if (articleId.equals(StringPool.BLANK)) {
8046                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8047                                    }
8048                                    else {
8049                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8050                                    }
8051                            }
8052    
8053                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8054                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
8055                                            _FILTER_COLUMN_USERID, groupId);
8056    
8057                            SQLQuery q = session.createSQLQuery(sql);
8058    
8059                            q.addScalar(COUNT_COLUMN_NAME,
8060                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8061    
8062                            QueryPos qPos = QueryPos.getInstance(q);
8063    
8064                            qPos.add(groupId);
8065    
8066                            if (articleId != null) {
8067                                    qPos.add(articleId);
8068                            }
8069    
8070                            Long count = (Long)q.uniqueResult();
8071    
8072                            return count.intValue();
8073                    }
8074                    catch (Exception e) {
8075                            throw processException(e);
8076                    }
8077                    finally {
8078                            closeSession(session);
8079                    }
8080            }
8081    
8082            /**
8083             * Counts all the journal articles where groupId = &#63; and structureId = &#63;.
8084             *
8085             * @param groupId the group id to search with
8086             * @param structureId the structure id to search with
8087             * @return the number of matching journal articles
8088             * @throws SystemException if a system exception occurred
8089             */
8090            public int countByG_S(long groupId, String structureId)
8091                    throws SystemException {
8092                    Object[] finderArgs = new Object[] { groupId, structureId };
8093    
8094                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
8095                                    finderArgs, this);
8096    
8097                    if (count == null) {
8098                            Session session = null;
8099    
8100                            try {
8101                                    session = openSession();
8102    
8103                                    StringBundler query = new StringBundler(3);
8104    
8105                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8106    
8107                                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
8108    
8109                                    if (structureId == null) {
8110                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
8111                                    }
8112                                    else {
8113                                            if (structureId.equals(StringPool.BLANK)) {
8114                                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
8115                                            }
8116                                            else {
8117                                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
8118                                            }
8119                                    }
8120    
8121                                    String sql = query.toString();
8122    
8123                                    Query q = session.createQuery(sql);
8124    
8125                                    QueryPos qPos = QueryPos.getInstance(q);
8126    
8127                                    qPos.add(groupId);
8128    
8129                                    if (structureId != null) {
8130                                            qPos.add(structureId);
8131                                    }
8132    
8133                                    count = (Long)q.uniqueResult();
8134                            }
8135                            catch (Exception e) {
8136                                    throw processException(e);
8137                            }
8138                            finally {
8139                                    if (count == null) {
8140                                            count = Long.valueOf(0);
8141                                    }
8142    
8143                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
8144                                            count);
8145    
8146                                    closeSession(session);
8147                            }
8148                    }
8149    
8150                    return count.intValue();
8151            }
8152    
8153            /**
8154             * Filters by the user's permissions and counts all the journal articles where groupId = &#63; and structureId = &#63;.
8155             *
8156             * @param groupId the group id to search with
8157             * @param structureId the structure id to search with
8158             * @return the number of matching journal articles that the user has permission to view
8159             * @throws SystemException if a system exception occurred
8160             */
8161            public int filterCountByG_S(long groupId, String structureId)
8162                    throws SystemException {
8163                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8164                            return countByG_S(groupId, structureId);
8165                    }
8166    
8167                    Session session = null;
8168    
8169                    try {
8170                            session = openSession();
8171    
8172                            StringBundler query = new StringBundler(3);
8173    
8174                            query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8175    
8176                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
8177    
8178                            if (structureId == null) {
8179                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
8180                            }
8181                            else {
8182                                    if (structureId.equals(StringPool.BLANK)) {
8183                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
8184                                    }
8185                                    else {
8186                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
8187                                    }
8188                            }
8189    
8190                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8191                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
8192                                            _FILTER_COLUMN_USERID, groupId);
8193    
8194                            SQLQuery q = session.createSQLQuery(sql);
8195    
8196                            q.addScalar(COUNT_COLUMN_NAME,
8197                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8198    
8199                            QueryPos qPos = QueryPos.getInstance(q);
8200    
8201                            qPos.add(groupId);
8202    
8203                            if (structureId != null) {
8204                                    qPos.add(structureId);
8205                            }
8206    
8207                            Long count = (Long)q.uniqueResult();
8208    
8209                            return count.intValue();
8210                    }
8211                    catch (Exception e) {
8212                            throw processException(e);
8213                    }
8214                    finally {
8215                            closeSession(session);
8216                    }
8217            }
8218    
8219            /**
8220             * Counts all the journal articles where groupId = &#63; and templateId = &#63;.
8221             *
8222             * @param groupId the group id to search with
8223             * @param templateId the template id to search with
8224             * @return the number of matching journal articles
8225             * @throws SystemException if a system exception occurred
8226             */
8227            public int countByG_T(long groupId, String templateId)
8228                    throws SystemException {
8229                    Object[] finderArgs = new Object[] { groupId, templateId };
8230    
8231                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T,
8232                                    finderArgs, this);
8233    
8234                    if (count == null) {
8235                            Session session = null;
8236    
8237                            try {
8238                                    session = openSession();
8239    
8240                                    StringBundler query = new StringBundler(3);
8241    
8242                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8243    
8244                                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
8245    
8246                                    if (templateId == null) {
8247                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
8248                                    }
8249                                    else {
8250                                            if (templateId.equals(StringPool.BLANK)) {
8251                                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
8252                                            }
8253                                            else {
8254                                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
8255                                            }
8256                                    }
8257    
8258                                    String sql = query.toString();
8259    
8260                                    Query q = session.createQuery(sql);
8261    
8262                                    QueryPos qPos = QueryPos.getInstance(q);
8263    
8264                                    qPos.add(groupId);
8265    
8266                                    if (templateId != null) {
8267                                            qPos.add(templateId);
8268                                    }
8269    
8270                                    count = (Long)q.uniqueResult();
8271                            }
8272                            catch (Exception e) {
8273                                    throw processException(e);
8274                            }
8275                            finally {
8276                                    if (count == null) {
8277                                            count = Long.valueOf(0);
8278                                    }
8279    
8280                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_T, finderArgs,
8281                                            count);
8282    
8283                                    closeSession(session);
8284                            }
8285                    }
8286    
8287                    return count.intValue();
8288            }
8289    
8290            /**
8291             * Filters by the user's permissions and counts all the journal articles where groupId = &#63; and templateId = &#63;.
8292             *
8293             * @param groupId the group id to search with
8294             * @param templateId the template id to search with
8295             * @return the number of matching journal articles that the user has permission to view
8296             * @throws SystemException if a system exception occurred
8297             */
8298            public int filterCountByG_T(long groupId, String templateId)
8299                    throws SystemException {
8300                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8301                            return countByG_T(groupId, templateId);
8302                    }
8303    
8304                    Session session = null;
8305    
8306                    try {
8307                            session = openSession();
8308    
8309                            StringBundler query = new StringBundler(3);
8310    
8311                            query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8312    
8313                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
8314    
8315                            if (templateId == null) {
8316                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
8317                            }
8318                            else {
8319                                    if (templateId.equals(StringPool.BLANK)) {
8320                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
8321                                    }
8322                                    else {
8323                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
8324                                    }
8325                            }
8326    
8327                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8328                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
8329                                            _FILTER_COLUMN_USERID, groupId);
8330    
8331                            SQLQuery q = session.createSQLQuery(sql);
8332    
8333                            q.addScalar(COUNT_COLUMN_NAME,
8334                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8335    
8336                            QueryPos qPos = QueryPos.getInstance(q);
8337    
8338                            qPos.add(groupId);
8339    
8340                            if (templateId != null) {
8341                                    qPos.add(templateId);
8342                            }
8343    
8344                            Long count = (Long)q.uniqueResult();
8345    
8346                            return count.intValue();
8347                    }
8348                    catch (Exception e) {
8349                            throw processException(e);
8350                    }
8351                    finally {
8352                            closeSession(session);
8353                    }
8354            }
8355    
8356            /**
8357             * Counts all the journal articles where groupId = &#63; and urlTitle = &#63;.
8358             *
8359             * @param groupId the group id to search with
8360             * @param urlTitle the url title to search with
8361             * @return the number of matching journal articles
8362             * @throws SystemException if a system exception occurred
8363             */
8364            public int countByG_UT(long groupId, String urlTitle)
8365                    throws SystemException {
8366                    Object[] finderArgs = new Object[] { groupId, urlTitle };
8367    
8368                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT,
8369                                    finderArgs, this);
8370    
8371                    if (count == null) {
8372                            Session session = null;
8373    
8374                            try {
8375                                    session = openSession();
8376    
8377                                    StringBundler query = new StringBundler(3);
8378    
8379                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8380    
8381                                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
8382    
8383                                    if (urlTitle == null) {
8384                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
8385                                    }
8386                                    else {
8387                                            if (urlTitle.equals(StringPool.BLANK)) {
8388                                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
8389                                            }
8390                                            else {
8391                                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
8392                                            }
8393                                    }
8394    
8395                                    String sql = query.toString();
8396    
8397                                    Query q = session.createQuery(sql);
8398    
8399                                    QueryPos qPos = QueryPos.getInstance(q);
8400    
8401                                    qPos.add(groupId);
8402    
8403                                    if (urlTitle != null) {
8404                                            qPos.add(urlTitle);
8405                                    }
8406    
8407                                    count = (Long)q.uniqueResult();
8408                            }
8409                            catch (Exception e) {
8410                                    throw processException(e);
8411                            }
8412                            finally {
8413                                    if (count == null) {
8414                                            count = Long.valueOf(0);
8415                                    }
8416    
8417                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT,
8418                                            finderArgs, count);
8419    
8420                                    closeSession(session);
8421                            }
8422                    }
8423    
8424                    return count.intValue();
8425            }
8426    
8427            /**
8428             * Filters by the user's permissions and counts all the journal articles where groupId = &#63; and urlTitle = &#63;.
8429             *
8430             * @param groupId the group id to search with
8431             * @param urlTitle the url title to search with
8432             * @return the number of matching journal articles that the user has permission to view
8433             * @throws SystemException if a system exception occurred
8434             */
8435            public int filterCountByG_UT(long groupId, String urlTitle)
8436                    throws SystemException {
8437                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8438                            return countByG_UT(groupId, urlTitle);
8439                    }
8440    
8441                    Session session = null;
8442    
8443                    try {
8444                            session = openSession();
8445    
8446                            StringBundler query = new StringBundler(3);
8447    
8448                            query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8449    
8450                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
8451    
8452                            if (urlTitle == null) {
8453                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
8454                            }
8455                            else {
8456                                    if (urlTitle.equals(StringPool.BLANK)) {
8457                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
8458                                    }
8459                                    else {
8460                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
8461                                    }
8462                            }
8463    
8464                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8465                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
8466                                            _FILTER_COLUMN_USERID, groupId);
8467    
8468                            SQLQuery q = session.createSQLQuery(sql);
8469    
8470                            q.addScalar(COUNT_COLUMN_NAME,
8471                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8472    
8473                            QueryPos qPos = QueryPos.getInstance(q);
8474    
8475                            qPos.add(groupId);
8476    
8477                            if (urlTitle != null) {
8478                                    qPos.add(urlTitle);
8479                            }
8480    
8481                            Long count = (Long)q.uniqueResult();
8482    
8483                            return count.intValue();
8484                    }
8485                    catch (Exception e) {
8486                            throw processException(e);
8487                    }
8488                    finally {
8489                            closeSession(session);
8490                    }
8491            }
8492    
8493            /**
8494             * Counts all the journal articles where groupId = &#63; and status = &#63;.
8495             *
8496             * @param groupId the group id to search with
8497             * @param status the status to search with
8498             * @return the number of matching journal articles
8499             * @throws SystemException if a system exception occurred
8500             */
8501            public int countByG_ST(long groupId, int status) throws SystemException {
8502                    Object[] finderArgs = new Object[] { groupId, status };
8503    
8504                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_ST,
8505                                    finderArgs, this);
8506    
8507                    if (count == null) {
8508                            Session session = null;
8509    
8510                            try {
8511                                    session = openSession();
8512    
8513                                    StringBundler query = new StringBundler(3);
8514    
8515                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8516    
8517                                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
8518    
8519                                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
8520    
8521                                    String sql = query.toString();
8522    
8523                                    Query q = session.createQuery(sql);
8524    
8525                                    QueryPos qPos = QueryPos.getInstance(q);
8526    
8527                                    qPos.add(groupId);
8528    
8529                                    qPos.add(status);
8530    
8531                                    count = (Long)q.uniqueResult();
8532                            }
8533                            catch (Exception e) {
8534                                    throw processException(e);
8535                            }
8536                            finally {
8537                                    if (count == null) {
8538                                            count = Long.valueOf(0);
8539                                    }
8540    
8541                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_ST,
8542                                            finderArgs, count);
8543    
8544                                    closeSession(session);
8545                            }
8546                    }
8547    
8548                    return count.intValue();
8549            }
8550    
8551            /**
8552             * Filters by the user's permissions and counts all the journal articles where groupId = &#63; and status = &#63;.
8553             *
8554             * @param groupId the group id to search with
8555             * @param status the status to search with
8556             * @return the number of matching journal articles that the user has permission to view
8557             * @throws SystemException if a system exception occurred
8558             */
8559            public int filterCountByG_ST(long groupId, int status)
8560                    throws SystemException {
8561                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8562                            return countByG_ST(groupId, status);
8563                    }
8564    
8565                    Session session = null;
8566    
8567                    try {
8568                            session = openSession();
8569    
8570                            StringBundler query = new StringBundler(3);
8571    
8572                            query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8573    
8574                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
8575    
8576                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
8577    
8578                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8579                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
8580                                            _FILTER_COLUMN_USERID, groupId);
8581    
8582                            SQLQuery q = session.createSQLQuery(sql);
8583    
8584                            q.addScalar(COUNT_COLUMN_NAME,
8585                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8586    
8587                            QueryPos qPos = QueryPos.getInstance(q);
8588    
8589                            qPos.add(groupId);
8590    
8591                            qPos.add(status);
8592    
8593                            Long count = (Long)q.uniqueResult();
8594    
8595                            return count.intValue();
8596                    }
8597                    catch (Exception e) {
8598                            throw processException(e);
8599                    }
8600                    finally {
8601                            closeSession(session);
8602                    }
8603            }
8604    
8605            /**
8606             * Counts all the journal articles where companyId = &#63; and status = &#63;.
8607             *
8608             * @param companyId the company id to search with
8609             * @param status the status to search with
8610             * @return the number of matching journal articles
8611             * @throws SystemException if a system exception occurred
8612             */
8613            public int countByC_ST(long companyId, int status)
8614                    throws SystemException {
8615                    Object[] finderArgs = new Object[] { companyId, status };
8616    
8617                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_ST,
8618                                    finderArgs, this);
8619    
8620                    if (count == null) {
8621                            Session session = null;
8622    
8623                            try {
8624                                    session = openSession();
8625    
8626                                    StringBundler query = new StringBundler(3);
8627    
8628                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8629    
8630                                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
8631    
8632                                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
8633    
8634                                    String sql = query.toString();
8635    
8636                                    Query q = session.createQuery(sql);
8637    
8638                                    QueryPos qPos = QueryPos.getInstance(q);
8639    
8640                                    qPos.add(companyId);
8641    
8642                                    qPos.add(status);
8643    
8644                                    count = (Long)q.uniqueResult();
8645                            }
8646                            catch (Exception e) {
8647                                    throw processException(e);
8648                            }
8649                            finally {
8650                                    if (count == null) {
8651                                            count = Long.valueOf(0);
8652                                    }
8653    
8654                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_ST,
8655                                            finderArgs, count);
8656    
8657                                    closeSession(session);
8658                            }
8659                    }
8660    
8661                    return count.intValue();
8662            }
8663    
8664            /**
8665             * Counts all the journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
8666             *
8667             * @param groupId the group id to search with
8668             * @param articleId the article id to search with
8669             * @param version the version to search with
8670             * @return the number of matching journal articles
8671             * @throws SystemException if a system exception occurred
8672             */
8673            public int countByG_A_V(long groupId, String articleId, double version)
8674                    throws SystemException {
8675                    Object[] finderArgs = new Object[] { groupId, articleId, version };
8676    
8677                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_V,
8678                                    finderArgs, this);
8679    
8680                    if (count == null) {
8681                            Session session = null;
8682    
8683                            try {
8684                                    session = openSession();
8685    
8686                                    StringBundler query = new StringBundler(4);
8687    
8688                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8689    
8690                                    query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
8691    
8692                                    if (articleId == null) {
8693                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
8694                                    }
8695                                    else {
8696                                            if (articleId.equals(StringPool.BLANK)) {
8697                                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
8698                                            }
8699                                            else {
8700                                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
8701                                            }
8702                                    }
8703    
8704                                    query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
8705    
8706                                    String sql = query.toString();
8707    
8708                                    Query q = session.createQuery(sql);
8709    
8710                                    QueryPos qPos = QueryPos.getInstance(q);
8711    
8712                                    qPos.add(groupId);
8713    
8714                                    if (articleId != null) {
8715                                            qPos.add(articleId);
8716                                    }
8717    
8718                                    qPos.add(version);
8719    
8720                                    count = (Long)q.uniqueResult();
8721                            }
8722                            catch (Exception e) {
8723                                    throw processException(e);
8724                            }
8725                            finally {
8726                                    if (count == null) {
8727                                            count = Long.valueOf(0);
8728                                    }
8729    
8730                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V,
8731                                            finderArgs, count);
8732    
8733                                    closeSession(session);
8734                            }
8735                    }
8736    
8737                    return count.intValue();
8738            }
8739    
8740            /**
8741             * Filters by the user's permissions and counts all the journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
8742             *
8743             * @param groupId the group id to search with
8744             * @param articleId the article id to search with
8745             * @param version the version to search with
8746             * @return the number of matching journal articles that the user has permission to view
8747             * @throws SystemException if a system exception occurred
8748             */
8749            public int filterCountByG_A_V(long groupId, String articleId, double version)
8750                    throws SystemException {
8751                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8752                            return countByG_A_V(groupId, articleId, version);
8753                    }
8754    
8755                    Session session = null;
8756    
8757                    try {
8758                            session = openSession();
8759    
8760                            StringBundler query = new StringBundler(4);
8761    
8762                            query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8763    
8764                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
8765    
8766                            if (articleId == null) {
8767                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
8768                            }
8769                            else {
8770                                    if (articleId.equals(StringPool.BLANK)) {
8771                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
8772                                    }
8773                                    else {
8774                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
8775                                    }
8776                            }
8777    
8778                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
8779    
8780                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8781                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
8782                                            _FILTER_COLUMN_USERID, groupId);
8783    
8784                            SQLQuery q = session.createSQLQuery(sql);
8785    
8786                            q.addScalar(COUNT_COLUMN_NAME,
8787                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8788    
8789                            QueryPos qPos = QueryPos.getInstance(q);
8790    
8791                            qPos.add(groupId);
8792    
8793                            if (articleId != null) {
8794                                    qPos.add(articleId);
8795                            }
8796    
8797                            qPos.add(version);
8798    
8799                            Long count = (Long)q.uniqueResult();
8800    
8801                            return count.intValue();
8802                    }
8803                    catch (Exception e) {
8804                            throw processException(e);
8805                    }
8806                    finally {
8807                            closeSession(session);
8808                    }
8809            }
8810    
8811            /**
8812             * Counts all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
8813             *
8814             * @param groupId the group id to search with
8815             * @param articleId the article id to search with
8816             * @param status the status to search with
8817             * @return the number of matching journal articles
8818             * @throws SystemException if a system exception occurred
8819             */
8820            public int countByG_A_ST(long groupId, String articleId, int status)
8821                    throws SystemException {
8822                    Object[] finderArgs = new Object[] { groupId, articleId, status };
8823    
8824                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_ST,
8825                                    finderArgs, this);
8826    
8827                    if (count == null) {
8828                            Session session = null;
8829    
8830                            try {
8831                                    session = openSession();
8832    
8833                                    StringBundler query = new StringBundler(4);
8834    
8835                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8836    
8837                                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
8838    
8839                                    if (articleId == null) {
8840                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
8841                                    }
8842                                    else {
8843                                            if (articleId.equals(StringPool.BLANK)) {
8844                                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
8845                                            }
8846                                            else {
8847                                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
8848                                            }
8849                                    }
8850    
8851                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
8852    
8853                                    String sql = query.toString();
8854    
8855                                    Query q = session.createQuery(sql);
8856    
8857                                    QueryPos qPos = QueryPos.getInstance(q);
8858    
8859                                    qPos.add(groupId);
8860    
8861                                    if (articleId != null) {
8862                                            qPos.add(articleId);
8863                                    }
8864    
8865                                    qPos.add(status);
8866    
8867                                    count = (Long)q.uniqueResult();
8868                            }
8869                            catch (Exception e) {
8870                                    throw processException(e);
8871                            }
8872                            finally {
8873                                    if (count == null) {
8874                                            count = Long.valueOf(0);
8875                                    }
8876    
8877                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_ST,
8878                                            finderArgs, count);
8879    
8880                                    closeSession(session);
8881                            }
8882                    }
8883    
8884                    return count.intValue();
8885            }
8886    
8887            /**
8888             * Filters by the user's permissions and counts all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
8889             *
8890             * @param groupId the group id to search with
8891             * @param articleId the article id to search with
8892             * @param status the status to search with
8893             * @return the number of matching journal articles that the user has permission to view
8894             * @throws SystemException if a system exception occurred
8895             */
8896            public int filterCountByG_A_ST(long groupId, String articleId, int status)
8897                    throws SystemException {
8898                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8899                            return countByG_A_ST(groupId, articleId, status);
8900                    }
8901    
8902                    Session session = null;
8903    
8904                    try {
8905                            session = openSession();
8906    
8907                            StringBundler query = new StringBundler(4);
8908    
8909                            query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
8910    
8911                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
8912    
8913                            if (articleId == null) {
8914                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
8915                            }
8916                            else {
8917                                    if (articleId.equals(StringPool.BLANK)) {
8918                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
8919                                    }
8920                                    else {
8921                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
8922                                    }
8923                            }
8924    
8925                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
8926    
8927                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8928                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
8929                                            _FILTER_COLUMN_USERID, groupId);
8930    
8931                            SQLQuery q = session.createSQLQuery(sql);
8932    
8933                            q.addScalar(COUNT_COLUMN_NAME,
8934                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8935    
8936                            QueryPos qPos = QueryPos.getInstance(q);
8937    
8938                            qPos.add(groupId);
8939    
8940                            if (articleId != null) {
8941                                    qPos.add(articleId);
8942                            }
8943    
8944                            qPos.add(status);
8945    
8946                            Long count = (Long)q.uniqueResult();
8947    
8948                            return count.intValue();
8949                    }
8950                    catch (Exception e) {
8951                            throw processException(e);
8952                    }
8953                    finally {
8954                            closeSession(session);
8955                    }
8956            }
8957    
8958            /**
8959             * Counts all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
8960             *
8961             * @param groupId the group id to search with
8962             * @param urlTitle the url title to search with
8963             * @param status the status to search with
8964             * @return the number of matching journal articles
8965             * @throws SystemException if a system exception occurred
8966             */
8967            public int countByG_UT_ST(long groupId, String urlTitle, int status)
8968                    throws SystemException {
8969                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
8970    
8971                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT_ST,
8972                                    finderArgs, this);
8973    
8974                    if (count == null) {
8975                            Session session = null;
8976    
8977                            try {
8978                                    session = openSession();
8979    
8980                                    StringBundler query = new StringBundler(4);
8981    
8982                                    query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
8983    
8984                                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
8985    
8986                                    if (urlTitle == null) {
8987                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
8988                                    }
8989                                    else {
8990                                            if (urlTitle.equals(StringPool.BLANK)) {
8991                                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
8992                                            }
8993                                            else {
8994                                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
8995                                            }
8996                                    }
8997    
8998                                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
8999    
9000                                    String sql = query.toString();
9001    
9002                                    Query q = session.createQuery(sql);
9003    
9004                                    QueryPos qPos = QueryPos.getInstance(q);
9005    
9006                                    qPos.add(groupId);
9007    
9008                                    if (urlTitle != null) {
9009                                            qPos.add(urlTitle);
9010                                    }
9011    
9012                                    qPos.add(status);
9013    
9014                                    count = (Long)q.uniqueResult();
9015                            }
9016                            catch (Exception e) {
9017                                    throw processException(e);
9018                            }
9019                            finally {
9020                                    if (count == null) {
9021                                            count = Long.valueOf(0);
9022                                    }
9023    
9024                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT_ST,
9025                                            finderArgs, count);
9026    
9027                                    closeSession(session);
9028                            }
9029                    }
9030    
9031                    return count.intValue();
9032            }
9033    
9034            /**
9035             * Filters by the user's permissions and counts all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
9036             *
9037             * @param groupId the group id to search with
9038             * @param urlTitle the url title to search with
9039             * @param status the status to search with
9040             * @return the number of matching journal articles that the user has permission to view
9041             * @throws SystemException if a system exception occurred
9042             */
9043            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
9044                    throws SystemException {
9045                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9046                            return countByG_UT_ST(groupId, urlTitle, status);
9047                    }
9048    
9049                    Session session = null;
9050    
9051                    try {
9052                            session = openSession();
9053    
9054                            StringBundler query = new StringBundler(4);
9055    
9056                            query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
9057    
9058                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
9059    
9060                            if (urlTitle == null) {
9061                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
9062                            }
9063                            else {
9064                                    if (urlTitle.equals(StringPool.BLANK)) {
9065                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
9066                                    }
9067                                    else {
9068                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
9069                                    }
9070                            }
9071    
9072                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
9073    
9074                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9075                                            JournalArticle.class.getName(), _FILTER_COLUMN_PK,
9076                                            _FILTER_COLUMN_USERID, groupId);
9077    
9078                            SQLQuery q = session.createSQLQuery(sql);
9079    
9080                            q.addScalar(COUNT_COLUMN_NAME,
9081                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9082    
9083                            QueryPos qPos = QueryPos.getInstance(q);
9084    
9085                            qPos.add(groupId);
9086    
9087                            if (urlTitle != null) {
9088                                    qPos.add(urlTitle);
9089                            }
9090    
9091                            qPos.add(status);
9092    
9093                            Long count = (Long)q.uniqueResult();
9094    
9095                            return count.intValue();
9096                    }
9097                    catch (Exception e) {
9098                            throw processException(e);
9099                    }
9100                    finally {
9101                            closeSession(session);
9102                    }
9103            }
9104    
9105            /**
9106             * Counts all the journal articles.
9107             *
9108             * @return the number of journal articles
9109             * @throws SystemException if a system exception occurred
9110             */
9111            public int countAll() throws SystemException {
9112                    Object[] finderArgs = new Object[0];
9113    
9114                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
9115                                    finderArgs, this);
9116    
9117                    if (count == null) {
9118                            Session session = null;
9119    
9120                            try {
9121                                    session = openSession();
9122    
9123                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
9124    
9125                                    count = (Long)q.uniqueResult();
9126                            }
9127                            catch (Exception e) {
9128                                    throw processException(e);
9129                            }
9130                            finally {
9131                                    if (count == null) {
9132                                            count = Long.valueOf(0);
9133                                    }
9134    
9135                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
9136                                            count);
9137    
9138                                    closeSession(session);
9139                            }
9140                    }
9141    
9142                    return count.intValue();
9143            }
9144    
9145            /**
9146             * Initializes the journal article persistence.
9147             */
9148            public void afterPropertiesSet() {
9149                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
9150                                            com.liferay.portal.util.PropsUtil.get(
9151                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
9152    
9153                    if (listenerClassNames.length > 0) {
9154                            try {
9155                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
9156    
9157                                    for (String listenerClassName : listenerClassNames) {
9158                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
9159                                                            listenerClassName));
9160                                    }
9161    
9162                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
9163                            }
9164                            catch (Exception e) {
9165                                    _log.error(e);
9166                            }
9167                    }
9168            }
9169    
9170            @BeanReference(type = JournalArticlePersistence.class)
9171            protected JournalArticlePersistence journalArticlePersistence;
9172            @BeanReference(type = JournalArticleImagePersistence.class)
9173            protected JournalArticleImagePersistence journalArticleImagePersistence;
9174            @BeanReference(type = JournalArticleResourcePersistence.class)
9175            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
9176            @BeanReference(type = JournalContentSearchPersistence.class)
9177            protected JournalContentSearchPersistence journalContentSearchPersistence;
9178            @BeanReference(type = JournalFeedPersistence.class)
9179            protected JournalFeedPersistence journalFeedPersistence;
9180            @BeanReference(type = JournalStructurePersistence.class)
9181            protected JournalStructurePersistence journalStructurePersistence;
9182            @BeanReference(type = JournalTemplatePersistence.class)
9183            protected JournalTemplatePersistence journalTemplatePersistence;
9184            @BeanReference(type = CompanyPersistence.class)
9185            protected CompanyPersistence companyPersistence;
9186            @BeanReference(type = GroupPersistence.class)
9187            protected GroupPersistence groupPersistence;
9188            @BeanReference(type = ImagePersistence.class)
9189            protected ImagePersistence imagePersistence;
9190            @BeanReference(type = PortletPreferencesPersistence.class)
9191            protected PortletPreferencesPersistence portletPreferencesPersistence;
9192            @BeanReference(type = ResourcePersistence.class)
9193            protected ResourcePersistence resourcePersistence;
9194            @BeanReference(type = SubscriptionPersistence.class)
9195            protected SubscriptionPersistence subscriptionPersistence;
9196            @BeanReference(type = UserPersistence.class)
9197            protected UserPersistence userPersistence;
9198            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
9199            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
9200            @BeanReference(type = AssetCategoryPersistence.class)
9201            protected AssetCategoryPersistence assetCategoryPersistence;
9202            @BeanReference(type = AssetEntryPersistence.class)
9203            protected AssetEntryPersistence assetEntryPersistence;
9204            @BeanReference(type = AssetTagPersistence.class)
9205            protected AssetTagPersistence assetTagPersistence;
9206            @BeanReference(type = ExpandoValuePersistence.class)
9207            protected ExpandoValuePersistence expandoValuePersistence;
9208            @BeanReference(type = MBMessagePersistence.class)
9209            protected MBMessagePersistence mbMessagePersistence;
9210            @BeanReference(type = RatingsStatsPersistence.class)
9211            protected RatingsStatsPersistence ratingsStatsPersistence;
9212            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
9213            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
9214            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
9215            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
9216            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
9217            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
9218            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?)";
9219            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
9220            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
9221            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?) AND ";
9222            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
9223            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
9224                    "journalArticle.resourcePrimKey = ?";
9225            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
9226            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
9227            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
9228            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
9229            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
9230            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
9231            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
9232            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
9233            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?)";
9234            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
9235            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
9236            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
9237            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
9238            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
9239            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
9240            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
9241            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
9242            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
9243            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
9244            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
9245            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?)";
9246            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
9247            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
9248            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
9249            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
9250            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
9251            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
9252            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
9253            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
9254            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
9255            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
9256            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
9257            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
9258            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
9259            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
9260            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
9261            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
9262            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
9263            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?) AND ";
9264            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
9265            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
9266            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
9267            private static final String _FILTER_COLUMN_PK = "journalArticle.id";
9268            private static final String _FILTER_COLUMN_USERID = "journalArticle.userId";
9269            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
9270            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
9271            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
9272            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
9273            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
9274    }