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