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