001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.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.ArrayUtil;
032    import com.liferay.portal.kernel.util.GetterUtil;
033    import com.liferay.portal.kernel.util.InstanceFactory;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.kernel.util.StringBundler;
036    import com.liferay.portal.kernel.util.StringPool;
037    import com.liferay.portal.kernel.util.StringUtil;
038    import com.liferay.portal.kernel.util.Validator;
039    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
040    import com.liferay.portal.model.CacheModel;
041    import com.liferay.portal.model.ModelListener;
042    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
043    import com.liferay.portal.service.persistence.CompanyPersistence;
044    import com.liferay.portal.service.persistence.GroupPersistence;
045    import com.liferay.portal.service.persistence.ImagePersistence;
046    import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
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.AssetLinkPersistence;
055    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
056    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
057    import com.liferay.portlet.journal.NoSuchArticleException;
058    import com.liferay.portlet.journal.model.JournalArticle;
059    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
060    import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
061    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
062    import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
063    
064    import java.io.Serializable;
065    
066    import java.util.ArrayList;
067    import java.util.Collections;
068    import java.util.List;
069    
070    /**
071     * The persistence implementation for the journal article service.
072     *
073     * <p>
074     * Caching information and settings can be found in <code>portal.properties</code>
075     * </p>
076     *
077     * @author Brian Wing Shun Chan
078     * @see JournalArticlePersistence
079     * @see JournalArticleUtil
080     * @generated
081     */
082    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
083            implements JournalArticlePersistence {
084            /*
085             * NOTE FOR DEVELOPERS:
086             *
087             * 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.
088             */
089            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
090            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
091                    ".List1";
092            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
093                    ".List2";
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
095                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
096                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
097                            "findByUuid",
098                            new String[] {
099                                    String.class.getName(),
100                                    
101                            "java.lang.Integer", "java.lang.Integer",
102                                    "com.liferay.portal.kernel.util.OrderByComparator"
103                            });
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
105                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
106                            JournalArticleImpl.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
108                            new String[] { String.class.getName() },
109                            JournalArticleModelImpl.UUID_COLUMN_BITMASK);
110            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
111                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
112                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
113                            new String[] { String.class.getName() });
114            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
115                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
116                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
117                            "fetchByUUID_G",
118                            new String[] { String.class.getName(), Long.class.getName() },
119                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
120                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
121            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
122                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
123                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
124                            new String[] { String.class.getName(), Long.class.getName() });
125            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
126                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
127                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
128                            "findByUuid_C",
129                            new String[] {
130                                    String.class.getName(), Long.class.getName(),
131                                    
132                            "java.lang.Integer", "java.lang.Integer",
133                                    "com.liferay.portal.kernel.util.OrderByComparator"
134                            });
135            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
136                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
137                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
138                            JournalArticleImpl.class,
139                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
140                            new String[] { String.class.getName(), Long.class.getName() },
141                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
142                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK);
143            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
144                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
145                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
146                            new String[] { String.class.getName(), Long.class.getName() });
147            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
148                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
149                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
150                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
151                            "findByResourcePrimKey",
152                            new String[] {
153                                    Long.class.getName(),
154                                    
155                            "java.lang.Integer", "java.lang.Integer",
156                                    "com.liferay.portal.kernel.util.OrderByComparator"
157                            });
158            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
159                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
160                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
161                            JournalArticleImpl.class,
162                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
163                            new String[] { Long.class.getName() },
164                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK);
165            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
166                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
167                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
168                            "countByResourcePrimKey", new String[] { Long.class.getName() });
169            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
170                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
171                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
172                            "findByGroupId",
173                            new String[] {
174                                    Long.class.getName(),
175                                    
176                            "java.lang.Integer", "java.lang.Integer",
177                                    "com.liferay.portal.kernel.util.OrderByComparator"
178                            });
179            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
180                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
181                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
182                            JournalArticleImpl.class,
183                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
184                            new String[] { Long.class.getName() },
185                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
186            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
187                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
188                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
189                            new String[] { Long.class.getName() });
190            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
191                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
192                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
193                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
194                            "findByCompanyId",
195                            new String[] {
196                                    Long.class.getName(),
197                                    
198                            "java.lang.Integer", "java.lang.Integer",
199                                    "com.liferay.portal.kernel.util.OrderByComparator"
200                            });
201            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
202                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
203                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
204                            JournalArticleImpl.class,
205                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
206                            new String[] { Long.class.getName() },
207                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK);
208            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
209                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
210                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
211                            new String[] { Long.class.getName() });
212            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
213                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
214                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
215                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
216                            "findByStructureId",
217                            new String[] {
218                                    String.class.getName(),
219                                    
220                            "java.lang.Integer", "java.lang.Integer",
221                                    "com.liferay.portal.kernel.util.OrderByComparator"
222                            });
223            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
224                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
225                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
226                            JournalArticleImpl.class,
227                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
228                            new String[] { String.class.getName() },
229                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
230            public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
231                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
232                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
233                            new String[] { String.class.getName() });
234            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID =
235                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
236                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
237                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
238                            "findByTemplateId",
239                            new String[] {
240                                    String.class.getName(),
241                                    
242                            "java.lang.Integer", "java.lang.Integer",
243                                    "com.liferay.portal.kernel.util.OrderByComparator"
244                            });
245            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID =
246                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
247                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
248                            JournalArticleImpl.class,
249                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTemplateId",
250                            new String[] { String.class.getName() },
251                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK);
252            public static final FinderPath FINDER_PATH_COUNT_BY_TEMPLATEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
253                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
254                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTemplateId",
255                            new String[] { String.class.getName() });
256            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
257                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
258                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
259                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
260                            "findByLayoutUuid",
261                            new String[] {
262                                    String.class.getName(),
263                                    
264                            "java.lang.Integer", "java.lang.Integer",
265                                    "com.liferay.portal.kernel.util.OrderByComparator"
266                            });
267            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
268                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
269                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
270                            JournalArticleImpl.class,
271                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
272                            new String[] { String.class.getName() },
273                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK);
274            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
275                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
276                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
277                            new String[] { String.class.getName() });
278            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
279                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
280                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
281                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
282                            "findBySmallImageId",
283                            new String[] {
284                                    Long.class.getName(),
285                                    
286                            "java.lang.Integer", "java.lang.Integer",
287                                    "com.liferay.portal.kernel.util.OrderByComparator"
288                            });
289            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
290                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
291                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
292                            JournalArticleImpl.class,
293                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
294                            new String[] { Long.class.getName() },
295                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK);
296            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
297                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
298                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
299                            new String[] { Long.class.getName() });
300            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
301                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
302                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
303                            "findByR_ST",
304                            new String[] {
305                                    Long.class.getName(), Integer.class.getName(),
306                                    
307                            "java.lang.Integer", "java.lang.Integer",
308                                    "com.liferay.portal.kernel.util.OrderByComparator"
309                            });
310            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
311                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
312                            JournalArticleImpl.class,
313                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
314                            new String[] { Long.class.getName(), Integer.class.getName() },
315                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
316                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
317            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
318                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
319                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
320                            new String[] { Long.class.getName(), Integer.class.getName() });
321            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
322                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
323                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
324                            "findByG_U",
325                            new String[] {
326                                    Long.class.getName(), Long.class.getName(),
327                                    
328                            "java.lang.Integer", "java.lang.Integer",
329                                    "com.liferay.portal.kernel.util.OrderByComparator"
330                            });
331            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
332                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
333                            JournalArticleImpl.class,
334                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
335                            new String[] { Long.class.getName(), Long.class.getName() },
336                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
337                            JournalArticleModelImpl.USERID_COLUMN_BITMASK);
338            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
339                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
340                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
341                            new String[] { Long.class.getName(), Long.class.getName() });
342            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
343                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
344                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
345                            "findByG_F",
346                            new String[] {
347                                    Long.class.getName(), Long.class.getName(),
348                                    
349                            "java.lang.Integer", "java.lang.Integer",
350                                    "com.liferay.portal.kernel.util.OrderByComparator"
351                            });
352            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
353                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
354                            JournalArticleImpl.class,
355                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
356                            new String[] { Long.class.getName(), Long.class.getName() },
357                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
358                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK);
359            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
360                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
361                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
362                            new String[] { Long.class.getName(), Long.class.getName() });
363            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
364                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
365                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
366                            new String[] { Long.class.getName(), Long.class.getName() });
367            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
368                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
369                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
370                            "findByG_A",
371                            new String[] {
372                                    Long.class.getName(), String.class.getName(),
373                                    
374                            "java.lang.Integer", "java.lang.Integer",
375                                    "com.liferay.portal.kernel.util.OrderByComparator"
376                            });
377            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
378                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
379                            JournalArticleImpl.class,
380                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
381                            new String[] { Long.class.getName(), String.class.getName() },
382                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
383                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
384            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
385                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
386                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
387                            new String[] { Long.class.getName(), String.class.getName() });
388            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
389                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
390                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
391                            "findByG_UT",
392                            new String[] {
393                                    Long.class.getName(), String.class.getName(),
394                                    
395                            "java.lang.Integer", "java.lang.Integer",
396                                    "com.liferay.portal.kernel.util.OrderByComparator"
397                            });
398            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
399                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
400                            JournalArticleImpl.class,
401                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
402                            new String[] { Long.class.getName(), String.class.getName() },
403                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
404                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK);
405            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
406                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
407                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
408                            new String[] { Long.class.getName(), String.class.getName() });
409            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
410                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
411                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
412                            "findByG_S",
413                            new String[] {
414                                    Long.class.getName(), String.class.getName(),
415                                    
416                            "java.lang.Integer", "java.lang.Integer",
417                                    "com.liferay.portal.kernel.util.OrderByComparator"
418                            });
419            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
420                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
421                            JournalArticleImpl.class,
422                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
423                            new String[] { Long.class.getName(), String.class.getName() },
424                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
425                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
426            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
427                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
428                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
429                            new String[] { Long.class.getName(), String.class.getName() });
430            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
431                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
432                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
433                            "findByG_T",
434                            new String[] {
435                                    Long.class.getName(), String.class.getName(),
436                                    
437                            "java.lang.Integer", "java.lang.Integer",
438                                    "com.liferay.portal.kernel.util.OrderByComparator"
439                            });
440            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
441                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
442                            JournalArticleImpl.class,
443                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
444                            new String[] { Long.class.getName(), String.class.getName() },
445                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
446                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK);
447            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
448                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
449                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
450                            new String[] { Long.class.getName(), String.class.getName() });
451            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
452                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
453                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
454                            "findByG_L",
455                            new String[] {
456                                    Long.class.getName(), String.class.getName(),
457                                    
458                            "java.lang.Integer", "java.lang.Integer",
459                                    "com.liferay.portal.kernel.util.OrderByComparator"
460                            });
461            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
462                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
463                            JournalArticleImpl.class,
464                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
465                            new String[] { Long.class.getName(), String.class.getName() },
466                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
467                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK);
468            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
469                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
470                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
471                            new String[] { Long.class.getName(), String.class.getName() });
472            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
473                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
474                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
475                            "findByG_ST",
476                            new String[] {
477                                    Long.class.getName(), Integer.class.getName(),
478                                    
479                            "java.lang.Integer", "java.lang.Integer",
480                                    "com.liferay.portal.kernel.util.OrderByComparator"
481                            });
482            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
483                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
484                            JournalArticleImpl.class,
485                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
486                            new String[] { Long.class.getName(), Integer.class.getName() },
487                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
488                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
489            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
490                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
491                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
492                            new String[] { Long.class.getName(), Integer.class.getName() });
493            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
494                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
495                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
496                            "findByC_V",
497                            new String[] {
498                                    Long.class.getName(), Double.class.getName(),
499                                    
500                            "java.lang.Integer", "java.lang.Integer",
501                                    "com.liferay.portal.kernel.util.OrderByComparator"
502                            });
503            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
504                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
505                            JournalArticleImpl.class,
506                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
507                            new String[] { Long.class.getName(), Double.class.getName() },
508                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
509                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
510            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
511                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
512                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
513                            new String[] { Long.class.getName(), Double.class.getName() });
514            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
515                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
516                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
517                            "findByC_ST",
518                            new String[] {
519                                    Long.class.getName(), Integer.class.getName(),
520                                    
521                            "java.lang.Integer", "java.lang.Integer",
522                                    "com.liferay.portal.kernel.util.OrderByComparator"
523                            });
524            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
525                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
526                            JournalArticleImpl.class,
527                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
528                            new String[] { Long.class.getName(), Integer.class.getName() },
529                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
530                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
531            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
532                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
533                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
534                            new String[] { Long.class.getName(), Integer.class.getName() });
535            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
536                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
537                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
538                            "findByG_F_ST",
539                            new String[] {
540                                    Long.class.getName(), Long.class.getName(),
541                                    Integer.class.getName(),
542                                    
543                            "java.lang.Integer", "java.lang.Integer",
544                                    "com.liferay.portal.kernel.util.OrderByComparator"
545                            });
546            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST =
547                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
548                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
549                            JournalArticleImpl.class,
550                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_ST",
551                            new String[] {
552                                    Long.class.getName(), Long.class.getName(),
553                                    Integer.class.getName()
554                            },
555                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
556                            JournalArticleModelImpl.FOLDERID_COLUMN_BITMASK |
557                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
558            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
559                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
560                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_ST",
561                            new String[] {
562                                    Long.class.getName(), Long.class.getName(),
563                                    Integer.class.getName()
564                            });
565            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
566                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
567                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_ST",
568                            new String[] {
569                                    Long.class.getName(), Long.class.getName(),
570                                    Integer.class.getName()
571                            });
572            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
573                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
574                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
575                            "findByG_C_C",
576                            new String[] {
577                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
578                                    
579                            "java.lang.Integer", "java.lang.Integer",
580                                    "com.liferay.portal.kernel.util.OrderByComparator"
581                            });
582            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
583                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
584                            JournalArticleImpl.class,
585                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
586                            new String[] {
587                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
588                            },
589                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
590                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
591                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK);
592            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
593                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
594                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
595                            new String[] {
596                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
597                            });
598            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
599                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
600                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
601                            new String[] {
602                                    Long.class.getName(), Long.class.getName(),
603                                    String.class.getName()
604                            },
605                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
606                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
607                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
608            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
609                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
610                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
611                            new String[] {
612                                    Long.class.getName(), Long.class.getName(),
613                                    String.class.getName()
614                            });
615            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
616                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
617                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
618                            "findByG_C_T",
619                            new String[] {
620                                    Long.class.getName(), Long.class.getName(),
621                                    String.class.getName(),
622                                    
623                            "java.lang.Integer", "java.lang.Integer",
624                                    "com.liferay.portal.kernel.util.OrderByComparator"
625                            });
626            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
627                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
628                            JournalArticleImpl.class,
629                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
630                            new String[] {
631                                    Long.class.getName(), Long.class.getName(),
632                                    String.class.getName()
633                            },
634                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
635                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
636                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK);
637            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
638                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
639                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
640                            new String[] {
641                                    Long.class.getName(), Long.class.getName(),
642                                    String.class.getName()
643                            });
644            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
645                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
646                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
647                            "findByG_C_L",
648                            new String[] {
649                                    Long.class.getName(), Long.class.getName(),
650                                    String.class.getName(),
651                                    
652                            "java.lang.Integer", "java.lang.Integer",
653                                    "com.liferay.portal.kernel.util.OrderByComparator"
654                            });
655            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
656                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
657                            JournalArticleImpl.class,
658                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
659                            new String[] {
660                                    Long.class.getName(), Long.class.getName(),
661                                    String.class.getName()
662                            },
663                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
664                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
665                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK);
666            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
667                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
668                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
669                            new String[] {
670                                    Long.class.getName(), Long.class.getName(),
671                                    String.class.getName()
672                            });
673            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
674                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
675                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
676                            new String[] {
677                                    Long.class.getName(), String.class.getName(),
678                                    Double.class.getName()
679                            },
680                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
681                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
682                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
683            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
684                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
685                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
686                            new String[] {
687                                    Long.class.getName(), String.class.getName(),
688                                    Double.class.getName()
689                            });
690            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
691                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
692                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
693                            "findByG_A_ST",
694                            new String[] {
695                                    Long.class.getName(), String.class.getName(),
696                                    Integer.class.getName(),
697                                    
698                            "java.lang.Integer", "java.lang.Integer",
699                                    "com.liferay.portal.kernel.util.OrderByComparator"
700                            });
701            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
702                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
703                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
704                            JournalArticleImpl.class,
705                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
706                            new String[] {
707                                    Long.class.getName(), String.class.getName(),
708                                    Integer.class.getName()
709                            },
710                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
711                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
712                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
713            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
714                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
715                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
716                            new String[] {
717                                    Long.class.getName(), String.class.getName(),
718                                    Integer.class.getName()
719                            });
720            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
721                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
722                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
723                            new String[] {
724                                    Long.class.getName(), String.class.getName(),
725                                    Integer.class.getName()
726                            });
727            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
728                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
729                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
730                            "findByG_UT_ST",
731                            new String[] {
732                                    Long.class.getName(), String.class.getName(),
733                                    Integer.class.getName(),
734                                    
735                            "java.lang.Integer", "java.lang.Integer",
736                                    "com.liferay.portal.kernel.util.OrderByComparator"
737                            });
738            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
739                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
740                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
741                            JournalArticleImpl.class,
742                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
743                            new String[] {
744                                    Long.class.getName(), String.class.getName(),
745                                    Integer.class.getName()
746                            },
747                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
748                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
749                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
750            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
751                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
752                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
753                            new String[] {
754                                    Long.class.getName(), String.class.getName(),
755                                    Integer.class.getName()
756                            });
757            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
758                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
759                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
760                            "findByC_V_ST",
761                            new String[] {
762                                    Long.class.getName(), Double.class.getName(),
763                                    Integer.class.getName(),
764                                    
765                            "java.lang.Integer", "java.lang.Integer",
766                                    "com.liferay.portal.kernel.util.OrderByComparator"
767                            });
768            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
769                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
770                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
771                            JournalArticleImpl.class,
772                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
773                            new String[] {
774                                    Long.class.getName(), Double.class.getName(),
775                                    Integer.class.getName()
776                            },
777                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
778                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
779                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
780            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
781                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
782                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
783                            new String[] {
784                                    Long.class.getName(), Double.class.getName(),
785                                    Integer.class.getName()
786                            });
787            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
788                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
789                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
790                            "findAll", new String[0]);
791            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
792                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
793                            JournalArticleImpl.class,
794                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
795            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
796                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
797                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
798    
799            /**
800             * Caches the journal article in the entity cache if it is enabled.
801             *
802             * @param journalArticle the journal article
803             */
804            public void cacheResult(JournalArticle journalArticle) {
805                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
806                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
807                            journalArticle);
808    
809                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
810                            new Object[] {
811                                    journalArticle.getUuid(),
812                                    Long.valueOf(journalArticle.getGroupId())
813                            }, journalArticle);
814    
815                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
816                            new Object[] {
817                                    Long.valueOf(journalArticle.getGroupId()),
818                                    Long.valueOf(journalArticle.getClassNameId()),
819                                    
820                            journalArticle.getStructureId()
821                            }, journalArticle);
822    
823                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
824                            new Object[] {
825                                    Long.valueOf(journalArticle.getGroupId()),
826                                    
827                            journalArticle.getArticleId(),
828                                    Double.valueOf(journalArticle.getVersion())
829                            }, journalArticle);
830    
831                    journalArticle.resetOriginalValues();
832            }
833    
834            /**
835             * Caches the journal articles in the entity cache if it is enabled.
836             *
837             * @param journalArticles the journal articles
838             */
839            public void cacheResult(List<JournalArticle> journalArticles) {
840                    for (JournalArticle journalArticle : journalArticles) {
841                            if (EntityCacheUtil.getResult(
842                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
843                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
844                                    cacheResult(journalArticle);
845                            }
846                            else {
847                                    journalArticle.resetOriginalValues();
848                            }
849                    }
850            }
851    
852            /**
853             * Clears the cache for all journal articles.
854             *
855             * <p>
856             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
857             * </p>
858             */
859            @Override
860            public void clearCache() {
861                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
862                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
863                    }
864    
865                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
866    
867                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
868                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
869                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
870            }
871    
872            /**
873             * Clears the cache for the journal article.
874             *
875             * <p>
876             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
877             * </p>
878             */
879            @Override
880            public void clearCache(JournalArticle journalArticle) {
881                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
882                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
883    
884                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
885                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
886    
887                    clearUniqueFindersCache(journalArticle);
888            }
889    
890            @Override
891            public void clearCache(List<JournalArticle> journalArticles) {
892                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
893                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
894    
895                    for (JournalArticle journalArticle : journalArticles) {
896                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
897                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
898    
899                            clearUniqueFindersCache(journalArticle);
900                    }
901            }
902    
903            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
904                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
905                            new Object[] {
906                                    journalArticle.getUuid(),
907                                    Long.valueOf(journalArticle.getGroupId())
908                            });
909    
910                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
911                            new Object[] {
912                                    Long.valueOf(journalArticle.getGroupId()),
913                                    Long.valueOf(journalArticle.getClassNameId()),
914                                    
915                            journalArticle.getStructureId()
916                            });
917    
918                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
919                            new Object[] {
920                                    Long.valueOf(journalArticle.getGroupId()),
921                                    
922                            journalArticle.getArticleId(),
923                                    Double.valueOf(journalArticle.getVersion())
924                            });
925            }
926    
927            /**
928             * Creates a new journal article with the primary key. Does not add the journal article to the database.
929             *
930             * @param id the primary key for the new journal article
931             * @return the new journal article
932             */
933            public JournalArticle create(long id) {
934                    JournalArticle journalArticle = new JournalArticleImpl();
935    
936                    journalArticle.setNew(true);
937                    journalArticle.setPrimaryKey(id);
938    
939                    String uuid = PortalUUIDUtil.generate();
940    
941                    journalArticle.setUuid(uuid);
942    
943                    return journalArticle;
944            }
945    
946            /**
947             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
948             *
949             * @param id the primary key of the journal article
950             * @return the journal article that was removed
951             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
952             * @throws SystemException if a system exception occurred
953             */
954            public JournalArticle remove(long id)
955                    throws NoSuchArticleException, SystemException {
956                    return remove(Long.valueOf(id));
957            }
958    
959            /**
960             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
961             *
962             * @param primaryKey the primary key of the journal article
963             * @return the journal article that was removed
964             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
965             * @throws SystemException if a system exception occurred
966             */
967            @Override
968            public JournalArticle remove(Serializable primaryKey)
969                    throws NoSuchArticleException, SystemException {
970                    Session session = null;
971    
972                    try {
973                            session = openSession();
974    
975                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
976                                            primaryKey);
977    
978                            if (journalArticle == null) {
979                                    if (_log.isWarnEnabled()) {
980                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
981                                    }
982    
983                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
984                                            primaryKey);
985                            }
986    
987                            return remove(journalArticle);
988                    }
989                    catch (NoSuchArticleException nsee) {
990                            throw nsee;
991                    }
992                    catch (Exception e) {
993                            throw processException(e);
994                    }
995                    finally {
996                            closeSession(session);
997                    }
998            }
999    
1000            @Override
1001            protected JournalArticle removeImpl(JournalArticle journalArticle)
1002                    throws SystemException {
1003                    journalArticle = toUnwrappedModel(journalArticle);
1004    
1005                    Session session = null;
1006    
1007                    try {
1008                            session = openSession();
1009    
1010                            if (journalArticle.isCachedModel()) {
1011                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
1012                                                    journalArticle.getPrimaryKeyObj());
1013                            }
1014    
1015                            session.delete(journalArticle);
1016                    }
1017                    catch (Exception e) {
1018                            throw processException(e);
1019                    }
1020                    finally {
1021                            closeSession(session);
1022                    }
1023    
1024                    clearCache(journalArticle);
1025    
1026                    return journalArticle;
1027            }
1028    
1029            @Override
1030            public JournalArticle updateImpl(
1031                    com.liferay.portlet.journal.model.JournalArticle journalArticle)
1032                    throws SystemException {
1033                    journalArticle = toUnwrappedModel(journalArticle);
1034    
1035                    boolean isNew = journalArticle.isNew();
1036    
1037                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
1038    
1039                    if (Validator.isNull(journalArticle.getUuid())) {
1040                            String uuid = PortalUUIDUtil.generate();
1041    
1042                            journalArticle.setUuid(uuid);
1043                    }
1044    
1045                    Session session = null;
1046    
1047                    try {
1048                            session = openSession();
1049    
1050                            if (journalArticle.isNew()) {
1051                                    session.save(journalArticle);
1052    
1053                                    journalArticle.setNew(false);
1054                            }
1055                            else {
1056                                    session.merge(journalArticle);
1057                            }
1058                    }
1059                    catch (Exception e) {
1060                            throw processException(e);
1061                    }
1062                    finally {
1063                            closeSession(session);
1064                    }
1065    
1066                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1067    
1068                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
1069                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1070                    }
1071    
1072                    else {
1073                            if ((journalArticleModelImpl.getColumnBitmask() &
1074                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
1075                                    Object[] args = new Object[] {
1076                                                    journalArticleModelImpl.getOriginalUuid()
1077                                            };
1078    
1079                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
1080                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
1081                                            args);
1082    
1083                                    args = new Object[] { journalArticleModelImpl.getUuid() };
1084    
1085                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
1086                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
1087                                            args);
1088                            }
1089    
1090                            if ((journalArticleModelImpl.getColumnBitmask() &
1091                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
1092                                    Object[] args = new Object[] {
1093                                                    journalArticleModelImpl.getOriginalUuid(),
1094                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId())
1095                                            };
1096    
1097                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
1098                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
1099                                            args);
1100    
1101                                    args = new Object[] {
1102                                                    journalArticleModelImpl.getUuid(),
1103                                                    Long.valueOf(journalArticleModelImpl.getCompanyId())
1104                                            };
1105    
1106                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
1107                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
1108                                            args);
1109                            }
1110    
1111                            if ((journalArticleModelImpl.getColumnBitmask() &
1112                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
1113                                    Object[] args = new Object[] {
1114                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey())
1115                                            };
1116    
1117                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
1118                                            args);
1119                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
1120                                            args);
1121    
1122                                    args = new Object[] {
1123                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey())
1124                                            };
1125    
1126                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
1127                                            args);
1128                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
1129                                            args);
1130                            }
1131    
1132                            if ((journalArticleModelImpl.getColumnBitmask() &
1133                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
1134                                    Object[] args = new Object[] {
1135                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
1136                                            };
1137    
1138                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
1139                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
1140                                            args);
1141    
1142                                    args = new Object[] {
1143                                                    Long.valueOf(journalArticleModelImpl.getGroupId())
1144                                            };
1145    
1146                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
1147                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
1148                                            args);
1149                            }
1150    
1151                            if ((journalArticleModelImpl.getColumnBitmask() &
1152                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
1153                                    Object[] args = new Object[] {
1154                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId())
1155                                            };
1156    
1157                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
1158                                            args);
1159                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
1160                                            args);
1161    
1162                                    args = new Object[] {
1163                                                    Long.valueOf(journalArticleModelImpl.getCompanyId())
1164                                            };
1165    
1166                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
1167                                            args);
1168                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
1169                                            args);
1170                            }
1171    
1172                            if ((journalArticleModelImpl.getColumnBitmask() &
1173                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
1174                                    Object[] args = new Object[] {
1175                                                    journalArticleModelImpl.getOriginalStructureId()
1176                                            };
1177    
1178                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1179                                            args);
1180                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
1181                                            args);
1182    
1183                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
1184    
1185                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1186                                            args);
1187                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
1188                                            args);
1189                            }
1190    
1191                            if ((journalArticleModelImpl.getColumnBitmask() &
1192                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
1193                                    Object[] args = new Object[] {
1194                                                    journalArticleModelImpl.getOriginalTemplateId()
1195                                            };
1196    
1197                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
1198                                            args);
1199                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
1200                                            args);
1201    
1202                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
1203    
1204                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
1205                                            args);
1206                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
1207                                            args);
1208                            }
1209    
1210                            if ((journalArticleModelImpl.getColumnBitmask() &
1211                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
1212                                    Object[] args = new Object[] {
1213                                                    journalArticleModelImpl.getOriginalLayoutUuid()
1214                                            };
1215    
1216                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
1217                                            args);
1218                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
1219                                            args);
1220    
1221                                    args = new Object[] { journalArticleModelImpl.getLayoutUuid() };
1222    
1223                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
1224                                            args);
1225                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
1226                                            args);
1227                            }
1228    
1229                            if ((journalArticleModelImpl.getColumnBitmask() &
1230                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
1231                                    Object[] args = new Object[] {
1232                                                    Long.valueOf(journalArticleModelImpl.getOriginalSmallImageId())
1233                                            };
1234    
1235                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
1236                                            args);
1237                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
1238                                            args);
1239    
1240                                    args = new Object[] {
1241                                                    Long.valueOf(journalArticleModelImpl.getSmallImageId())
1242                                            };
1243    
1244                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
1245                                            args);
1246                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
1247                                            args);
1248                            }
1249    
1250                            if ((journalArticleModelImpl.getColumnBitmask() &
1251                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
1252                                    Object[] args = new Object[] {
1253                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey()),
1254                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1255                                            };
1256    
1257                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
1258                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
1259                                            args);
1260    
1261                                    args = new Object[] {
1262                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey()),
1263                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1264                                            };
1265    
1266                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
1267                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
1268                                            args);
1269                            }
1270    
1271                            if ((journalArticleModelImpl.getColumnBitmask() &
1272                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
1273                                    Object[] args = new Object[] {
1274                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1275                                                    Long.valueOf(journalArticleModelImpl.getOriginalUserId())
1276                                            };
1277    
1278                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
1279                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
1280                                            args);
1281    
1282                                    args = new Object[] {
1283                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1284                                                    Long.valueOf(journalArticleModelImpl.getUserId())
1285                                            };
1286    
1287                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
1288                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
1289                                            args);
1290                            }
1291    
1292                            if ((journalArticleModelImpl.getColumnBitmask() &
1293                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
1294                                    Object[] args = new Object[] {
1295                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1296                                                    Long.valueOf(journalArticleModelImpl.getOriginalFolderId())
1297                                            };
1298    
1299                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
1300                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
1301                                            args);
1302    
1303                                    args = new Object[] {
1304                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1305                                                    Long.valueOf(journalArticleModelImpl.getFolderId())
1306                                            };
1307    
1308                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
1309                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
1310                                            args);
1311                            }
1312    
1313                            if ((journalArticleModelImpl.getColumnBitmask() &
1314                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
1315                                    Object[] args = new Object[] {
1316                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1317                                                    
1318                                                    journalArticleModelImpl.getOriginalArticleId()
1319                                            };
1320    
1321                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1322                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
1323                                            args);
1324    
1325                                    args = new Object[] {
1326                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1327                                                    
1328                                                    journalArticleModelImpl.getArticleId()
1329                                            };
1330    
1331                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1332                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
1333                                            args);
1334                            }
1335    
1336                            if ((journalArticleModelImpl.getColumnBitmask() &
1337                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
1338                                    Object[] args = new Object[] {
1339                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1340                                                    
1341                                                    journalArticleModelImpl.getOriginalUrlTitle()
1342                                            };
1343    
1344                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
1345                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
1346                                            args);
1347    
1348                                    args = new Object[] {
1349                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1350                                                    
1351                                                    journalArticleModelImpl.getUrlTitle()
1352                                            };
1353    
1354                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
1355                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
1356                                            args);
1357                            }
1358    
1359                            if ((journalArticleModelImpl.getColumnBitmask() &
1360                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
1361                                    Object[] args = new Object[] {
1362                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1363                                                    
1364                                                    journalArticleModelImpl.getOriginalStructureId()
1365                                            };
1366    
1367                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1368                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1369                                            args);
1370    
1371                                    args = new Object[] {
1372                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1373                                                    
1374                                                    journalArticleModelImpl.getStructureId()
1375                                            };
1376    
1377                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1378                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1379                                            args);
1380                            }
1381    
1382                            if ((journalArticleModelImpl.getColumnBitmask() &
1383                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
1384                                    Object[] args = new Object[] {
1385                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1386                                                    
1387                                                    journalArticleModelImpl.getOriginalTemplateId()
1388                                            };
1389    
1390                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
1391                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
1392                                            args);
1393    
1394                                    args = new Object[] {
1395                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1396                                                    
1397                                                    journalArticleModelImpl.getTemplateId()
1398                                            };
1399    
1400                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
1401                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
1402                                            args);
1403                            }
1404    
1405                            if ((journalArticleModelImpl.getColumnBitmask() &
1406                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
1407                                    Object[] args = new Object[] {
1408                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1409                                                    
1410                                                    journalArticleModelImpl.getOriginalLayoutUuid()
1411                                            };
1412    
1413                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
1414                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
1415                                            args);
1416    
1417                                    args = new Object[] {
1418                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1419                                                    
1420                                                    journalArticleModelImpl.getLayoutUuid()
1421                                            };
1422    
1423                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
1424                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
1425                                            args);
1426                            }
1427    
1428                            if ((journalArticleModelImpl.getColumnBitmask() &
1429                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
1430                                    Object[] args = new Object[] {
1431                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1432                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1433                                            };
1434    
1435                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
1436                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
1437                                            args);
1438    
1439                                    args = new Object[] {
1440                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1441                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1442                                            };
1443    
1444                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
1445                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
1446                                            args);
1447                            }
1448    
1449                            if ((journalArticleModelImpl.getColumnBitmask() &
1450                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
1451                                    Object[] args = new Object[] {
1452                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1453                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion())
1454                                            };
1455    
1456                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
1457                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
1458                                            args);
1459    
1460                                    args = new Object[] {
1461                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1462                                                    Double.valueOf(journalArticleModelImpl.getVersion())
1463                                            };
1464    
1465                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
1466                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
1467                                            args);
1468                            }
1469    
1470                            if ((journalArticleModelImpl.getColumnBitmask() &
1471                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
1472                                    Object[] args = new Object[] {
1473                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1474                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1475                                            };
1476    
1477                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
1478                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
1479                                            args);
1480    
1481                                    args = new Object[] {
1482                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1483                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1484                                            };
1485    
1486                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
1487                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
1488                                            args);
1489                            }
1490    
1491                            if ((journalArticleModelImpl.getColumnBitmask() &
1492                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST.getColumnBitmask()) != 0) {
1493                                    Object[] args = new Object[] {
1494                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1495                                                    Long.valueOf(journalArticleModelImpl.getOriginalFolderId()),
1496                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1497                                            };
1498    
1499                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
1500                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
1501                                            args);
1502    
1503                                    args = new Object[] {
1504                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1505                                                    Long.valueOf(journalArticleModelImpl.getFolderId()),
1506                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1507                                            };
1508    
1509                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_ST, args);
1510                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST,
1511                                            args);
1512                            }
1513    
1514                            if ((journalArticleModelImpl.getColumnBitmask() &
1515                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
1516                                    Object[] args = new Object[] {
1517                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1518                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1519                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassPK())
1520                                            };
1521    
1522                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
1523                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
1524                                            args);
1525    
1526                                    args = new Object[] {
1527                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1528                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1529                                                    Long.valueOf(journalArticleModelImpl.getClassPK())
1530                                            };
1531    
1532                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
1533                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
1534                                            args);
1535                            }
1536    
1537                            if ((journalArticleModelImpl.getColumnBitmask() &
1538                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
1539                                    Object[] args = new Object[] {
1540                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1541                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1542                                                    
1543                                                    journalArticleModelImpl.getOriginalTemplateId()
1544                                            };
1545    
1546                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1547                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1548                                            args);
1549    
1550                                    args = new Object[] {
1551                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1552                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1553                                                    
1554                                                    journalArticleModelImpl.getTemplateId()
1555                                            };
1556    
1557                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1558                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1559                                            args);
1560                            }
1561    
1562                            if ((journalArticleModelImpl.getColumnBitmask() &
1563                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
1564                                    Object[] args = new Object[] {
1565                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1566                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1567                                                    
1568                                                    journalArticleModelImpl.getOriginalLayoutUuid()
1569                                            };
1570    
1571                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
1572                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
1573                                            args);
1574    
1575                                    args = new Object[] {
1576                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1577                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1578                                                    
1579                                                    journalArticleModelImpl.getLayoutUuid()
1580                                            };
1581    
1582                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
1583                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
1584                                            args);
1585                            }
1586    
1587                            if ((journalArticleModelImpl.getColumnBitmask() &
1588                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
1589                                    Object[] args = new Object[] {
1590                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1591                                                    
1592                                                    journalArticleModelImpl.getOriginalArticleId(),
1593                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1594                                            };
1595    
1596                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
1597                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
1598                                            args);
1599    
1600                                    args = new Object[] {
1601                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1602                                                    
1603                                                    journalArticleModelImpl.getArticleId(),
1604                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1605                                            };
1606    
1607                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
1608                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
1609                                            args);
1610                            }
1611    
1612                            if ((journalArticleModelImpl.getColumnBitmask() &
1613                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
1614                                    Object[] args = new Object[] {
1615                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1616                                                    
1617                                                    journalArticleModelImpl.getOriginalUrlTitle(),
1618                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1619                                            };
1620    
1621                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
1622                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
1623                                            args);
1624    
1625                                    args = new Object[] {
1626                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1627                                                    
1628                                                    journalArticleModelImpl.getUrlTitle(),
1629                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1630                                            };
1631    
1632                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
1633                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
1634                                            args);
1635                            }
1636    
1637                            if ((journalArticleModelImpl.getColumnBitmask() &
1638                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
1639                                    Object[] args = new Object[] {
1640                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1641                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion()),
1642                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1643                                            };
1644    
1645                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
1646                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
1647                                            args);
1648    
1649                                    args = new Object[] {
1650                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1651                                                    Double.valueOf(journalArticleModelImpl.getVersion()),
1652                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1653                                            };
1654    
1655                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
1656                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
1657                                            args);
1658                            }
1659                    }
1660    
1661                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1662                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
1663                            journalArticle);
1664    
1665                    if (isNew) {
1666                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1667                                    new Object[] {
1668                                            journalArticle.getUuid(),
1669                                            Long.valueOf(journalArticle.getGroupId())
1670                                    }, journalArticle);
1671    
1672                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
1673                                    new Object[] {
1674                                            Long.valueOf(journalArticle.getGroupId()),
1675                                            Long.valueOf(journalArticle.getClassNameId()),
1676                                            
1677                                    journalArticle.getStructureId()
1678                                    }, journalArticle);
1679    
1680                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
1681                                    new Object[] {
1682                                            Long.valueOf(journalArticle.getGroupId()),
1683                                            
1684                                    journalArticle.getArticleId(),
1685                                            Double.valueOf(journalArticle.getVersion())
1686                                    }, journalArticle);
1687                    }
1688                    else {
1689                            if ((journalArticleModelImpl.getColumnBitmask() &
1690                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
1691                                    Object[] args = new Object[] {
1692                                                    journalArticleModelImpl.getOriginalUuid(),
1693                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
1694                                            };
1695    
1696                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
1697    
1698                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
1699    
1700                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1701                                            new Object[] {
1702                                                    journalArticle.getUuid(),
1703                                                    Long.valueOf(journalArticle.getGroupId())
1704                                            }, journalArticle);
1705                            }
1706    
1707                            if ((journalArticleModelImpl.getColumnBitmask() &
1708                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
1709                                    Object[] args = new Object[] {
1710                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1711                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1712                                                    
1713                                                    journalArticleModelImpl.getOriginalStructureId()
1714                                            };
1715    
1716                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
1717    
1718                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
1719    
1720                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
1721                                            new Object[] {
1722                                                    Long.valueOf(journalArticle.getGroupId()),
1723                                                    Long.valueOf(journalArticle.getClassNameId()),
1724                                                    
1725                                            journalArticle.getStructureId()
1726                                            }, journalArticle);
1727                            }
1728    
1729                            if ((journalArticleModelImpl.getColumnBitmask() &
1730                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
1731                                    Object[] args = new Object[] {
1732                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1733                                                    
1734                                                    journalArticleModelImpl.getOriginalArticleId(),
1735                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion())
1736                                            };
1737    
1738                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
1739    
1740                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
1741    
1742                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
1743                                            new Object[] {
1744                                                    Long.valueOf(journalArticle.getGroupId()),
1745                                                    
1746                                            journalArticle.getArticleId(),
1747                                                    Double.valueOf(journalArticle.getVersion())
1748                                            }, journalArticle);
1749                            }
1750                    }
1751    
1752                    return journalArticle;
1753            }
1754    
1755            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
1756                    if (journalArticle instanceof JournalArticleImpl) {
1757                            return journalArticle;
1758                    }
1759    
1760                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
1761    
1762                    journalArticleImpl.setNew(journalArticle.isNew());
1763                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
1764    
1765                    journalArticleImpl.setUuid(journalArticle.getUuid());
1766                    journalArticleImpl.setId(journalArticle.getId());
1767                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
1768                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
1769                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
1770                    journalArticleImpl.setUserId(journalArticle.getUserId());
1771                    journalArticleImpl.setUserName(journalArticle.getUserName());
1772                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
1773                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
1774                    journalArticleImpl.setFolderId(journalArticle.getFolderId());
1775                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
1776                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
1777                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
1778                    journalArticleImpl.setVersion(journalArticle.getVersion());
1779                    journalArticleImpl.setTitle(journalArticle.getTitle());
1780                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
1781                    journalArticleImpl.setDescription(journalArticle.getDescription());
1782                    journalArticleImpl.setContent(journalArticle.getContent());
1783                    journalArticleImpl.setType(journalArticle.getType());
1784                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
1785                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
1786                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
1787                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
1788                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
1789                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
1790                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
1791                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
1792                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
1793                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
1794                    journalArticleImpl.setStatus(journalArticle.getStatus());
1795                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
1796                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
1797                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
1798    
1799                    return journalArticleImpl;
1800            }
1801    
1802            /**
1803             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
1804             *
1805             * @param primaryKey the primary key of the journal article
1806             * @return the journal article
1807             * @throws com.liferay.portal.NoSuchModelException if a journal article with the primary key could not be found
1808             * @throws SystemException if a system exception occurred
1809             */
1810            @Override
1811            public JournalArticle findByPrimaryKey(Serializable primaryKey)
1812                    throws NoSuchModelException, SystemException {
1813                    return findByPrimaryKey(((Long)primaryKey).longValue());
1814            }
1815    
1816            /**
1817             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
1818             *
1819             * @param id the primary key of the journal article
1820             * @return the journal article
1821             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1822             * @throws SystemException if a system exception occurred
1823             */
1824            public JournalArticle findByPrimaryKey(long id)
1825                    throws NoSuchArticleException, SystemException {
1826                    JournalArticle journalArticle = fetchByPrimaryKey(id);
1827    
1828                    if (journalArticle == null) {
1829                            if (_log.isWarnEnabled()) {
1830                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
1831                            }
1832    
1833                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1834                                    id);
1835                    }
1836    
1837                    return journalArticle;
1838            }
1839    
1840            /**
1841             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
1842             *
1843             * @param primaryKey the primary key of the journal article
1844             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
1845             * @throws SystemException if a system exception occurred
1846             */
1847            @Override
1848            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
1849                    throws SystemException {
1850                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
1851            }
1852    
1853            /**
1854             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
1855             *
1856             * @param id the primary key of the journal article
1857             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
1858             * @throws SystemException if a system exception occurred
1859             */
1860            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
1861                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1862                                    JournalArticleImpl.class, id);
1863    
1864                    if (journalArticle == _nullJournalArticle) {
1865                            return null;
1866                    }
1867    
1868                    if (journalArticle == null) {
1869                            Session session = null;
1870    
1871                            boolean hasException = false;
1872    
1873                            try {
1874                                    session = openSession();
1875    
1876                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
1877                                                    Long.valueOf(id));
1878                            }
1879                            catch (Exception e) {
1880                                    hasException = true;
1881    
1882                                    throw processException(e);
1883                            }
1884                            finally {
1885                                    if (journalArticle != null) {
1886                                            cacheResult(journalArticle);
1887                                    }
1888                                    else if (!hasException) {
1889                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1890                                                    JournalArticleImpl.class, id, _nullJournalArticle);
1891                                    }
1892    
1893                                    closeSession(session);
1894                            }
1895                    }
1896    
1897                    return journalArticle;
1898            }
1899    
1900            /**
1901             * Returns all the journal articles where uuid = &#63;.
1902             *
1903             * @param uuid the uuid
1904             * @return the matching journal articles
1905             * @throws SystemException if a system exception occurred
1906             */
1907            public List<JournalArticle> findByUuid(String uuid)
1908                    throws SystemException {
1909                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1910            }
1911    
1912            /**
1913             * Returns a range of all the journal articles where uuid = &#63;.
1914             *
1915             * <p>
1916             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1917             * </p>
1918             *
1919             * @param uuid the uuid
1920             * @param start the lower bound of the range of journal articles
1921             * @param end the upper bound of the range of journal articles (not inclusive)
1922             * @return the range of matching journal articles
1923             * @throws SystemException if a system exception occurred
1924             */
1925            public List<JournalArticle> findByUuid(String uuid, int start, int end)
1926                    throws SystemException {
1927                    return findByUuid(uuid, start, end, null);
1928            }
1929    
1930            /**
1931             * Returns an ordered range of all the journal articles where uuid = &#63;.
1932             *
1933             * <p>
1934             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1935             * </p>
1936             *
1937             * @param uuid the uuid
1938             * @param start the lower bound of the range of journal articles
1939             * @param end the upper bound of the range of journal articles (not inclusive)
1940             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1941             * @return the ordered range of matching journal articles
1942             * @throws SystemException if a system exception occurred
1943             */
1944            public List<JournalArticle> findByUuid(String uuid, int start, int end,
1945                    OrderByComparator orderByComparator) throws SystemException {
1946                    FinderPath finderPath = null;
1947                    Object[] finderArgs = null;
1948    
1949                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1950                                    (orderByComparator == null)) {
1951                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1952                            finderArgs = new Object[] { uuid };
1953                    }
1954                    else {
1955                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1956                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1957                    }
1958    
1959                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1960                                    finderArgs, this);
1961    
1962                    if ((list != null) && !list.isEmpty()) {
1963                            for (JournalArticle journalArticle : list) {
1964                                    if (!Validator.equals(uuid, journalArticle.getUuid())) {
1965                                            list = null;
1966    
1967                                            break;
1968                                    }
1969                            }
1970                    }
1971    
1972                    if (list == null) {
1973                            StringBundler query = null;
1974    
1975                            if (orderByComparator != null) {
1976                                    query = new StringBundler(3 +
1977                                                    (orderByComparator.getOrderByFields().length * 3));
1978                            }
1979                            else {
1980                                    query = new StringBundler(3);
1981                            }
1982    
1983                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1984    
1985                            if (uuid == null) {
1986                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1987                            }
1988                            else {
1989                                    if (uuid.equals(StringPool.BLANK)) {
1990                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1991                                    }
1992                                    else {
1993                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1994                                    }
1995                            }
1996    
1997                            if (orderByComparator != null) {
1998                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1999                                            orderByComparator);
2000                            }
2001    
2002                            else {
2003                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2004                            }
2005    
2006                            String sql = query.toString();
2007    
2008                            Session session = null;
2009    
2010                            try {
2011                                    session = openSession();
2012    
2013                                    Query q = session.createQuery(sql);
2014    
2015                                    QueryPos qPos = QueryPos.getInstance(q);
2016    
2017                                    if (uuid != null) {
2018                                            qPos.add(uuid);
2019                                    }
2020    
2021                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2022                                                    start, end);
2023                            }
2024                            catch (Exception e) {
2025                                    throw processException(e);
2026                            }
2027                            finally {
2028                                    if (list == null) {
2029                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2030                                    }
2031                                    else {
2032                                            cacheResult(list);
2033    
2034                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2035                                    }
2036    
2037                                    closeSession(session);
2038                            }
2039                    }
2040    
2041                    return list;
2042            }
2043    
2044            /**
2045             * Returns the first journal article in the ordered set where uuid = &#63;.
2046             *
2047             * @param uuid the uuid
2048             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2049             * @return the first matching journal article
2050             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2051             * @throws SystemException if a system exception occurred
2052             */
2053            public JournalArticle findByUuid_First(String uuid,
2054                    OrderByComparator orderByComparator)
2055                    throws NoSuchArticleException, SystemException {
2056                    JournalArticle journalArticle = fetchByUuid_First(uuid,
2057                                    orderByComparator);
2058    
2059                    if (journalArticle != null) {
2060                            return journalArticle;
2061                    }
2062    
2063                    StringBundler msg = new StringBundler(4);
2064    
2065                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2066    
2067                    msg.append("uuid=");
2068                    msg.append(uuid);
2069    
2070                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2071    
2072                    throw new NoSuchArticleException(msg.toString());
2073            }
2074    
2075            /**
2076             * Returns the first journal article in the ordered set where uuid = &#63;.
2077             *
2078             * @param uuid the uuid
2079             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2080             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2081             * @throws SystemException if a system exception occurred
2082             */
2083            public JournalArticle fetchByUuid_First(String uuid,
2084                    OrderByComparator orderByComparator) throws SystemException {
2085                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
2086    
2087                    if (!list.isEmpty()) {
2088                            return list.get(0);
2089                    }
2090    
2091                    return null;
2092            }
2093    
2094            /**
2095             * Returns the last journal article in the ordered set where uuid = &#63;.
2096             *
2097             * @param uuid the uuid
2098             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2099             * @return the last matching journal article
2100             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2101             * @throws SystemException if a system exception occurred
2102             */
2103            public JournalArticle findByUuid_Last(String uuid,
2104                    OrderByComparator orderByComparator)
2105                    throws NoSuchArticleException, SystemException {
2106                    JournalArticle journalArticle = fetchByUuid_Last(uuid, orderByComparator);
2107    
2108                    if (journalArticle != null) {
2109                            return journalArticle;
2110                    }
2111    
2112                    StringBundler msg = new StringBundler(4);
2113    
2114                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2115    
2116                    msg.append("uuid=");
2117                    msg.append(uuid);
2118    
2119                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2120    
2121                    throw new NoSuchArticleException(msg.toString());
2122            }
2123    
2124            /**
2125             * Returns the last journal article in the ordered set where uuid = &#63;.
2126             *
2127             * @param uuid the uuid
2128             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2129             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2130             * @throws SystemException if a system exception occurred
2131             */
2132            public JournalArticle fetchByUuid_Last(String uuid,
2133                    OrderByComparator orderByComparator) throws SystemException {
2134                    int count = countByUuid(uuid);
2135    
2136                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
2137                                    orderByComparator);
2138    
2139                    if (!list.isEmpty()) {
2140                            return list.get(0);
2141                    }
2142    
2143                    return null;
2144            }
2145    
2146            /**
2147             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
2148             *
2149             * @param id the primary key of the current journal article
2150             * @param uuid the uuid
2151             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2152             * @return the previous, current, and next journal article
2153             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2154             * @throws SystemException if a system exception occurred
2155             */
2156            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
2157                    OrderByComparator orderByComparator)
2158                    throws NoSuchArticleException, SystemException {
2159                    JournalArticle journalArticle = findByPrimaryKey(id);
2160    
2161                    Session session = null;
2162    
2163                    try {
2164                            session = openSession();
2165    
2166                            JournalArticle[] array = new JournalArticleImpl[3];
2167    
2168                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
2169                                            orderByComparator, true);
2170    
2171                            array[1] = journalArticle;
2172    
2173                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
2174                                            orderByComparator, false);
2175    
2176                            return array;
2177                    }
2178                    catch (Exception e) {
2179                            throw processException(e);
2180                    }
2181                    finally {
2182                            closeSession(session);
2183                    }
2184            }
2185    
2186            protected JournalArticle getByUuid_PrevAndNext(Session session,
2187                    JournalArticle journalArticle, String uuid,
2188                    OrderByComparator orderByComparator, boolean previous) {
2189                    StringBundler query = null;
2190    
2191                    if (orderByComparator != null) {
2192                            query = new StringBundler(6 +
2193                                            (orderByComparator.getOrderByFields().length * 6));
2194                    }
2195                    else {
2196                            query = new StringBundler(3);
2197                    }
2198    
2199                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2200    
2201                    if (uuid == null) {
2202                            query.append(_FINDER_COLUMN_UUID_UUID_1);
2203                    }
2204                    else {
2205                            if (uuid.equals(StringPool.BLANK)) {
2206                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
2207                            }
2208                            else {
2209                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
2210                            }
2211                    }
2212    
2213                    if (orderByComparator != null) {
2214                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2215    
2216                            if (orderByConditionFields.length > 0) {
2217                                    query.append(WHERE_AND);
2218                            }
2219    
2220                            for (int i = 0; i < orderByConditionFields.length; i++) {
2221                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2222                                    query.append(orderByConditionFields[i]);
2223    
2224                                    if ((i + 1) < orderByConditionFields.length) {
2225                                            if (orderByComparator.isAscending() ^ previous) {
2226                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2227                                            }
2228                                            else {
2229                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2230                                            }
2231                                    }
2232                                    else {
2233                                            if (orderByComparator.isAscending() ^ previous) {
2234                                                    query.append(WHERE_GREATER_THAN);
2235                                            }
2236                                            else {
2237                                                    query.append(WHERE_LESSER_THAN);
2238                                            }
2239                                    }
2240                            }
2241    
2242                            query.append(ORDER_BY_CLAUSE);
2243    
2244                            String[] orderByFields = orderByComparator.getOrderByFields();
2245    
2246                            for (int i = 0; i < orderByFields.length; i++) {
2247                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2248                                    query.append(orderByFields[i]);
2249    
2250                                    if ((i + 1) < orderByFields.length) {
2251                                            if (orderByComparator.isAscending() ^ previous) {
2252                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2253                                            }
2254                                            else {
2255                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2256                                            }
2257                                    }
2258                                    else {
2259                                            if (orderByComparator.isAscending() ^ previous) {
2260                                                    query.append(ORDER_BY_ASC);
2261                                            }
2262                                            else {
2263                                                    query.append(ORDER_BY_DESC);
2264                                            }
2265                                    }
2266                            }
2267                    }
2268    
2269                    else {
2270                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2271                    }
2272    
2273                    String sql = query.toString();
2274    
2275                    Query q = session.createQuery(sql);
2276    
2277                    q.setFirstResult(0);
2278                    q.setMaxResults(2);
2279    
2280                    QueryPos qPos = QueryPos.getInstance(q);
2281    
2282                    if (uuid != null) {
2283                            qPos.add(uuid);
2284                    }
2285    
2286                    if (orderByComparator != null) {
2287                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2288    
2289                            for (Object value : values) {
2290                                    qPos.add(value);
2291                            }
2292                    }
2293    
2294                    List<JournalArticle> list = q.list();
2295    
2296                    if (list.size() == 2) {
2297                            return list.get(1);
2298                    }
2299                    else {
2300                            return null;
2301                    }
2302            }
2303    
2304            /**
2305             * Returns the journal article where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
2306             *
2307             * @param uuid the uuid
2308             * @param groupId the group ID
2309             * @return the matching journal article
2310             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2311             * @throws SystemException if a system exception occurred
2312             */
2313            public JournalArticle findByUUID_G(String uuid, long groupId)
2314                    throws NoSuchArticleException, SystemException {
2315                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
2316    
2317                    if (journalArticle == null) {
2318                            StringBundler msg = new StringBundler(6);
2319    
2320                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2321    
2322                            msg.append("uuid=");
2323                            msg.append(uuid);
2324    
2325                            msg.append(", groupId=");
2326                            msg.append(groupId);
2327    
2328                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2329    
2330                            if (_log.isWarnEnabled()) {
2331                                    _log.warn(msg.toString());
2332                            }
2333    
2334                            throw new NoSuchArticleException(msg.toString());
2335                    }
2336    
2337                    return journalArticle;
2338            }
2339    
2340            /**
2341             * Returns the journal article where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2342             *
2343             * @param uuid the uuid
2344             * @param groupId the group ID
2345             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
2346             * @throws SystemException if a system exception occurred
2347             */
2348            public JournalArticle fetchByUUID_G(String uuid, long groupId)
2349                    throws SystemException {
2350                    return fetchByUUID_G(uuid, groupId, true);
2351            }
2352    
2353            /**
2354             * Returns the journal article where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2355             *
2356             * @param uuid the uuid
2357             * @param groupId the group ID
2358             * @param retrieveFromCache whether to use the finder cache
2359             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
2360             * @throws SystemException if a system exception occurred
2361             */
2362            public JournalArticle fetchByUUID_G(String uuid, long groupId,
2363                    boolean retrieveFromCache) throws SystemException {
2364                    Object[] finderArgs = new Object[] { uuid, groupId };
2365    
2366                    Object result = null;
2367    
2368                    if (retrieveFromCache) {
2369                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
2370                                            finderArgs, this);
2371                    }
2372    
2373                    if (result instanceof JournalArticle) {
2374                            JournalArticle journalArticle = (JournalArticle)result;
2375    
2376                            if (!Validator.equals(uuid, journalArticle.getUuid()) ||
2377                                            (groupId != journalArticle.getGroupId())) {
2378                                    result = null;
2379                            }
2380                    }
2381    
2382                    if (result == null) {
2383                            StringBundler query = new StringBundler(4);
2384    
2385                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2386    
2387                            if (uuid == null) {
2388                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2389                            }
2390                            else {
2391                                    if (uuid.equals(StringPool.BLANK)) {
2392                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2393                                    }
2394                                    else {
2395                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2396                                    }
2397                            }
2398    
2399                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2400    
2401                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2402    
2403                            String sql = query.toString();
2404    
2405                            Session session = null;
2406    
2407                            try {
2408                                    session = openSession();
2409    
2410                                    Query q = session.createQuery(sql);
2411    
2412                                    QueryPos qPos = QueryPos.getInstance(q);
2413    
2414                                    if (uuid != null) {
2415                                            qPos.add(uuid);
2416                                    }
2417    
2418                                    qPos.add(groupId);
2419    
2420                                    List<JournalArticle> list = q.list();
2421    
2422                                    result = list;
2423    
2424                                    JournalArticle journalArticle = null;
2425    
2426                                    if (list.isEmpty()) {
2427                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2428                                                    finderArgs, list);
2429                                    }
2430                                    else {
2431                                            journalArticle = list.get(0);
2432    
2433                                            cacheResult(journalArticle);
2434    
2435                                            if ((journalArticle.getUuid() == null) ||
2436                                                            !journalArticle.getUuid().equals(uuid) ||
2437                                                            (journalArticle.getGroupId() != groupId)) {
2438                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2439                                                            finderArgs, journalArticle);
2440                                            }
2441                                    }
2442    
2443                                    return journalArticle;
2444                            }
2445                            catch (Exception e) {
2446                                    throw processException(e);
2447                            }
2448                            finally {
2449                                    if (result == null) {
2450                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
2451                                                    finderArgs);
2452                                    }
2453    
2454                                    closeSession(session);
2455                            }
2456                    }
2457                    else {
2458                            if (result instanceof List<?>) {
2459                                    return null;
2460                            }
2461                            else {
2462                                    return (JournalArticle)result;
2463                            }
2464                    }
2465            }
2466    
2467            /**
2468             * Returns all the journal articles where uuid = &#63; and companyId = &#63;.
2469             *
2470             * @param uuid the uuid
2471             * @param companyId the company ID
2472             * @return the matching journal articles
2473             * @throws SystemException if a system exception occurred
2474             */
2475            public List<JournalArticle> findByUuid_C(String uuid, long companyId)
2476                    throws SystemException {
2477                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
2478                            QueryUtil.ALL_POS, null);
2479            }
2480    
2481            /**
2482             * Returns a range of all the journal articles where uuid = &#63; and companyId = &#63;.
2483             *
2484             * <p>
2485             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2486             * </p>
2487             *
2488             * @param uuid the uuid
2489             * @param companyId the company ID
2490             * @param start the lower bound of the range of journal articles
2491             * @param end the upper bound of the range of journal articles (not inclusive)
2492             * @return the range of matching journal articles
2493             * @throws SystemException if a system exception occurred
2494             */
2495            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
2496                    int start, int end) throws SystemException {
2497                    return findByUuid_C(uuid, companyId, start, end, null);
2498            }
2499    
2500            /**
2501             * Returns an ordered range of all the journal articles where uuid = &#63; and companyId = &#63;.
2502             *
2503             * <p>
2504             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2505             * </p>
2506             *
2507             * @param uuid the uuid
2508             * @param companyId the company ID
2509             * @param start the lower bound of the range of journal articles
2510             * @param end the upper bound of the range of journal articles (not inclusive)
2511             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2512             * @return the ordered range of matching journal articles
2513             * @throws SystemException if a system exception occurred
2514             */
2515            public List<JournalArticle> findByUuid_C(String uuid, long companyId,
2516                    int start, int end, OrderByComparator orderByComparator)
2517                    throws SystemException {
2518                    FinderPath finderPath = null;
2519                    Object[] finderArgs = null;
2520    
2521                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2522                                    (orderByComparator == null)) {
2523                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
2524                            finderArgs = new Object[] { uuid, companyId };
2525                    }
2526                    else {
2527                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
2528                            finderArgs = new Object[] {
2529                                            uuid, companyId,
2530                                            
2531                                            start, end, orderByComparator
2532                                    };
2533                    }
2534    
2535                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2536                                    finderArgs, this);
2537    
2538                    if ((list != null) && !list.isEmpty()) {
2539                            for (JournalArticle journalArticle : list) {
2540                                    if (!Validator.equals(uuid, journalArticle.getUuid()) ||
2541                                                    (companyId != journalArticle.getCompanyId())) {
2542                                            list = null;
2543    
2544                                            break;
2545                                    }
2546                            }
2547                    }
2548    
2549                    if (list == null) {
2550                            StringBundler query = null;
2551    
2552                            if (orderByComparator != null) {
2553                                    query = new StringBundler(4 +
2554                                                    (orderByComparator.getOrderByFields().length * 3));
2555                            }
2556                            else {
2557                                    query = new StringBundler(4);
2558                            }
2559    
2560                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2561    
2562                            if (uuid == null) {
2563                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
2564                            }
2565                            else {
2566                                    if (uuid.equals(StringPool.BLANK)) {
2567                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
2568                                    }
2569                                    else {
2570                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
2571                                    }
2572                            }
2573    
2574                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
2575    
2576                            if (orderByComparator != null) {
2577                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2578                                            orderByComparator);
2579                            }
2580    
2581                            else {
2582                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2583                            }
2584    
2585                            String sql = query.toString();
2586    
2587                            Session session = null;
2588    
2589                            try {
2590                                    session = openSession();
2591    
2592                                    Query q = session.createQuery(sql);
2593    
2594                                    QueryPos qPos = QueryPos.getInstance(q);
2595    
2596                                    if (uuid != null) {
2597                                            qPos.add(uuid);
2598                                    }
2599    
2600                                    qPos.add(companyId);
2601    
2602                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2603                                                    start, end);
2604                            }
2605                            catch (Exception e) {
2606                                    throw processException(e);
2607                            }
2608                            finally {
2609                                    if (list == null) {
2610                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2611                                    }
2612                                    else {
2613                                            cacheResult(list);
2614    
2615                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2616                                    }
2617    
2618                                    closeSession(session);
2619                            }
2620                    }
2621    
2622                    return list;
2623            }
2624    
2625            /**
2626             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
2627             *
2628             * @param uuid the uuid
2629             * @param companyId the company ID
2630             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2631             * @return the first matching journal article
2632             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2633             * @throws SystemException if a system exception occurred
2634             */
2635            public JournalArticle findByUuid_C_First(String uuid, long companyId,
2636                    OrderByComparator orderByComparator)
2637                    throws NoSuchArticleException, SystemException {
2638                    JournalArticle journalArticle = fetchByUuid_C_First(uuid, companyId,
2639                                    orderByComparator);
2640    
2641                    if (journalArticle != null) {
2642                            return journalArticle;
2643                    }
2644    
2645                    StringBundler msg = new StringBundler(6);
2646    
2647                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2648    
2649                    msg.append("uuid=");
2650                    msg.append(uuid);
2651    
2652                    msg.append(", companyId=");
2653                    msg.append(companyId);
2654    
2655                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2656    
2657                    throw new NoSuchArticleException(msg.toString());
2658            }
2659    
2660            /**
2661             * Returns the first journal article in the ordered set where uuid = &#63; and companyId = &#63;.
2662             *
2663             * @param uuid the uuid
2664             * @param companyId the company ID
2665             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2666             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2667             * @throws SystemException if a system exception occurred
2668             */
2669            public JournalArticle fetchByUuid_C_First(String uuid, long companyId,
2670                    OrderByComparator orderByComparator) throws SystemException {
2671                    List<JournalArticle> list = findByUuid_C(uuid, companyId, 0, 1,
2672                                    orderByComparator);
2673    
2674                    if (!list.isEmpty()) {
2675                            return list.get(0);
2676                    }
2677    
2678                    return null;
2679            }
2680    
2681            /**
2682             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
2683             *
2684             * @param uuid the uuid
2685             * @param companyId the company ID
2686             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2687             * @return the last matching journal article
2688             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2689             * @throws SystemException if a system exception occurred
2690             */
2691            public JournalArticle findByUuid_C_Last(String uuid, long companyId,
2692                    OrderByComparator orderByComparator)
2693                    throws NoSuchArticleException, SystemException {
2694                    JournalArticle journalArticle = fetchByUuid_C_Last(uuid, companyId,
2695                                    orderByComparator);
2696    
2697                    if (journalArticle != null) {
2698                            return journalArticle;
2699                    }
2700    
2701                    StringBundler msg = new StringBundler(6);
2702    
2703                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2704    
2705                    msg.append("uuid=");
2706                    msg.append(uuid);
2707    
2708                    msg.append(", companyId=");
2709                    msg.append(companyId);
2710    
2711                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2712    
2713                    throw new NoSuchArticleException(msg.toString());
2714            }
2715    
2716            /**
2717             * Returns the last journal article in the ordered set where uuid = &#63; and companyId = &#63;.
2718             *
2719             * @param uuid the uuid
2720             * @param companyId the company ID
2721             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2722             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2723             * @throws SystemException if a system exception occurred
2724             */
2725            public JournalArticle fetchByUuid_C_Last(String uuid, long companyId,
2726                    OrderByComparator orderByComparator) throws SystemException {
2727                    int count = countByUuid_C(uuid, companyId);
2728    
2729                    List<JournalArticle> list = findByUuid_C(uuid, companyId, count - 1,
2730                                    count, orderByComparator);
2731    
2732                    if (!list.isEmpty()) {
2733                            return list.get(0);
2734                    }
2735    
2736                    return null;
2737            }
2738    
2739            /**
2740             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63; and companyId = &#63;.
2741             *
2742             * @param id the primary key of the current journal article
2743             * @param uuid the uuid
2744             * @param companyId the company ID
2745             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2746             * @return the previous, current, and next journal article
2747             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2748             * @throws SystemException if a system exception occurred
2749             */
2750            public JournalArticle[] findByUuid_C_PrevAndNext(long id, String uuid,
2751                    long companyId, OrderByComparator orderByComparator)
2752                    throws NoSuchArticleException, SystemException {
2753                    JournalArticle journalArticle = findByPrimaryKey(id);
2754    
2755                    Session session = null;
2756    
2757                    try {
2758                            session = openSession();
2759    
2760                            JournalArticle[] array = new JournalArticleImpl[3];
2761    
2762                            array[0] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
2763                                            companyId, orderByComparator, true);
2764    
2765                            array[1] = journalArticle;
2766    
2767                            array[2] = getByUuid_C_PrevAndNext(session, journalArticle, uuid,
2768                                            companyId, orderByComparator, false);
2769    
2770                            return array;
2771                    }
2772                    catch (Exception e) {
2773                            throw processException(e);
2774                    }
2775                    finally {
2776                            closeSession(session);
2777                    }
2778            }
2779    
2780            protected JournalArticle getByUuid_C_PrevAndNext(Session session,
2781                    JournalArticle journalArticle, String uuid, long companyId,
2782                    OrderByComparator orderByComparator, boolean previous) {
2783                    StringBundler query = null;
2784    
2785                    if (orderByComparator != null) {
2786                            query = new StringBundler(6 +
2787                                            (orderByComparator.getOrderByFields().length * 6));
2788                    }
2789                    else {
2790                            query = new StringBundler(3);
2791                    }
2792    
2793                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2794    
2795                    if (uuid == null) {
2796                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
2797                    }
2798                    else {
2799                            if (uuid.equals(StringPool.BLANK)) {
2800                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
2801                            }
2802                            else {
2803                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
2804                            }
2805                    }
2806    
2807                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
2808    
2809                    if (orderByComparator != null) {
2810                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2811    
2812                            if (orderByConditionFields.length > 0) {
2813                                    query.append(WHERE_AND);
2814                            }
2815    
2816                            for (int i = 0; i < orderByConditionFields.length; i++) {
2817                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2818                                    query.append(orderByConditionFields[i]);
2819    
2820                                    if ((i + 1) < orderByConditionFields.length) {
2821                                            if (orderByComparator.isAscending() ^ previous) {
2822                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2823                                            }
2824                                            else {
2825                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2826                                            }
2827                                    }
2828                                    else {
2829                                            if (orderByComparator.isAscending() ^ previous) {
2830                                                    query.append(WHERE_GREATER_THAN);
2831                                            }
2832                                            else {
2833                                                    query.append(WHERE_LESSER_THAN);
2834                                            }
2835                                    }
2836                            }
2837    
2838                            query.append(ORDER_BY_CLAUSE);
2839    
2840                            String[] orderByFields = orderByComparator.getOrderByFields();
2841    
2842                            for (int i = 0; i < orderByFields.length; i++) {
2843                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2844                                    query.append(orderByFields[i]);
2845    
2846                                    if ((i + 1) < orderByFields.length) {
2847                                            if (orderByComparator.isAscending() ^ previous) {
2848                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2849                                            }
2850                                            else {
2851                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2852                                            }
2853                                    }
2854                                    else {
2855                                            if (orderByComparator.isAscending() ^ previous) {
2856                                                    query.append(ORDER_BY_ASC);
2857                                            }
2858                                            else {
2859                                                    query.append(ORDER_BY_DESC);
2860                                            }
2861                                    }
2862                            }
2863                    }
2864    
2865                    else {
2866                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2867                    }
2868    
2869                    String sql = query.toString();
2870    
2871                    Query q = session.createQuery(sql);
2872    
2873                    q.setFirstResult(0);
2874                    q.setMaxResults(2);
2875    
2876                    QueryPos qPos = QueryPos.getInstance(q);
2877    
2878                    if (uuid != null) {
2879                            qPos.add(uuid);
2880                    }
2881    
2882                    qPos.add(companyId);
2883    
2884                    if (orderByComparator != null) {
2885                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2886    
2887                            for (Object value : values) {
2888                                    qPos.add(value);
2889                            }
2890                    }
2891    
2892                    List<JournalArticle> list = q.list();
2893    
2894                    if (list.size() == 2) {
2895                            return list.get(1);
2896                    }
2897                    else {
2898                            return null;
2899                    }
2900            }
2901    
2902            /**
2903             * Returns all the journal articles where resourcePrimKey = &#63;.
2904             *
2905             * @param resourcePrimKey the resource prim key
2906             * @return the matching journal articles
2907             * @throws SystemException if a system exception occurred
2908             */
2909            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
2910                    throws SystemException {
2911                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
2912                            QueryUtil.ALL_POS, null);
2913            }
2914    
2915            /**
2916             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
2917             *
2918             * <p>
2919             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2920             * </p>
2921             *
2922             * @param resourcePrimKey the resource prim key
2923             * @param start the lower bound of the range of journal articles
2924             * @param end the upper bound of the range of journal articles (not inclusive)
2925             * @return the range of matching journal articles
2926             * @throws SystemException if a system exception occurred
2927             */
2928            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
2929                    int start, int end) throws SystemException {
2930                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
2931            }
2932    
2933            /**
2934             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
2935             *
2936             * <p>
2937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2938             * </p>
2939             *
2940             * @param resourcePrimKey the resource prim key
2941             * @param start the lower bound of the range of journal articles
2942             * @param end the upper bound of the range of journal articles (not inclusive)
2943             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2944             * @return the ordered range of matching journal articles
2945             * @throws SystemException if a system exception occurred
2946             */
2947            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
2948                    int start, int end, OrderByComparator orderByComparator)
2949                    throws SystemException {
2950                    FinderPath finderPath = null;
2951                    Object[] finderArgs = null;
2952    
2953                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2954                                    (orderByComparator == null)) {
2955                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
2956                            finderArgs = new Object[] { resourcePrimKey };
2957                    }
2958                    else {
2959                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
2960                            finderArgs = new Object[] {
2961                                            resourcePrimKey,
2962                                            
2963                                            start, end, orderByComparator
2964                                    };
2965                    }
2966    
2967                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2968                                    finderArgs, this);
2969    
2970                    if ((list != null) && !list.isEmpty()) {
2971                            for (JournalArticle journalArticle : list) {
2972                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey())) {
2973                                            list = null;
2974    
2975                                            break;
2976                                    }
2977                            }
2978                    }
2979    
2980                    if (list == null) {
2981                            StringBundler query = null;
2982    
2983                            if (orderByComparator != null) {
2984                                    query = new StringBundler(3 +
2985                                                    (orderByComparator.getOrderByFields().length * 3));
2986                            }
2987                            else {
2988                                    query = new StringBundler(3);
2989                            }
2990    
2991                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2992    
2993                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
2994    
2995                            if (orderByComparator != null) {
2996                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2997                                            orderByComparator);
2998                            }
2999    
3000                            else {
3001                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3002                            }
3003    
3004                            String sql = query.toString();
3005    
3006                            Session session = null;
3007    
3008                            try {
3009                                    session = openSession();
3010    
3011                                    Query q = session.createQuery(sql);
3012    
3013                                    QueryPos qPos = QueryPos.getInstance(q);
3014    
3015                                    qPos.add(resourcePrimKey);
3016    
3017                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3018                                                    start, end);
3019                            }
3020                            catch (Exception e) {
3021                                    throw processException(e);
3022                            }
3023                            finally {
3024                                    if (list == null) {
3025                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3026                                    }
3027                                    else {
3028                                            cacheResult(list);
3029    
3030                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3031                                    }
3032    
3033                                    closeSession(session);
3034                            }
3035                    }
3036    
3037                    return list;
3038            }
3039    
3040            /**
3041             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
3042             *
3043             * @param resourcePrimKey the resource prim key
3044             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3045             * @return the first matching journal article
3046             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3047             * @throws SystemException if a system exception occurred
3048             */
3049            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
3050                    OrderByComparator orderByComparator)
3051                    throws NoSuchArticleException, SystemException {
3052                    JournalArticle journalArticle = fetchByResourcePrimKey_First(resourcePrimKey,
3053                                    orderByComparator);
3054    
3055                    if (journalArticle != null) {
3056                            return journalArticle;
3057                    }
3058    
3059                    StringBundler msg = new StringBundler(4);
3060    
3061                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3062    
3063                    msg.append("resourcePrimKey=");
3064                    msg.append(resourcePrimKey);
3065    
3066                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3067    
3068                    throw new NoSuchArticleException(msg.toString());
3069            }
3070    
3071            /**
3072             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
3073             *
3074             * @param resourcePrimKey the resource prim key
3075             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3076             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3077             * @throws SystemException if a system exception occurred
3078             */
3079            public JournalArticle fetchByResourcePrimKey_First(long resourcePrimKey,
3080                    OrderByComparator orderByComparator) throws SystemException {
3081                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
3082                                    1, orderByComparator);
3083    
3084                    if (!list.isEmpty()) {
3085                            return list.get(0);
3086                    }
3087    
3088                    return null;
3089            }
3090    
3091            /**
3092             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
3093             *
3094             * @param resourcePrimKey the resource prim key
3095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3096             * @return the last matching journal article
3097             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3098             * @throws SystemException if a system exception occurred
3099             */
3100            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
3101                    OrderByComparator orderByComparator)
3102                    throws NoSuchArticleException, SystemException {
3103                    JournalArticle journalArticle = fetchByResourcePrimKey_Last(resourcePrimKey,
3104                                    orderByComparator);
3105    
3106                    if (journalArticle != null) {
3107                            return journalArticle;
3108                    }
3109    
3110                    StringBundler msg = new StringBundler(4);
3111    
3112                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3113    
3114                    msg.append("resourcePrimKey=");
3115                    msg.append(resourcePrimKey);
3116    
3117                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3118    
3119                    throw new NoSuchArticleException(msg.toString());
3120            }
3121    
3122            /**
3123             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
3124             *
3125             * @param resourcePrimKey the resource prim key
3126             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3127             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3128             * @throws SystemException if a system exception occurred
3129             */
3130            public JournalArticle fetchByResourcePrimKey_Last(long resourcePrimKey,
3131                    OrderByComparator orderByComparator) throws SystemException {
3132                    int count = countByResourcePrimKey(resourcePrimKey);
3133    
3134                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
3135                                    count - 1, count, orderByComparator);
3136    
3137                    if (!list.isEmpty()) {
3138                            return list.get(0);
3139                    }
3140    
3141                    return null;
3142            }
3143    
3144            /**
3145             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
3146             *
3147             * @param id the primary key of the current journal article
3148             * @param resourcePrimKey the resource prim key
3149             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3150             * @return the previous, current, and next journal article
3151             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3152             * @throws SystemException if a system exception occurred
3153             */
3154            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
3155                    long resourcePrimKey, OrderByComparator orderByComparator)
3156                    throws NoSuchArticleException, SystemException {
3157                    JournalArticle journalArticle = findByPrimaryKey(id);
3158    
3159                    Session session = null;
3160    
3161                    try {
3162                            session = openSession();
3163    
3164                            JournalArticle[] array = new JournalArticleImpl[3];
3165    
3166                            array[0] = getByResourcePrimKey_PrevAndNext(session,
3167                                            journalArticle, resourcePrimKey, orderByComparator, true);
3168    
3169                            array[1] = journalArticle;
3170    
3171                            array[2] = getByResourcePrimKey_PrevAndNext(session,
3172                                            journalArticle, resourcePrimKey, orderByComparator, false);
3173    
3174                            return array;
3175                    }
3176                    catch (Exception e) {
3177                            throw processException(e);
3178                    }
3179                    finally {
3180                            closeSession(session);
3181                    }
3182            }
3183    
3184            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
3185                    JournalArticle journalArticle, long resourcePrimKey,
3186                    OrderByComparator orderByComparator, boolean previous) {
3187                    StringBundler query = null;
3188    
3189                    if (orderByComparator != null) {
3190                            query = new StringBundler(6 +
3191                                            (orderByComparator.getOrderByFields().length * 6));
3192                    }
3193                    else {
3194                            query = new StringBundler(3);
3195                    }
3196    
3197                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3198    
3199                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
3200    
3201                    if (orderByComparator != null) {
3202                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3203    
3204                            if (orderByConditionFields.length > 0) {
3205                                    query.append(WHERE_AND);
3206                            }
3207    
3208                            for (int i = 0; i < orderByConditionFields.length; i++) {
3209                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3210                                    query.append(orderByConditionFields[i]);
3211    
3212                                    if ((i + 1) < orderByConditionFields.length) {
3213                                            if (orderByComparator.isAscending() ^ previous) {
3214                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3215                                            }
3216                                            else {
3217                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3218                                            }
3219                                    }
3220                                    else {
3221                                            if (orderByComparator.isAscending() ^ previous) {
3222                                                    query.append(WHERE_GREATER_THAN);
3223                                            }
3224                                            else {
3225                                                    query.append(WHERE_LESSER_THAN);
3226                                            }
3227                                    }
3228                            }
3229    
3230                            query.append(ORDER_BY_CLAUSE);
3231    
3232                            String[] orderByFields = orderByComparator.getOrderByFields();
3233    
3234                            for (int i = 0; i < orderByFields.length; i++) {
3235                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3236                                    query.append(orderByFields[i]);
3237    
3238                                    if ((i + 1) < orderByFields.length) {
3239                                            if (orderByComparator.isAscending() ^ previous) {
3240                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3241                                            }
3242                                            else {
3243                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3244                                            }
3245                                    }
3246                                    else {
3247                                            if (orderByComparator.isAscending() ^ previous) {
3248                                                    query.append(ORDER_BY_ASC);
3249                                            }
3250                                            else {
3251                                                    query.append(ORDER_BY_DESC);
3252                                            }
3253                                    }
3254                            }
3255                    }
3256    
3257                    else {
3258                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3259                    }
3260    
3261                    String sql = query.toString();
3262    
3263                    Query q = session.createQuery(sql);
3264    
3265                    q.setFirstResult(0);
3266                    q.setMaxResults(2);
3267    
3268                    QueryPos qPos = QueryPos.getInstance(q);
3269    
3270                    qPos.add(resourcePrimKey);
3271    
3272                    if (orderByComparator != null) {
3273                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3274    
3275                            for (Object value : values) {
3276                                    qPos.add(value);
3277                            }
3278                    }
3279    
3280                    List<JournalArticle> list = q.list();
3281    
3282                    if (list.size() == 2) {
3283                            return list.get(1);
3284                    }
3285                    else {
3286                            return null;
3287                    }
3288            }
3289    
3290            /**
3291             * Returns all the journal articles where groupId = &#63;.
3292             *
3293             * @param groupId the group ID
3294             * @return the matching journal articles
3295             * @throws SystemException if a system exception occurred
3296             */
3297            public List<JournalArticle> findByGroupId(long groupId)
3298                    throws SystemException {
3299                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3300            }
3301    
3302            /**
3303             * Returns a range of all the journal articles where groupId = &#63;.
3304             *
3305             * <p>
3306             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3307             * </p>
3308             *
3309             * @param groupId the group ID
3310             * @param start the lower bound of the range of journal articles
3311             * @param end the upper bound of the range of journal articles (not inclusive)
3312             * @return the range of matching journal articles
3313             * @throws SystemException if a system exception occurred
3314             */
3315            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
3316                    throws SystemException {
3317                    return findByGroupId(groupId, start, end, null);
3318            }
3319    
3320            /**
3321             * Returns an ordered range of all the journal articles where groupId = &#63;.
3322             *
3323             * <p>
3324             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3325             * </p>
3326             *
3327             * @param groupId the group ID
3328             * @param start the lower bound of the range of journal articles
3329             * @param end the upper bound of the range of journal articles (not inclusive)
3330             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3331             * @return the ordered range of matching journal articles
3332             * @throws SystemException if a system exception occurred
3333             */
3334            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
3335                    OrderByComparator orderByComparator) throws SystemException {
3336                    FinderPath finderPath = null;
3337                    Object[] finderArgs = null;
3338    
3339                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3340                                    (orderByComparator == null)) {
3341                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
3342                            finderArgs = new Object[] { groupId };
3343                    }
3344                    else {
3345                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
3346                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
3347                    }
3348    
3349                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3350                                    finderArgs, this);
3351    
3352                    if ((list != null) && !list.isEmpty()) {
3353                            for (JournalArticle journalArticle : list) {
3354                                    if ((groupId != journalArticle.getGroupId())) {
3355                                            list = null;
3356    
3357                                            break;
3358                                    }
3359                            }
3360                    }
3361    
3362                    if (list == null) {
3363                            StringBundler query = null;
3364    
3365                            if (orderByComparator != null) {
3366                                    query = new StringBundler(3 +
3367                                                    (orderByComparator.getOrderByFields().length * 3));
3368                            }
3369                            else {
3370                                    query = new StringBundler(3);
3371                            }
3372    
3373                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3374    
3375                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3376    
3377                            if (orderByComparator != null) {
3378                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3379                                            orderByComparator);
3380                            }
3381    
3382                            else {
3383                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3384                            }
3385    
3386                            String sql = query.toString();
3387    
3388                            Session session = null;
3389    
3390                            try {
3391                                    session = openSession();
3392    
3393                                    Query q = session.createQuery(sql);
3394    
3395                                    QueryPos qPos = QueryPos.getInstance(q);
3396    
3397                                    qPos.add(groupId);
3398    
3399                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3400                                                    start, end);
3401                            }
3402                            catch (Exception e) {
3403                                    throw processException(e);
3404                            }
3405                            finally {
3406                                    if (list == null) {
3407                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3408                                    }
3409                                    else {
3410                                            cacheResult(list);
3411    
3412                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3413                                    }
3414    
3415                                    closeSession(session);
3416                            }
3417                    }
3418    
3419                    return list;
3420            }
3421    
3422            /**
3423             * Returns the first journal article in the ordered set where groupId = &#63;.
3424             *
3425             * @param groupId the group ID
3426             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3427             * @return the first matching journal article
3428             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3429             * @throws SystemException if a system exception occurred
3430             */
3431            public JournalArticle findByGroupId_First(long groupId,
3432                    OrderByComparator orderByComparator)
3433                    throws NoSuchArticleException, SystemException {
3434                    JournalArticle journalArticle = fetchByGroupId_First(groupId,
3435                                    orderByComparator);
3436    
3437                    if (journalArticle != null) {
3438                            return journalArticle;
3439                    }
3440    
3441                    StringBundler msg = new StringBundler(4);
3442    
3443                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3444    
3445                    msg.append("groupId=");
3446                    msg.append(groupId);
3447    
3448                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3449    
3450                    throw new NoSuchArticleException(msg.toString());
3451            }
3452    
3453            /**
3454             * Returns the first journal article in the ordered set where groupId = &#63;.
3455             *
3456             * @param groupId the group ID
3457             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3458             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3459             * @throws SystemException if a system exception occurred
3460             */
3461            public JournalArticle fetchByGroupId_First(long groupId,
3462                    OrderByComparator orderByComparator) throws SystemException {
3463                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
3464                                    orderByComparator);
3465    
3466                    if (!list.isEmpty()) {
3467                            return list.get(0);
3468                    }
3469    
3470                    return null;
3471            }
3472    
3473            /**
3474             * Returns the last journal article in the ordered set where groupId = &#63;.
3475             *
3476             * @param groupId the group ID
3477             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3478             * @return the last matching journal article
3479             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3480             * @throws SystemException if a system exception occurred
3481             */
3482            public JournalArticle findByGroupId_Last(long groupId,
3483                    OrderByComparator orderByComparator)
3484                    throws NoSuchArticleException, SystemException {
3485                    JournalArticle journalArticle = fetchByGroupId_Last(groupId,
3486                                    orderByComparator);
3487    
3488                    if (journalArticle != null) {
3489                            return journalArticle;
3490                    }
3491    
3492                    StringBundler msg = new StringBundler(4);
3493    
3494                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3495    
3496                    msg.append("groupId=");
3497                    msg.append(groupId);
3498    
3499                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3500    
3501                    throw new NoSuchArticleException(msg.toString());
3502            }
3503    
3504            /**
3505             * Returns the last journal article in the ordered set where groupId = &#63;.
3506             *
3507             * @param groupId the group ID
3508             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3509             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3510             * @throws SystemException if a system exception occurred
3511             */
3512            public JournalArticle fetchByGroupId_Last(long groupId,
3513                    OrderByComparator orderByComparator) throws SystemException {
3514                    int count = countByGroupId(groupId);
3515    
3516                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
3517                                    orderByComparator);
3518    
3519                    if (!list.isEmpty()) {
3520                            return list.get(0);
3521                    }
3522    
3523                    return null;
3524            }
3525    
3526            /**
3527             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
3528             *
3529             * @param id the primary key of the current journal article
3530             * @param groupId the group ID
3531             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3532             * @return the previous, current, and next journal article
3533             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3534             * @throws SystemException if a system exception occurred
3535             */
3536            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
3537                    OrderByComparator orderByComparator)
3538                    throws NoSuchArticleException, SystemException {
3539                    JournalArticle journalArticle = findByPrimaryKey(id);
3540    
3541                    Session session = null;
3542    
3543                    try {
3544                            session = openSession();
3545    
3546                            JournalArticle[] array = new JournalArticleImpl[3];
3547    
3548                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
3549                                            groupId, orderByComparator, true);
3550    
3551                            array[1] = journalArticle;
3552    
3553                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
3554                                            groupId, orderByComparator, false);
3555    
3556                            return array;
3557                    }
3558                    catch (Exception e) {
3559                            throw processException(e);
3560                    }
3561                    finally {
3562                            closeSession(session);
3563                    }
3564            }
3565    
3566            protected JournalArticle getByGroupId_PrevAndNext(Session session,
3567                    JournalArticle journalArticle, long groupId,
3568                    OrderByComparator orderByComparator, boolean previous) {
3569                    StringBundler query = null;
3570    
3571                    if (orderByComparator != null) {
3572                            query = new StringBundler(6 +
3573                                            (orderByComparator.getOrderByFields().length * 6));
3574                    }
3575                    else {
3576                            query = new StringBundler(3);
3577                    }
3578    
3579                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3580    
3581                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3582    
3583                    if (orderByComparator != null) {
3584                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3585    
3586                            if (orderByConditionFields.length > 0) {
3587                                    query.append(WHERE_AND);
3588                            }
3589    
3590                            for (int i = 0; i < orderByConditionFields.length; i++) {
3591                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3592                                    query.append(orderByConditionFields[i]);
3593    
3594                                    if ((i + 1) < orderByConditionFields.length) {
3595                                            if (orderByComparator.isAscending() ^ previous) {
3596                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3597                                            }
3598                                            else {
3599                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3600                                            }
3601                                    }
3602                                    else {
3603                                            if (orderByComparator.isAscending() ^ previous) {
3604                                                    query.append(WHERE_GREATER_THAN);
3605                                            }
3606                                            else {
3607                                                    query.append(WHERE_LESSER_THAN);
3608                                            }
3609                                    }
3610                            }
3611    
3612                            query.append(ORDER_BY_CLAUSE);
3613    
3614                            String[] orderByFields = orderByComparator.getOrderByFields();
3615    
3616                            for (int i = 0; i < orderByFields.length; i++) {
3617                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3618                                    query.append(orderByFields[i]);
3619    
3620                                    if ((i + 1) < orderByFields.length) {
3621                                            if (orderByComparator.isAscending() ^ previous) {
3622                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3623                                            }
3624                                            else {
3625                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3626                                            }
3627                                    }
3628                                    else {
3629                                            if (orderByComparator.isAscending() ^ previous) {
3630                                                    query.append(ORDER_BY_ASC);
3631                                            }
3632                                            else {
3633                                                    query.append(ORDER_BY_DESC);
3634                                            }
3635                                    }
3636                            }
3637                    }
3638    
3639                    else {
3640                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3641                    }
3642    
3643                    String sql = query.toString();
3644    
3645                    Query q = session.createQuery(sql);
3646    
3647                    q.setFirstResult(0);
3648                    q.setMaxResults(2);
3649    
3650                    QueryPos qPos = QueryPos.getInstance(q);
3651    
3652                    qPos.add(groupId);
3653    
3654                    if (orderByComparator != null) {
3655                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3656    
3657                            for (Object value : values) {
3658                                    qPos.add(value);
3659                            }
3660                    }
3661    
3662                    List<JournalArticle> list = q.list();
3663    
3664                    if (list.size() == 2) {
3665                            return list.get(1);
3666                    }
3667                    else {
3668                            return null;
3669                    }
3670            }
3671    
3672            /**
3673             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
3674             *
3675             * @param groupId the group ID
3676             * @return the matching journal articles that the user has permission to view
3677             * @throws SystemException if a system exception occurred
3678             */
3679            public List<JournalArticle> filterFindByGroupId(long groupId)
3680                    throws SystemException {
3681                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
3682                            QueryUtil.ALL_POS, null);
3683            }
3684    
3685            /**
3686             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
3687             *
3688             * <p>
3689             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3690             * </p>
3691             *
3692             * @param groupId the group ID
3693             * @param start the lower bound of the range of journal articles
3694             * @param end the upper bound of the range of journal articles (not inclusive)
3695             * @return the range of matching journal articles that the user has permission to view
3696             * @throws SystemException if a system exception occurred
3697             */
3698            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
3699                    int end) throws SystemException {
3700                    return filterFindByGroupId(groupId, start, end, null);
3701            }
3702    
3703            /**
3704             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
3705             *
3706             * <p>
3707             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3708             * </p>
3709             *
3710             * @param groupId the group ID
3711             * @param start the lower bound of the range of journal articles
3712             * @param end the upper bound of the range of journal articles (not inclusive)
3713             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3714             * @return the ordered range of matching journal articles that the user has permission to view
3715             * @throws SystemException if a system exception occurred
3716             */
3717            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
3718                    int end, OrderByComparator orderByComparator) throws SystemException {
3719                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3720                            return findByGroupId(groupId, start, end, orderByComparator);
3721                    }
3722    
3723                    StringBundler query = null;
3724    
3725                    if (orderByComparator != null) {
3726                            query = new StringBundler(3 +
3727                                            (orderByComparator.getOrderByFields().length * 3));
3728                    }
3729                    else {
3730                            query = new StringBundler(3);
3731                    }
3732    
3733                    if (getDB().isSupportsInlineDistinct()) {
3734                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
3735                    }
3736                    else {
3737                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
3738                    }
3739    
3740                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3741    
3742                    if (!getDB().isSupportsInlineDistinct()) {
3743                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
3744                    }
3745    
3746                    if (orderByComparator != null) {
3747                            if (getDB().isSupportsInlineDistinct()) {
3748                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3749                                            orderByComparator);
3750                            }
3751                            else {
3752                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3753                                            orderByComparator);
3754                            }
3755                    }
3756    
3757                    else {
3758                            if (getDB().isSupportsInlineDistinct()) {
3759                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3760                            }
3761                            else {
3762                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
3763                            }
3764                    }
3765    
3766                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3767                                    JournalArticle.class.getName(),
3768                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3769    
3770                    Session session = null;
3771    
3772                    try {
3773                            session = openSession();
3774    
3775                            SQLQuery q = session.createSQLQuery(sql);
3776    
3777                            if (getDB().isSupportsInlineDistinct()) {
3778                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
3779                            }
3780                            else {
3781                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
3782                            }
3783    
3784                            QueryPos qPos = QueryPos.getInstance(q);
3785    
3786                            qPos.add(groupId);
3787    
3788                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
3789                                    end);
3790                    }
3791                    catch (Exception e) {
3792                            throw processException(e);
3793                    }
3794                    finally {
3795                            closeSession(session);
3796                    }
3797            }
3798    
3799            /**
3800             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63;.
3801             *
3802             * @param id the primary key of the current journal article
3803             * @param groupId the group ID
3804             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3805             * @return the previous, current, and next journal article
3806             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3807             * @throws SystemException if a system exception occurred
3808             */
3809            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
3810                    long groupId, OrderByComparator orderByComparator)
3811                    throws NoSuchArticleException, SystemException {
3812                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3813                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
3814                    }
3815    
3816                    JournalArticle journalArticle = findByPrimaryKey(id);
3817    
3818                    Session session = null;
3819    
3820                    try {
3821                            session = openSession();
3822    
3823                            JournalArticle[] array = new JournalArticleImpl[3];
3824    
3825                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
3826                                            groupId, orderByComparator, true);
3827    
3828                            array[1] = journalArticle;
3829    
3830                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
3831                                            groupId, orderByComparator, false);
3832    
3833                            return array;
3834                    }
3835                    catch (Exception e) {
3836                            throw processException(e);
3837                    }
3838                    finally {
3839                            closeSession(session);
3840                    }
3841            }
3842    
3843            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
3844                    JournalArticle journalArticle, long groupId,
3845                    OrderByComparator orderByComparator, boolean previous) {
3846                    StringBundler query = null;
3847    
3848                    if (orderByComparator != null) {
3849                            query = new StringBundler(6 +
3850                                            (orderByComparator.getOrderByFields().length * 6));
3851                    }
3852                    else {
3853                            query = new StringBundler(3);
3854                    }
3855    
3856                    if (getDB().isSupportsInlineDistinct()) {
3857                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
3858                    }
3859                    else {
3860                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
3861                    }
3862    
3863                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3864    
3865                    if (!getDB().isSupportsInlineDistinct()) {
3866                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
3867                    }
3868    
3869                    if (orderByComparator != null) {
3870                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3871    
3872                            if (orderByConditionFields.length > 0) {
3873                                    query.append(WHERE_AND);
3874                            }
3875    
3876                            for (int i = 0; i < orderByConditionFields.length; i++) {
3877                                    if (getDB().isSupportsInlineDistinct()) {
3878                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3879                                    }
3880                                    else {
3881                                            query.append(_ORDER_BY_ENTITY_TABLE);
3882                                    }
3883    
3884                                    query.append(orderByConditionFields[i]);
3885    
3886                                    if ((i + 1) < orderByConditionFields.length) {
3887                                            if (orderByComparator.isAscending() ^ previous) {
3888                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3889                                            }
3890                                            else {
3891                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3892                                            }
3893                                    }
3894                                    else {
3895                                            if (orderByComparator.isAscending() ^ previous) {
3896                                                    query.append(WHERE_GREATER_THAN);
3897                                            }
3898                                            else {
3899                                                    query.append(WHERE_LESSER_THAN);
3900                                            }
3901                                    }
3902                            }
3903    
3904                            query.append(ORDER_BY_CLAUSE);
3905    
3906                            String[] orderByFields = orderByComparator.getOrderByFields();
3907    
3908                            for (int i = 0; i < orderByFields.length; i++) {
3909                                    if (getDB().isSupportsInlineDistinct()) {
3910                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3911                                    }
3912                                    else {
3913                                            query.append(_ORDER_BY_ENTITY_TABLE);
3914                                    }
3915    
3916                                    query.append(orderByFields[i]);
3917    
3918                                    if ((i + 1) < orderByFields.length) {
3919                                            if (orderByComparator.isAscending() ^ previous) {
3920                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3921                                            }
3922                                            else {
3923                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3924                                            }
3925                                    }
3926                                    else {
3927                                            if (orderByComparator.isAscending() ^ previous) {
3928                                                    query.append(ORDER_BY_ASC);
3929                                            }
3930                                            else {
3931                                                    query.append(ORDER_BY_DESC);
3932                                            }
3933                                    }
3934                            }
3935                    }
3936    
3937                    else {
3938                            if (getDB().isSupportsInlineDistinct()) {
3939                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3940                            }
3941                            else {
3942                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
3943                            }
3944                    }
3945    
3946                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3947                                    JournalArticle.class.getName(),
3948                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3949    
3950                    SQLQuery q = session.createSQLQuery(sql);
3951    
3952                    q.setFirstResult(0);
3953                    q.setMaxResults(2);
3954    
3955                    if (getDB().isSupportsInlineDistinct()) {
3956                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
3957                    }
3958                    else {
3959                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
3960                    }
3961    
3962                    QueryPos qPos = QueryPos.getInstance(q);
3963    
3964                    qPos.add(groupId);
3965    
3966                    if (orderByComparator != null) {
3967                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3968    
3969                            for (Object value : values) {
3970                                    qPos.add(value);
3971                            }
3972                    }
3973    
3974                    List<JournalArticle> list = q.list();
3975    
3976                    if (list.size() == 2) {
3977                            return list.get(1);
3978                    }
3979                    else {
3980                            return null;
3981                    }
3982            }
3983    
3984            /**
3985             * Returns all the journal articles where companyId = &#63;.
3986             *
3987             * @param companyId the company ID
3988             * @return the matching journal articles
3989             * @throws SystemException if a system exception occurred
3990             */
3991            public List<JournalArticle> findByCompanyId(long companyId)
3992                    throws SystemException {
3993                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3994                            null);
3995            }
3996    
3997            /**
3998             * Returns a range of all the journal articles where companyId = &#63;.
3999             *
4000             * <p>
4001             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4002             * </p>
4003             *
4004             * @param companyId the company ID
4005             * @param start the lower bound of the range of journal articles
4006             * @param end the upper bound of the range of journal articles (not inclusive)
4007             * @return the range of matching journal articles
4008             * @throws SystemException if a system exception occurred
4009             */
4010            public List<JournalArticle> findByCompanyId(long companyId, int start,
4011                    int end) throws SystemException {
4012                    return findByCompanyId(companyId, start, end, null);
4013            }
4014    
4015            /**
4016             * Returns an ordered range of all the journal articles where companyId = &#63;.
4017             *
4018             * <p>
4019             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4020             * </p>
4021             *
4022             * @param companyId the company ID
4023             * @param start the lower bound of the range of journal articles
4024             * @param end the upper bound of the range of journal articles (not inclusive)
4025             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4026             * @return the ordered range of matching journal articles
4027             * @throws SystemException if a system exception occurred
4028             */
4029            public List<JournalArticle> findByCompanyId(long companyId, int start,
4030                    int end, OrderByComparator orderByComparator) throws SystemException {
4031                    FinderPath finderPath = null;
4032                    Object[] finderArgs = null;
4033    
4034                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4035                                    (orderByComparator == null)) {
4036                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
4037                            finderArgs = new Object[] { companyId };
4038                    }
4039                    else {
4040                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
4041                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
4042                    }
4043    
4044                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4045                                    finderArgs, this);
4046    
4047                    if ((list != null) && !list.isEmpty()) {
4048                            for (JournalArticle journalArticle : list) {
4049                                    if ((companyId != journalArticle.getCompanyId())) {
4050                                            list = null;
4051    
4052                                            break;
4053                                    }
4054                            }
4055                    }
4056    
4057                    if (list == null) {
4058                            StringBundler query = null;
4059    
4060                            if (orderByComparator != null) {
4061                                    query = new StringBundler(3 +
4062                                                    (orderByComparator.getOrderByFields().length * 3));
4063                            }
4064                            else {
4065                                    query = new StringBundler(3);
4066                            }
4067    
4068                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4069    
4070                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4071    
4072                            if (orderByComparator != null) {
4073                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4074                                            orderByComparator);
4075                            }
4076    
4077                            else {
4078                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4079                            }
4080    
4081                            String sql = query.toString();
4082    
4083                            Session session = null;
4084    
4085                            try {
4086                                    session = openSession();
4087    
4088                                    Query q = session.createQuery(sql);
4089    
4090                                    QueryPos qPos = QueryPos.getInstance(q);
4091    
4092                                    qPos.add(companyId);
4093    
4094                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4095                                                    start, end);
4096                            }
4097                            catch (Exception e) {
4098                                    throw processException(e);
4099                            }
4100                            finally {
4101                                    if (list == null) {
4102                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4103                                    }
4104                                    else {
4105                                            cacheResult(list);
4106    
4107                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4108                                    }
4109    
4110                                    closeSession(session);
4111                            }
4112                    }
4113    
4114                    return list;
4115            }
4116    
4117            /**
4118             * Returns the first journal article in the ordered set where companyId = &#63;.
4119             *
4120             * @param companyId the company ID
4121             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4122             * @return the first matching journal article
4123             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4124             * @throws SystemException if a system exception occurred
4125             */
4126            public JournalArticle findByCompanyId_First(long companyId,
4127                    OrderByComparator orderByComparator)
4128                    throws NoSuchArticleException, SystemException {
4129                    JournalArticle journalArticle = fetchByCompanyId_First(companyId,
4130                                    orderByComparator);
4131    
4132                    if (journalArticle != null) {
4133                            return journalArticle;
4134                    }
4135    
4136                    StringBundler msg = new StringBundler(4);
4137    
4138                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4139    
4140                    msg.append("companyId=");
4141                    msg.append(companyId);
4142    
4143                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4144    
4145                    throw new NoSuchArticleException(msg.toString());
4146            }
4147    
4148            /**
4149             * Returns the first journal article in the ordered set where companyId = &#63;.
4150             *
4151             * @param companyId the company ID
4152             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4153             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4154             * @throws SystemException if a system exception occurred
4155             */
4156            public JournalArticle fetchByCompanyId_First(long companyId,
4157                    OrderByComparator orderByComparator) throws SystemException {
4158                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
4159                                    orderByComparator);
4160    
4161                    if (!list.isEmpty()) {
4162                            return list.get(0);
4163                    }
4164    
4165                    return null;
4166            }
4167    
4168            /**
4169             * Returns the last journal article in the ordered set where companyId = &#63;.
4170             *
4171             * @param companyId the company ID
4172             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4173             * @return the last matching journal article
4174             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4175             * @throws SystemException if a system exception occurred
4176             */
4177            public JournalArticle findByCompanyId_Last(long companyId,
4178                    OrderByComparator orderByComparator)
4179                    throws NoSuchArticleException, SystemException {
4180                    JournalArticle journalArticle = fetchByCompanyId_Last(companyId,
4181                                    orderByComparator);
4182    
4183                    if (journalArticle != null) {
4184                            return journalArticle;
4185                    }
4186    
4187                    StringBundler msg = new StringBundler(4);
4188    
4189                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4190    
4191                    msg.append("companyId=");
4192                    msg.append(companyId);
4193    
4194                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4195    
4196                    throw new NoSuchArticleException(msg.toString());
4197            }
4198    
4199            /**
4200             * Returns the last journal article in the ordered set where companyId = &#63;.
4201             *
4202             * @param companyId the company ID
4203             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4204             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4205             * @throws SystemException if a system exception occurred
4206             */
4207            public JournalArticle fetchByCompanyId_Last(long companyId,
4208                    OrderByComparator orderByComparator) throws SystemException {
4209                    int count = countByCompanyId(companyId);
4210    
4211                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
4212                                    count, orderByComparator);
4213    
4214                    if (!list.isEmpty()) {
4215                            return list.get(0);
4216                    }
4217    
4218                    return null;
4219            }
4220    
4221            /**
4222             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
4223             *
4224             * @param id the primary key of the current journal article
4225             * @param companyId the company ID
4226             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4227             * @return the previous, current, and next journal article
4228             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4229             * @throws SystemException if a system exception occurred
4230             */
4231            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
4232                    long companyId, OrderByComparator orderByComparator)
4233                    throws NoSuchArticleException, SystemException {
4234                    JournalArticle journalArticle = findByPrimaryKey(id);
4235    
4236                    Session session = null;
4237    
4238                    try {
4239                            session = openSession();
4240    
4241                            JournalArticle[] array = new JournalArticleImpl[3];
4242    
4243                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
4244                                            companyId, orderByComparator, true);
4245    
4246                            array[1] = journalArticle;
4247    
4248                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
4249                                            companyId, orderByComparator, false);
4250    
4251                            return array;
4252                    }
4253                    catch (Exception e) {
4254                            throw processException(e);
4255                    }
4256                    finally {
4257                            closeSession(session);
4258                    }
4259            }
4260    
4261            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
4262                    JournalArticle journalArticle, long companyId,
4263                    OrderByComparator orderByComparator, boolean previous) {
4264                    StringBundler query = null;
4265    
4266                    if (orderByComparator != null) {
4267                            query = new StringBundler(6 +
4268                                            (orderByComparator.getOrderByFields().length * 6));
4269                    }
4270                    else {
4271                            query = new StringBundler(3);
4272                    }
4273    
4274                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4275    
4276                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4277    
4278                    if (orderByComparator != null) {
4279                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4280    
4281                            if (orderByConditionFields.length > 0) {
4282                                    query.append(WHERE_AND);
4283                            }
4284    
4285                            for (int i = 0; i < orderByConditionFields.length; i++) {
4286                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4287                                    query.append(orderByConditionFields[i]);
4288    
4289                                    if ((i + 1) < orderByConditionFields.length) {
4290                                            if (orderByComparator.isAscending() ^ previous) {
4291                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4292                                            }
4293                                            else {
4294                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4295                                            }
4296                                    }
4297                                    else {
4298                                            if (orderByComparator.isAscending() ^ previous) {
4299                                                    query.append(WHERE_GREATER_THAN);
4300                                            }
4301                                            else {
4302                                                    query.append(WHERE_LESSER_THAN);
4303                                            }
4304                                    }
4305                            }
4306    
4307                            query.append(ORDER_BY_CLAUSE);
4308    
4309                            String[] orderByFields = orderByComparator.getOrderByFields();
4310    
4311                            for (int i = 0; i < orderByFields.length; i++) {
4312                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4313                                    query.append(orderByFields[i]);
4314    
4315                                    if ((i + 1) < orderByFields.length) {
4316                                            if (orderByComparator.isAscending() ^ previous) {
4317                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4318                                            }
4319                                            else {
4320                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4321                                            }
4322                                    }
4323                                    else {
4324                                            if (orderByComparator.isAscending() ^ previous) {
4325                                                    query.append(ORDER_BY_ASC);
4326                                            }
4327                                            else {
4328                                                    query.append(ORDER_BY_DESC);
4329                                            }
4330                                    }
4331                            }
4332                    }
4333    
4334                    else {
4335                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4336                    }
4337    
4338                    String sql = query.toString();
4339    
4340                    Query q = session.createQuery(sql);
4341    
4342                    q.setFirstResult(0);
4343                    q.setMaxResults(2);
4344    
4345                    QueryPos qPos = QueryPos.getInstance(q);
4346    
4347                    qPos.add(companyId);
4348    
4349                    if (orderByComparator != null) {
4350                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4351    
4352                            for (Object value : values) {
4353                                    qPos.add(value);
4354                            }
4355                    }
4356    
4357                    List<JournalArticle> list = q.list();
4358    
4359                    if (list.size() == 2) {
4360                            return list.get(1);
4361                    }
4362                    else {
4363                            return null;
4364                    }
4365            }
4366    
4367            /**
4368             * Returns all the journal articles where structureId = &#63;.
4369             *
4370             * @param structureId the structure ID
4371             * @return the matching journal articles
4372             * @throws SystemException if a system exception occurred
4373             */
4374            public List<JournalArticle> findByStructureId(String structureId)
4375                    throws SystemException {
4376                    return findByStructureId(structureId, QueryUtil.ALL_POS,
4377                            QueryUtil.ALL_POS, null);
4378            }
4379    
4380            /**
4381             * Returns a range of all the journal articles where structureId = &#63;.
4382             *
4383             * <p>
4384             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4385             * </p>
4386             *
4387             * @param structureId the structure ID
4388             * @param start the lower bound of the range of journal articles
4389             * @param end the upper bound of the range of journal articles (not inclusive)
4390             * @return the range of matching journal articles
4391             * @throws SystemException if a system exception occurred
4392             */
4393            public List<JournalArticle> findByStructureId(String structureId,
4394                    int start, int end) throws SystemException {
4395                    return findByStructureId(structureId, start, end, null);
4396            }
4397    
4398            /**
4399             * Returns an ordered range of all the journal articles where structureId = &#63;.
4400             *
4401             * <p>
4402             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4403             * </p>
4404             *
4405             * @param structureId the structure ID
4406             * @param start the lower bound of the range of journal articles
4407             * @param end the upper bound of the range of journal articles (not inclusive)
4408             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4409             * @return the ordered range of matching journal articles
4410             * @throws SystemException if a system exception occurred
4411             */
4412            public List<JournalArticle> findByStructureId(String structureId,
4413                    int start, int end, OrderByComparator orderByComparator)
4414                    throws SystemException {
4415                    FinderPath finderPath = null;
4416                    Object[] finderArgs = null;
4417    
4418                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4419                                    (orderByComparator == null)) {
4420                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
4421                            finderArgs = new Object[] { structureId };
4422                    }
4423                    else {
4424                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
4425                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
4426                    }
4427    
4428                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4429                                    finderArgs, this);
4430    
4431                    if ((list != null) && !list.isEmpty()) {
4432                            for (JournalArticle journalArticle : list) {
4433                                    if (!Validator.equals(structureId,
4434                                                            journalArticle.getStructureId())) {
4435                                            list = null;
4436    
4437                                            break;
4438                                    }
4439                            }
4440                    }
4441    
4442                    if (list == null) {
4443                            StringBundler query = null;
4444    
4445                            if (orderByComparator != null) {
4446                                    query = new StringBundler(3 +
4447                                                    (orderByComparator.getOrderByFields().length * 3));
4448                            }
4449                            else {
4450                                    query = new StringBundler(3);
4451                            }
4452    
4453                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4454    
4455                            if (structureId == null) {
4456                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
4457                            }
4458                            else {
4459                                    if (structureId.equals(StringPool.BLANK)) {
4460                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
4461                                    }
4462                                    else {
4463                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
4464                                    }
4465                            }
4466    
4467                            if (orderByComparator != null) {
4468                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4469                                            orderByComparator);
4470                            }
4471    
4472                            else {
4473                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4474                            }
4475    
4476                            String sql = query.toString();
4477    
4478                            Session session = null;
4479    
4480                            try {
4481                                    session = openSession();
4482    
4483                                    Query q = session.createQuery(sql);
4484    
4485                                    QueryPos qPos = QueryPos.getInstance(q);
4486    
4487                                    if (structureId != null) {
4488                                            qPos.add(structureId);
4489                                    }
4490    
4491                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4492                                                    start, end);
4493                            }
4494                            catch (Exception e) {
4495                                    throw processException(e);
4496                            }
4497                            finally {
4498                                    if (list == null) {
4499                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4500                                    }
4501                                    else {
4502                                            cacheResult(list);
4503    
4504                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4505                                    }
4506    
4507                                    closeSession(session);
4508                            }
4509                    }
4510    
4511                    return list;
4512            }
4513    
4514            /**
4515             * Returns the first journal article in the ordered set where structureId = &#63;.
4516             *
4517             * @param structureId the structure ID
4518             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4519             * @return the first matching journal article
4520             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4521             * @throws SystemException if a system exception occurred
4522             */
4523            public JournalArticle findByStructureId_First(String structureId,
4524                    OrderByComparator orderByComparator)
4525                    throws NoSuchArticleException, SystemException {
4526                    JournalArticle journalArticle = fetchByStructureId_First(structureId,
4527                                    orderByComparator);
4528    
4529                    if (journalArticle != null) {
4530                            return journalArticle;
4531                    }
4532    
4533                    StringBundler msg = new StringBundler(4);
4534    
4535                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4536    
4537                    msg.append("structureId=");
4538                    msg.append(structureId);
4539    
4540                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4541    
4542                    throw new NoSuchArticleException(msg.toString());
4543            }
4544    
4545            /**
4546             * Returns the first journal article in the ordered set where structureId = &#63;.
4547             *
4548             * @param structureId the structure ID
4549             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4550             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4551             * @throws SystemException if a system exception occurred
4552             */
4553            public JournalArticle fetchByStructureId_First(String structureId,
4554                    OrderByComparator orderByComparator) throws SystemException {
4555                    List<JournalArticle> list = findByStructureId(structureId, 0, 1,
4556                                    orderByComparator);
4557    
4558                    if (!list.isEmpty()) {
4559                            return list.get(0);
4560                    }
4561    
4562                    return null;
4563            }
4564    
4565            /**
4566             * Returns the last journal article in the ordered set where structureId = &#63;.
4567             *
4568             * @param structureId the structure ID
4569             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4570             * @return the last matching journal article
4571             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4572             * @throws SystemException if a system exception occurred
4573             */
4574            public JournalArticle findByStructureId_Last(String structureId,
4575                    OrderByComparator orderByComparator)
4576                    throws NoSuchArticleException, SystemException {
4577                    JournalArticle journalArticle = fetchByStructureId_Last(structureId,
4578                                    orderByComparator);
4579    
4580                    if (journalArticle != null) {
4581                            return journalArticle;
4582                    }
4583    
4584                    StringBundler msg = new StringBundler(4);
4585    
4586                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4587    
4588                    msg.append("structureId=");
4589                    msg.append(structureId);
4590    
4591                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4592    
4593                    throw new NoSuchArticleException(msg.toString());
4594            }
4595    
4596            /**
4597             * Returns the last journal article in the ordered set where structureId = &#63;.
4598             *
4599             * @param structureId the structure ID
4600             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4601             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4602             * @throws SystemException if a system exception occurred
4603             */
4604            public JournalArticle fetchByStructureId_Last(String structureId,
4605                    OrderByComparator orderByComparator) throws SystemException {
4606                    int count = countByStructureId(structureId);
4607    
4608                    List<JournalArticle> list = findByStructureId(structureId, count - 1,
4609                                    count, orderByComparator);
4610    
4611                    if (!list.isEmpty()) {
4612                            return list.get(0);
4613                    }
4614    
4615                    return null;
4616            }
4617    
4618            /**
4619             * Returns the journal articles before and after the current journal article in the ordered set where structureId = &#63;.
4620             *
4621             * @param id the primary key of the current journal article
4622             * @param structureId the structure ID
4623             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4624             * @return the previous, current, and next journal article
4625             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4626             * @throws SystemException if a system exception occurred
4627             */
4628            public JournalArticle[] findByStructureId_PrevAndNext(long id,
4629                    String structureId, OrderByComparator orderByComparator)
4630                    throws NoSuchArticleException, SystemException {
4631                    JournalArticle journalArticle = findByPrimaryKey(id);
4632    
4633                    Session session = null;
4634    
4635                    try {
4636                            session = openSession();
4637    
4638                            JournalArticle[] array = new JournalArticleImpl[3];
4639    
4640                            array[0] = getByStructureId_PrevAndNext(session, journalArticle,
4641                                            structureId, orderByComparator, true);
4642    
4643                            array[1] = journalArticle;
4644    
4645                            array[2] = getByStructureId_PrevAndNext(session, journalArticle,
4646                                            structureId, orderByComparator, false);
4647    
4648                            return array;
4649                    }
4650                    catch (Exception e) {
4651                            throw processException(e);
4652                    }
4653                    finally {
4654                            closeSession(session);
4655                    }
4656            }
4657    
4658            protected JournalArticle getByStructureId_PrevAndNext(Session session,
4659                    JournalArticle journalArticle, String structureId,
4660                    OrderByComparator orderByComparator, boolean previous) {
4661                    StringBundler query = null;
4662    
4663                    if (orderByComparator != null) {
4664                            query = new StringBundler(6 +
4665                                            (orderByComparator.getOrderByFields().length * 6));
4666                    }
4667                    else {
4668                            query = new StringBundler(3);
4669                    }
4670    
4671                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4672    
4673                    if (structureId == null) {
4674                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
4675                    }
4676                    else {
4677                            if (structureId.equals(StringPool.BLANK)) {
4678                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
4679                            }
4680                            else {
4681                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
4682                            }
4683                    }
4684    
4685                    if (orderByComparator != null) {
4686                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4687    
4688                            if (orderByConditionFields.length > 0) {
4689                                    query.append(WHERE_AND);
4690                            }
4691    
4692                            for (int i = 0; i < orderByConditionFields.length; i++) {
4693                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4694                                    query.append(orderByConditionFields[i]);
4695    
4696                                    if ((i + 1) < orderByConditionFields.length) {
4697                                            if (orderByComparator.isAscending() ^ previous) {
4698                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4699                                            }
4700                                            else {
4701                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4702                                            }
4703                                    }
4704                                    else {
4705                                            if (orderByComparator.isAscending() ^ previous) {
4706                                                    query.append(WHERE_GREATER_THAN);
4707                                            }
4708                                            else {
4709                                                    query.append(WHERE_LESSER_THAN);
4710                                            }
4711                                    }
4712                            }
4713    
4714                            query.append(ORDER_BY_CLAUSE);
4715    
4716                            String[] orderByFields = orderByComparator.getOrderByFields();
4717    
4718                            for (int i = 0; i < orderByFields.length; i++) {
4719                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4720                                    query.append(orderByFields[i]);
4721    
4722                                    if ((i + 1) < orderByFields.length) {
4723                                            if (orderByComparator.isAscending() ^ previous) {
4724                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4725                                            }
4726                                            else {
4727                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4728                                            }
4729                                    }
4730                                    else {
4731                                            if (orderByComparator.isAscending() ^ previous) {
4732                                                    query.append(ORDER_BY_ASC);
4733                                            }
4734                                            else {
4735                                                    query.append(ORDER_BY_DESC);
4736                                            }
4737                                    }
4738                            }
4739                    }
4740    
4741                    else {
4742                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4743                    }
4744    
4745                    String sql = query.toString();
4746    
4747                    Query q = session.createQuery(sql);
4748    
4749                    q.setFirstResult(0);
4750                    q.setMaxResults(2);
4751    
4752                    QueryPos qPos = QueryPos.getInstance(q);
4753    
4754                    if (structureId != null) {
4755                            qPos.add(structureId);
4756                    }
4757    
4758                    if (orderByComparator != null) {
4759                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4760    
4761                            for (Object value : values) {
4762                                    qPos.add(value);
4763                            }
4764                    }
4765    
4766                    List<JournalArticle> list = q.list();
4767    
4768                    if (list.size() == 2) {
4769                            return list.get(1);
4770                    }
4771                    else {
4772                            return null;
4773                    }
4774            }
4775    
4776            /**
4777             * Returns all the journal articles where templateId = &#63;.
4778             *
4779             * @param templateId the template ID
4780             * @return the matching journal articles
4781             * @throws SystemException if a system exception occurred
4782             */
4783            public List<JournalArticle> findByTemplateId(String templateId)
4784                    throws SystemException {
4785                    return findByTemplateId(templateId, QueryUtil.ALL_POS,
4786                            QueryUtil.ALL_POS, null);
4787            }
4788    
4789            /**
4790             * Returns a range of all the journal articles where templateId = &#63;.
4791             *
4792             * <p>
4793             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4794             * </p>
4795             *
4796             * @param templateId the template ID
4797             * @param start the lower bound of the range of journal articles
4798             * @param end the upper bound of the range of journal articles (not inclusive)
4799             * @return the range of matching journal articles
4800             * @throws SystemException if a system exception occurred
4801             */
4802            public List<JournalArticle> findByTemplateId(String templateId, int start,
4803                    int end) throws SystemException {
4804                    return findByTemplateId(templateId, start, end, null);
4805            }
4806    
4807            /**
4808             * Returns an ordered range of all the journal articles where templateId = &#63;.
4809             *
4810             * <p>
4811             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4812             * </p>
4813             *
4814             * @param templateId the template ID
4815             * @param start the lower bound of the range of journal articles
4816             * @param end the upper bound of the range of journal articles (not inclusive)
4817             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4818             * @return the ordered range of matching journal articles
4819             * @throws SystemException if a system exception occurred
4820             */
4821            public List<JournalArticle> findByTemplateId(String templateId, int start,
4822                    int end, OrderByComparator orderByComparator) throws SystemException {
4823                    FinderPath finderPath = null;
4824                    Object[] finderArgs = null;
4825    
4826                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4827                                    (orderByComparator == null)) {
4828                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID;
4829                            finderArgs = new Object[] { templateId };
4830                    }
4831                    else {
4832                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID;
4833                            finderArgs = new Object[] { templateId, start, end, orderByComparator };
4834                    }
4835    
4836                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4837                                    finderArgs, this);
4838    
4839                    if ((list != null) && !list.isEmpty()) {
4840                            for (JournalArticle journalArticle : list) {
4841                                    if (!Validator.equals(templateId, journalArticle.getTemplateId())) {
4842                                            list = null;
4843    
4844                                            break;
4845                                    }
4846                            }
4847                    }
4848    
4849                    if (list == null) {
4850                            StringBundler query = null;
4851    
4852                            if (orderByComparator != null) {
4853                                    query = new StringBundler(3 +
4854                                                    (orderByComparator.getOrderByFields().length * 3));
4855                            }
4856                            else {
4857                                    query = new StringBundler(3);
4858                            }
4859    
4860                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4861    
4862                            if (templateId == null) {
4863                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4864                            }
4865                            else {
4866                                    if (templateId.equals(StringPool.BLANK)) {
4867                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4868                                    }
4869                                    else {
4870                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4871                                    }
4872                            }
4873    
4874                            if (orderByComparator != null) {
4875                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4876                                            orderByComparator);
4877                            }
4878    
4879                            else {
4880                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4881                            }
4882    
4883                            String sql = query.toString();
4884    
4885                            Session session = null;
4886    
4887                            try {
4888                                    session = openSession();
4889    
4890                                    Query q = session.createQuery(sql);
4891    
4892                                    QueryPos qPos = QueryPos.getInstance(q);
4893    
4894                                    if (templateId != null) {
4895                                            qPos.add(templateId);
4896                                    }
4897    
4898                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4899                                                    start, end);
4900                            }
4901                            catch (Exception e) {
4902                                    throw processException(e);
4903                            }
4904                            finally {
4905                                    if (list == null) {
4906                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4907                                    }
4908                                    else {
4909                                            cacheResult(list);
4910    
4911                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4912                                    }
4913    
4914                                    closeSession(session);
4915                            }
4916                    }
4917    
4918                    return list;
4919            }
4920    
4921            /**
4922             * Returns the first journal article in the ordered set where templateId = &#63;.
4923             *
4924             * @param templateId the template ID
4925             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4926             * @return the first matching journal article
4927             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4928             * @throws SystemException if a system exception occurred
4929             */
4930            public JournalArticle findByTemplateId_First(String templateId,
4931                    OrderByComparator orderByComparator)
4932                    throws NoSuchArticleException, SystemException {
4933                    JournalArticle journalArticle = fetchByTemplateId_First(templateId,
4934                                    orderByComparator);
4935    
4936                    if (journalArticle != null) {
4937                            return journalArticle;
4938                    }
4939    
4940                    StringBundler msg = new StringBundler(4);
4941    
4942                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4943    
4944                    msg.append("templateId=");
4945                    msg.append(templateId);
4946    
4947                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4948    
4949                    throw new NoSuchArticleException(msg.toString());
4950            }
4951    
4952            /**
4953             * Returns the first journal article in the ordered set where templateId = &#63;.
4954             *
4955             * @param templateId the template ID
4956             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4957             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4958             * @throws SystemException if a system exception occurred
4959             */
4960            public JournalArticle fetchByTemplateId_First(String templateId,
4961                    OrderByComparator orderByComparator) throws SystemException {
4962                    List<JournalArticle> list = findByTemplateId(templateId, 0, 1,
4963                                    orderByComparator);
4964    
4965                    if (!list.isEmpty()) {
4966                            return list.get(0);
4967                    }
4968    
4969                    return null;
4970            }
4971    
4972            /**
4973             * Returns the last journal article in the ordered set where templateId = &#63;.
4974             *
4975             * @param templateId the template ID
4976             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4977             * @return the last matching journal article
4978             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4979             * @throws SystemException if a system exception occurred
4980             */
4981            public JournalArticle findByTemplateId_Last(String templateId,
4982                    OrderByComparator orderByComparator)
4983                    throws NoSuchArticleException, SystemException {
4984                    JournalArticle journalArticle = fetchByTemplateId_Last(templateId,
4985                                    orderByComparator);
4986    
4987                    if (journalArticle != null) {
4988                            return journalArticle;
4989                    }
4990    
4991                    StringBundler msg = new StringBundler(4);
4992    
4993                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4994    
4995                    msg.append("templateId=");
4996                    msg.append(templateId);
4997    
4998                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4999    
5000                    throw new NoSuchArticleException(msg.toString());
5001            }
5002    
5003            /**
5004             * Returns the last journal article in the ordered set where templateId = &#63;.
5005             *
5006             * @param templateId the template ID
5007             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5008             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5009             * @throws SystemException if a system exception occurred
5010             */
5011            public JournalArticle fetchByTemplateId_Last(String templateId,
5012                    OrderByComparator orderByComparator) throws SystemException {
5013                    int count = countByTemplateId(templateId);
5014    
5015                    List<JournalArticle> list = findByTemplateId(templateId, count - 1,
5016                                    count, orderByComparator);
5017    
5018                    if (!list.isEmpty()) {
5019                            return list.get(0);
5020                    }
5021    
5022                    return null;
5023            }
5024    
5025            /**
5026             * Returns the journal articles before and after the current journal article in the ordered set where templateId = &#63;.
5027             *
5028             * @param id the primary key of the current journal article
5029             * @param templateId the template ID
5030             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5031             * @return the previous, current, and next journal article
5032             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5033             * @throws SystemException if a system exception occurred
5034             */
5035            public JournalArticle[] findByTemplateId_PrevAndNext(long id,
5036                    String templateId, OrderByComparator orderByComparator)
5037                    throws NoSuchArticleException, SystemException {
5038                    JournalArticle journalArticle = findByPrimaryKey(id);
5039    
5040                    Session session = null;
5041    
5042                    try {
5043                            session = openSession();
5044    
5045                            JournalArticle[] array = new JournalArticleImpl[3];
5046    
5047                            array[0] = getByTemplateId_PrevAndNext(session, journalArticle,
5048                                            templateId, orderByComparator, true);
5049    
5050                            array[1] = journalArticle;
5051    
5052                            array[2] = getByTemplateId_PrevAndNext(session, journalArticle,
5053                                            templateId, orderByComparator, false);
5054    
5055                            return array;
5056                    }
5057                    catch (Exception e) {
5058                            throw processException(e);
5059                    }
5060                    finally {
5061                            closeSession(session);
5062                    }
5063            }
5064    
5065            protected JournalArticle getByTemplateId_PrevAndNext(Session session,
5066                    JournalArticle journalArticle, String templateId,
5067                    OrderByComparator orderByComparator, boolean previous) {
5068                    StringBundler query = null;
5069    
5070                    if (orderByComparator != null) {
5071                            query = new StringBundler(6 +
5072                                            (orderByComparator.getOrderByFields().length * 6));
5073                    }
5074                    else {
5075                            query = new StringBundler(3);
5076                    }
5077    
5078                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5079    
5080                    if (templateId == null) {
5081                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
5082                    }
5083                    else {
5084                            if (templateId.equals(StringPool.BLANK)) {
5085                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
5086                            }
5087                            else {
5088                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
5089                            }
5090                    }
5091    
5092                    if (orderByComparator != null) {
5093                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5094    
5095                            if (orderByConditionFields.length > 0) {
5096                                    query.append(WHERE_AND);
5097                            }
5098    
5099                            for (int i = 0; i < orderByConditionFields.length; i++) {
5100                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5101                                    query.append(orderByConditionFields[i]);
5102    
5103                                    if ((i + 1) < orderByConditionFields.length) {
5104                                            if (orderByComparator.isAscending() ^ previous) {
5105                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5106                                            }
5107                                            else {
5108                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5109                                            }
5110                                    }
5111                                    else {
5112                                            if (orderByComparator.isAscending() ^ previous) {
5113                                                    query.append(WHERE_GREATER_THAN);
5114                                            }
5115                                            else {
5116                                                    query.append(WHERE_LESSER_THAN);
5117                                            }
5118                                    }
5119                            }
5120    
5121                            query.append(ORDER_BY_CLAUSE);
5122    
5123                            String[] orderByFields = orderByComparator.getOrderByFields();
5124    
5125                            for (int i = 0; i < orderByFields.length; i++) {
5126                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5127                                    query.append(orderByFields[i]);
5128    
5129                                    if ((i + 1) < orderByFields.length) {
5130                                            if (orderByComparator.isAscending() ^ previous) {
5131                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5132                                            }
5133                                            else {
5134                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5135                                            }
5136                                    }
5137                                    else {
5138                                            if (orderByComparator.isAscending() ^ previous) {
5139                                                    query.append(ORDER_BY_ASC);
5140                                            }
5141                                            else {
5142                                                    query.append(ORDER_BY_DESC);
5143                                            }
5144                                    }
5145                            }
5146                    }
5147    
5148                    else {
5149                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5150                    }
5151    
5152                    String sql = query.toString();
5153    
5154                    Query q = session.createQuery(sql);
5155    
5156                    q.setFirstResult(0);
5157                    q.setMaxResults(2);
5158    
5159                    QueryPos qPos = QueryPos.getInstance(q);
5160    
5161                    if (templateId != null) {
5162                            qPos.add(templateId);
5163                    }
5164    
5165                    if (orderByComparator != null) {
5166                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5167    
5168                            for (Object value : values) {
5169                                    qPos.add(value);
5170                            }
5171                    }
5172    
5173                    List<JournalArticle> list = q.list();
5174    
5175                    if (list.size() == 2) {
5176                            return list.get(1);
5177                    }
5178                    else {
5179                            return null;
5180                    }
5181            }
5182    
5183            /**
5184             * Returns all the journal articles where layoutUuid = &#63;.
5185             *
5186             * @param layoutUuid the layout uuid
5187             * @return the matching journal articles
5188             * @throws SystemException if a system exception occurred
5189             */
5190            public List<JournalArticle> findByLayoutUuid(String layoutUuid)
5191                    throws SystemException {
5192                    return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
5193                            QueryUtil.ALL_POS, null);
5194            }
5195    
5196            /**
5197             * Returns a range of all the journal articles where layoutUuid = &#63;.
5198             *
5199             * <p>
5200             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5201             * </p>
5202             *
5203             * @param layoutUuid the layout uuid
5204             * @param start the lower bound of the range of journal articles
5205             * @param end the upper bound of the range of journal articles (not inclusive)
5206             * @return the range of matching journal articles
5207             * @throws SystemException if a system exception occurred
5208             */
5209            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
5210                    int end) throws SystemException {
5211                    return findByLayoutUuid(layoutUuid, start, end, null);
5212            }
5213    
5214            /**
5215             * Returns an ordered range of all the journal articles where layoutUuid = &#63;.
5216             *
5217             * <p>
5218             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5219             * </p>
5220             *
5221             * @param layoutUuid the layout uuid
5222             * @param start the lower bound of the range of journal articles
5223             * @param end the upper bound of the range of journal articles (not inclusive)
5224             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5225             * @return the ordered range of matching journal articles
5226             * @throws SystemException if a system exception occurred
5227             */
5228            public List<JournalArticle> findByLayoutUuid(String layoutUuid, int start,
5229                    int end, OrderByComparator orderByComparator) throws SystemException {
5230                    FinderPath finderPath = null;
5231                    Object[] finderArgs = null;
5232    
5233                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5234                                    (orderByComparator == null)) {
5235                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
5236                            finderArgs = new Object[] { layoutUuid };
5237                    }
5238                    else {
5239                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
5240                            finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
5241                    }
5242    
5243                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5244                                    finderArgs, this);
5245    
5246                    if ((list != null) && !list.isEmpty()) {
5247                            for (JournalArticle journalArticle : list) {
5248                                    if (!Validator.equals(layoutUuid, journalArticle.getLayoutUuid())) {
5249                                            list = null;
5250    
5251                                            break;
5252                                    }
5253                            }
5254                    }
5255    
5256                    if (list == null) {
5257                            StringBundler query = null;
5258    
5259                            if (orderByComparator != null) {
5260                                    query = new StringBundler(3 +
5261                                                    (orderByComparator.getOrderByFields().length * 3));
5262                            }
5263                            else {
5264                                    query = new StringBundler(3);
5265                            }
5266    
5267                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5268    
5269                            if (layoutUuid == null) {
5270                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5271                            }
5272                            else {
5273                                    if (layoutUuid.equals(StringPool.BLANK)) {
5274                                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5275                                    }
5276                                    else {
5277                                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5278                                    }
5279                            }
5280    
5281                            if (orderByComparator != null) {
5282                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5283                                            orderByComparator);
5284                            }
5285    
5286                            else {
5287                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5288                            }
5289    
5290                            String sql = query.toString();
5291    
5292                            Session session = null;
5293    
5294                            try {
5295                                    session = openSession();
5296    
5297                                    Query q = session.createQuery(sql);
5298    
5299                                    QueryPos qPos = QueryPos.getInstance(q);
5300    
5301                                    if (layoutUuid != null) {
5302                                            qPos.add(layoutUuid);
5303                                    }
5304    
5305                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5306                                                    start, end);
5307                            }
5308                            catch (Exception e) {
5309                                    throw processException(e);
5310                            }
5311                            finally {
5312                                    if (list == null) {
5313                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5314                                    }
5315                                    else {
5316                                            cacheResult(list);
5317    
5318                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5319                                    }
5320    
5321                                    closeSession(session);
5322                            }
5323                    }
5324    
5325                    return list;
5326            }
5327    
5328            /**
5329             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
5330             *
5331             * @param layoutUuid the layout uuid
5332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5333             * @return the first matching journal article
5334             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5335             * @throws SystemException if a system exception occurred
5336             */
5337            public JournalArticle findByLayoutUuid_First(String layoutUuid,
5338                    OrderByComparator orderByComparator)
5339                    throws NoSuchArticleException, SystemException {
5340                    JournalArticle journalArticle = fetchByLayoutUuid_First(layoutUuid,
5341                                    orderByComparator);
5342    
5343                    if (journalArticle != null) {
5344                            return journalArticle;
5345                    }
5346    
5347                    StringBundler msg = new StringBundler(4);
5348    
5349                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5350    
5351                    msg.append("layoutUuid=");
5352                    msg.append(layoutUuid);
5353    
5354                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5355    
5356                    throw new NoSuchArticleException(msg.toString());
5357            }
5358    
5359            /**
5360             * Returns the first journal article in the ordered set where layoutUuid = &#63;.
5361             *
5362             * @param layoutUuid the layout uuid
5363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5364             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5365             * @throws SystemException if a system exception occurred
5366             */
5367            public JournalArticle fetchByLayoutUuid_First(String layoutUuid,
5368                    OrderByComparator orderByComparator) throws SystemException {
5369                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, 0, 1,
5370                                    orderByComparator);
5371    
5372                    if (!list.isEmpty()) {
5373                            return list.get(0);
5374                    }
5375    
5376                    return null;
5377            }
5378    
5379            /**
5380             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
5381             *
5382             * @param layoutUuid the layout uuid
5383             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5384             * @return the last matching journal article
5385             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5386             * @throws SystemException if a system exception occurred
5387             */
5388            public JournalArticle findByLayoutUuid_Last(String layoutUuid,
5389                    OrderByComparator orderByComparator)
5390                    throws NoSuchArticleException, SystemException {
5391                    JournalArticle journalArticle = fetchByLayoutUuid_Last(layoutUuid,
5392                                    orderByComparator);
5393    
5394                    if (journalArticle != null) {
5395                            return journalArticle;
5396                    }
5397    
5398                    StringBundler msg = new StringBundler(4);
5399    
5400                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5401    
5402                    msg.append("layoutUuid=");
5403                    msg.append(layoutUuid);
5404    
5405                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5406    
5407                    throw new NoSuchArticleException(msg.toString());
5408            }
5409    
5410            /**
5411             * Returns the last journal article in the ordered set where layoutUuid = &#63;.
5412             *
5413             * @param layoutUuid the layout uuid
5414             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5415             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5416             * @throws SystemException if a system exception occurred
5417             */
5418            public JournalArticle fetchByLayoutUuid_Last(String layoutUuid,
5419                    OrderByComparator orderByComparator) throws SystemException {
5420                    int count = countByLayoutUuid(layoutUuid);
5421    
5422                    List<JournalArticle> list = findByLayoutUuid(layoutUuid, count - 1,
5423                                    count, orderByComparator);
5424    
5425                    if (!list.isEmpty()) {
5426                            return list.get(0);
5427                    }
5428    
5429                    return null;
5430            }
5431    
5432            /**
5433             * Returns the journal articles before and after the current journal article in the ordered set where layoutUuid = &#63;.
5434             *
5435             * @param id the primary key of the current journal article
5436             * @param layoutUuid the layout uuid
5437             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5438             * @return the previous, current, and next journal article
5439             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5440             * @throws SystemException if a system exception occurred
5441             */
5442            public JournalArticle[] findByLayoutUuid_PrevAndNext(long id,
5443                    String layoutUuid, OrderByComparator orderByComparator)
5444                    throws NoSuchArticleException, SystemException {
5445                    JournalArticle journalArticle = findByPrimaryKey(id);
5446    
5447                    Session session = null;
5448    
5449                    try {
5450                            session = openSession();
5451    
5452                            JournalArticle[] array = new JournalArticleImpl[3];
5453    
5454                            array[0] = getByLayoutUuid_PrevAndNext(session, journalArticle,
5455                                            layoutUuid, orderByComparator, true);
5456    
5457                            array[1] = journalArticle;
5458    
5459                            array[2] = getByLayoutUuid_PrevAndNext(session, journalArticle,
5460                                            layoutUuid, orderByComparator, false);
5461    
5462                            return array;
5463                    }
5464                    catch (Exception e) {
5465                            throw processException(e);
5466                    }
5467                    finally {
5468                            closeSession(session);
5469                    }
5470            }
5471    
5472            protected JournalArticle getByLayoutUuid_PrevAndNext(Session session,
5473                    JournalArticle journalArticle, String layoutUuid,
5474                    OrderByComparator orderByComparator, boolean previous) {
5475                    StringBundler query = null;
5476    
5477                    if (orderByComparator != null) {
5478                            query = new StringBundler(6 +
5479                                            (orderByComparator.getOrderByFields().length * 6));
5480                    }
5481                    else {
5482                            query = new StringBundler(3);
5483                    }
5484    
5485                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5486    
5487                    if (layoutUuid == null) {
5488                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
5489                    }
5490                    else {
5491                            if (layoutUuid.equals(StringPool.BLANK)) {
5492                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
5493                            }
5494                            else {
5495                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
5496                            }
5497                    }
5498    
5499                    if (orderByComparator != null) {
5500                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5501    
5502                            if (orderByConditionFields.length > 0) {
5503                                    query.append(WHERE_AND);
5504                            }
5505    
5506                            for (int i = 0; i < orderByConditionFields.length; i++) {
5507                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5508                                    query.append(orderByConditionFields[i]);
5509    
5510                                    if ((i + 1) < orderByConditionFields.length) {
5511                                            if (orderByComparator.isAscending() ^ previous) {
5512                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5513                                            }
5514                                            else {
5515                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5516                                            }
5517                                    }
5518                                    else {
5519                                            if (orderByComparator.isAscending() ^ previous) {
5520                                                    query.append(WHERE_GREATER_THAN);
5521                                            }
5522                                            else {
5523                                                    query.append(WHERE_LESSER_THAN);
5524                                            }
5525                                    }
5526                            }
5527    
5528                            query.append(ORDER_BY_CLAUSE);
5529    
5530                            String[] orderByFields = orderByComparator.getOrderByFields();
5531    
5532                            for (int i = 0; i < orderByFields.length; i++) {
5533                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5534                                    query.append(orderByFields[i]);
5535    
5536                                    if ((i + 1) < orderByFields.length) {
5537                                            if (orderByComparator.isAscending() ^ previous) {
5538                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5539                                            }
5540                                            else {
5541                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5542                                            }
5543                                    }
5544                                    else {
5545                                            if (orderByComparator.isAscending() ^ previous) {
5546                                                    query.append(ORDER_BY_ASC);
5547                                            }
5548                                            else {
5549                                                    query.append(ORDER_BY_DESC);
5550                                            }
5551                                    }
5552                            }
5553                    }
5554    
5555                    else {
5556                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5557                    }
5558    
5559                    String sql = query.toString();
5560    
5561                    Query q = session.createQuery(sql);
5562    
5563                    q.setFirstResult(0);
5564                    q.setMaxResults(2);
5565    
5566                    QueryPos qPos = QueryPos.getInstance(q);
5567    
5568                    if (layoutUuid != null) {
5569                            qPos.add(layoutUuid);
5570                    }
5571    
5572                    if (orderByComparator != null) {
5573                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5574    
5575                            for (Object value : values) {
5576                                    qPos.add(value);
5577                            }
5578                    }
5579    
5580                    List<JournalArticle> list = q.list();
5581    
5582                    if (list.size() == 2) {
5583                            return list.get(1);
5584                    }
5585                    else {
5586                            return null;
5587                    }
5588            }
5589    
5590            /**
5591             * Returns all the journal articles where smallImageId = &#63;.
5592             *
5593             * @param smallImageId the small image ID
5594             * @return the matching journal articles
5595             * @throws SystemException if a system exception occurred
5596             */
5597            public List<JournalArticle> findBySmallImageId(long smallImageId)
5598                    throws SystemException {
5599                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
5600                            QueryUtil.ALL_POS, null);
5601            }
5602    
5603            /**
5604             * Returns a range of all the journal articles where smallImageId = &#63;.
5605             *
5606             * <p>
5607             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5608             * </p>
5609             *
5610             * @param smallImageId the small image ID
5611             * @param start the lower bound of the range of journal articles
5612             * @param end the upper bound of the range of journal articles (not inclusive)
5613             * @return the range of matching journal articles
5614             * @throws SystemException if a system exception occurred
5615             */
5616            public List<JournalArticle> findBySmallImageId(long smallImageId,
5617                    int start, int end) throws SystemException {
5618                    return findBySmallImageId(smallImageId, start, end, null);
5619            }
5620    
5621            /**
5622             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
5623             *
5624             * <p>
5625             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5626             * </p>
5627             *
5628             * @param smallImageId the small image ID
5629             * @param start the lower bound of the range of journal articles
5630             * @param end the upper bound of the range of journal articles (not inclusive)
5631             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5632             * @return the ordered range of matching journal articles
5633             * @throws SystemException if a system exception occurred
5634             */
5635            public List<JournalArticle> findBySmallImageId(long smallImageId,
5636                    int start, int end, OrderByComparator orderByComparator)
5637                    throws SystemException {
5638                    FinderPath finderPath = null;
5639                    Object[] finderArgs = null;
5640    
5641                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5642                                    (orderByComparator == null)) {
5643                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
5644                            finderArgs = new Object[] { smallImageId };
5645                    }
5646                    else {
5647                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
5648                            finderArgs = new Object[] {
5649                                            smallImageId,
5650                                            
5651                                            start, end, orderByComparator
5652                                    };
5653                    }
5654    
5655                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5656                                    finderArgs, this);
5657    
5658                    if ((list != null) && !list.isEmpty()) {
5659                            for (JournalArticle journalArticle : list) {
5660                                    if ((smallImageId != journalArticle.getSmallImageId())) {
5661                                            list = null;
5662    
5663                                            break;
5664                                    }
5665                            }
5666                    }
5667    
5668                    if (list == null) {
5669                            StringBundler query = null;
5670    
5671                            if (orderByComparator != null) {
5672                                    query = new StringBundler(3 +
5673                                                    (orderByComparator.getOrderByFields().length * 3));
5674                            }
5675                            else {
5676                                    query = new StringBundler(3);
5677                            }
5678    
5679                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5680    
5681                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5682    
5683                            if (orderByComparator != null) {
5684                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5685                                            orderByComparator);
5686                            }
5687    
5688                            else {
5689                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5690                            }
5691    
5692                            String sql = query.toString();
5693    
5694                            Session session = null;
5695    
5696                            try {
5697                                    session = openSession();
5698    
5699                                    Query q = session.createQuery(sql);
5700    
5701                                    QueryPos qPos = QueryPos.getInstance(q);
5702    
5703                                    qPos.add(smallImageId);
5704    
5705                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5706                                                    start, end);
5707                            }
5708                            catch (Exception e) {
5709                                    throw processException(e);
5710                            }
5711                            finally {
5712                                    if (list == null) {
5713                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5714                                    }
5715                                    else {
5716                                            cacheResult(list);
5717    
5718                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5719                                    }
5720    
5721                                    closeSession(session);
5722                            }
5723                    }
5724    
5725                    return list;
5726            }
5727    
5728            /**
5729             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5730             *
5731             * @param smallImageId the small image ID
5732             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5733             * @return the first matching journal article
5734             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5735             * @throws SystemException if a system exception occurred
5736             */
5737            public JournalArticle findBySmallImageId_First(long smallImageId,
5738                    OrderByComparator orderByComparator)
5739                    throws NoSuchArticleException, SystemException {
5740                    JournalArticle journalArticle = fetchBySmallImageId_First(smallImageId,
5741                                    orderByComparator);
5742    
5743                    if (journalArticle != null) {
5744                            return journalArticle;
5745                    }
5746    
5747                    StringBundler msg = new StringBundler(4);
5748    
5749                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5750    
5751                    msg.append("smallImageId=");
5752                    msg.append(smallImageId);
5753    
5754                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5755    
5756                    throw new NoSuchArticleException(msg.toString());
5757            }
5758    
5759            /**
5760             * Returns the first journal article in the ordered set where smallImageId = &#63;.
5761             *
5762             * @param smallImageId the small image ID
5763             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5764             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5765             * @throws SystemException if a system exception occurred
5766             */
5767            public JournalArticle fetchBySmallImageId_First(long smallImageId,
5768                    OrderByComparator orderByComparator) throws SystemException {
5769                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
5770                                    orderByComparator);
5771    
5772                    if (!list.isEmpty()) {
5773                            return list.get(0);
5774                    }
5775    
5776                    return null;
5777            }
5778    
5779            /**
5780             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5781             *
5782             * @param smallImageId the small image ID
5783             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5784             * @return the last matching journal article
5785             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5786             * @throws SystemException if a system exception occurred
5787             */
5788            public JournalArticle findBySmallImageId_Last(long smallImageId,
5789                    OrderByComparator orderByComparator)
5790                    throws NoSuchArticleException, SystemException {
5791                    JournalArticle journalArticle = fetchBySmallImageId_Last(smallImageId,
5792                                    orderByComparator);
5793    
5794                    if (journalArticle != null) {
5795                            return journalArticle;
5796                    }
5797    
5798                    StringBundler msg = new StringBundler(4);
5799    
5800                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5801    
5802                    msg.append("smallImageId=");
5803                    msg.append(smallImageId);
5804    
5805                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5806    
5807                    throw new NoSuchArticleException(msg.toString());
5808            }
5809    
5810            /**
5811             * Returns the last journal article in the ordered set where smallImageId = &#63;.
5812             *
5813             * @param smallImageId the small image ID
5814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5815             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5816             * @throws SystemException if a system exception occurred
5817             */
5818            public JournalArticle fetchBySmallImageId_Last(long smallImageId,
5819                    OrderByComparator orderByComparator) throws SystemException {
5820                    int count = countBySmallImageId(smallImageId);
5821    
5822                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
5823                                    count, orderByComparator);
5824    
5825                    if (!list.isEmpty()) {
5826                            return list.get(0);
5827                    }
5828    
5829                    return null;
5830            }
5831    
5832            /**
5833             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
5834             *
5835             * @param id the primary key of the current journal article
5836             * @param smallImageId the small image ID
5837             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5838             * @return the previous, current, and next journal article
5839             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5840             * @throws SystemException if a system exception occurred
5841             */
5842            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
5843                    long smallImageId, OrderByComparator orderByComparator)
5844                    throws NoSuchArticleException, SystemException {
5845                    JournalArticle journalArticle = findByPrimaryKey(id);
5846    
5847                    Session session = null;
5848    
5849                    try {
5850                            session = openSession();
5851    
5852                            JournalArticle[] array = new JournalArticleImpl[3];
5853    
5854                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
5855                                            smallImageId, orderByComparator, true);
5856    
5857                            array[1] = journalArticle;
5858    
5859                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
5860                                            smallImageId, orderByComparator, false);
5861    
5862                            return array;
5863                    }
5864                    catch (Exception e) {
5865                            throw processException(e);
5866                    }
5867                    finally {
5868                            closeSession(session);
5869                    }
5870            }
5871    
5872            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
5873                    JournalArticle journalArticle, long smallImageId,
5874                    OrderByComparator orderByComparator, boolean previous) {
5875                    StringBundler query = null;
5876    
5877                    if (orderByComparator != null) {
5878                            query = new StringBundler(6 +
5879                                            (orderByComparator.getOrderByFields().length * 6));
5880                    }
5881                    else {
5882                            query = new StringBundler(3);
5883                    }
5884    
5885                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5886    
5887                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
5888    
5889                    if (orderByComparator != null) {
5890                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5891    
5892                            if (orderByConditionFields.length > 0) {
5893                                    query.append(WHERE_AND);
5894                            }
5895    
5896                            for (int i = 0; i < orderByConditionFields.length; i++) {
5897                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5898                                    query.append(orderByConditionFields[i]);
5899    
5900                                    if ((i + 1) < orderByConditionFields.length) {
5901                                            if (orderByComparator.isAscending() ^ previous) {
5902                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5903                                            }
5904                                            else {
5905                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5906                                            }
5907                                    }
5908                                    else {
5909                                            if (orderByComparator.isAscending() ^ previous) {
5910                                                    query.append(WHERE_GREATER_THAN);
5911                                            }
5912                                            else {
5913                                                    query.append(WHERE_LESSER_THAN);
5914                                            }
5915                                    }
5916                            }
5917    
5918                            query.append(ORDER_BY_CLAUSE);
5919    
5920                            String[] orderByFields = orderByComparator.getOrderByFields();
5921    
5922                            for (int i = 0; i < orderByFields.length; i++) {
5923                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5924                                    query.append(orderByFields[i]);
5925    
5926                                    if ((i + 1) < orderByFields.length) {
5927                                            if (orderByComparator.isAscending() ^ previous) {
5928                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5929                                            }
5930                                            else {
5931                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5932                                            }
5933                                    }
5934                                    else {
5935                                            if (orderByComparator.isAscending() ^ previous) {
5936                                                    query.append(ORDER_BY_ASC);
5937                                            }
5938                                            else {
5939                                                    query.append(ORDER_BY_DESC);
5940                                            }
5941                                    }
5942                            }
5943                    }
5944    
5945                    else {
5946                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5947                    }
5948    
5949                    String sql = query.toString();
5950    
5951                    Query q = session.createQuery(sql);
5952    
5953                    q.setFirstResult(0);
5954                    q.setMaxResults(2);
5955    
5956                    QueryPos qPos = QueryPos.getInstance(q);
5957    
5958                    qPos.add(smallImageId);
5959    
5960                    if (orderByComparator != null) {
5961                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5962    
5963                            for (Object value : values) {
5964                                    qPos.add(value);
5965                            }
5966                    }
5967    
5968                    List<JournalArticle> list = q.list();
5969    
5970                    if (list.size() == 2) {
5971                            return list.get(1);
5972                    }
5973                    else {
5974                            return null;
5975                    }
5976            }
5977    
5978            /**
5979             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5980             *
5981             * @param resourcePrimKey the resource prim key
5982             * @param status the status
5983             * @return the matching journal articles
5984             * @throws SystemException if a system exception occurred
5985             */
5986            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
5987                    throws SystemException {
5988                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
5989                            QueryUtil.ALL_POS, null);
5990            }
5991    
5992            /**
5993             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
5994             *
5995             * <p>
5996             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5997             * </p>
5998             *
5999             * @param resourcePrimKey the resource prim key
6000             * @param status the status
6001             * @param start the lower bound of the range of journal articles
6002             * @param end the upper bound of the range of journal articles (not inclusive)
6003             * @return the range of matching journal articles
6004             * @throws SystemException if a system exception occurred
6005             */
6006            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6007                    int start, int end) throws SystemException {
6008                    return findByR_ST(resourcePrimKey, status, start, end, null);
6009            }
6010    
6011            /**
6012             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
6013             *
6014             * <p>
6015             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6016             * </p>
6017             *
6018             * @param resourcePrimKey the resource prim key
6019             * @param status the status
6020             * @param start the lower bound of the range of journal articles
6021             * @param end the upper bound of the range of journal articles (not inclusive)
6022             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6023             * @return the ordered range of matching journal articles
6024             * @throws SystemException if a system exception occurred
6025             */
6026            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
6027                    int start, int end, OrderByComparator orderByComparator)
6028                    throws SystemException {
6029                    FinderPath finderPath = null;
6030                    Object[] finderArgs = null;
6031    
6032                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6033                                    (orderByComparator == null)) {
6034                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
6035                            finderArgs = new Object[] { resourcePrimKey, status };
6036                    }
6037                    else {
6038                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
6039                            finderArgs = new Object[] {
6040                                            resourcePrimKey, status,
6041                                            
6042                                            start, end, orderByComparator
6043                                    };
6044                    }
6045    
6046                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6047                                    finderArgs, this);
6048    
6049                    if ((list != null) && !list.isEmpty()) {
6050                            for (JournalArticle journalArticle : list) {
6051                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
6052                                                    (status != journalArticle.getStatus())) {
6053                                            list = null;
6054    
6055                                            break;
6056                                    }
6057                            }
6058                    }
6059    
6060                    if (list == null) {
6061                            StringBundler query = null;
6062    
6063                            if (orderByComparator != null) {
6064                                    query = new StringBundler(4 +
6065                                                    (orderByComparator.getOrderByFields().length * 3));
6066                            }
6067                            else {
6068                                    query = new StringBundler(4);
6069                            }
6070    
6071                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6072    
6073                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6074    
6075                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6076    
6077                            if (orderByComparator != null) {
6078                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6079                                            orderByComparator);
6080                            }
6081    
6082                            else {
6083                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6084                            }
6085    
6086                            String sql = query.toString();
6087    
6088                            Session session = null;
6089    
6090                            try {
6091                                    session = openSession();
6092    
6093                                    Query q = session.createQuery(sql);
6094    
6095                                    QueryPos qPos = QueryPos.getInstance(q);
6096    
6097                                    qPos.add(resourcePrimKey);
6098    
6099                                    qPos.add(status);
6100    
6101                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
6102                                                    start, end);
6103                            }
6104                            catch (Exception e) {
6105                                    throw processException(e);
6106                            }
6107                            finally {
6108                                    if (list == null) {
6109                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6110                                    }
6111                                    else {
6112                                            cacheResult(list);
6113    
6114                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6115                                    }
6116    
6117                                    closeSession(session);
6118                            }
6119                    }
6120    
6121                    return list;
6122            }
6123    
6124            /**
6125             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6126             *
6127             * @param resourcePrimKey the resource prim key
6128             * @param status the status
6129             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6130             * @return the first matching journal article
6131             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6132             * @throws SystemException if a system exception occurred
6133             */
6134            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
6135                    OrderByComparator orderByComparator)
6136                    throws NoSuchArticleException, SystemException {
6137                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
6138                                    status, orderByComparator);
6139    
6140                    if (journalArticle != null) {
6141                            return journalArticle;
6142                    }
6143    
6144                    StringBundler msg = new StringBundler(6);
6145    
6146                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6147    
6148                    msg.append("resourcePrimKey=");
6149                    msg.append(resourcePrimKey);
6150    
6151                    msg.append(", status=");
6152                    msg.append(status);
6153    
6154                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6155    
6156                    throw new NoSuchArticleException(msg.toString());
6157            }
6158    
6159            /**
6160             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6161             *
6162             * @param resourcePrimKey the resource prim key
6163             * @param status the status
6164             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6165             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6166             * @throws SystemException if a system exception occurred
6167             */
6168            public JournalArticle fetchByR_ST_First(long resourcePrimKey, int status,
6169                    OrderByComparator orderByComparator) throws SystemException {
6170                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
6171                                    orderByComparator);
6172    
6173                    if (!list.isEmpty()) {
6174                            return list.get(0);
6175                    }
6176    
6177                    return null;
6178            }
6179    
6180            /**
6181             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6182             *
6183             * @param resourcePrimKey the resource prim key
6184             * @param status the status
6185             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6186             * @return the last matching journal article
6187             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6188             * @throws SystemException if a system exception occurred
6189             */
6190            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
6191                    OrderByComparator orderByComparator)
6192                    throws NoSuchArticleException, SystemException {
6193                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
6194                                    status, orderByComparator);
6195    
6196                    if (journalArticle != null) {
6197                            return journalArticle;
6198                    }
6199    
6200                    StringBundler msg = new StringBundler(6);
6201    
6202                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6203    
6204                    msg.append("resourcePrimKey=");
6205                    msg.append(resourcePrimKey);
6206    
6207                    msg.append(", status=");
6208                    msg.append(status);
6209    
6210                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6211    
6212                    throw new NoSuchArticleException(msg.toString());
6213            }
6214    
6215            /**
6216             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6217             *
6218             * @param resourcePrimKey the resource prim key
6219             * @param status the status
6220             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6221             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6222             * @throws SystemException if a system exception occurred
6223             */
6224            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
6225                    OrderByComparator orderByComparator) throws SystemException {
6226                    int count = countByR_ST(resourcePrimKey, status);
6227    
6228                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
6229                                    count - 1, count, orderByComparator);
6230    
6231                    if (!list.isEmpty()) {
6232                            return list.get(0);
6233                    }
6234    
6235                    return null;
6236            }
6237    
6238            /**
6239             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
6240             *
6241             * @param id the primary key of the current journal article
6242             * @param resourcePrimKey the resource prim key
6243             * @param status the status
6244             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6245             * @return the previous, current, and next journal article
6246             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6247             * @throws SystemException if a system exception occurred
6248             */
6249            public JournalArticle[] findByR_ST_PrevAndNext(long id,
6250                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
6251                    throws NoSuchArticleException, SystemException {
6252                    JournalArticle journalArticle = findByPrimaryKey(id);
6253    
6254                    Session session = null;
6255    
6256                    try {
6257                            session = openSession();
6258    
6259                            JournalArticle[] array = new JournalArticleImpl[3];
6260    
6261                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
6262                                            resourcePrimKey, status, orderByComparator, true);
6263    
6264                            array[1] = journalArticle;
6265    
6266                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
6267                                            resourcePrimKey, status, orderByComparator, false);
6268    
6269                            return array;
6270                    }
6271                    catch (Exception e) {
6272                            throw processException(e);
6273                    }
6274                    finally {
6275                            closeSession(session);
6276                    }
6277            }
6278    
6279            protected JournalArticle getByR_ST_PrevAndNext(Session session,
6280                    JournalArticle journalArticle, long resourcePrimKey, int status,
6281                    OrderByComparator orderByComparator, boolean previous) {
6282                    StringBundler query = null;
6283    
6284                    if (orderByComparator != null) {
6285                            query = new StringBundler(6 +
6286                                            (orderByComparator.getOrderByFields().length * 6));
6287                    }
6288                    else {
6289                            query = new StringBundler(3);
6290                    }
6291    
6292                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6293    
6294                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
6295    
6296                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
6297    
6298                    if (orderByComparator != null) {
6299                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6300    
6301                            if (orderByConditionFields.length > 0) {
6302                                    query.append(WHERE_AND);
6303                            }
6304    
6305                            for (int i = 0; i < orderByConditionFields.length; i++) {
6306                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6307                                    query.append(orderByConditionFields[i]);
6308    
6309                                    if ((i + 1) < orderByConditionFields.length) {
6310                                            if (orderByComparator.isAscending() ^ previous) {
6311                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6312                                            }
6313                                            else {
6314                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6315                                            }
6316                                    }
6317                                    else {
6318                                            if (orderByComparator.isAscending() ^ previous) {
6319                                                    query.append(WHERE_GREATER_THAN);
6320                                            }
6321                                            else {
6322                                                    query.append(WHERE_LESSER_THAN);
6323                                            }
6324                                    }
6325                            }
6326    
6327                            query.append(ORDER_BY_CLAUSE);
6328    
6329                            String[] orderByFields = orderByComparator.getOrderByFields();
6330    
6331                            for (int i = 0; i < orderByFields.length; i++) {
6332                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6333                                    query.append(orderByFields[i]);
6334    
6335                                    if ((i + 1) < orderByFields.length) {
6336                                            if (orderByComparator.isAscending() ^ previous) {
6337                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6338                                            }
6339                                            else {
6340                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6341                                            }
6342                                    }
6343                                    else {
6344                                            if (orderByComparator.isAscending() ^ previous) {
6345                                                    query.append(ORDER_BY_ASC);
6346                                            }
6347                                            else {
6348                                                    query.append(ORDER_BY_DESC);
6349                                            }
6350                                    }
6351                            }
6352                    }
6353    
6354                    else {
6355                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6356                    }
6357    
6358                    String sql = query.toString();
6359    
6360                    Query q = session.createQuery(sql);
6361    
6362                    q.setFirstResult(0);
6363                    q.setMaxResults(2);
6364    
6365                    QueryPos qPos = QueryPos.getInstance(q);
6366    
6367                    qPos.add(resourcePrimKey);
6368    
6369                    qPos.add(status);
6370    
6371                    if (orderByComparator != null) {
6372                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6373    
6374                            for (Object value : values) {
6375                                    qPos.add(value);
6376                            }
6377                    }
6378    
6379                    List<JournalArticle> list = q.list();
6380    
6381                    if (list.size() == 2) {
6382                            return list.get(1);
6383                    }
6384                    else {
6385                            return null;
6386                    }
6387            }
6388    
6389            /**
6390             * Returns all the journal articles where groupId = &#63; and userId = &#63;.
6391             *
6392             * @param groupId the group ID
6393             * @param userId the user ID
6394             * @return the matching journal articles
6395             * @throws SystemException if a system exception occurred
6396             */
6397            public List<JournalArticle> findByG_U(long groupId, long userId)
6398                    throws SystemException {
6399                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6400                            null);
6401            }
6402    
6403            /**
6404             * Returns a range of all the journal articles where groupId = &#63; and userId = &#63;.
6405             *
6406             * <p>
6407             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6408             * </p>
6409             *
6410             * @param groupId the group ID
6411             * @param userId the user ID
6412             * @param start the lower bound of the range of journal articles
6413             * @param end the upper bound of the range of journal articles (not inclusive)
6414             * @return the range of matching journal articles
6415             * @throws SystemException if a system exception occurred
6416             */
6417            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6418                    int end) throws SystemException {
6419                    return findByG_U(groupId, userId, start, end, null);
6420            }
6421    
6422            /**
6423             * Returns an ordered range of all the journal articles where groupId = &#63; and userId = &#63;.
6424             *
6425             * <p>
6426             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6427             * </p>
6428             *
6429             * @param groupId the group ID
6430             * @param userId the user ID
6431             * @param start the lower bound of the range of journal articles
6432             * @param end the upper bound of the range of journal articles (not inclusive)
6433             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6434             * @return the ordered range of matching journal articles
6435             * @throws SystemException if a system exception occurred
6436             */
6437            public List<JournalArticle> findByG_U(long groupId, long userId, int start,
6438                    int end, OrderByComparator orderByComparator) throws SystemException {
6439                    FinderPath finderPath = null;
6440                    Object[] finderArgs = null;
6441    
6442                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6443                                    (orderByComparator == null)) {
6444                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
6445                            finderArgs = new Object[] { groupId, userId };
6446                    }
6447                    else {
6448                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
6449                            finderArgs = new Object[] {
6450                                            groupId, userId,
6451                                            
6452                                            start, end, orderByComparator
6453                                    };
6454                    }
6455    
6456                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6457                                    finderArgs, this);
6458    
6459                    if ((list != null) && !list.isEmpty()) {
6460                            for (JournalArticle journalArticle : list) {
6461                                    if ((groupId != journalArticle.getGroupId()) ||
6462                                                    (userId != journalArticle.getUserId())) {
6463                                            list = null;
6464    
6465                                            break;
6466                                    }
6467                            }
6468                    }
6469    
6470                    if (list == null) {
6471                            StringBundler query = null;
6472    
6473                            if (orderByComparator != null) {
6474                                    query = new StringBundler(4 +
6475                                                    (orderByComparator.getOrderByFields().length * 3));
6476                            }
6477                            else {
6478                                    query = new StringBundler(4);
6479                            }
6480    
6481                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6482    
6483                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6484    
6485                            query.append(_FINDER_COLUMN_G_U_USERID_2);
6486    
6487                            if (orderByComparator != null) {
6488                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6489                                            orderByComparator);
6490                            }
6491    
6492                            else {
6493                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6494                            }
6495    
6496                            String sql = query.toString();
6497    
6498                            Session session = null;
6499    
6500                            try {
6501                                    session = openSession();
6502    
6503                                    Query q = session.createQuery(sql);
6504    
6505                                    QueryPos qPos = QueryPos.getInstance(q);
6506    
6507                                    qPos.add(groupId);
6508    
6509                                    qPos.add(userId);
6510    
6511                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
6512                                                    start, end);
6513                            }
6514                            catch (Exception e) {
6515                                    throw processException(e);
6516                            }
6517                            finally {
6518                                    if (list == null) {
6519                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6520                                    }
6521                                    else {
6522                                            cacheResult(list);
6523    
6524                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6525                                    }
6526    
6527                                    closeSession(session);
6528                            }
6529                    }
6530    
6531                    return list;
6532            }
6533    
6534            /**
6535             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
6536             *
6537             * @param groupId the group ID
6538             * @param userId the user ID
6539             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6540             * @return the first matching journal article
6541             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6542             * @throws SystemException if a system exception occurred
6543             */
6544            public JournalArticle findByG_U_First(long groupId, long userId,
6545                    OrderByComparator orderByComparator)
6546                    throws NoSuchArticleException, SystemException {
6547                    JournalArticle journalArticle = fetchByG_U_First(groupId, userId,
6548                                    orderByComparator);
6549    
6550                    if (journalArticle != null) {
6551                            return journalArticle;
6552                    }
6553    
6554                    StringBundler msg = new StringBundler(6);
6555    
6556                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6557    
6558                    msg.append("groupId=");
6559                    msg.append(groupId);
6560    
6561                    msg.append(", userId=");
6562                    msg.append(userId);
6563    
6564                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6565    
6566                    throw new NoSuchArticleException(msg.toString());
6567            }
6568    
6569            /**
6570             * Returns the first journal article in the ordered set where groupId = &#63; and userId = &#63;.
6571             *
6572             * @param groupId the group ID
6573             * @param userId the user ID
6574             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6575             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6576             * @throws SystemException if a system exception occurred
6577             */
6578            public JournalArticle fetchByG_U_First(long groupId, long userId,
6579                    OrderByComparator orderByComparator) throws SystemException {
6580                    List<JournalArticle> list = findByG_U(groupId, userId, 0, 1,
6581                                    orderByComparator);
6582    
6583                    if (!list.isEmpty()) {
6584                            return list.get(0);
6585                    }
6586    
6587                    return null;
6588            }
6589    
6590            /**
6591             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
6592             *
6593             * @param groupId the group ID
6594             * @param userId the user ID
6595             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6596             * @return the last matching journal article
6597             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6598             * @throws SystemException if a system exception occurred
6599             */
6600            public JournalArticle findByG_U_Last(long groupId, long userId,
6601                    OrderByComparator orderByComparator)
6602                    throws NoSuchArticleException, SystemException {
6603                    JournalArticle journalArticle = fetchByG_U_Last(groupId, userId,
6604                                    orderByComparator);
6605    
6606                    if (journalArticle != null) {
6607                            return journalArticle;
6608                    }
6609    
6610                    StringBundler msg = new StringBundler(6);
6611    
6612                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6613    
6614                    msg.append("groupId=");
6615                    msg.append(groupId);
6616    
6617                    msg.append(", userId=");
6618                    msg.append(userId);
6619    
6620                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6621    
6622                    throw new NoSuchArticleException(msg.toString());
6623            }
6624    
6625            /**
6626             * Returns the last journal article in the ordered set where groupId = &#63; and userId = &#63;.
6627             *
6628             * @param groupId the group ID
6629             * @param userId the user ID
6630             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6631             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6632             * @throws SystemException if a system exception occurred
6633             */
6634            public JournalArticle fetchByG_U_Last(long groupId, long userId,
6635                    OrderByComparator orderByComparator) throws SystemException {
6636                    int count = countByG_U(groupId, userId);
6637    
6638                    List<JournalArticle> list = findByG_U(groupId, userId, count - 1,
6639                                    count, orderByComparator);
6640    
6641                    if (!list.isEmpty()) {
6642                            return list.get(0);
6643                    }
6644    
6645                    return null;
6646            }
6647    
6648            /**
6649             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and userId = &#63;.
6650             *
6651             * @param id the primary key of the current journal article
6652             * @param groupId the group ID
6653             * @param userId the user ID
6654             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6655             * @return the previous, current, and next journal article
6656             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6657             * @throws SystemException if a system exception occurred
6658             */
6659            public JournalArticle[] findByG_U_PrevAndNext(long id, long groupId,
6660                    long userId, OrderByComparator orderByComparator)
6661                    throws NoSuchArticleException, SystemException {
6662                    JournalArticle journalArticle = findByPrimaryKey(id);
6663    
6664                    Session session = null;
6665    
6666                    try {
6667                            session = openSession();
6668    
6669                            JournalArticle[] array = new JournalArticleImpl[3];
6670    
6671                            array[0] = getByG_U_PrevAndNext(session, journalArticle, groupId,
6672                                            userId, orderByComparator, true);
6673    
6674                            array[1] = journalArticle;
6675    
6676                            array[2] = getByG_U_PrevAndNext(session, journalArticle, groupId,
6677                                            userId, orderByComparator, false);
6678    
6679                            return array;
6680                    }
6681                    catch (Exception e) {
6682                            throw processException(e);
6683                    }
6684                    finally {
6685                            closeSession(session);
6686                    }
6687            }
6688    
6689            protected JournalArticle getByG_U_PrevAndNext(Session session,
6690                    JournalArticle journalArticle, long groupId, long userId,
6691                    OrderByComparator orderByComparator, boolean previous) {
6692                    StringBundler query = null;
6693    
6694                    if (orderByComparator != null) {
6695                            query = new StringBundler(6 +
6696                                            (orderByComparator.getOrderByFields().length * 6));
6697                    }
6698                    else {
6699                            query = new StringBundler(3);
6700                    }
6701    
6702                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6703    
6704                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6705    
6706                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6707    
6708                    if (orderByComparator != null) {
6709                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6710    
6711                            if (orderByConditionFields.length > 0) {
6712                                    query.append(WHERE_AND);
6713                            }
6714    
6715                            for (int i = 0; i < orderByConditionFields.length; i++) {
6716                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6717                                    query.append(orderByConditionFields[i]);
6718    
6719                                    if ((i + 1) < orderByConditionFields.length) {
6720                                            if (orderByComparator.isAscending() ^ previous) {
6721                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6722                                            }
6723                                            else {
6724                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6725                                            }
6726                                    }
6727                                    else {
6728                                            if (orderByComparator.isAscending() ^ previous) {
6729                                                    query.append(WHERE_GREATER_THAN);
6730                                            }
6731                                            else {
6732                                                    query.append(WHERE_LESSER_THAN);
6733                                            }
6734                                    }
6735                            }
6736    
6737                            query.append(ORDER_BY_CLAUSE);
6738    
6739                            String[] orderByFields = orderByComparator.getOrderByFields();
6740    
6741                            for (int i = 0; i < orderByFields.length; i++) {
6742                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6743                                    query.append(orderByFields[i]);
6744    
6745                                    if ((i + 1) < orderByFields.length) {
6746                                            if (orderByComparator.isAscending() ^ previous) {
6747                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6748                                            }
6749                                            else {
6750                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6751                                            }
6752                                    }
6753                                    else {
6754                                            if (orderByComparator.isAscending() ^ previous) {
6755                                                    query.append(ORDER_BY_ASC);
6756                                            }
6757                                            else {
6758                                                    query.append(ORDER_BY_DESC);
6759                                            }
6760                                    }
6761                            }
6762                    }
6763    
6764                    else {
6765                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6766                    }
6767    
6768                    String sql = query.toString();
6769    
6770                    Query q = session.createQuery(sql);
6771    
6772                    q.setFirstResult(0);
6773                    q.setMaxResults(2);
6774    
6775                    QueryPos qPos = QueryPos.getInstance(q);
6776    
6777                    qPos.add(groupId);
6778    
6779                    qPos.add(userId);
6780    
6781                    if (orderByComparator != null) {
6782                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6783    
6784                            for (Object value : values) {
6785                                    qPos.add(value);
6786                            }
6787                    }
6788    
6789                    List<JournalArticle> list = q.list();
6790    
6791                    if (list.size() == 2) {
6792                            return list.get(1);
6793                    }
6794                    else {
6795                            return null;
6796                    }
6797            }
6798    
6799            /**
6800             * Returns all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6801             *
6802             * @param groupId the group ID
6803             * @param userId the user ID
6804             * @return the matching journal articles that the user has permission to view
6805             * @throws SystemException if a system exception occurred
6806             */
6807            public List<JournalArticle> filterFindByG_U(long groupId, long userId)
6808                    throws SystemException {
6809                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
6810                            QueryUtil.ALL_POS, null);
6811            }
6812    
6813            /**
6814             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6815             *
6816             * <p>
6817             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6818             * </p>
6819             *
6820             * @param groupId the group ID
6821             * @param userId the user ID
6822             * @param start the lower bound of the range of journal articles
6823             * @param end the upper bound of the range of journal articles (not inclusive)
6824             * @return the range of matching journal articles that the user has permission to view
6825             * @throws SystemException if a system exception occurred
6826             */
6827            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
6828                    int start, int end) throws SystemException {
6829                    return filterFindByG_U(groupId, userId, start, end, null);
6830            }
6831    
6832            /**
6833             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and userId = &#63;.
6834             *
6835             * <p>
6836             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6837             * </p>
6838             *
6839             * @param groupId the group ID
6840             * @param userId the user ID
6841             * @param start the lower bound of the range of journal articles
6842             * @param end the upper bound of the range of journal articles (not inclusive)
6843             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6844             * @return the ordered range of matching journal articles that the user has permission to view
6845             * @throws SystemException if a system exception occurred
6846             */
6847            public List<JournalArticle> filterFindByG_U(long groupId, long userId,
6848                    int start, int end, OrderByComparator orderByComparator)
6849                    throws SystemException {
6850                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6851                            return findByG_U(groupId, userId, start, end, orderByComparator);
6852                    }
6853    
6854                    StringBundler query = null;
6855    
6856                    if (orderByComparator != null) {
6857                            query = new StringBundler(4 +
6858                                            (orderByComparator.getOrderByFields().length * 3));
6859                    }
6860                    else {
6861                            query = new StringBundler(4);
6862                    }
6863    
6864                    if (getDB().isSupportsInlineDistinct()) {
6865                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6866                    }
6867                    else {
6868                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6869                    }
6870    
6871                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
6872    
6873                    query.append(_FINDER_COLUMN_G_U_USERID_2);
6874    
6875                    if (!getDB().isSupportsInlineDistinct()) {
6876                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6877                    }
6878    
6879                    if (orderByComparator != null) {
6880                            if (getDB().isSupportsInlineDistinct()) {
6881                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6882                                            orderByComparator);
6883                            }
6884                            else {
6885                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6886                                            orderByComparator);
6887                            }
6888                    }
6889    
6890                    else {
6891                            if (getDB().isSupportsInlineDistinct()) {
6892                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6893                            }
6894                            else {
6895                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6896                            }
6897                    }
6898    
6899                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6900                                    JournalArticle.class.getName(),
6901                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6902    
6903                    Session session = null;
6904    
6905                    try {
6906                            session = openSession();
6907    
6908                            SQLQuery q = session.createSQLQuery(sql);
6909    
6910                            if (getDB().isSupportsInlineDistinct()) {
6911                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6912                            }
6913                            else {
6914                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6915                            }
6916    
6917                            QueryPos qPos = QueryPos.getInstance(q);
6918    
6919                            qPos.add(groupId);
6920    
6921                            qPos.add(userId);
6922    
6923                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6924                                    end);
6925                    }
6926                    catch (Exception e) {
6927                            throw processException(e);
6928                    }
6929                    finally {
6930                            closeSession(session);
6931                    }
6932            }
6933    
6934            /**
6935             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
6936             *
6937             * @param id the primary key of the current journal article
6938             * @param groupId the group ID
6939             * @param userId the user ID
6940             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6941             * @return the previous, current, and next journal article
6942             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6943             * @throws SystemException if a system exception occurred
6944             */
6945            public JournalArticle[] filterFindByG_U_PrevAndNext(long id, long groupId,
6946                    long userId, OrderByComparator orderByComparator)
6947                    throws NoSuchArticleException, SystemException {
6948                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6949                            return findByG_U_PrevAndNext(id, groupId, userId, orderByComparator);
6950                    }
6951    
6952                    JournalArticle journalArticle = findByPrimaryKey(id);
6953    
6954                    Session session = null;
6955    
6956                    try {
6957                            session = openSession();
6958    
6959                            JournalArticle[] array = new JournalArticleImpl[3];
6960    
6961                            array[0] = filterGetByG_U_PrevAndNext(session, journalArticle,
6962                                            groupId, userId, orderByComparator, true);
6963    
6964                            array[1] = journalArticle;
6965    
6966                            array[2] = filterGetByG_U_PrevAndNext(session, journalArticle,
6967                                            groupId, userId, orderByComparator, false);
6968    
6969                            return array;
6970                    }
6971                    catch (Exception e) {
6972                            throw processException(e);
6973                    }
6974                    finally {
6975                            closeSession(session);
6976                    }
6977            }
6978    
6979            protected JournalArticle filterGetByG_U_PrevAndNext(Session session,
6980                    JournalArticle journalArticle, long groupId, long userId,
6981                    OrderByComparator orderByComparator, boolean previous) {
6982                    StringBundler query = null;
6983    
6984                    if (orderByComparator != null) {
6985                            query = new StringBundler(6 +
6986                                            (orderByComparator.getOrderByFields().length * 6));
6987                    }
6988                    else {
6989                            query = new StringBundler(3);
6990                    }
6991    
6992                    if (getDB().isSupportsInlineDistinct()) {
6993                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6994                    }
6995                    else {
6996                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6997                    }
6998    
6999                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7000    
7001                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7002    
7003                    if (!getDB().isSupportsInlineDistinct()) {
7004                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7005                    }
7006    
7007                    if (orderByComparator != null) {
7008                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7009    
7010                            if (orderByConditionFields.length > 0) {
7011                                    query.append(WHERE_AND);
7012                            }
7013    
7014                            for (int i = 0; i < orderByConditionFields.length; i++) {
7015                                    if (getDB().isSupportsInlineDistinct()) {
7016                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7017                                    }
7018                                    else {
7019                                            query.append(_ORDER_BY_ENTITY_TABLE);
7020                                    }
7021    
7022                                    query.append(orderByConditionFields[i]);
7023    
7024                                    if ((i + 1) < orderByConditionFields.length) {
7025                                            if (orderByComparator.isAscending() ^ previous) {
7026                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7027                                            }
7028                                            else {
7029                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7030                                            }
7031                                    }
7032                                    else {
7033                                            if (orderByComparator.isAscending() ^ previous) {
7034                                                    query.append(WHERE_GREATER_THAN);
7035                                            }
7036                                            else {
7037                                                    query.append(WHERE_LESSER_THAN);
7038                                            }
7039                                    }
7040                            }
7041    
7042                            query.append(ORDER_BY_CLAUSE);
7043    
7044                            String[] orderByFields = orderByComparator.getOrderByFields();
7045    
7046                            for (int i = 0; i < orderByFields.length; i++) {
7047                                    if (getDB().isSupportsInlineDistinct()) {
7048                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7049                                    }
7050                                    else {
7051                                            query.append(_ORDER_BY_ENTITY_TABLE);
7052                                    }
7053    
7054                                    query.append(orderByFields[i]);
7055    
7056                                    if ((i + 1) < orderByFields.length) {
7057                                            if (orderByComparator.isAscending() ^ previous) {
7058                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7059                                            }
7060                                            else {
7061                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7062                                            }
7063                                    }
7064                                    else {
7065                                            if (orderByComparator.isAscending() ^ previous) {
7066                                                    query.append(ORDER_BY_ASC);
7067                                            }
7068                                            else {
7069                                                    query.append(ORDER_BY_DESC);
7070                                            }
7071                                    }
7072                            }
7073                    }
7074    
7075                    else {
7076                            if (getDB().isSupportsInlineDistinct()) {
7077                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7078                            }
7079                            else {
7080                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7081                            }
7082                    }
7083    
7084                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7085                                    JournalArticle.class.getName(),
7086                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7087    
7088                    SQLQuery q = session.createSQLQuery(sql);
7089    
7090                    q.setFirstResult(0);
7091                    q.setMaxResults(2);
7092    
7093                    if (getDB().isSupportsInlineDistinct()) {
7094                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7095                    }
7096                    else {
7097                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7098                    }
7099    
7100                    QueryPos qPos = QueryPos.getInstance(q);
7101    
7102                    qPos.add(groupId);
7103    
7104                    qPos.add(userId);
7105    
7106                    if (orderByComparator != null) {
7107                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7108    
7109                            for (Object value : values) {
7110                                    qPos.add(value);
7111                            }
7112                    }
7113    
7114                    List<JournalArticle> list = q.list();
7115    
7116                    if (list.size() == 2) {
7117                            return list.get(1);
7118                    }
7119                    else {
7120                            return null;
7121                    }
7122            }
7123    
7124            /**
7125             * Returns all the journal articles where groupId = &#63; and folderId = &#63;.
7126             *
7127             * @param groupId the group ID
7128             * @param folderId the folder ID
7129             * @return the matching journal articles
7130             * @throws SystemException if a system exception occurred
7131             */
7132            public List<JournalArticle> findByG_F(long groupId, long folderId)
7133                    throws SystemException {
7134                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
7135                            QueryUtil.ALL_POS, null);
7136            }
7137    
7138            /**
7139             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63;.
7140             *
7141             * <p>
7142             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7143             * </p>
7144             *
7145             * @param groupId the group ID
7146             * @param folderId the folder ID
7147             * @param start the lower bound of the range of journal articles
7148             * @param end the upper bound of the range of journal articles (not inclusive)
7149             * @return the range of matching journal articles
7150             * @throws SystemException if a system exception occurred
7151             */
7152            public List<JournalArticle> findByG_F(long groupId, long folderId,
7153                    int start, int end) throws SystemException {
7154                    return findByG_F(groupId, folderId, start, end, null);
7155            }
7156    
7157            /**
7158             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63;.
7159             *
7160             * <p>
7161             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7162             * </p>
7163             *
7164             * @param groupId the group ID
7165             * @param folderId the folder ID
7166             * @param start the lower bound of the range of journal articles
7167             * @param end the upper bound of the range of journal articles (not inclusive)
7168             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7169             * @return the ordered range of matching journal articles
7170             * @throws SystemException if a system exception occurred
7171             */
7172            public List<JournalArticle> findByG_F(long groupId, long folderId,
7173                    int start, int end, OrderByComparator orderByComparator)
7174                    throws SystemException {
7175                    FinderPath finderPath = null;
7176                    Object[] finderArgs = null;
7177    
7178                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7179                                    (orderByComparator == null)) {
7180                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
7181                            finderArgs = new Object[] { groupId, folderId };
7182                    }
7183                    else {
7184                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
7185                            finderArgs = new Object[] {
7186                                            groupId, folderId,
7187                                            
7188                                            start, end, orderByComparator
7189                                    };
7190                    }
7191    
7192                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7193                                    finderArgs, this);
7194    
7195                    if ((list != null) && !list.isEmpty()) {
7196                            for (JournalArticle journalArticle : list) {
7197                                    if ((groupId != journalArticle.getGroupId()) ||
7198                                                    (folderId != journalArticle.getFolderId())) {
7199                                            list = null;
7200    
7201                                            break;
7202                                    }
7203                            }
7204                    }
7205    
7206                    if (list == null) {
7207                            StringBundler query = null;
7208    
7209                            if (orderByComparator != null) {
7210                                    query = new StringBundler(4 +
7211                                                    (orderByComparator.getOrderByFields().length * 3));
7212                            }
7213                            else {
7214                                    query = new StringBundler(4);
7215                            }
7216    
7217                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7218    
7219                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7220    
7221                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7222    
7223                            if (orderByComparator != null) {
7224                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7225                                            orderByComparator);
7226                            }
7227    
7228                            else {
7229                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7230                            }
7231    
7232                            String sql = query.toString();
7233    
7234                            Session session = null;
7235    
7236                            try {
7237                                    session = openSession();
7238    
7239                                    Query q = session.createQuery(sql);
7240    
7241                                    QueryPos qPos = QueryPos.getInstance(q);
7242    
7243                                    qPos.add(groupId);
7244    
7245                                    qPos.add(folderId);
7246    
7247                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
7248                                                    start, end);
7249                            }
7250                            catch (Exception e) {
7251                                    throw processException(e);
7252                            }
7253                            finally {
7254                                    if (list == null) {
7255                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7256                                    }
7257                                    else {
7258                                            cacheResult(list);
7259    
7260                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7261                                    }
7262    
7263                                    closeSession(session);
7264                            }
7265                    }
7266    
7267                    return list;
7268            }
7269    
7270            /**
7271             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7272             *
7273             * @param groupId the group ID
7274             * @param folderId the folder ID
7275             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7276             * @return the first matching journal article
7277             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7278             * @throws SystemException if a system exception occurred
7279             */
7280            public JournalArticle findByG_F_First(long groupId, long folderId,
7281                    OrderByComparator orderByComparator)
7282                    throws NoSuchArticleException, SystemException {
7283                    JournalArticle journalArticle = fetchByG_F_First(groupId, folderId,
7284                                    orderByComparator);
7285    
7286                    if (journalArticle != null) {
7287                            return journalArticle;
7288                    }
7289    
7290                    StringBundler msg = new StringBundler(6);
7291    
7292                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7293    
7294                    msg.append("groupId=");
7295                    msg.append(groupId);
7296    
7297                    msg.append(", folderId=");
7298                    msg.append(folderId);
7299    
7300                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7301    
7302                    throw new NoSuchArticleException(msg.toString());
7303            }
7304    
7305            /**
7306             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7307             *
7308             * @param groupId the group ID
7309             * @param folderId the folder ID
7310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7311             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7312             * @throws SystemException if a system exception occurred
7313             */
7314            public JournalArticle fetchByG_F_First(long groupId, long folderId,
7315                    OrderByComparator orderByComparator) throws SystemException {
7316                    List<JournalArticle> list = findByG_F(groupId, folderId, 0, 1,
7317                                    orderByComparator);
7318    
7319                    if (!list.isEmpty()) {
7320                            return list.get(0);
7321                    }
7322    
7323                    return null;
7324            }
7325    
7326            /**
7327             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7328             *
7329             * @param groupId the group ID
7330             * @param folderId the folder ID
7331             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7332             * @return the last matching journal article
7333             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7334             * @throws SystemException if a system exception occurred
7335             */
7336            public JournalArticle findByG_F_Last(long groupId, long folderId,
7337                    OrderByComparator orderByComparator)
7338                    throws NoSuchArticleException, SystemException {
7339                    JournalArticle journalArticle = fetchByG_F_Last(groupId, folderId,
7340                                    orderByComparator);
7341    
7342                    if (journalArticle != null) {
7343                            return journalArticle;
7344                    }
7345    
7346                    StringBundler msg = new StringBundler(6);
7347    
7348                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7349    
7350                    msg.append("groupId=");
7351                    msg.append(groupId);
7352    
7353                    msg.append(", folderId=");
7354                    msg.append(folderId);
7355    
7356                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7357    
7358                    throw new NoSuchArticleException(msg.toString());
7359            }
7360    
7361            /**
7362             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7363             *
7364             * @param groupId the group ID
7365             * @param folderId the folder ID
7366             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7367             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7368             * @throws SystemException if a system exception occurred
7369             */
7370            public JournalArticle fetchByG_F_Last(long groupId, long folderId,
7371                    OrderByComparator orderByComparator) throws SystemException {
7372                    int count = countByG_F(groupId, folderId);
7373    
7374                    List<JournalArticle> list = findByG_F(groupId, folderId, count - 1,
7375                                    count, orderByComparator);
7376    
7377                    if (!list.isEmpty()) {
7378                            return list.get(0);
7379                    }
7380    
7381                    return null;
7382            }
7383    
7384            /**
7385             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63;.
7386             *
7387             * @param id the primary key of the current journal article
7388             * @param groupId the group ID
7389             * @param folderId the folder ID
7390             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7391             * @return the previous, current, and next journal article
7392             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7393             * @throws SystemException if a system exception occurred
7394             */
7395            public JournalArticle[] findByG_F_PrevAndNext(long id, long groupId,
7396                    long folderId, OrderByComparator orderByComparator)
7397                    throws NoSuchArticleException, SystemException {
7398                    JournalArticle journalArticle = findByPrimaryKey(id);
7399    
7400                    Session session = null;
7401    
7402                    try {
7403                            session = openSession();
7404    
7405                            JournalArticle[] array = new JournalArticleImpl[3];
7406    
7407                            array[0] = getByG_F_PrevAndNext(session, journalArticle, groupId,
7408                                            folderId, orderByComparator, true);
7409    
7410                            array[1] = journalArticle;
7411    
7412                            array[2] = getByG_F_PrevAndNext(session, journalArticle, groupId,
7413                                            folderId, orderByComparator, false);
7414    
7415                            return array;
7416                    }
7417                    catch (Exception e) {
7418                            throw processException(e);
7419                    }
7420                    finally {
7421                            closeSession(session);
7422                    }
7423            }
7424    
7425            protected JournalArticle getByG_F_PrevAndNext(Session session,
7426                    JournalArticle journalArticle, long groupId, long folderId,
7427                    OrderByComparator orderByComparator, boolean previous) {
7428                    StringBundler query = null;
7429    
7430                    if (orderByComparator != null) {
7431                            query = new StringBundler(6 +
7432                                            (orderByComparator.getOrderByFields().length * 6));
7433                    }
7434                    else {
7435                            query = new StringBundler(3);
7436                    }
7437    
7438                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7439    
7440                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7441    
7442                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7443    
7444                    if (orderByComparator != null) {
7445                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7446    
7447                            if (orderByConditionFields.length > 0) {
7448                                    query.append(WHERE_AND);
7449                            }
7450    
7451                            for (int i = 0; i < orderByConditionFields.length; i++) {
7452                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7453                                    query.append(orderByConditionFields[i]);
7454    
7455                                    if ((i + 1) < orderByConditionFields.length) {
7456                                            if (orderByComparator.isAscending() ^ previous) {
7457                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7458                                            }
7459                                            else {
7460                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7461                                            }
7462                                    }
7463                                    else {
7464                                            if (orderByComparator.isAscending() ^ previous) {
7465                                                    query.append(WHERE_GREATER_THAN);
7466                                            }
7467                                            else {
7468                                                    query.append(WHERE_LESSER_THAN);
7469                                            }
7470                                    }
7471                            }
7472    
7473                            query.append(ORDER_BY_CLAUSE);
7474    
7475                            String[] orderByFields = orderByComparator.getOrderByFields();
7476    
7477                            for (int i = 0; i < orderByFields.length; i++) {
7478                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7479                                    query.append(orderByFields[i]);
7480    
7481                                    if ((i + 1) < orderByFields.length) {
7482                                            if (orderByComparator.isAscending() ^ previous) {
7483                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7484                                            }
7485                                            else {
7486                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7487                                            }
7488                                    }
7489                                    else {
7490                                            if (orderByComparator.isAscending() ^ previous) {
7491                                                    query.append(ORDER_BY_ASC);
7492                                            }
7493                                            else {
7494                                                    query.append(ORDER_BY_DESC);
7495                                            }
7496                                    }
7497                            }
7498                    }
7499    
7500                    else {
7501                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7502                    }
7503    
7504                    String sql = query.toString();
7505    
7506                    Query q = session.createQuery(sql);
7507    
7508                    q.setFirstResult(0);
7509                    q.setMaxResults(2);
7510    
7511                    QueryPos qPos = QueryPos.getInstance(q);
7512    
7513                    qPos.add(groupId);
7514    
7515                    qPos.add(folderId);
7516    
7517                    if (orderByComparator != null) {
7518                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7519    
7520                            for (Object value : values) {
7521                                    qPos.add(value);
7522                            }
7523                    }
7524    
7525                    List<JournalArticle> list = q.list();
7526    
7527                    if (list.size() == 2) {
7528                            return list.get(1);
7529                    }
7530                    else {
7531                            return null;
7532                    }
7533            }
7534    
7535            /**
7536             * Returns all the journal articles where groupId = &#63; and folderId = any &#63;.
7537             *
7538             * <p>
7539             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7540             * </p>
7541             *
7542             * @param groupId the group ID
7543             * @param folderIds the folder IDs
7544             * @return the matching journal articles
7545             * @throws SystemException if a system exception occurred
7546             */
7547            public List<JournalArticle> findByG_F(long groupId, long[] folderIds)
7548                    throws SystemException {
7549                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
7550                            QueryUtil.ALL_POS, null);
7551            }
7552    
7553            /**
7554             * Returns a range of all the journal articles where groupId = &#63; and folderId = any &#63;.
7555             *
7556             * <p>
7557             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7558             * </p>
7559             *
7560             * @param groupId the group ID
7561             * @param folderIds the folder IDs
7562             * @param start the lower bound of the range of journal articles
7563             * @param end the upper bound of the range of journal articles (not inclusive)
7564             * @return the range of matching journal articles
7565             * @throws SystemException if a system exception occurred
7566             */
7567            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
7568                    int start, int end) throws SystemException {
7569                    return findByG_F(groupId, folderIds, start, end, null);
7570            }
7571    
7572            /**
7573             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = any &#63;.
7574             *
7575             * <p>
7576             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7577             * </p>
7578             *
7579             * @param groupId the group ID
7580             * @param folderIds the folder IDs
7581             * @param start the lower bound of the range of journal articles
7582             * @param end the upper bound of the range of journal articles (not inclusive)
7583             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7584             * @return the ordered range of matching journal articles
7585             * @throws SystemException if a system exception occurred
7586             */
7587            public List<JournalArticle> findByG_F(long groupId, long[] folderIds,
7588                    int start, int end, OrderByComparator orderByComparator)
7589                    throws SystemException {
7590                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
7591                    Object[] finderArgs = null;
7592    
7593                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7594                                    (orderByComparator == null)) {
7595                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
7596                    }
7597                    else {
7598                            finderArgs = new Object[] {
7599                                            groupId, StringUtil.merge(folderIds),
7600                                            
7601                                            start, end, orderByComparator
7602                                    };
7603                    }
7604    
7605                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7606                                    finderArgs, this);
7607    
7608                    if ((list != null) && !list.isEmpty()) {
7609                            for (JournalArticle journalArticle : list) {
7610                                    if ((groupId != journalArticle.getGroupId()) ||
7611                                                    !ArrayUtil.contains(folderIds,
7612                                                            journalArticle.getFolderId())) {
7613                                            list = null;
7614    
7615                                            break;
7616                                    }
7617                            }
7618                    }
7619    
7620                    if (list == null) {
7621                            StringBundler query = new StringBundler();
7622    
7623                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7624    
7625                            boolean conjunctionable = false;
7626    
7627                            if (conjunctionable) {
7628                                    query.append(WHERE_AND);
7629                            }
7630    
7631                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7632    
7633                            conjunctionable = true;
7634    
7635                            if ((folderIds == null) || (folderIds.length > 0)) {
7636                                    if (conjunctionable) {
7637                                            query.append(WHERE_AND);
7638                                    }
7639    
7640                                    query.append(StringPool.OPEN_PARENTHESIS);
7641    
7642                                    for (int i = 0; i < folderIds.length; i++) {
7643                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7644    
7645                                            if ((i + 1) < folderIds.length) {
7646                                                    query.append(WHERE_OR);
7647                                            }
7648                                    }
7649    
7650                                    query.append(StringPool.CLOSE_PARENTHESIS);
7651    
7652                                    conjunctionable = true;
7653                            }
7654    
7655                            if (orderByComparator != null) {
7656                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7657                                            orderByComparator);
7658                            }
7659    
7660                            else {
7661                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7662                            }
7663    
7664                            String sql = query.toString();
7665    
7666                            Session session = null;
7667    
7668                            try {
7669                                    session = openSession();
7670    
7671                                    Query q = session.createQuery(sql);
7672    
7673                                    QueryPos qPos = QueryPos.getInstance(q);
7674    
7675                                    qPos.add(groupId);
7676    
7677                                    if (folderIds != null) {
7678                                            qPos.add(folderIds);
7679                                    }
7680    
7681                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
7682                                                    start, end);
7683                            }
7684                            catch (Exception e) {
7685                                    throw processException(e);
7686                            }
7687                            finally {
7688                                    if (list == null) {
7689                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7690                                    }
7691                                    else {
7692                                            cacheResult(list);
7693    
7694                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7695                                    }
7696    
7697                                    closeSession(session);
7698                            }
7699                    }
7700    
7701                    return list;
7702            }
7703    
7704            /**
7705             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7706             *
7707             * @param groupId the group ID
7708             * @param folderId the folder ID
7709             * @return the matching journal articles that the user has permission to view
7710             * @throws SystemException if a system exception occurred
7711             */
7712            public List<JournalArticle> filterFindByG_F(long groupId, long folderId)
7713                    throws SystemException {
7714                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
7715                            QueryUtil.ALL_POS, null);
7716            }
7717    
7718            /**
7719             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7720             *
7721             * <p>
7722             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7723             * </p>
7724             *
7725             * @param groupId the group ID
7726             * @param folderId the folder ID
7727             * @param start the lower bound of the range of journal articles
7728             * @param end the upper bound of the range of journal articles (not inclusive)
7729             * @return the range of matching journal articles that the user has permission to view
7730             * @throws SystemException if a system exception occurred
7731             */
7732            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
7733                    int start, int end) throws SystemException {
7734                    return filterFindByG_F(groupId, folderId, start, end, null);
7735            }
7736    
7737            /**
7738             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63;.
7739             *
7740             * <p>
7741             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7742             * </p>
7743             *
7744             * @param groupId the group ID
7745             * @param folderId the folder ID
7746             * @param start the lower bound of the range of journal articles
7747             * @param end the upper bound of the range of journal articles (not inclusive)
7748             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7749             * @return the ordered range of matching journal articles that the user has permission to view
7750             * @throws SystemException if a system exception occurred
7751             */
7752            public List<JournalArticle> filterFindByG_F(long groupId, long folderId,
7753                    int start, int end, OrderByComparator orderByComparator)
7754                    throws SystemException {
7755                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7756                            return findByG_F(groupId, folderId, start, end, orderByComparator);
7757                    }
7758    
7759                    StringBundler query = null;
7760    
7761                    if (orderByComparator != null) {
7762                            query = new StringBundler(4 +
7763                                            (orderByComparator.getOrderByFields().length * 3));
7764                    }
7765                    else {
7766                            query = new StringBundler(4);
7767                    }
7768    
7769                    if (getDB().isSupportsInlineDistinct()) {
7770                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7771                    }
7772                    else {
7773                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7774                    }
7775    
7776                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7777    
7778                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7779    
7780                    if (!getDB().isSupportsInlineDistinct()) {
7781                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7782                    }
7783    
7784                    if (orderByComparator != null) {
7785                            if (getDB().isSupportsInlineDistinct()) {
7786                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7787                                            orderByComparator);
7788                            }
7789                            else {
7790                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7791                                            orderByComparator);
7792                            }
7793                    }
7794    
7795                    else {
7796                            if (getDB().isSupportsInlineDistinct()) {
7797                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7798                            }
7799                            else {
7800                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7801                            }
7802                    }
7803    
7804                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7805                                    JournalArticle.class.getName(),
7806                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7807    
7808                    Session session = null;
7809    
7810                    try {
7811                            session = openSession();
7812    
7813                            SQLQuery q = session.createSQLQuery(sql);
7814    
7815                            if (getDB().isSupportsInlineDistinct()) {
7816                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7817                            }
7818                            else {
7819                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7820                            }
7821    
7822                            QueryPos qPos = QueryPos.getInstance(q);
7823    
7824                            qPos.add(groupId);
7825    
7826                            qPos.add(folderId);
7827    
7828                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7829                                    end);
7830                    }
7831                    catch (Exception e) {
7832                            throw processException(e);
7833                    }
7834                    finally {
7835                            closeSession(session);
7836                    }
7837            }
7838    
7839            /**
7840             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
7841             *
7842             * @param id the primary key of the current journal article
7843             * @param groupId the group ID
7844             * @param folderId the folder ID
7845             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7846             * @return the previous, current, and next journal article
7847             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7848             * @throws SystemException if a system exception occurred
7849             */
7850            public JournalArticle[] filterFindByG_F_PrevAndNext(long id, long groupId,
7851                    long folderId, OrderByComparator orderByComparator)
7852                    throws NoSuchArticleException, SystemException {
7853                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7854                            return findByG_F_PrevAndNext(id, groupId, folderId,
7855                                    orderByComparator);
7856                    }
7857    
7858                    JournalArticle journalArticle = findByPrimaryKey(id);
7859    
7860                    Session session = null;
7861    
7862                    try {
7863                            session = openSession();
7864    
7865                            JournalArticle[] array = new JournalArticleImpl[3];
7866    
7867                            array[0] = filterGetByG_F_PrevAndNext(session, journalArticle,
7868                                            groupId, folderId, orderByComparator, true);
7869    
7870                            array[1] = journalArticle;
7871    
7872                            array[2] = filterGetByG_F_PrevAndNext(session, journalArticle,
7873                                            groupId, folderId, orderByComparator, false);
7874    
7875                            return array;
7876                    }
7877                    catch (Exception e) {
7878                            throw processException(e);
7879                    }
7880                    finally {
7881                            closeSession(session);
7882                    }
7883            }
7884    
7885            protected JournalArticle filterGetByG_F_PrevAndNext(Session session,
7886                    JournalArticle journalArticle, long groupId, long folderId,
7887                    OrderByComparator orderByComparator, boolean previous) {
7888                    StringBundler query = null;
7889    
7890                    if (orderByComparator != null) {
7891                            query = new StringBundler(6 +
7892                                            (orderByComparator.getOrderByFields().length * 6));
7893                    }
7894                    else {
7895                            query = new StringBundler(3);
7896                    }
7897    
7898                    if (getDB().isSupportsInlineDistinct()) {
7899                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7900                    }
7901                    else {
7902                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7903                    }
7904    
7905                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7906    
7907                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7908    
7909                    if (!getDB().isSupportsInlineDistinct()) {
7910                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7911                    }
7912    
7913                    if (orderByComparator != null) {
7914                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7915    
7916                            if (orderByConditionFields.length > 0) {
7917                                    query.append(WHERE_AND);
7918                            }
7919    
7920                            for (int i = 0; i < orderByConditionFields.length; i++) {
7921                                    if (getDB().isSupportsInlineDistinct()) {
7922                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7923                                    }
7924                                    else {
7925                                            query.append(_ORDER_BY_ENTITY_TABLE);
7926                                    }
7927    
7928                                    query.append(orderByConditionFields[i]);
7929    
7930                                    if ((i + 1) < orderByConditionFields.length) {
7931                                            if (orderByComparator.isAscending() ^ previous) {
7932                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7933                                            }
7934                                            else {
7935                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7936                                            }
7937                                    }
7938                                    else {
7939                                            if (orderByComparator.isAscending() ^ previous) {
7940                                                    query.append(WHERE_GREATER_THAN);
7941                                            }
7942                                            else {
7943                                                    query.append(WHERE_LESSER_THAN);
7944                                            }
7945                                    }
7946                            }
7947    
7948                            query.append(ORDER_BY_CLAUSE);
7949    
7950                            String[] orderByFields = orderByComparator.getOrderByFields();
7951    
7952                            for (int i = 0; i < orderByFields.length; i++) {
7953                                    if (getDB().isSupportsInlineDistinct()) {
7954                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7955                                    }
7956                                    else {
7957                                            query.append(_ORDER_BY_ENTITY_TABLE);
7958                                    }
7959    
7960                                    query.append(orderByFields[i]);
7961    
7962                                    if ((i + 1) < orderByFields.length) {
7963                                            if (orderByComparator.isAscending() ^ previous) {
7964                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7965                                            }
7966                                            else {
7967                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7968                                            }
7969                                    }
7970                                    else {
7971                                            if (orderByComparator.isAscending() ^ previous) {
7972                                                    query.append(ORDER_BY_ASC);
7973                                            }
7974                                            else {
7975                                                    query.append(ORDER_BY_DESC);
7976                                            }
7977                                    }
7978                            }
7979                    }
7980    
7981                    else {
7982                            if (getDB().isSupportsInlineDistinct()) {
7983                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7984                            }
7985                            else {
7986                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7987                            }
7988                    }
7989    
7990                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7991                                    JournalArticle.class.getName(),
7992                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7993    
7994                    SQLQuery q = session.createSQLQuery(sql);
7995    
7996                    q.setFirstResult(0);
7997                    q.setMaxResults(2);
7998    
7999                    if (getDB().isSupportsInlineDistinct()) {
8000                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8001                    }
8002                    else {
8003                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8004                    }
8005    
8006                    QueryPos qPos = QueryPos.getInstance(q);
8007    
8008                    qPos.add(groupId);
8009    
8010                    qPos.add(folderId);
8011    
8012                    if (orderByComparator != null) {
8013                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8014    
8015                            for (Object value : values) {
8016                                    qPos.add(value);
8017                            }
8018                    }
8019    
8020                    List<JournalArticle> list = q.list();
8021    
8022                    if (list.size() == 2) {
8023                            return list.get(1);
8024                    }
8025                    else {
8026                            return null;
8027                    }
8028            }
8029    
8030            /**
8031             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8032             *
8033             * @param groupId the group ID
8034             * @param folderIds the folder IDs
8035             * @return the matching journal articles that the user has permission to view
8036             * @throws SystemException if a system exception occurred
8037             */
8038            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds)
8039                    throws SystemException {
8040                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
8041                            QueryUtil.ALL_POS, null);
8042            }
8043    
8044            /**
8045             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8046             *
8047             * <p>
8048             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8049             * </p>
8050             *
8051             * @param groupId the group ID
8052             * @param folderIds the folder IDs
8053             * @param start the lower bound of the range of journal articles
8054             * @param end the upper bound of the range of journal articles (not inclusive)
8055             * @return the range of matching journal articles that the user has permission to view
8056             * @throws SystemException if a system exception occurred
8057             */
8058            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8059                    int start, int end) throws SystemException {
8060                    return filterFindByG_F(groupId, folderIds, start, end, null);
8061            }
8062    
8063            /**
8064             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
8065             *
8066             * <p>
8067             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8068             * </p>
8069             *
8070             * @param groupId the group ID
8071             * @param folderIds the folder IDs
8072             * @param start the lower bound of the range of journal articles
8073             * @param end the upper bound of the range of journal articles (not inclusive)
8074             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8075             * @return the ordered range of matching journal articles that the user has permission to view
8076             * @throws SystemException if a system exception occurred
8077             */
8078            public List<JournalArticle> filterFindByG_F(long groupId, long[] folderIds,
8079                    int start, int end, OrderByComparator orderByComparator)
8080                    throws SystemException {
8081                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8082                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
8083                    }
8084    
8085                    StringBundler query = new StringBundler();
8086    
8087                    if (getDB().isSupportsInlineDistinct()) {
8088                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8089                    }
8090                    else {
8091                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8092                    }
8093    
8094                    boolean conjunctionable = false;
8095    
8096                    if (conjunctionable) {
8097                            query.append(WHERE_AND);
8098                    }
8099    
8100                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
8101    
8102                    conjunctionable = true;
8103    
8104                    if ((folderIds == null) || (folderIds.length > 0)) {
8105                            if (conjunctionable) {
8106                                    query.append(WHERE_AND);
8107                            }
8108    
8109                            query.append(StringPool.OPEN_PARENTHESIS);
8110    
8111                            for (int i = 0; i < folderIds.length; i++) {
8112                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
8113    
8114                                    if ((i + 1) < folderIds.length) {
8115                                            query.append(WHERE_OR);
8116                                    }
8117                            }
8118    
8119                            query.append(StringPool.CLOSE_PARENTHESIS);
8120    
8121                            conjunctionable = true;
8122                    }
8123    
8124                    if (!getDB().isSupportsInlineDistinct()) {
8125                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8126                    }
8127    
8128                    if (orderByComparator != null) {
8129                            if (getDB().isSupportsInlineDistinct()) {
8130                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8131                                            orderByComparator);
8132                            }
8133                            else {
8134                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8135                                            orderByComparator);
8136                            }
8137                    }
8138    
8139                    else {
8140                            if (getDB().isSupportsInlineDistinct()) {
8141                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8142                            }
8143                            else {
8144                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8145                            }
8146                    }
8147    
8148                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8149                                    JournalArticle.class.getName(),
8150                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8151    
8152                    Session session = null;
8153    
8154                    try {
8155                            session = openSession();
8156    
8157                            SQLQuery q = session.createSQLQuery(sql);
8158    
8159                            if (getDB().isSupportsInlineDistinct()) {
8160                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8161                            }
8162                            else {
8163                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8164                            }
8165    
8166                            QueryPos qPos = QueryPos.getInstance(q);
8167    
8168                            qPos.add(groupId);
8169    
8170                            if (folderIds != null) {
8171                                    qPos.add(folderIds);
8172                            }
8173    
8174                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8175                                    end);
8176                    }
8177                    catch (Exception e) {
8178                            throw processException(e);
8179                    }
8180                    finally {
8181                            closeSession(session);
8182                    }
8183            }
8184    
8185            /**
8186             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
8187             *
8188             * @param groupId the group ID
8189             * @param articleId the article ID
8190             * @return the matching journal articles
8191             * @throws SystemException if a system exception occurred
8192             */
8193            public List<JournalArticle> findByG_A(long groupId, String articleId)
8194                    throws SystemException {
8195                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
8196                            QueryUtil.ALL_POS, null);
8197            }
8198    
8199            /**
8200             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
8201             *
8202             * <p>
8203             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8204             * </p>
8205             *
8206             * @param groupId the group ID
8207             * @param articleId the article ID
8208             * @param start the lower bound of the range of journal articles
8209             * @param end the upper bound of the range of journal articles (not inclusive)
8210             * @return the range of matching journal articles
8211             * @throws SystemException if a system exception occurred
8212             */
8213            public List<JournalArticle> findByG_A(long groupId, String articleId,
8214                    int start, int end) throws SystemException {
8215                    return findByG_A(groupId, articleId, start, end, null);
8216            }
8217    
8218            /**
8219             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
8220             *
8221             * <p>
8222             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8223             * </p>
8224             *
8225             * @param groupId the group ID
8226             * @param articleId the article ID
8227             * @param start the lower bound of the range of journal articles
8228             * @param end the upper bound of the range of journal articles (not inclusive)
8229             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8230             * @return the ordered range of matching journal articles
8231             * @throws SystemException if a system exception occurred
8232             */
8233            public List<JournalArticle> findByG_A(long groupId, String articleId,
8234                    int start, int end, OrderByComparator orderByComparator)
8235                    throws SystemException {
8236                    FinderPath finderPath = null;
8237                    Object[] finderArgs = null;
8238    
8239                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8240                                    (orderByComparator == null)) {
8241                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
8242                            finderArgs = new Object[] { groupId, articleId };
8243                    }
8244                    else {
8245                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
8246                            finderArgs = new Object[] {
8247                                            groupId, articleId,
8248                                            
8249                                            start, end, orderByComparator
8250                                    };
8251                    }
8252    
8253                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8254                                    finderArgs, this);
8255    
8256                    if ((list != null) && !list.isEmpty()) {
8257                            for (JournalArticle journalArticle : list) {
8258                                    if ((groupId != journalArticle.getGroupId()) ||
8259                                                    !Validator.equals(articleId,
8260                                                            journalArticle.getArticleId())) {
8261                                            list = null;
8262    
8263                                            break;
8264                                    }
8265                            }
8266                    }
8267    
8268                    if (list == null) {
8269                            StringBundler query = null;
8270    
8271                            if (orderByComparator != null) {
8272                                    query = new StringBundler(4 +
8273                                                    (orderByComparator.getOrderByFields().length * 3));
8274                            }
8275                            else {
8276                                    query = new StringBundler(4);
8277                            }
8278    
8279                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8280    
8281                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8282    
8283                            if (articleId == null) {
8284                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8285                            }
8286                            else {
8287                                    if (articleId.equals(StringPool.BLANK)) {
8288                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8289                                    }
8290                                    else {
8291                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8292                                    }
8293                            }
8294    
8295                            if (orderByComparator != null) {
8296                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8297                                            orderByComparator);
8298                            }
8299    
8300                            else {
8301                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8302                            }
8303    
8304                            String sql = query.toString();
8305    
8306                            Session session = null;
8307    
8308                            try {
8309                                    session = openSession();
8310    
8311                                    Query q = session.createQuery(sql);
8312    
8313                                    QueryPos qPos = QueryPos.getInstance(q);
8314    
8315                                    qPos.add(groupId);
8316    
8317                                    if (articleId != null) {
8318                                            qPos.add(articleId);
8319                                    }
8320    
8321                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
8322                                                    start, end);
8323                            }
8324                            catch (Exception e) {
8325                                    throw processException(e);
8326                            }
8327                            finally {
8328                                    if (list == null) {
8329                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8330                                    }
8331                                    else {
8332                                            cacheResult(list);
8333    
8334                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8335                                    }
8336    
8337                                    closeSession(session);
8338                            }
8339                    }
8340    
8341                    return list;
8342            }
8343    
8344            /**
8345             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8346             *
8347             * @param groupId the group ID
8348             * @param articleId the article ID
8349             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8350             * @return the first matching journal article
8351             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8352             * @throws SystemException if a system exception occurred
8353             */
8354            public JournalArticle findByG_A_First(long groupId, String articleId,
8355                    OrderByComparator orderByComparator)
8356                    throws NoSuchArticleException, SystemException {
8357                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
8358                                    orderByComparator);
8359    
8360                    if (journalArticle != null) {
8361                            return journalArticle;
8362                    }
8363    
8364                    StringBundler msg = new StringBundler(6);
8365    
8366                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8367    
8368                    msg.append("groupId=");
8369                    msg.append(groupId);
8370    
8371                    msg.append(", articleId=");
8372                    msg.append(articleId);
8373    
8374                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8375    
8376                    throw new NoSuchArticleException(msg.toString());
8377            }
8378    
8379            /**
8380             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8381             *
8382             * @param groupId the group ID
8383             * @param articleId the article ID
8384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8385             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
8386             * @throws SystemException if a system exception occurred
8387             */
8388            public JournalArticle fetchByG_A_First(long groupId, String articleId,
8389                    OrderByComparator orderByComparator) throws SystemException {
8390                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
8391                                    orderByComparator);
8392    
8393                    if (!list.isEmpty()) {
8394                            return list.get(0);
8395                    }
8396    
8397                    return null;
8398            }
8399    
8400            /**
8401             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8402             *
8403             * @param groupId the group ID
8404             * @param articleId the article ID
8405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8406             * @return the last matching journal article
8407             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8408             * @throws SystemException if a system exception occurred
8409             */
8410            public JournalArticle findByG_A_Last(long groupId, String articleId,
8411                    OrderByComparator orderByComparator)
8412                    throws NoSuchArticleException, SystemException {
8413                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
8414                                    orderByComparator);
8415    
8416                    if (journalArticle != null) {
8417                            return journalArticle;
8418                    }
8419    
8420                    StringBundler msg = new StringBundler(6);
8421    
8422                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8423    
8424                    msg.append("groupId=");
8425                    msg.append(groupId);
8426    
8427                    msg.append(", articleId=");
8428                    msg.append(articleId);
8429    
8430                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8431    
8432                    throw new NoSuchArticleException(msg.toString());
8433            }
8434    
8435            /**
8436             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8437             *
8438             * @param groupId the group ID
8439             * @param articleId the article ID
8440             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8441             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
8442             * @throws SystemException if a system exception occurred
8443             */
8444            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
8445                    OrderByComparator orderByComparator) throws SystemException {
8446                    int count = countByG_A(groupId, articleId);
8447    
8448                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
8449                                    count, orderByComparator);
8450    
8451                    if (!list.isEmpty()) {
8452                            return list.get(0);
8453                    }
8454    
8455                    return null;
8456            }
8457    
8458            /**
8459             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
8460             *
8461             * @param id the primary key of the current journal article
8462             * @param groupId the group ID
8463             * @param articleId the article ID
8464             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8465             * @return the previous, current, and next journal article
8466             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8467             * @throws SystemException if a system exception occurred
8468             */
8469            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
8470                    String articleId, OrderByComparator orderByComparator)
8471                    throws NoSuchArticleException, SystemException {
8472                    JournalArticle journalArticle = findByPrimaryKey(id);
8473    
8474                    Session session = null;
8475    
8476                    try {
8477                            session = openSession();
8478    
8479                            JournalArticle[] array = new JournalArticleImpl[3];
8480    
8481                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
8482                                            articleId, orderByComparator, true);
8483    
8484                            array[1] = journalArticle;
8485    
8486                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
8487                                            articleId, orderByComparator, false);
8488    
8489                            return array;
8490                    }
8491                    catch (Exception e) {
8492                            throw processException(e);
8493                    }
8494                    finally {
8495                            closeSession(session);
8496                    }
8497            }
8498    
8499            protected JournalArticle getByG_A_PrevAndNext(Session session,
8500                    JournalArticle journalArticle, long groupId, String articleId,
8501                    OrderByComparator orderByComparator, boolean previous) {
8502                    StringBundler query = null;
8503    
8504                    if (orderByComparator != null) {
8505                            query = new StringBundler(6 +
8506                                            (orderByComparator.getOrderByFields().length * 6));
8507                    }
8508                    else {
8509                            query = new StringBundler(3);
8510                    }
8511    
8512                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8513    
8514                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8515    
8516                    if (articleId == null) {
8517                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8518                    }
8519                    else {
8520                            if (articleId.equals(StringPool.BLANK)) {
8521                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8522                            }
8523                            else {
8524                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8525                            }
8526                    }
8527    
8528                    if (orderByComparator != null) {
8529                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8530    
8531                            if (orderByConditionFields.length > 0) {
8532                                    query.append(WHERE_AND);
8533                            }
8534    
8535                            for (int i = 0; i < orderByConditionFields.length; i++) {
8536                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8537                                    query.append(orderByConditionFields[i]);
8538    
8539                                    if ((i + 1) < orderByConditionFields.length) {
8540                                            if (orderByComparator.isAscending() ^ previous) {
8541                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8542                                            }
8543                                            else {
8544                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8545                                            }
8546                                    }
8547                                    else {
8548                                            if (orderByComparator.isAscending() ^ previous) {
8549                                                    query.append(WHERE_GREATER_THAN);
8550                                            }
8551                                            else {
8552                                                    query.append(WHERE_LESSER_THAN);
8553                                            }
8554                                    }
8555                            }
8556    
8557                            query.append(ORDER_BY_CLAUSE);
8558    
8559                            String[] orderByFields = orderByComparator.getOrderByFields();
8560    
8561                            for (int i = 0; i < orderByFields.length; i++) {
8562                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8563                                    query.append(orderByFields[i]);
8564    
8565                                    if ((i + 1) < orderByFields.length) {
8566                                            if (orderByComparator.isAscending() ^ previous) {
8567                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8568                                            }
8569                                            else {
8570                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8571                                            }
8572                                    }
8573                                    else {
8574                                            if (orderByComparator.isAscending() ^ previous) {
8575                                                    query.append(ORDER_BY_ASC);
8576                                            }
8577                                            else {
8578                                                    query.append(ORDER_BY_DESC);
8579                                            }
8580                                    }
8581                            }
8582                    }
8583    
8584                    else {
8585                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8586                    }
8587    
8588                    String sql = query.toString();
8589    
8590                    Query q = session.createQuery(sql);
8591    
8592                    q.setFirstResult(0);
8593                    q.setMaxResults(2);
8594    
8595                    QueryPos qPos = QueryPos.getInstance(q);
8596    
8597                    qPos.add(groupId);
8598    
8599                    if (articleId != null) {
8600                            qPos.add(articleId);
8601                    }
8602    
8603                    if (orderByComparator != null) {
8604                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8605    
8606                            for (Object value : values) {
8607                                    qPos.add(value);
8608                            }
8609                    }
8610    
8611                    List<JournalArticle> list = q.list();
8612    
8613                    if (list.size() == 2) {
8614                            return list.get(1);
8615                    }
8616                    else {
8617                            return null;
8618                    }
8619            }
8620    
8621            /**
8622             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
8623             *
8624             * @param groupId the group ID
8625             * @param articleId the article ID
8626             * @return the matching journal articles that the user has permission to view
8627             * @throws SystemException if a system exception occurred
8628             */
8629            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
8630                    throws SystemException {
8631                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
8632                            QueryUtil.ALL_POS, null);
8633            }
8634    
8635            /**
8636             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
8637             *
8638             * <p>
8639             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8640             * </p>
8641             *
8642             * @param groupId the group ID
8643             * @param articleId the article ID
8644             * @param start the lower bound of the range of journal articles
8645             * @param end the upper bound of the range of journal articles (not inclusive)
8646             * @return the range of matching journal articles that the user has permission to view
8647             * @throws SystemException if a system exception occurred
8648             */
8649            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
8650                    int start, int end) throws SystemException {
8651                    return filterFindByG_A(groupId, articleId, start, end, null);
8652            }
8653    
8654            /**
8655             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
8656             *
8657             * <p>
8658             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8659             * </p>
8660             *
8661             * @param groupId the group ID
8662             * @param articleId the article ID
8663             * @param start the lower bound of the range of journal articles
8664             * @param end the upper bound of the range of journal articles (not inclusive)
8665             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8666             * @return the ordered range of matching journal articles that the user has permission to view
8667             * @throws SystemException if a system exception occurred
8668             */
8669            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
8670                    int start, int end, OrderByComparator orderByComparator)
8671                    throws SystemException {
8672                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8673                            return findByG_A(groupId, articleId, start, end, orderByComparator);
8674                    }
8675    
8676                    StringBundler query = null;
8677    
8678                    if (orderByComparator != null) {
8679                            query = new StringBundler(4 +
8680                                            (orderByComparator.getOrderByFields().length * 3));
8681                    }
8682                    else {
8683                            query = new StringBundler(4);
8684                    }
8685    
8686                    if (getDB().isSupportsInlineDistinct()) {
8687                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8688                    }
8689                    else {
8690                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8691                    }
8692    
8693                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8694    
8695                    if (articleId == null) {
8696                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8697                    }
8698                    else {
8699                            if (articleId.equals(StringPool.BLANK)) {
8700                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8701                            }
8702                            else {
8703                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8704                            }
8705                    }
8706    
8707                    if (!getDB().isSupportsInlineDistinct()) {
8708                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8709                    }
8710    
8711                    if (orderByComparator != null) {
8712                            if (getDB().isSupportsInlineDistinct()) {
8713                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8714                                            orderByComparator);
8715                            }
8716                            else {
8717                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8718                                            orderByComparator);
8719                            }
8720                    }
8721    
8722                    else {
8723                            if (getDB().isSupportsInlineDistinct()) {
8724                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8725                            }
8726                            else {
8727                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8728                            }
8729                    }
8730    
8731                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8732                                    JournalArticle.class.getName(),
8733                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8734    
8735                    Session session = null;
8736    
8737                    try {
8738                            session = openSession();
8739    
8740                            SQLQuery q = session.createSQLQuery(sql);
8741    
8742                            if (getDB().isSupportsInlineDistinct()) {
8743                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8744                            }
8745                            else {
8746                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8747                            }
8748    
8749                            QueryPos qPos = QueryPos.getInstance(q);
8750    
8751                            qPos.add(groupId);
8752    
8753                            if (articleId != null) {
8754                                    qPos.add(articleId);
8755                            }
8756    
8757                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8758                                    end);
8759                    }
8760                    catch (Exception e) {
8761                            throw processException(e);
8762                    }
8763                    finally {
8764                            closeSession(session);
8765                    }
8766            }
8767    
8768            /**
8769             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
8770             *
8771             * @param id the primary key of the current journal article
8772             * @param groupId the group ID
8773             * @param articleId the article ID
8774             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8775             * @return the previous, current, and next journal article
8776             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8777             * @throws SystemException if a system exception occurred
8778             */
8779            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
8780                    String articleId, OrderByComparator orderByComparator)
8781                    throws NoSuchArticleException, SystemException {
8782                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8783                            return findByG_A_PrevAndNext(id, groupId, articleId,
8784                                    orderByComparator);
8785                    }
8786    
8787                    JournalArticle journalArticle = findByPrimaryKey(id);
8788    
8789                    Session session = null;
8790    
8791                    try {
8792                            session = openSession();
8793    
8794                            JournalArticle[] array = new JournalArticleImpl[3];
8795    
8796                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
8797                                            groupId, articleId, orderByComparator, true);
8798    
8799                            array[1] = journalArticle;
8800    
8801                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
8802                                            groupId, articleId, orderByComparator, false);
8803    
8804                            return array;
8805                    }
8806                    catch (Exception e) {
8807                            throw processException(e);
8808                    }
8809                    finally {
8810                            closeSession(session);
8811                    }
8812            }
8813    
8814            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
8815                    JournalArticle journalArticle, long groupId, String articleId,
8816                    OrderByComparator orderByComparator, boolean previous) {
8817                    StringBundler query = null;
8818    
8819                    if (orderByComparator != null) {
8820                            query = new StringBundler(6 +
8821                                            (orderByComparator.getOrderByFields().length * 6));
8822                    }
8823                    else {
8824                            query = new StringBundler(3);
8825                    }
8826    
8827                    if (getDB().isSupportsInlineDistinct()) {
8828                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8829                    }
8830                    else {
8831                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8832                    }
8833    
8834                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
8835    
8836                    if (articleId == null) {
8837                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
8838                    }
8839                    else {
8840                            if (articleId.equals(StringPool.BLANK)) {
8841                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
8842                            }
8843                            else {
8844                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
8845                            }
8846                    }
8847    
8848                    if (!getDB().isSupportsInlineDistinct()) {
8849                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8850                    }
8851    
8852                    if (orderByComparator != null) {
8853                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8854    
8855                            if (orderByConditionFields.length > 0) {
8856                                    query.append(WHERE_AND);
8857                            }
8858    
8859                            for (int i = 0; i < orderByConditionFields.length; i++) {
8860                                    if (getDB().isSupportsInlineDistinct()) {
8861                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8862                                    }
8863                                    else {
8864                                            query.append(_ORDER_BY_ENTITY_TABLE);
8865                                    }
8866    
8867                                    query.append(orderByConditionFields[i]);
8868    
8869                                    if ((i + 1) < orderByConditionFields.length) {
8870                                            if (orderByComparator.isAscending() ^ previous) {
8871                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8872                                            }
8873                                            else {
8874                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8875                                            }
8876                                    }
8877                                    else {
8878                                            if (orderByComparator.isAscending() ^ previous) {
8879                                                    query.append(WHERE_GREATER_THAN);
8880                                            }
8881                                            else {
8882                                                    query.append(WHERE_LESSER_THAN);
8883                                            }
8884                                    }
8885                            }
8886    
8887                            query.append(ORDER_BY_CLAUSE);
8888    
8889                            String[] orderByFields = orderByComparator.getOrderByFields();
8890    
8891                            for (int i = 0; i < orderByFields.length; i++) {
8892                                    if (getDB().isSupportsInlineDistinct()) {
8893                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8894                                    }
8895                                    else {
8896                                            query.append(_ORDER_BY_ENTITY_TABLE);
8897                                    }
8898    
8899                                    query.append(orderByFields[i]);
8900    
8901                                    if ((i + 1) < orderByFields.length) {
8902                                            if (orderByComparator.isAscending() ^ previous) {
8903                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8904                                            }
8905                                            else {
8906                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8907                                            }
8908                                    }
8909                                    else {
8910                                            if (orderByComparator.isAscending() ^ previous) {
8911                                                    query.append(ORDER_BY_ASC);
8912                                            }
8913                                            else {
8914                                                    query.append(ORDER_BY_DESC);
8915                                            }
8916                                    }
8917                            }
8918                    }
8919    
8920                    else {
8921                            if (getDB().isSupportsInlineDistinct()) {
8922                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8923                            }
8924                            else {
8925                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8926                            }
8927                    }
8928    
8929                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8930                                    JournalArticle.class.getName(),
8931                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8932    
8933                    SQLQuery q = session.createSQLQuery(sql);
8934    
8935                    q.setFirstResult(0);
8936                    q.setMaxResults(2);
8937    
8938                    if (getDB().isSupportsInlineDistinct()) {
8939                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8940                    }
8941                    else {
8942                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8943                    }
8944    
8945                    QueryPos qPos = QueryPos.getInstance(q);
8946    
8947                    qPos.add(groupId);
8948    
8949                    if (articleId != null) {
8950                            qPos.add(articleId);
8951                    }
8952    
8953                    if (orderByComparator != null) {
8954                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8955    
8956                            for (Object value : values) {
8957                                    qPos.add(value);
8958                            }
8959                    }
8960    
8961                    List<JournalArticle> list = q.list();
8962    
8963                    if (list.size() == 2) {
8964                            return list.get(1);
8965                    }
8966                    else {
8967                            return null;
8968                    }
8969            }
8970    
8971            /**
8972             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
8973             *
8974             * @param groupId the group ID
8975             * @param urlTitle the url title
8976             * @return the matching journal articles
8977             * @throws SystemException if a system exception occurred
8978             */
8979            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
8980                    throws SystemException {
8981                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
8982                            QueryUtil.ALL_POS, null);
8983            }
8984    
8985            /**
8986             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
8987             *
8988             * <p>
8989             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8990             * </p>
8991             *
8992             * @param groupId the group ID
8993             * @param urlTitle the url title
8994             * @param start the lower bound of the range of journal articles
8995             * @param end the upper bound of the range of journal articles (not inclusive)
8996             * @return the range of matching journal articles
8997             * @throws SystemException if a system exception occurred
8998             */
8999            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
9000                    int start, int end) throws SystemException {
9001                    return findByG_UT(groupId, urlTitle, start, end, null);
9002            }
9003    
9004            /**
9005             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
9006             *
9007             * <p>
9008             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9009             * </p>
9010             *
9011             * @param groupId the group ID
9012             * @param urlTitle the url title
9013             * @param start the lower bound of the range of journal articles
9014             * @param end the upper bound of the range of journal articles (not inclusive)
9015             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9016             * @return the ordered range of matching journal articles
9017             * @throws SystemException if a system exception occurred
9018             */
9019            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
9020                    int start, int end, OrderByComparator orderByComparator)
9021                    throws SystemException {
9022                    FinderPath finderPath = null;
9023                    Object[] finderArgs = null;
9024    
9025                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9026                                    (orderByComparator == null)) {
9027                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
9028                            finderArgs = new Object[] { groupId, urlTitle };
9029                    }
9030                    else {
9031                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
9032                            finderArgs = new Object[] {
9033                                            groupId, urlTitle,
9034                                            
9035                                            start, end, orderByComparator
9036                                    };
9037                    }
9038    
9039                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9040                                    finderArgs, this);
9041    
9042                    if ((list != null) && !list.isEmpty()) {
9043                            for (JournalArticle journalArticle : list) {
9044                                    if ((groupId != journalArticle.getGroupId()) ||
9045                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
9046                                            list = null;
9047    
9048                                            break;
9049                                    }
9050                            }
9051                    }
9052    
9053                    if (list == null) {
9054                            StringBundler query = null;
9055    
9056                            if (orderByComparator != null) {
9057                                    query = new StringBundler(4 +
9058                                                    (orderByComparator.getOrderByFields().length * 3));
9059                            }
9060                            else {
9061                                    query = new StringBundler(4);
9062                            }
9063    
9064                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9065    
9066                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9067    
9068                            if (urlTitle == null) {
9069                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9070                            }
9071                            else {
9072                                    if (urlTitle.equals(StringPool.BLANK)) {
9073                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9074                                    }
9075                                    else {
9076                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9077                                    }
9078                            }
9079    
9080                            if (orderByComparator != null) {
9081                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9082                                            orderByComparator);
9083                            }
9084    
9085                            else {
9086                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9087                            }
9088    
9089                            String sql = query.toString();
9090    
9091                            Session session = null;
9092    
9093                            try {
9094                                    session = openSession();
9095    
9096                                    Query q = session.createQuery(sql);
9097    
9098                                    QueryPos qPos = QueryPos.getInstance(q);
9099    
9100                                    qPos.add(groupId);
9101    
9102                                    if (urlTitle != null) {
9103                                            qPos.add(urlTitle);
9104                                    }
9105    
9106                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
9107                                                    start, end);
9108                            }
9109                            catch (Exception e) {
9110                                    throw processException(e);
9111                            }
9112                            finally {
9113                                    if (list == null) {
9114                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9115                                    }
9116                                    else {
9117                                            cacheResult(list);
9118    
9119                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9120                                    }
9121    
9122                                    closeSession(session);
9123                            }
9124                    }
9125    
9126                    return list;
9127            }
9128    
9129            /**
9130             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9131             *
9132             * @param groupId the group ID
9133             * @param urlTitle the url title
9134             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9135             * @return the first matching journal article
9136             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9137             * @throws SystemException if a system exception occurred
9138             */
9139            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
9140                    OrderByComparator orderByComparator)
9141                    throws NoSuchArticleException, SystemException {
9142                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
9143                                    orderByComparator);
9144    
9145                    if (journalArticle != null) {
9146                            return journalArticle;
9147                    }
9148    
9149                    StringBundler msg = new StringBundler(6);
9150    
9151                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9152    
9153                    msg.append("groupId=");
9154                    msg.append(groupId);
9155    
9156                    msg.append(", urlTitle=");
9157                    msg.append(urlTitle);
9158    
9159                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9160    
9161                    throw new NoSuchArticleException(msg.toString());
9162            }
9163    
9164            /**
9165             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9166             *
9167             * @param groupId the group ID
9168             * @param urlTitle the url title
9169             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9170             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9171             * @throws SystemException if a system exception occurred
9172             */
9173            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
9174                    OrderByComparator orderByComparator) throws SystemException {
9175                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
9176                                    orderByComparator);
9177    
9178                    if (!list.isEmpty()) {
9179                            return list.get(0);
9180                    }
9181    
9182                    return null;
9183            }
9184    
9185            /**
9186             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9187             *
9188             * @param groupId the group ID
9189             * @param urlTitle the url title
9190             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9191             * @return the last matching journal article
9192             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9193             * @throws SystemException if a system exception occurred
9194             */
9195            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
9196                    OrderByComparator orderByComparator)
9197                    throws NoSuchArticleException, SystemException {
9198                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
9199                                    orderByComparator);
9200    
9201                    if (journalArticle != null) {
9202                            return journalArticle;
9203                    }
9204    
9205                    StringBundler msg = new StringBundler(6);
9206    
9207                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9208    
9209                    msg.append("groupId=");
9210                    msg.append(groupId);
9211    
9212                    msg.append(", urlTitle=");
9213                    msg.append(urlTitle);
9214    
9215                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9216    
9217                    throw new NoSuchArticleException(msg.toString());
9218            }
9219    
9220            /**
9221             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9222             *
9223             * @param groupId the group ID
9224             * @param urlTitle the url title
9225             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9226             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9227             * @throws SystemException if a system exception occurred
9228             */
9229            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
9230                    OrderByComparator orderByComparator) throws SystemException {
9231                    int count = countByG_UT(groupId, urlTitle);
9232    
9233                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
9234                                    count, orderByComparator);
9235    
9236                    if (!list.isEmpty()) {
9237                            return list.get(0);
9238                    }
9239    
9240                    return null;
9241            }
9242    
9243            /**
9244             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
9245             *
9246             * @param id the primary key of the current journal article
9247             * @param groupId the group ID
9248             * @param urlTitle the url title
9249             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9250             * @return the previous, current, and next journal article
9251             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9252             * @throws SystemException if a system exception occurred
9253             */
9254            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
9255                    String urlTitle, OrderByComparator orderByComparator)
9256                    throws NoSuchArticleException, SystemException {
9257                    JournalArticle journalArticle = findByPrimaryKey(id);
9258    
9259                    Session session = null;
9260    
9261                    try {
9262                            session = openSession();
9263    
9264                            JournalArticle[] array = new JournalArticleImpl[3];
9265    
9266                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
9267                                            urlTitle, orderByComparator, true);
9268    
9269                            array[1] = journalArticle;
9270    
9271                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
9272                                            urlTitle, orderByComparator, false);
9273    
9274                            return array;
9275                    }
9276                    catch (Exception e) {
9277                            throw processException(e);
9278                    }
9279                    finally {
9280                            closeSession(session);
9281                    }
9282            }
9283    
9284            protected JournalArticle getByG_UT_PrevAndNext(Session session,
9285                    JournalArticle journalArticle, long groupId, String urlTitle,
9286                    OrderByComparator orderByComparator, boolean previous) {
9287                    StringBundler query = null;
9288    
9289                    if (orderByComparator != null) {
9290                            query = new StringBundler(6 +
9291                                            (orderByComparator.getOrderByFields().length * 6));
9292                    }
9293                    else {
9294                            query = new StringBundler(3);
9295                    }
9296    
9297                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9298    
9299                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9300    
9301                    if (urlTitle == null) {
9302                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9303                    }
9304                    else {
9305                            if (urlTitle.equals(StringPool.BLANK)) {
9306                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9307                            }
9308                            else {
9309                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9310                            }
9311                    }
9312    
9313                    if (orderByComparator != null) {
9314                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9315    
9316                            if (orderByConditionFields.length > 0) {
9317                                    query.append(WHERE_AND);
9318                            }
9319    
9320                            for (int i = 0; i < orderByConditionFields.length; i++) {
9321                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9322                                    query.append(orderByConditionFields[i]);
9323    
9324                                    if ((i + 1) < orderByConditionFields.length) {
9325                                            if (orderByComparator.isAscending() ^ previous) {
9326                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9327                                            }
9328                                            else {
9329                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9330                                            }
9331                                    }
9332                                    else {
9333                                            if (orderByComparator.isAscending() ^ previous) {
9334                                                    query.append(WHERE_GREATER_THAN);
9335                                            }
9336                                            else {
9337                                                    query.append(WHERE_LESSER_THAN);
9338                                            }
9339                                    }
9340                            }
9341    
9342                            query.append(ORDER_BY_CLAUSE);
9343    
9344                            String[] orderByFields = orderByComparator.getOrderByFields();
9345    
9346                            for (int i = 0; i < orderByFields.length; i++) {
9347                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9348                                    query.append(orderByFields[i]);
9349    
9350                                    if ((i + 1) < orderByFields.length) {
9351                                            if (orderByComparator.isAscending() ^ previous) {
9352                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9353                                            }
9354                                            else {
9355                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9356                                            }
9357                                    }
9358                                    else {
9359                                            if (orderByComparator.isAscending() ^ previous) {
9360                                                    query.append(ORDER_BY_ASC);
9361                                            }
9362                                            else {
9363                                                    query.append(ORDER_BY_DESC);
9364                                            }
9365                                    }
9366                            }
9367                    }
9368    
9369                    else {
9370                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9371                    }
9372    
9373                    String sql = query.toString();
9374    
9375                    Query q = session.createQuery(sql);
9376    
9377                    q.setFirstResult(0);
9378                    q.setMaxResults(2);
9379    
9380                    QueryPos qPos = QueryPos.getInstance(q);
9381    
9382                    qPos.add(groupId);
9383    
9384                    if (urlTitle != null) {
9385                            qPos.add(urlTitle);
9386                    }
9387    
9388                    if (orderByComparator != null) {
9389                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9390    
9391                            for (Object value : values) {
9392                                    qPos.add(value);
9393                            }
9394                    }
9395    
9396                    List<JournalArticle> list = q.list();
9397    
9398                    if (list.size() == 2) {
9399                            return list.get(1);
9400                    }
9401                    else {
9402                            return null;
9403                    }
9404            }
9405    
9406            /**
9407             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
9408             *
9409             * @param groupId the group ID
9410             * @param urlTitle the url title
9411             * @return the matching journal articles that the user has permission to view
9412             * @throws SystemException if a system exception occurred
9413             */
9414            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
9415                    throws SystemException {
9416                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
9417                            QueryUtil.ALL_POS, null);
9418            }
9419    
9420            /**
9421             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
9422             *
9423             * <p>
9424             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9425             * </p>
9426             *
9427             * @param groupId the group ID
9428             * @param urlTitle the url title
9429             * @param start the lower bound of the range of journal articles
9430             * @param end the upper bound of the range of journal articles (not inclusive)
9431             * @return the range of matching journal articles that the user has permission to view
9432             * @throws SystemException if a system exception occurred
9433             */
9434            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
9435                    int start, int end) throws SystemException {
9436                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
9437            }
9438    
9439            /**
9440             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
9441             *
9442             * <p>
9443             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9444             * </p>
9445             *
9446             * @param groupId the group ID
9447             * @param urlTitle the url title
9448             * @param start the lower bound of the range of journal articles
9449             * @param end the upper bound of the range of journal articles (not inclusive)
9450             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9451             * @return the ordered range of matching journal articles that the user has permission to view
9452             * @throws SystemException if a system exception occurred
9453             */
9454            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
9455                    int start, int end, OrderByComparator orderByComparator)
9456                    throws SystemException {
9457                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9458                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
9459                    }
9460    
9461                    StringBundler query = null;
9462    
9463                    if (orderByComparator != null) {
9464                            query = new StringBundler(4 +
9465                                            (orderByComparator.getOrderByFields().length * 3));
9466                    }
9467                    else {
9468                            query = new StringBundler(4);
9469                    }
9470    
9471                    if (getDB().isSupportsInlineDistinct()) {
9472                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9473                    }
9474                    else {
9475                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9476                    }
9477    
9478                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9479    
9480                    if (urlTitle == null) {
9481                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9482                    }
9483                    else {
9484                            if (urlTitle.equals(StringPool.BLANK)) {
9485                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9486                            }
9487                            else {
9488                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9489                            }
9490                    }
9491    
9492                    if (!getDB().isSupportsInlineDistinct()) {
9493                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9494                    }
9495    
9496                    if (orderByComparator != null) {
9497                            if (getDB().isSupportsInlineDistinct()) {
9498                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9499                                            orderByComparator);
9500                            }
9501                            else {
9502                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9503                                            orderByComparator);
9504                            }
9505                    }
9506    
9507                    else {
9508                            if (getDB().isSupportsInlineDistinct()) {
9509                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9510                            }
9511                            else {
9512                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9513                            }
9514                    }
9515    
9516                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9517                                    JournalArticle.class.getName(),
9518                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9519    
9520                    Session session = null;
9521    
9522                    try {
9523                            session = openSession();
9524    
9525                            SQLQuery q = session.createSQLQuery(sql);
9526    
9527                            if (getDB().isSupportsInlineDistinct()) {
9528                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9529                            }
9530                            else {
9531                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9532                            }
9533    
9534                            QueryPos qPos = QueryPos.getInstance(q);
9535    
9536                            qPos.add(groupId);
9537    
9538                            if (urlTitle != null) {
9539                                    qPos.add(urlTitle);
9540                            }
9541    
9542                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9543                                    end);
9544                    }
9545                    catch (Exception e) {
9546                            throw processException(e);
9547                    }
9548                    finally {
9549                            closeSession(session);
9550                    }
9551            }
9552    
9553            /**
9554             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
9555             *
9556             * @param id the primary key of the current journal article
9557             * @param groupId the group ID
9558             * @param urlTitle the url title
9559             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9560             * @return the previous, current, and next journal article
9561             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9562             * @throws SystemException if a system exception occurred
9563             */
9564            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
9565                    String urlTitle, OrderByComparator orderByComparator)
9566                    throws NoSuchArticleException, SystemException {
9567                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9568                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
9569                                    orderByComparator);
9570                    }
9571    
9572                    JournalArticle journalArticle = findByPrimaryKey(id);
9573    
9574                    Session session = null;
9575    
9576                    try {
9577                            session = openSession();
9578    
9579                            JournalArticle[] array = new JournalArticleImpl[3];
9580    
9581                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
9582                                            groupId, urlTitle, orderByComparator, true);
9583    
9584                            array[1] = journalArticle;
9585    
9586                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
9587                                            groupId, urlTitle, orderByComparator, false);
9588    
9589                            return array;
9590                    }
9591                    catch (Exception e) {
9592                            throw processException(e);
9593                    }
9594                    finally {
9595                            closeSession(session);
9596                    }
9597            }
9598    
9599            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
9600                    JournalArticle journalArticle, long groupId, String urlTitle,
9601                    OrderByComparator orderByComparator, boolean previous) {
9602                    StringBundler query = null;
9603    
9604                    if (orderByComparator != null) {
9605                            query = new StringBundler(6 +
9606                                            (orderByComparator.getOrderByFields().length * 6));
9607                    }
9608                    else {
9609                            query = new StringBundler(3);
9610                    }
9611    
9612                    if (getDB().isSupportsInlineDistinct()) {
9613                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9614                    }
9615                    else {
9616                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9617                    }
9618    
9619                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
9620    
9621                    if (urlTitle == null) {
9622                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
9623                    }
9624                    else {
9625                            if (urlTitle.equals(StringPool.BLANK)) {
9626                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
9627                            }
9628                            else {
9629                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
9630                            }
9631                    }
9632    
9633                    if (!getDB().isSupportsInlineDistinct()) {
9634                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9635                    }
9636    
9637                    if (orderByComparator != null) {
9638                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9639    
9640                            if (orderByConditionFields.length > 0) {
9641                                    query.append(WHERE_AND);
9642                            }
9643    
9644                            for (int i = 0; i < orderByConditionFields.length; i++) {
9645                                    if (getDB().isSupportsInlineDistinct()) {
9646                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9647                                    }
9648                                    else {
9649                                            query.append(_ORDER_BY_ENTITY_TABLE);
9650                                    }
9651    
9652                                    query.append(orderByConditionFields[i]);
9653    
9654                                    if ((i + 1) < orderByConditionFields.length) {
9655                                            if (orderByComparator.isAscending() ^ previous) {
9656                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9657                                            }
9658                                            else {
9659                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9660                                            }
9661                                    }
9662                                    else {
9663                                            if (orderByComparator.isAscending() ^ previous) {
9664                                                    query.append(WHERE_GREATER_THAN);
9665                                            }
9666                                            else {
9667                                                    query.append(WHERE_LESSER_THAN);
9668                                            }
9669                                    }
9670                            }
9671    
9672                            query.append(ORDER_BY_CLAUSE);
9673    
9674                            String[] orderByFields = orderByComparator.getOrderByFields();
9675    
9676                            for (int i = 0; i < orderByFields.length; i++) {
9677                                    if (getDB().isSupportsInlineDistinct()) {
9678                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9679                                    }
9680                                    else {
9681                                            query.append(_ORDER_BY_ENTITY_TABLE);
9682                                    }
9683    
9684                                    query.append(orderByFields[i]);
9685    
9686                                    if ((i + 1) < orderByFields.length) {
9687                                            if (orderByComparator.isAscending() ^ previous) {
9688                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9689                                            }
9690                                            else {
9691                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9692                                            }
9693                                    }
9694                                    else {
9695                                            if (orderByComparator.isAscending() ^ previous) {
9696                                                    query.append(ORDER_BY_ASC);
9697                                            }
9698                                            else {
9699                                                    query.append(ORDER_BY_DESC);
9700                                            }
9701                                    }
9702                            }
9703                    }
9704    
9705                    else {
9706                            if (getDB().isSupportsInlineDistinct()) {
9707                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9708                            }
9709                            else {
9710                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9711                            }
9712                    }
9713    
9714                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9715                                    JournalArticle.class.getName(),
9716                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9717    
9718                    SQLQuery q = session.createSQLQuery(sql);
9719    
9720                    q.setFirstResult(0);
9721                    q.setMaxResults(2);
9722    
9723                    if (getDB().isSupportsInlineDistinct()) {
9724                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9725                    }
9726                    else {
9727                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9728                    }
9729    
9730                    QueryPos qPos = QueryPos.getInstance(q);
9731    
9732                    qPos.add(groupId);
9733    
9734                    if (urlTitle != null) {
9735                            qPos.add(urlTitle);
9736                    }
9737    
9738                    if (orderByComparator != null) {
9739                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9740    
9741                            for (Object value : values) {
9742                                    qPos.add(value);
9743                            }
9744                    }
9745    
9746                    List<JournalArticle> list = q.list();
9747    
9748                    if (list.size() == 2) {
9749                            return list.get(1);
9750                    }
9751                    else {
9752                            return null;
9753                    }
9754            }
9755    
9756            /**
9757             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
9758             *
9759             * @param groupId the group ID
9760             * @param structureId the structure ID
9761             * @return the matching journal articles
9762             * @throws SystemException if a system exception occurred
9763             */
9764            public List<JournalArticle> findByG_S(long groupId, String structureId)
9765                    throws SystemException {
9766                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
9767                            QueryUtil.ALL_POS, null);
9768            }
9769    
9770            /**
9771             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
9772             *
9773             * <p>
9774             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9775             * </p>
9776             *
9777             * @param groupId the group ID
9778             * @param structureId the structure ID
9779             * @param start the lower bound of the range of journal articles
9780             * @param end the upper bound of the range of journal articles (not inclusive)
9781             * @return the range of matching journal articles
9782             * @throws SystemException if a system exception occurred
9783             */
9784            public List<JournalArticle> findByG_S(long groupId, String structureId,
9785                    int start, int end) throws SystemException {
9786                    return findByG_S(groupId, structureId, start, end, null);
9787            }
9788    
9789            /**
9790             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
9791             *
9792             * <p>
9793             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9794             * </p>
9795             *
9796             * @param groupId the group ID
9797             * @param structureId the structure ID
9798             * @param start the lower bound of the range of journal articles
9799             * @param end the upper bound of the range of journal articles (not inclusive)
9800             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9801             * @return the ordered range of matching journal articles
9802             * @throws SystemException if a system exception occurred
9803             */
9804            public List<JournalArticle> findByG_S(long groupId, String structureId,
9805                    int start, int end, OrderByComparator orderByComparator)
9806                    throws SystemException {
9807                    FinderPath finderPath = null;
9808                    Object[] finderArgs = null;
9809    
9810                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9811                                    (orderByComparator == null)) {
9812                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
9813                            finderArgs = new Object[] { groupId, structureId };
9814                    }
9815                    else {
9816                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
9817                            finderArgs = new Object[] {
9818                                            groupId, structureId,
9819                                            
9820                                            start, end, orderByComparator
9821                                    };
9822                    }
9823    
9824                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9825                                    finderArgs, this);
9826    
9827                    if ((list != null) && !list.isEmpty()) {
9828                            for (JournalArticle journalArticle : list) {
9829                                    if ((groupId != journalArticle.getGroupId()) ||
9830                                                    !Validator.equals(structureId,
9831                                                            journalArticle.getStructureId())) {
9832                                            list = null;
9833    
9834                                            break;
9835                                    }
9836                            }
9837                    }
9838    
9839                    if (list == null) {
9840                            StringBundler query = null;
9841    
9842                            if (orderByComparator != null) {
9843                                    query = new StringBundler(4 +
9844                                                    (orderByComparator.getOrderByFields().length * 3));
9845                            }
9846                            else {
9847                                    query = new StringBundler(4);
9848                            }
9849    
9850                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9851    
9852                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
9853    
9854                            if (structureId == null) {
9855                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
9856                            }
9857                            else {
9858                                    if (structureId.equals(StringPool.BLANK)) {
9859                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
9860                                    }
9861                                    else {
9862                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
9863                                    }
9864                            }
9865    
9866                            if (orderByComparator != null) {
9867                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9868                                            orderByComparator);
9869                            }
9870    
9871                            else {
9872                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9873                            }
9874    
9875                            String sql = query.toString();
9876    
9877                            Session session = null;
9878    
9879                            try {
9880                                    session = openSession();
9881    
9882                                    Query q = session.createQuery(sql);
9883    
9884                                    QueryPos qPos = QueryPos.getInstance(q);
9885    
9886                                    qPos.add(groupId);
9887    
9888                                    if (structureId != null) {
9889                                            qPos.add(structureId);
9890                                    }
9891    
9892                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
9893                                                    start, end);
9894                            }
9895                            catch (Exception e) {
9896                                    throw processException(e);
9897                            }
9898                            finally {
9899                                    if (list == null) {
9900                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9901                                    }
9902                                    else {
9903                                            cacheResult(list);
9904    
9905                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9906                                    }
9907    
9908                                    closeSession(session);
9909                            }
9910                    }
9911    
9912                    return list;
9913            }
9914    
9915            /**
9916             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
9917             *
9918             * @param groupId the group ID
9919             * @param structureId the structure ID
9920             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9921             * @return the first matching journal article
9922             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9923             * @throws SystemException if a system exception occurred
9924             */
9925            public JournalArticle findByG_S_First(long groupId, String structureId,
9926                    OrderByComparator orderByComparator)
9927                    throws NoSuchArticleException, SystemException {
9928                    JournalArticle journalArticle = fetchByG_S_First(groupId, structureId,
9929                                    orderByComparator);
9930    
9931                    if (journalArticle != null) {
9932                            return journalArticle;
9933                    }
9934    
9935                    StringBundler msg = new StringBundler(6);
9936    
9937                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9938    
9939                    msg.append("groupId=");
9940                    msg.append(groupId);
9941    
9942                    msg.append(", structureId=");
9943                    msg.append(structureId);
9944    
9945                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9946    
9947                    throw new NoSuchArticleException(msg.toString());
9948            }
9949    
9950            /**
9951             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
9952             *
9953             * @param groupId the group ID
9954             * @param structureId the structure ID
9955             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9956             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9957             * @throws SystemException if a system exception occurred
9958             */
9959            public JournalArticle fetchByG_S_First(long groupId, String structureId,
9960                    OrderByComparator orderByComparator) throws SystemException {
9961                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
9962                                    orderByComparator);
9963    
9964                    if (!list.isEmpty()) {
9965                            return list.get(0);
9966                    }
9967    
9968                    return null;
9969            }
9970    
9971            /**
9972             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
9973             *
9974             * @param groupId the group ID
9975             * @param structureId the structure ID
9976             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9977             * @return the last matching journal article
9978             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9979             * @throws SystemException if a system exception occurred
9980             */
9981            public JournalArticle findByG_S_Last(long groupId, String structureId,
9982                    OrderByComparator orderByComparator)
9983                    throws NoSuchArticleException, SystemException {
9984                    JournalArticle journalArticle = fetchByG_S_Last(groupId, structureId,
9985                                    orderByComparator);
9986    
9987                    if (journalArticle != null) {
9988                            return journalArticle;
9989                    }
9990    
9991                    StringBundler msg = new StringBundler(6);
9992    
9993                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9994    
9995                    msg.append("groupId=");
9996                    msg.append(groupId);
9997    
9998                    msg.append(", structureId=");
9999                    msg.append(structureId);
10000    
10001                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10002    
10003                    throw new NoSuchArticleException(msg.toString());
10004            }
10005    
10006            /**
10007             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10008             *
10009             * @param groupId the group ID
10010             * @param structureId the structure ID
10011             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10012             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10013             * @throws SystemException if a system exception occurred
10014             */
10015            public JournalArticle fetchByG_S_Last(long groupId, String structureId,
10016                    OrderByComparator orderByComparator) throws SystemException {
10017                    int count = countByG_S(groupId, structureId);
10018    
10019                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
10020                                    count, orderByComparator);
10021    
10022                    if (!list.isEmpty()) {
10023                            return list.get(0);
10024                    }
10025    
10026                    return null;
10027            }
10028    
10029            /**
10030             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
10031             *
10032             * @param id the primary key of the current journal article
10033             * @param groupId the group ID
10034             * @param structureId the structure ID
10035             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10036             * @return the previous, current, and next journal article
10037             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10038             * @throws SystemException if a system exception occurred
10039             */
10040            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
10041                    String structureId, OrderByComparator orderByComparator)
10042                    throws NoSuchArticleException, SystemException {
10043                    JournalArticle journalArticle = findByPrimaryKey(id);
10044    
10045                    Session session = null;
10046    
10047                    try {
10048                            session = openSession();
10049    
10050                            JournalArticle[] array = new JournalArticleImpl[3];
10051    
10052                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
10053                                            structureId, orderByComparator, true);
10054    
10055                            array[1] = journalArticle;
10056    
10057                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
10058                                            structureId, orderByComparator, false);
10059    
10060                            return array;
10061                    }
10062                    catch (Exception e) {
10063                            throw processException(e);
10064                    }
10065                    finally {
10066                            closeSession(session);
10067                    }
10068            }
10069    
10070            protected JournalArticle getByG_S_PrevAndNext(Session session,
10071                    JournalArticle journalArticle, long groupId, String structureId,
10072                    OrderByComparator orderByComparator, boolean previous) {
10073                    StringBundler query = null;
10074    
10075                    if (orderByComparator != null) {
10076                            query = new StringBundler(6 +
10077                                            (orderByComparator.getOrderByFields().length * 6));
10078                    }
10079                    else {
10080                            query = new StringBundler(3);
10081                    }
10082    
10083                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10084    
10085                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10086    
10087                    if (structureId == null) {
10088                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10089                    }
10090                    else {
10091                            if (structureId.equals(StringPool.BLANK)) {
10092                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10093                            }
10094                            else {
10095                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10096                            }
10097                    }
10098    
10099                    if (orderByComparator != null) {
10100                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10101    
10102                            if (orderByConditionFields.length > 0) {
10103                                    query.append(WHERE_AND);
10104                            }
10105    
10106                            for (int i = 0; i < orderByConditionFields.length; i++) {
10107                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10108                                    query.append(orderByConditionFields[i]);
10109    
10110                                    if ((i + 1) < orderByConditionFields.length) {
10111                                            if (orderByComparator.isAscending() ^ previous) {
10112                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10113                                            }
10114                                            else {
10115                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10116                                            }
10117                                    }
10118                                    else {
10119                                            if (orderByComparator.isAscending() ^ previous) {
10120                                                    query.append(WHERE_GREATER_THAN);
10121                                            }
10122                                            else {
10123                                                    query.append(WHERE_LESSER_THAN);
10124                                            }
10125                                    }
10126                            }
10127    
10128                            query.append(ORDER_BY_CLAUSE);
10129    
10130                            String[] orderByFields = orderByComparator.getOrderByFields();
10131    
10132                            for (int i = 0; i < orderByFields.length; i++) {
10133                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10134                                    query.append(orderByFields[i]);
10135    
10136                                    if ((i + 1) < orderByFields.length) {
10137                                            if (orderByComparator.isAscending() ^ previous) {
10138                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10139                                            }
10140                                            else {
10141                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10142                                            }
10143                                    }
10144                                    else {
10145                                            if (orderByComparator.isAscending() ^ previous) {
10146                                                    query.append(ORDER_BY_ASC);
10147                                            }
10148                                            else {
10149                                                    query.append(ORDER_BY_DESC);
10150                                            }
10151                                    }
10152                            }
10153                    }
10154    
10155                    else {
10156                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10157                    }
10158    
10159                    String sql = query.toString();
10160    
10161                    Query q = session.createQuery(sql);
10162    
10163                    q.setFirstResult(0);
10164                    q.setMaxResults(2);
10165    
10166                    QueryPos qPos = QueryPos.getInstance(q);
10167    
10168                    qPos.add(groupId);
10169    
10170                    if (structureId != null) {
10171                            qPos.add(structureId);
10172                    }
10173    
10174                    if (orderByComparator != null) {
10175                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10176    
10177                            for (Object value : values) {
10178                                    qPos.add(value);
10179                            }
10180                    }
10181    
10182                    List<JournalArticle> list = q.list();
10183    
10184                    if (list.size() == 2) {
10185                            return list.get(1);
10186                    }
10187                    else {
10188                            return null;
10189                    }
10190            }
10191    
10192            /**
10193             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
10194             *
10195             * @param groupId the group ID
10196             * @param structureId the structure ID
10197             * @return the matching journal articles that the user has permission to view
10198             * @throws SystemException if a system exception occurred
10199             */
10200            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
10201                    throws SystemException {
10202                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
10203                            QueryUtil.ALL_POS, null);
10204            }
10205    
10206            /**
10207             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
10208             *
10209             * <p>
10210             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10211             * </p>
10212             *
10213             * @param groupId the group ID
10214             * @param structureId the structure ID
10215             * @param start the lower bound of the range of journal articles
10216             * @param end the upper bound of the range of journal articles (not inclusive)
10217             * @return the range of matching journal articles that the user has permission to view
10218             * @throws SystemException if a system exception occurred
10219             */
10220            public List<JournalArticle> filterFindByG_S(long groupId,
10221                    String structureId, int start, int end) throws SystemException {
10222                    return filterFindByG_S(groupId, structureId, start, end, null);
10223            }
10224    
10225            /**
10226             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
10227             *
10228             * <p>
10229             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10230             * </p>
10231             *
10232             * @param groupId the group ID
10233             * @param structureId the structure ID
10234             * @param start the lower bound of the range of journal articles
10235             * @param end the upper bound of the range of journal articles (not inclusive)
10236             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10237             * @return the ordered range of matching journal articles that the user has permission to view
10238             * @throws SystemException if a system exception occurred
10239             */
10240            public List<JournalArticle> filterFindByG_S(long groupId,
10241                    String structureId, int start, int end,
10242                    OrderByComparator orderByComparator) throws SystemException {
10243                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10244                            return findByG_S(groupId, structureId, start, end, orderByComparator);
10245                    }
10246    
10247                    StringBundler query = null;
10248    
10249                    if (orderByComparator != null) {
10250                            query = new StringBundler(4 +
10251                                            (orderByComparator.getOrderByFields().length * 3));
10252                    }
10253                    else {
10254                            query = new StringBundler(4);
10255                    }
10256    
10257                    if (getDB().isSupportsInlineDistinct()) {
10258                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10259                    }
10260                    else {
10261                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10262                    }
10263    
10264                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10265    
10266                    if (structureId == null) {
10267                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10268                    }
10269                    else {
10270                            if (structureId.equals(StringPool.BLANK)) {
10271                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10272                            }
10273                            else {
10274                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10275                            }
10276                    }
10277    
10278                    if (!getDB().isSupportsInlineDistinct()) {
10279                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10280                    }
10281    
10282                    if (orderByComparator != null) {
10283                            if (getDB().isSupportsInlineDistinct()) {
10284                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10285                                            orderByComparator);
10286                            }
10287                            else {
10288                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10289                                            orderByComparator);
10290                            }
10291                    }
10292    
10293                    else {
10294                            if (getDB().isSupportsInlineDistinct()) {
10295                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10296                            }
10297                            else {
10298                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10299                            }
10300                    }
10301    
10302                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10303                                    JournalArticle.class.getName(),
10304                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10305    
10306                    Session session = null;
10307    
10308                    try {
10309                            session = openSession();
10310    
10311                            SQLQuery q = session.createSQLQuery(sql);
10312    
10313                            if (getDB().isSupportsInlineDistinct()) {
10314                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10315                            }
10316                            else {
10317                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10318                            }
10319    
10320                            QueryPos qPos = QueryPos.getInstance(q);
10321    
10322                            qPos.add(groupId);
10323    
10324                            if (structureId != null) {
10325                                    qPos.add(structureId);
10326                            }
10327    
10328                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10329                                    end);
10330                    }
10331                    catch (Exception e) {
10332                            throw processException(e);
10333                    }
10334                    finally {
10335                            closeSession(session);
10336                    }
10337            }
10338    
10339            /**
10340             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
10341             *
10342             * @param id the primary key of the current journal article
10343             * @param groupId the group ID
10344             * @param structureId the structure ID
10345             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10346             * @return the previous, current, and next journal article
10347             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10348             * @throws SystemException if a system exception occurred
10349             */
10350            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
10351                    String structureId, OrderByComparator orderByComparator)
10352                    throws NoSuchArticleException, SystemException {
10353                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10354                            return findByG_S_PrevAndNext(id, groupId, structureId,
10355                                    orderByComparator);
10356                    }
10357    
10358                    JournalArticle journalArticle = findByPrimaryKey(id);
10359    
10360                    Session session = null;
10361    
10362                    try {
10363                            session = openSession();
10364    
10365                            JournalArticle[] array = new JournalArticleImpl[3];
10366    
10367                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
10368                                            groupId, structureId, orderByComparator, true);
10369    
10370                            array[1] = journalArticle;
10371    
10372                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
10373                                            groupId, structureId, orderByComparator, false);
10374    
10375                            return array;
10376                    }
10377                    catch (Exception e) {
10378                            throw processException(e);
10379                    }
10380                    finally {
10381                            closeSession(session);
10382                    }
10383            }
10384    
10385            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
10386                    JournalArticle journalArticle, long groupId, String structureId,
10387                    OrderByComparator orderByComparator, boolean previous) {
10388                    StringBundler query = null;
10389    
10390                    if (orderByComparator != null) {
10391                            query = new StringBundler(6 +
10392                                            (orderByComparator.getOrderByFields().length * 6));
10393                    }
10394                    else {
10395                            query = new StringBundler(3);
10396                    }
10397    
10398                    if (getDB().isSupportsInlineDistinct()) {
10399                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10400                    }
10401                    else {
10402                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10403                    }
10404    
10405                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
10406    
10407                    if (structureId == null) {
10408                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
10409                    }
10410                    else {
10411                            if (structureId.equals(StringPool.BLANK)) {
10412                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
10413                            }
10414                            else {
10415                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
10416                            }
10417                    }
10418    
10419                    if (!getDB().isSupportsInlineDistinct()) {
10420                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10421                    }
10422    
10423                    if (orderByComparator != null) {
10424                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10425    
10426                            if (orderByConditionFields.length > 0) {
10427                                    query.append(WHERE_AND);
10428                            }
10429    
10430                            for (int i = 0; i < orderByConditionFields.length; i++) {
10431                                    if (getDB().isSupportsInlineDistinct()) {
10432                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10433                                    }
10434                                    else {
10435                                            query.append(_ORDER_BY_ENTITY_TABLE);
10436                                    }
10437    
10438                                    query.append(orderByConditionFields[i]);
10439    
10440                                    if ((i + 1) < orderByConditionFields.length) {
10441                                            if (orderByComparator.isAscending() ^ previous) {
10442                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10443                                            }
10444                                            else {
10445                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10446                                            }
10447                                    }
10448                                    else {
10449                                            if (orderByComparator.isAscending() ^ previous) {
10450                                                    query.append(WHERE_GREATER_THAN);
10451                                            }
10452                                            else {
10453                                                    query.append(WHERE_LESSER_THAN);
10454                                            }
10455                                    }
10456                            }
10457    
10458                            query.append(ORDER_BY_CLAUSE);
10459    
10460                            String[] orderByFields = orderByComparator.getOrderByFields();
10461    
10462                            for (int i = 0; i < orderByFields.length; i++) {
10463                                    if (getDB().isSupportsInlineDistinct()) {
10464                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10465                                    }
10466                                    else {
10467                                            query.append(_ORDER_BY_ENTITY_TABLE);
10468                                    }
10469    
10470                                    query.append(orderByFields[i]);
10471    
10472                                    if ((i + 1) < orderByFields.length) {
10473                                            if (orderByComparator.isAscending() ^ previous) {
10474                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10475                                            }
10476                                            else {
10477                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10478                                            }
10479                                    }
10480                                    else {
10481                                            if (orderByComparator.isAscending() ^ previous) {
10482                                                    query.append(ORDER_BY_ASC);
10483                                            }
10484                                            else {
10485                                                    query.append(ORDER_BY_DESC);
10486                                            }
10487                                    }
10488                            }
10489                    }
10490    
10491                    else {
10492                            if (getDB().isSupportsInlineDistinct()) {
10493                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10494                            }
10495                            else {
10496                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10497                            }
10498                    }
10499    
10500                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10501                                    JournalArticle.class.getName(),
10502                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10503    
10504                    SQLQuery q = session.createSQLQuery(sql);
10505    
10506                    q.setFirstResult(0);
10507                    q.setMaxResults(2);
10508    
10509                    if (getDB().isSupportsInlineDistinct()) {
10510                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10511                    }
10512                    else {
10513                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10514                    }
10515    
10516                    QueryPos qPos = QueryPos.getInstance(q);
10517    
10518                    qPos.add(groupId);
10519    
10520                    if (structureId != null) {
10521                            qPos.add(structureId);
10522                    }
10523    
10524                    if (orderByComparator != null) {
10525                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10526    
10527                            for (Object value : values) {
10528                                    qPos.add(value);
10529                            }
10530                    }
10531    
10532                    List<JournalArticle> list = q.list();
10533    
10534                    if (list.size() == 2) {
10535                            return list.get(1);
10536                    }
10537                    else {
10538                            return null;
10539                    }
10540            }
10541    
10542            /**
10543             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
10544             *
10545             * @param groupId the group ID
10546             * @param templateId the template ID
10547             * @return the matching journal articles
10548             * @throws SystemException if a system exception occurred
10549             */
10550            public List<JournalArticle> findByG_T(long groupId, String templateId)
10551                    throws SystemException {
10552                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
10553                            QueryUtil.ALL_POS, null);
10554            }
10555    
10556            /**
10557             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
10558             *
10559             * <p>
10560             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10561             * </p>
10562             *
10563             * @param groupId the group ID
10564             * @param templateId the template ID
10565             * @param start the lower bound of the range of journal articles
10566             * @param end the upper bound of the range of journal articles (not inclusive)
10567             * @return the range of matching journal articles
10568             * @throws SystemException if a system exception occurred
10569             */
10570            public List<JournalArticle> findByG_T(long groupId, String templateId,
10571                    int start, int end) throws SystemException {
10572                    return findByG_T(groupId, templateId, start, end, null);
10573            }
10574    
10575            /**
10576             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
10577             *
10578             * <p>
10579             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10580             * </p>
10581             *
10582             * @param groupId the group ID
10583             * @param templateId the template ID
10584             * @param start the lower bound of the range of journal articles
10585             * @param end the upper bound of the range of journal articles (not inclusive)
10586             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10587             * @return the ordered range of matching journal articles
10588             * @throws SystemException if a system exception occurred
10589             */
10590            public List<JournalArticle> findByG_T(long groupId, String templateId,
10591                    int start, int end, OrderByComparator orderByComparator)
10592                    throws SystemException {
10593                    FinderPath finderPath = null;
10594                    Object[] finderArgs = null;
10595    
10596                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10597                                    (orderByComparator == null)) {
10598                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
10599                            finderArgs = new Object[] { groupId, templateId };
10600                    }
10601                    else {
10602                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
10603                            finderArgs = new Object[] {
10604                                            groupId, templateId,
10605                                            
10606                                            start, end, orderByComparator
10607                                    };
10608                    }
10609    
10610                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10611                                    finderArgs, this);
10612    
10613                    if ((list != null) && !list.isEmpty()) {
10614                            for (JournalArticle journalArticle : list) {
10615                                    if ((groupId != journalArticle.getGroupId()) ||
10616                                                    !Validator.equals(templateId,
10617                                                            journalArticle.getTemplateId())) {
10618                                            list = null;
10619    
10620                                            break;
10621                                    }
10622                            }
10623                    }
10624    
10625                    if (list == null) {
10626                            StringBundler query = null;
10627    
10628                            if (orderByComparator != null) {
10629                                    query = new StringBundler(4 +
10630                                                    (orderByComparator.getOrderByFields().length * 3));
10631                            }
10632                            else {
10633                                    query = new StringBundler(4);
10634                            }
10635    
10636                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10637    
10638                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
10639    
10640                            if (templateId == null) {
10641                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
10642                            }
10643                            else {
10644                                    if (templateId.equals(StringPool.BLANK)) {
10645                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
10646                                    }
10647                                    else {
10648                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
10649                                    }
10650                            }
10651    
10652                            if (orderByComparator != null) {
10653                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10654                                            orderByComparator);
10655                            }
10656    
10657                            else {
10658                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10659                            }
10660    
10661                            String sql = query.toString();
10662    
10663                            Session session = null;
10664    
10665                            try {
10666                                    session = openSession();
10667    
10668                                    Query q = session.createQuery(sql);
10669    
10670                                    QueryPos qPos = QueryPos.getInstance(q);
10671    
10672                                    qPos.add(groupId);
10673    
10674                                    if (templateId != null) {
10675                                            qPos.add(templateId);
10676                                    }
10677    
10678                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
10679                                                    start, end);
10680                            }
10681                            catch (Exception e) {
10682                                    throw processException(e);
10683                            }
10684                            finally {
10685                                    if (list == null) {
10686                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
10687                                    }
10688                                    else {
10689                                            cacheResult(list);
10690    
10691                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
10692                                    }
10693    
10694                                    closeSession(session);
10695                            }
10696                    }
10697    
10698                    return list;
10699            }
10700    
10701            /**
10702             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
10703             *
10704             * @param groupId the group ID
10705             * @param templateId the template ID
10706             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10707             * @return the first matching journal article
10708             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10709             * @throws SystemException if a system exception occurred
10710             */
10711            public JournalArticle findByG_T_First(long groupId, String templateId,
10712                    OrderByComparator orderByComparator)
10713                    throws NoSuchArticleException, SystemException {
10714                    JournalArticle journalArticle = fetchByG_T_First(groupId, templateId,
10715                                    orderByComparator);
10716    
10717                    if (journalArticle != null) {
10718                            return journalArticle;
10719                    }
10720    
10721                    StringBundler msg = new StringBundler(6);
10722    
10723                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10724    
10725                    msg.append("groupId=");
10726                    msg.append(groupId);
10727    
10728                    msg.append(", templateId=");
10729                    msg.append(templateId);
10730    
10731                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10732    
10733                    throw new NoSuchArticleException(msg.toString());
10734            }
10735    
10736            /**
10737             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
10738             *
10739             * @param groupId the group ID
10740             * @param templateId the template ID
10741             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10742             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10743             * @throws SystemException if a system exception occurred
10744             */
10745            public JournalArticle fetchByG_T_First(long groupId, String templateId,
10746                    OrderByComparator orderByComparator) throws SystemException {
10747                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
10748                                    orderByComparator);
10749    
10750                    if (!list.isEmpty()) {
10751                            return list.get(0);
10752                    }
10753    
10754                    return null;
10755            }
10756    
10757            /**
10758             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
10759             *
10760             * @param groupId the group ID
10761             * @param templateId the template ID
10762             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10763             * @return the last matching journal article
10764             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10765             * @throws SystemException if a system exception occurred
10766             */
10767            public JournalArticle findByG_T_Last(long groupId, String templateId,
10768                    OrderByComparator orderByComparator)
10769                    throws NoSuchArticleException, SystemException {
10770                    JournalArticle journalArticle = fetchByG_T_Last(groupId, templateId,
10771                                    orderByComparator);
10772    
10773                    if (journalArticle != null) {
10774                            return journalArticle;
10775                    }
10776    
10777                    StringBundler msg = new StringBundler(6);
10778    
10779                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10780    
10781                    msg.append("groupId=");
10782                    msg.append(groupId);
10783    
10784                    msg.append(", templateId=");
10785                    msg.append(templateId);
10786    
10787                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10788    
10789                    throw new NoSuchArticleException(msg.toString());
10790            }
10791    
10792            /**
10793             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
10794             *
10795             * @param groupId the group ID
10796             * @param templateId the template ID
10797             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10798             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10799             * @throws SystemException if a system exception occurred
10800             */
10801            public JournalArticle fetchByG_T_Last(long groupId, String templateId,
10802                    OrderByComparator orderByComparator) throws SystemException {
10803                    int count = countByG_T(groupId, templateId);
10804    
10805                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
10806                                    count, orderByComparator);
10807    
10808                    if (!list.isEmpty()) {
10809                            return list.get(0);
10810                    }
10811    
10812                    return null;
10813            }
10814    
10815            /**
10816             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
10817             *
10818             * @param id the primary key of the current journal article
10819             * @param groupId the group ID
10820             * @param templateId the template ID
10821             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10822             * @return the previous, current, and next journal article
10823             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10824             * @throws SystemException if a system exception occurred
10825             */
10826            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
10827                    String templateId, OrderByComparator orderByComparator)
10828                    throws NoSuchArticleException, SystemException {
10829                    JournalArticle journalArticle = findByPrimaryKey(id);
10830    
10831                    Session session = null;
10832    
10833                    try {
10834                            session = openSession();
10835    
10836                            JournalArticle[] array = new JournalArticleImpl[3];
10837    
10838                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
10839                                            templateId, orderByComparator, true);
10840    
10841                            array[1] = journalArticle;
10842    
10843                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
10844                                            templateId, orderByComparator, false);
10845    
10846                            return array;
10847                    }
10848                    catch (Exception e) {
10849                            throw processException(e);
10850                    }
10851                    finally {
10852                            closeSession(session);
10853                    }
10854            }
10855    
10856            protected JournalArticle getByG_T_PrevAndNext(Session session,
10857                    JournalArticle journalArticle, long groupId, String templateId,
10858                    OrderByComparator orderByComparator, boolean previous) {
10859                    StringBundler query = null;
10860    
10861                    if (orderByComparator != null) {
10862                            query = new StringBundler(6 +
10863                                            (orderByComparator.getOrderByFields().length * 6));
10864                    }
10865                    else {
10866                            query = new StringBundler(3);
10867                    }
10868    
10869                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10870    
10871                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
10872    
10873                    if (templateId == null) {
10874                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
10875                    }
10876                    else {
10877                            if (templateId.equals(StringPool.BLANK)) {
10878                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
10879                            }
10880                            else {
10881                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
10882                            }
10883                    }
10884    
10885                    if (orderByComparator != null) {
10886                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10887    
10888                            if (orderByConditionFields.length > 0) {
10889                                    query.append(WHERE_AND);
10890                            }
10891    
10892                            for (int i = 0; i < orderByConditionFields.length; i++) {
10893                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10894                                    query.append(orderByConditionFields[i]);
10895    
10896                                    if ((i + 1) < orderByConditionFields.length) {
10897                                            if (orderByComparator.isAscending() ^ previous) {
10898                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10899                                            }
10900                                            else {
10901                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10902                                            }
10903                                    }
10904                                    else {
10905                                            if (orderByComparator.isAscending() ^ previous) {
10906                                                    query.append(WHERE_GREATER_THAN);
10907                                            }
10908                                            else {
10909                                                    query.append(WHERE_LESSER_THAN);
10910                                            }
10911                                    }
10912                            }
10913    
10914                            query.append(ORDER_BY_CLAUSE);
10915    
10916                            String[] orderByFields = orderByComparator.getOrderByFields();
10917    
10918                            for (int i = 0; i < orderByFields.length; i++) {
10919                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10920                                    query.append(orderByFields[i]);
10921    
10922                                    if ((i + 1) < orderByFields.length) {
10923                                            if (orderByComparator.isAscending() ^ previous) {
10924                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10925                                            }
10926                                            else {
10927                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10928                                            }
10929                                    }
10930                                    else {
10931                                            if (orderByComparator.isAscending() ^ previous) {
10932                                                    query.append(ORDER_BY_ASC);
10933                                            }
10934                                            else {
10935                                                    query.append(ORDER_BY_DESC);
10936                                            }
10937                                    }
10938                            }
10939                    }
10940    
10941                    else {
10942                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10943                    }
10944    
10945                    String sql = query.toString();
10946    
10947                    Query q = session.createQuery(sql);
10948    
10949                    q.setFirstResult(0);
10950                    q.setMaxResults(2);
10951    
10952                    QueryPos qPos = QueryPos.getInstance(q);
10953    
10954                    qPos.add(groupId);
10955    
10956                    if (templateId != null) {
10957                            qPos.add(templateId);
10958                    }
10959    
10960                    if (orderByComparator != null) {
10961                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10962    
10963                            for (Object value : values) {
10964                                    qPos.add(value);
10965                            }
10966                    }
10967    
10968                    List<JournalArticle> list = q.list();
10969    
10970                    if (list.size() == 2) {
10971                            return list.get(1);
10972                    }
10973                    else {
10974                            return null;
10975                    }
10976            }
10977    
10978            /**
10979             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
10980             *
10981             * @param groupId the group ID
10982             * @param templateId the template ID
10983             * @return the matching journal articles that the user has permission to view
10984             * @throws SystemException if a system exception occurred
10985             */
10986            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
10987                    throws SystemException {
10988                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
10989                            QueryUtil.ALL_POS, null);
10990            }
10991    
10992            /**
10993             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
10994             *
10995             * <p>
10996             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10997             * </p>
10998             *
10999             * @param groupId the group ID
11000             * @param templateId the template ID
11001             * @param start the lower bound of the range of journal articles
11002             * @param end the upper bound of the range of journal articles (not inclusive)
11003             * @return the range of matching journal articles that the user has permission to view
11004             * @throws SystemException if a system exception occurred
11005             */
11006            public List<JournalArticle> filterFindByG_T(long groupId,
11007                    String templateId, int start, int end) throws SystemException {
11008                    return filterFindByG_T(groupId, templateId, start, end, null);
11009            }
11010    
11011            /**
11012             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
11013             *
11014             * <p>
11015             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11016             * </p>
11017             *
11018             * @param groupId the group ID
11019             * @param templateId the template ID
11020             * @param start the lower bound of the range of journal articles
11021             * @param end the upper bound of the range of journal articles (not inclusive)
11022             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11023             * @return the ordered range of matching journal articles that the user has permission to view
11024             * @throws SystemException if a system exception occurred
11025             */
11026            public List<JournalArticle> filterFindByG_T(long groupId,
11027                    String templateId, int start, int end,
11028                    OrderByComparator orderByComparator) throws SystemException {
11029                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11030                            return findByG_T(groupId, templateId, start, end, orderByComparator);
11031                    }
11032    
11033                    StringBundler query = null;
11034    
11035                    if (orderByComparator != null) {
11036                            query = new StringBundler(4 +
11037                                            (orderByComparator.getOrderByFields().length * 3));
11038                    }
11039                    else {
11040                            query = new StringBundler(4);
11041                    }
11042    
11043                    if (getDB().isSupportsInlineDistinct()) {
11044                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11045                    }
11046                    else {
11047                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11048                    }
11049    
11050                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11051    
11052                    if (templateId == null) {
11053                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11054                    }
11055                    else {
11056                            if (templateId.equals(StringPool.BLANK)) {
11057                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11058                            }
11059                            else {
11060                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11061                            }
11062                    }
11063    
11064                    if (!getDB().isSupportsInlineDistinct()) {
11065                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11066                    }
11067    
11068                    if (orderByComparator != null) {
11069                            if (getDB().isSupportsInlineDistinct()) {
11070                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11071                                            orderByComparator);
11072                            }
11073                            else {
11074                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11075                                            orderByComparator);
11076                            }
11077                    }
11078    
11079                    else {
11080                            if (getDB().isSupportsInlineDistinct()) {
11081                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11082                            }
11083                            else {
11084                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11085                            }
11086                    }
11087    
11088                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11089                                    JournalArticle.class.getName(),
11090                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11091    
11092                    Session session = null;
11093    
11094                    try {
11095                            session = openSession();
11096    
11097                            SQLQuery q = session.createSQLQuery(sql);
11098    
11099                            if (getDB().isSupportsInlineDistinct()) {
11100                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11101                            }
11102                            else {
11103                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11104                            }
11105    
11106                            QueryPos qPos = QueryPos.getInstance(q);
11107    
11108                            qPos.add(groupId);
11109    
11110                            if (templateId != null) {
11111                                    qPos.add(templateId);
11112                            }
11113    
11114                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11115                                    end);
11116                    }
11117                    catch (Exception e) {
11118                            throw processException(e);
11119                    }
11120                    finally {
11121                            closeSession(session);
11122                    }
11123            }
11124    
11125            /**
11126             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
11127             *
11128             * @param id the primary key of the current journal article
11129             * @param groupId the group ID
11130             * @param templateId the template ID
11131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11132             * @return the previous, current, and next journal article
11133             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11134             * @throws SystemException if a system exception occurred
11135             */
11136            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
11137                    String templateId, OrderByComparator orderByComparator)
11138                    throws NoSuchArticleException, SystemException {
11139                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11140                            return findByG_T_PrevAndNext(id, groupId, templateId,
11141                                    orderByComparator);
11142                    }
11143    
11144                    JournalArticle journalArticle = findByPrimaryKey(id);
11145    
11146                    Session session = null;
11147    
11148                    try {
11149                            session = openSession();
11150    
11151                            JournalArticle[] array = new JournalArticleImpl[3];
11152    
11153                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
11154                                            groupId, templateId, orderByComparator, true);
11155    
11156                            array[1] = journalArticle;
11157    
11158                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
11159                                            groupId, templateId, orderByComparator, false);
11160    
11161                            return array;
11162                    }
11163                    catch (Exception e) {
11164                            throw processException(e);
11165                    }
11166                    finally {
11167                            closeSession(session);
11168                    }
11169            }
11170    
11171            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
11172                    JournalArticle journalArticle, long groupId, String templateId,
11173                    OrderByComparator orderByComparator, boolean previous) {
11174                    StringBundler query = null;
11175    
11176                    if (orderByComparator != null) {
11177                            query = new StringBundler(6 +
11178                                            (orderByComparator.getOrderByFields().length * 6));
11179                    }
11180                    else {
11181                            query = new StringBundler(3);
11182                    }
11183    
11184                    if (getDB().isSupportsInlineDistinct()) {
11185                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11186                    }
11187                    else {
11188                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11189                    }
11190    
11191                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
11192    
11193                    if (templateId == null) {
11194                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
11195                    }
11196                    else {
11197                            if (templateId.equals(StringPool.BLANK)) {
11198                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
11199                            }
11200                            else {
11201                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
11202                            }
11203                    }
11204    
11205                    if (!getDB().isSupportsInlineDistinct()) {
11206                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11207                    }
11208    
11209                    if (orderByComparator != null) {
11210                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11211    
11212                            if (orderByConditionFields.length > 0) {
11213                                    query.append(WHERE_AND);
11214                            }
11215    
11216                            for (int i = 0; i < orderByConditionFields.length; i++) {
11217                                    if (getDB().isSupportsInlineDistinct()) {
11218                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11219                                    }
11220                                    else {
11221                                            query.append(_ORDER_BY_ENTITY_TABLE);
11222                                    }
11223    
11224                                    query.append(orderByConditionFields[i]);
11225    
11226                                    if ((i + 1) < orderByConditionFields.length) {
11227                                            if (orderByComparator.isAscending() ^ previous) {
11228                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11229                                            }
11230                                            else {
11231                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11232                                            }
11233                                    }
11234                                    else {
11235                                            if (orderByComparator.isAscending() ^ previous) {
11236                                                    query.append(WHERE_GREATER_THAN);
11237                                            }
11238                                            else {
11239                                                    query.append(WHERE_LESSER_THAN);
11240                                            }
11241                                    }
11242                            }
11243    
11244                            query.append(ORDER_BY_CLAUSE);
11245    
11246                            String[] orderByFields = orderByComparator.getOrderByFields();
11247    
11248                            for (int i = 0; i < orderByFields.length; i++) {
11249                                    if (getDB().isSupportsInlineDistinct()) {
11250                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11251                                    }
11252                                    else {
11253                                            query.append(_ORDER_BY_ENTITY_TABLE);
11254                                    }
11255    
11256                                    query.append(orderByFields[i]);
11257    
11258                                    if ((i + 1) < orderByFields.length) {
11259                                            if (orderByComparator.isAscending() ^ previous) {
11260                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11261                                            }
11262                                            else {
11263                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11264                                            }
11265                                    }
11266                                    else {
11267                                            if (orderByComparator.isAscending() ^ previous) {
11268                                                    query.append(ORDER_BY_ASC);
11269                                            }
11270                                            else {
11271                                                    query.append(ORDER_BY_DESC);
11272                                            }
11273                                    }
11274                            }
11275                    }
11276    
11277                    else {
11278                            if (getDB().isSupportsInlineDistinct()) {
11279                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11280                            }
11281                            else {
11282                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11283                            }
11284                    }
11285    
11286                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11287                                    JournalArticle.class.getName(),
11288                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11289    
11290                    SQLQuery q = session.createSQLQuery(sql);
11291    
11292                    q.setFirstResult(0);
11293                    q.setMaxResults(2);
11294    
11295                    if (getDB().isSupportsInlineDistinct()) {
11296                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11297                    }
11298                    else {
11299                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11300                    }
11301    
11302                    QueryPos qPos = QueryPos.getInstance(q);
11303    
11304                    qPos.add(groupId);
11305    
11306                    if (templateId != null) {
11307                            qPos.add(templateId);
11308                    }
11309    
11310                    if (orderByComparator != null) {
11311                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11312    
11313                            for (Object value : values) {
11314                                    qPos.add(value);
11315                            }
11316                    }
11317    
11318                    List<JournalArticle> list = q.list();
11319    
11320                    if (list.size() == 2) {
11321                            return list.get(1);
11322                    }
11323                    else {
11324                            return null;
11325                    }
11326            }
11327    
11328            /**
11329             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
11330             *
11331             * @param groupId the group ID
11332             * @param layoutUuid the layout uuid
11333             * @return the matching journal articles
11334             * @throws SystemException if a system exception occurred
11335             */
11336            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
11337                    throws SystemException {
11338                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
11339                            QueryUtil.ALL_POS, null);
11340            }
11341    
11342            /**
11343             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
11344             *
11345             * <p>
11346             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11347             * </p>
11348             *
11349             * @param groupId the group ID
11350             * @param layoutUuid the layout uuid
11351             * @param start the lower bound of the range of journal articles
11352             * @param end the upper bound of the range of journal articles (not inclusive)
11353             * @return the range of matching journal articles
11354             * @throws SystemException if a system exception occurred
11355             */
11356            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
11357                    int start, int end) throws SystemException {
11358                    return findByG_L(groupId, layoutUuid, start, end, null);
11359            }
11360    
11361            /**
11362             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
11363             *
11364             * <p>
11365             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11366             * </p>
11367             *
11368             * @param groupId the group ID
11369             * @param layoutUuid the layout uuid
11370             * @param start the lower bound of the range of journal articles
11371             * @param end the upper bound of the range of journal articles (not inclusive)
11372             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11373             * @return the ordered range of matching journal articles
11374             * @throws SystemException if a system exception occurred
11375             */
11376            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
11377                    int start, int end, OrderByComparator orderByComparator)
11378                    throws SystemException {
11379                    FinderPath finderPath = null;
11380                    Object[] finderArgs = null;
11381    
11382                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11383                                    (orderByComparator == null)) {
11384                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
11385                            finderArgs = new Object[] { groupId, layoutUuid };
11386                    }
11387                    else {
11388                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
11389                            finderArgs = new Object[] {
11390                                            groupId, layoutUuid,
11391                                            
11392                                            start, end, orderByComparator
11393                                    };
11394                    }
11395    
11396                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11397                                    finderArgs, this);
11398    
11399                    if ((list != null) && !list.isEmpty()) {
11400                            for (JournalArticle journalArticle : list) {
11401                                    if ((groupId != journalArticle.getGroupId()) ||
11402                                                    !Validator.equals(layoutUuid,
11403                                                            journalArticle.getLayoutUuid())) {
11404                                            list = null;
11405    
11406                                            break;
11407                                    }
11408                            }
11409                    }
11410    
11411                    if (list == null) {
11412                            StringBundler query = null;
11413    
11414                            if (orderByComparator != null) {
11415                                    query = new StringBundler(4 +
11416                                                    (orderByComparator.getOrderByFields().length * 3));
11417                            }
11418                            else {
11419                                    query = new StringBundler(4);
11420                            }
11421    
11422                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11423    
11424                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
11425    
11426                            if (layoutUuid == null) {
11427                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
11428                            }
11429                            else {
11430                                    if (layoutUuid.equals(StringPool.BLANK)) {
11431                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
11432                                    }
11433                                    else {
11434                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
11435                                    }
11436                            }
11437    
11438                            if (orderByComparator != null) {
11439                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11440                                            orderByComparator);
11441                            }
11442    
11443                            else {
11444                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11445                            }
11446    
11447                            String sql = query.toString();
11448    
11449                            Session session = null;
11450    
11451                            try {
11452                                    session = openSession();
11453    
11454                                    Query q = session.createQuery(sql);
11455    
11456                                    QueryPos qPos = QueryPos.getInstance(q);
11457    
11458                                    qPos.add(groupId);
11459    
11460                                    if (layoutUuid != null) {
11461                                            qPos.add(layoutUuid);
11462                                    }
11463    
11464                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
11465                                                    start, end);
11466                            }
11467                            catch (Exception e) {
11468                                    throw processException(e);
11469                            }
11470                            finally {
11471                                    if (list == null) {
11472                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
11473                                    }
11474                                    else {
11475                                            cacheResult(list);
11476    
11477                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
11478                                    }
11479    
11480                                    closeSession(session);
11481                            }
11482                    }
11483    
11484                    return list;
11485            }
11486    
11487            /**
11488             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
11489             *
11490             * @param groupId the group ID
11491             * @param layoutUuid the layout uuid
11492             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11493             * @return the first matching journal article
11494             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11495             * @throws SystemException if a system exception occurred
11496             */
11497            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
11498                    OrderByComparator orderByComparator)
11499                    throws NoSuchArticleException, SystemException {
11500                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
11501                                    orderByComparator);
11502    
11503                    if (journalArticle != null) {
11504                            return journalArticle;
11505                    }
11506    
11507                    StringBundler msg = new StringBundler(6);
11508    
11509                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11510    
11511                    msg.append("groupId=");
11512                    msg.append(groupId);
11513    
11514                    msg.append(", layoutUuid=");
11515                    msg.append(layoutUuid);
11516    
11517                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11518    
11519                    throw new NoSuchArticleException(msg.toString());
11520            }
11521    
11522            /**
11523             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
11524             *
11525             * @param groupId the group ID
11526             * @param layoutUuid the layout uuid
11527             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11528             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11529             * @throws SystemException if a system exception occurred
11530             */
11531            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
11532                    OrderByComparator orderByComparator) throws SystemException {
11533                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
11534                                    orderByComparator);
11535    
11536                    if (!list.isEmpty()) {
11537                            return list.get(0);
11538                    }
11539    
11540                    return null;
11541            }
11542    
11543            /**
11544             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
11545             *
11546             * @param groupId the group ID
11547             * @param layoutUuid the layout uuid
11548             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11549             * @return the last matching journal article
11550             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11551             * @throws SystemException if a system exception occurred
11552             */
11553            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
11554                    OrderByComparator orderByComparator)
11555                    throws NoSuchArticleException, SystemException {
11556                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
11557                                    orderByComparator);
11558    
11559                    if (journalArticle != null) {
11560                            return journalArticle;
11561                    }
11562    
11563                    StringBundler msg = new StringBundler(6);
11564    
11565                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11566    
11567                    msg.append("groupId=");
11568                    msg.append(groupId);
11569    
11570                    msg.append(", layoutUuid=");
11571                    msg.append(layoutUuid);
11572    
11573                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11574    
11575                    throw new NoSuchArticleException(msg.toString());
11576            }
11577    
11578            /**
11579             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
11580             *
11581             * @param groupId the group ID
11582             * @param layoutUuid the layout uuid
11583             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11584             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
11585             * @throws SystemException if a system exception occurred
11586             */
11587            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
11588                    OrderByComparator orderByComparator) throws SystemException {
11589                    int count = countByG_L(groupId, layoutUuid);
11590    
11591                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
11592                                    count, orderByComparator);
11593    
11594                    if (!list.isEmpty()) {
11595                            return list.get(0);
11596                    }
11597    
11598                    return null;
11599            }
11600    
11601            /**
11602             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
11603             *
11604             * @param id the primary key of the current journal article
11605             * @param groupId the group ID
11606             * @param layoutUuid the layout uuid
11607             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11608             * @return the previous, current, and next journal article
11609             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11610             * @throws SystemException if a system exception occurred
11611             */
11612            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
11613                    String layoutUuid, OrderByComparator orderByComparator)
11614                    throws NoSuchArticleException, SystemException {
11615                    JournalArticle journalArticle = findByPrimaryKey(id);
11616    
11617                    Session session = null;
11618    
11619                    try {
11620                            session = openSession();
11621    
11622                            JournalArticle[] array = new JournalArticleImpl[3];
11623    
11624                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
11625                                            layoutUuid, orderByComparator, true);
11626    
11627                            array[1] = journalArticle;
11628    
11629                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
11630                                            layoutUuid, orderByComparator, false);
11631    
11632                            return array;
11633                    }
11634                    catch (Exception e) {
11635                            throw processException(e);
11636                    }
11637                    finally {
11638                            closeSession(session);
11639                    }
11640            }
11641    
11642            protected JournalArticle getByG_L_PrevAndNext(Session session,
11643                    JournalArticle journalArticle, long groupId, String layoutUuid,
11644                    OrderByComparator orderByComparator, boolean previous) {
11645                    StringBundler query = null;
11646    
11647                    if (orderByComparator != null) {
11648                            query = new StringBundler(6 +
11649                                            (orderByComparator.getOrderByFields().length * 6));
11650                    }
11651                    else {
11652                            query = new StringBundler(3);
11653                    }
11654    
11655                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11656    
11657                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
11658    
11659                    if (layoutUuid == null) {
11660                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
11661                    }
11662                    else {
11663                            if (layoutUuid.equals(StringPool.BLANK)) {
11664                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
11665                            }
11666                            else {
11667                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
11668                            }
11669                    }
11670    
11671                    if (orderByComparator != null) {
11672                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11673    
11674                            if (orderByConditionFields.length > 0) {
11675                                    query.append(WHERE_AND);
11676                            }
11677    
11678                            for (int i = 0; i < orderByConditionFields.length; i++) {
11679                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11680                                    query.append(orderByConditionFields[i]);
11681    
11682                                    if ((i + 1) < orderByConditionFields.length) {
11683                                            if (orderByComparator.isAscending() ^ previous) {
11684                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11685                                            }
11686                                            else {
11687                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11688                                            }
11689                                    }
11690                                    else {
11691                                            if (orderByComparator.isAscending() ^ previous) {
11692                                                    query.append(WHERE_GREATER_THAN);
11693                                            }
11694                                            else {
11695                                                    query.append(WHERE_LESSER_THAN);
11696                                            }
11697                                    }
11698                            }
11699    
11700                            query.append(ORDER_BY_CLAUSE);
11701    
11702                            String[] orderByFields = orderByComparator.getOrderByFields();
11703    
11704                            for (int i = 0; i < orderByFields.length; i++) {
11705                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11706                                    query.append(orderByFields[i]);
11707    
11708                                    if ((i + 1) < orderByFields.length) {
11709                                            if (orderByComparator.isAscending() ^ previous) {
11710                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11711                                            }
11712                                            else {
11713                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11714                                            }
11715                                    }
11716                                    else {
11717                                            if (orderByComparator.isAscending() ^ previous) {
11718                                                    query.append(ORDER_BY_ASC);
11719                                            }
11720                                            else {
11721                                                    query.append(ORDER_BY_DESC);
11722                                            }
11723                                    }
11724                            }
11725                    }
11726    
11727                    else {
11728                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11729                    }
11730    
11731                    String sql = query.toString();
11732    
11733                    Query q = session.createQuery(sql);
11734    
11735                    q.setFirstResult(0);
11736                    q.setMaxResults(2);
11737    
11738                    QueryPos qPos = QueryPos.getInstance(q);
11739    
11740                    qPos.add(groupId);
11741    
11742                    if (layoutUuid != null) {
11743                            qPos.add(layoutUuid);
11744                    }
11745    
11746                    if (orderByComparator != null) {
11747                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11748    
11749                            for (Object value : values) {
11750                                    qPos.add(value);
11751                            }
11752                    }
11753    
11754                    List<JournalArticle> list = q.list();
11755    
11756                    if (list.size() == 2) {
11757                            return list.get(1);
11758                    }
11759                    else {
11760                            return null;
11761                    }
11762            }
11763    
11764            /**
11765             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
11766             *
11767             * @param groupId the group ID
11768             * @param layoutUuid the layout uuid
11769             * @return the matching journal articles that the user has permission to view
11770             * @throws SystemException if a system exception occurred
11771             */
11772            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
11773                    throws SystemException {
11774                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
11775                            QueryUtil.ALL_POS, null);
11776            }
11777    
11778            /**
11779             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
11780             *
11781             * <p>
11782             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11783             * </p>
11784             *
11785             * @param groupId the group ID
11786             * @param layoutUuid the layout uuid
11787             * @param start the lower bound of the range of journal articles
11788             * @param end the upper bound of the range of journal articles (not inclusive)
11789             * @return the range of matching journal articles that the user has permission to view
11790             * @throws SystemException if a system exception occurred
11791             */
11792            public List<JournalArticle> filterFindByG_L(long groupId,
11793                    String layoutUuid, int start, int end) throws SystemException {
11794                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
11795            }
11796    
11797            /**
11798             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
11799             *
11800             * <p>
11801             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11802             * </p>
11803             *
11804             * @param groupId the group ID
11805             * @param layoutUuid the layout uuid
11806             * @param start the lower bound of the range of journal articles
11807             * @param end the upper bound of the range of journal articles (not inclusive)
11808             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11809             * @return the ordered range of matching journal articles that the user has permission to view
11810             * @throws SystemException if a system exception occurred
11811             */
11812            public List<JournalArticle> filterFindByG_L(long groupId,
11813                    String layoutUuid, int start, int end,
11814                    OrderByComparator orderByComparator) throws SystemException {
11815                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11816                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
11817                    }
11818    
11819                    StringBundler query = null;
11820    
11821                    if (orderByComparator != null) {
11822                            query = new StringBundler(4 +
11823                                            (orderByComparator.getOrderByFields().length * 3));
11824                    }
11825                    else {
11826                            query = new StringBundler(4);
11827                    }
11828    
11829                    if (getDB().isSupportsInlineDistinct()) {
11830                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11831                    }
11832                    else {
11833                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11834                    }
11835    
11836                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
11837    
11838                    if (layoutUuid == null) {
11839                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
11840                    }
11841                    else {
11842                            if (layoutUuid.equals(StringPool.BLANK)) {
11843                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
11844                            }
11845                            else {
11846                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
11847                            }
11848                    }
11849    
11850                    if (!getDB().isSupportsInlineDistinct()) {
11851                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11852                    }
11853    
11854                    if (orderByComparator != null) {
11855                            if (getDB().isSupportsInlineDistinct()) {
11856                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11857                                            orderByComparator);
11858                            }
11859                            else {
11860                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11861                                            orderByComparator);
11862                            }
11863                    }
11864    
11865                    else {
11866                            if (getDB().isSupportsInlineDistinct()) {
11867                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11868                            }
11869                            else {
11870                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11871                            }
11872                    }
11873    
11874                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11875                                    JournalArticle.class.getName(),
11876                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11877    
11878                    Session session = null;
11879    
11880                    try {
11881                            session = openSession();
11882    
11883                            SQLQuery q = session.createSQLQuery(sql);
11884    
11885                            if (getDB().isSupportsInlineDistinct()) {
11886                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11887                            }
11888                            else {
11889                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11890                            }
11891    
11892                            QueryPos qPos = QueryPos.getInstance(q);
11893    
11894                            qPos.add(groupId);
11895    
11896                            if (layoutUuid != null) {
11897                                    qPos.add(layoutUuid);
11898                            }
11899    
11900                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11901                                    end);
11902                    }
11903                    catch (Exception e) {
11904                            throw processException(e);
11905                    }
11906                    finally {
11907                            closeSession(session);
11908                    }
11909            }
11910    
11911            /**
11912             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
11913             *
11914             * @param id the primary key of the current journal article
11915             * @param groupId the group ID
11916             * @param layoutUuid the layout uuid
11917             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11918             * @return the previous, current, and next journal article
11919             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11920             * @throws SystemException if a system exception occurred
11921             */
11922            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
11923                    String layoutUuid, OrderByComparator orderByComparator)
11924                    throws NoSuchArticleException, SystemException {
11925                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11926                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
11927                                    orderByComparator);
11928                    }
11929    
11930                    JournalArticle journalArticle = findByPrimaryKey(id);
11931    
11932                    Session session = null;
11933    
11934                    try {
11935                            session = openSession();
11936    
11937                            JournalArticle[] array = new JournalArticleImpl[3];
11938    
11939                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
11940                                            groupId, layoutUuid, orderByComparator, true);
11941    
11942                            array[1] = journalArticle;
11943    
11944                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
11945                                            groupId, layoutUuid, orderByComparator, false);
11946    
11947                            return array;
11948                    }
11949                    catch (Exception e) {
11950                            throw processException(e);
11951                    }
11952                    finally {
11953                            closeSession(session);
11954                    }
11955            }
11956    
11957            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
11958                    JournalArticle journalArticle, long groupId, String layoutUuid,
11959                    OrderByComparator orderByComparator, boolean previous) {
11960                    StringBundler query = null;
11961    
11962                    if (orderByComparator != null) {
11963                            query = new StringBundler(6 +
11964                                            (orderByComparator.getOrderByFields().length * 6));
11965                    }
11966                    else {
11967                            query = new StringBundler(3);
11968                    }
11969    
11970                    if (getDB().isSupportsInlineDistinct()) {
11971                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11972                    }
11973                    else {
11974                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11975                    }
11976    
11977                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
11978    
11979                    if (layoutUuid == null) {
11980                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
11981                    }
11982                    else {
11983                            if (layoutUuid.equals(StringPool.BLANK)) {
11984                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
11985                            }
11986                            else {
11987                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
11988                            }
11989                    }
11990    
11991                    if (!getDB().isSupportsInlineDistinct()) {
11992                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11993                    }
11994    
11995                    if (orderByComparator != null) {
11996                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11997    
11998                            if (orderByConditionFields.length > 0) {
11999                                    query.append(WHERE_AND);
12000                            }
12001    
12002                            for (int i = 0; i < orderByConditionFields.length; i++) {
12003                                    if (getDB().isSupportsInlineDistinct()) {
12004                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12005                                    }
12006                                    else {
12007                                            query.append(_ORDER_BY_ENTITY_TABLE);
12008                                    }
12009    
12010                                    query.append(orderByConditionFields[i]);
12011    
12012                                    if ((i + 1) < orderByConditionFields.length) {
12013                                            if (orderByComparator.isAscending() ^ previous) {
12014                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12015                                            }
12016                                            else {
12017                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12018                                            }
12019                                    }
12020                                    else {
12021                                            if (orderByComparator.isAscending() ^ previous) {
12022                                                    query.append(WHERE_GREATER_THAN);
12023                                            }
12024                                            else {
12025                                                    query.append(WHERE_LESSER_THAN);
12026                                            }
12027                                    }
12028                            }
12029    
12030                            query.append(ORDER_BY_CLAUSE);
12031    
12032                            String[] orderByFields = orderByComparator.getOrderByFields();
12033    
12034                            for (int i = 0; i < orderByFields.length; i++) {
12035                                    if (getDB().isSupportsInlineDistinct()) {
12036                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12037                                    }
12038                                    else {
12039                                            query.append(_ORDER_BY_ENTITY_TABLE);
12040                                    }
12041    
12042                                    query.append(orderByFields[i]);
12043    
12044                                    if ((i + 1) < orderByFields.length) {
12045                                            if (orderByComparator.isAscending() ^ previous) {
12046                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12047                                            }
12048                                            else {
12049                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12050                                            }
12051                                    }
12052                                    else {
12053                                            if (orderByComparator.isAscending() ^ previous) {
12054                                                    query.append(ORDER_BY_ASC);
12055                                            }
12056                                            else {
12057                                                    query.append(ORDER_BY_DESC);
12058                                            }
12059                                    }
12060                            }
12061                    }
12062    
12063                    else {
12064                            if (getDB().isSupportsInlineDistinct()) {
12065                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12066                            }
12067                            else {
12068                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12069                            }
12070                    }
12071    
12072                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12073                                    JournalArticle.class.getName(),
12074                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12075    
12076                    SQLQuery q = session.createSQLQuery(sql);
12077    
12078                    q.setFirstResult(0);
12079                    q.setMaxResults(2);
12080    
12081                    if (getDB().isSupportsInlineDistinct()) {
12082                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12083                    }
12084                    else {
12085                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12086                    }
12087    
12088                    QueryPos qPos = QueryPos.getInstance(q);
12089    
12090                    qPos.add(groupId);
12091    
12092                    if (layoutUuid != null) {
12093                            qPos.add(layoutUuid);
12094                    }
12095    
12096                    if (orderByComparator != null) {
12097                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12098    
12099                            for (Object value : values) {
12100                                    qPos.add(value);
12101                            }
12102                    }
12103    
12104                    List<JournalArticle> list = q.list();
12105    
12106                    if (list.size() == 2) {
12107                            return list.get(1);
12108                    }
12109                    else {
12110                            return null;
12111                    }
12112            }
12113    
12114            /**
12115             * Returns all the journal articles where groupId = &#63; and status = &#63;.
12116             *
12117             * @param groupId the group ID
12118             * @param status the status
12119             * @return the matching journal articles
12120             * @throws SystemException if a system exception occurred
12121             */
12122            public List<JournalArticle> findByG_ST(long groupId, int status)
12123                    throws SystemException {
12124                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
12125                            QueryUtil.ALL_POS, null);
12126            }
12127    
12128            /**
12129             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
12130             *
12131             * <p>
12132             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12133             * </p>
12134             *
12135             * @param groupId the group ID
12136             * @param status the status
12137             * @param start the lower bound of the range of journal articles
12138             * @param end the upper bound of the range of journal articles (not inclusive)
12139             * @return the range of matching journal articles
12140             * @throws SystemException if a system exception occurred
12141             */
12142            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
12143                    int end) throws SystemException {
12144                    return findByG_ST(groupId, status, start, end, null);
12145            }
12146    
12147            /**
12148             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
12149             *
12150             * <p>
12151             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12152             * </p>
12153             *
12154             * @param groupId the group ID
12155             * @param status the status
12156             * @param start the lower bound of the range of journal articles
12157             * @param end the upper bound of the range of journal articles (not inclusive)
12158             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12159             * @return the ordered range of matching journal articles
12160             * @throws SystemException if a system exception occurred
12161             */
12162            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
12163                    int end, OrderByComparator orderByComparator) throws SystemException {
12164                    FinderPath finderPath = null;
12165                    Object[] finderArgs = null;
12166    
12167                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12168                                    (orderByComparator == null)) {
12169                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
12170                            finderArgs = new Object[] { groupId, status };
12171                    }
12172                    else {
12173                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
12174                            finderArgs = new Object[] {
12175                                            groupId, status,
12176                                            
12177                                            start, end, orderByComparator
12178                                    };
12179                    }
12180    
12181                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12182                                    finderArgs, this);
12183    
12184                    if ((list != null) && !list.isEmpty()) {
12185                            for (JournalArticle journalArticle : list) {
12186                                    if ((groupId != journalArticle.getGroupId()) ||
12187                                                    (status != journalArticle.getStatus())) {
12188                                            list = null;
12189    
12190                                            break;
12191                                    }
12192                            }
12193                    }
12194    
12195                    if (list == null) {
12196                            StringBundler query = null;
12197    
12198                            if (orderByComparator != null) {
12199                                    query = new StringBundler(4 +
12200                                                    (orderByComparator.getOrderByFields().length * 3));
12201                            }
12202                            else {
12203                                    query = new StringBundler(4);
12204                            }
12205    
12206                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12207    
12208                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
12209    
12210                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
12211    
12212                            if (orderByComparator != null) {
12213                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12214                                            orderByComparator);
12215                            }
12216    
12217                            else {
12218                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12219                            }
12220    
12221                            String sql = query.toString();
12222    
12223                            Session session = null;
12224    
12225                            try {
12226                                    session = openSession();
12227    
12228                                    Query q = session.createQuery(sql);
12229    
12230                                    QueryPos qPos = QueryPos.getInstance(q);
12231    
12232                                    qPos.add(groupId);
12233    
12234                                    qPos.add(status);
12235    
12236                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
12237                                                    start, end);
12238                            }
12239                            catch (Exception e) {
12240                                    throw processException(e);
12241                            }
12242                            finally {
12243                                    if (list == null) {
12244                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
12245                                    }
12246                                    else {
12247                                            cacheResult(list);
12248    
12249                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12250                                    }
12251    
12252                                    closeSession(session);
12253                            }
12254                    }
12255    
12256                    return list;
12257            }
12258    
12259            /**
12260             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
12261             *
12262             * @param groupId the group ID
12263             * @param status the status
12264             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12265             * @return the first matching journal article
12266             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12267             * @throws SystemException if a system exception occurred
12268             */
12269            public JournalArticle findByG_ST_First(long groupId, int status,
12270                    OrderByComparator orderByComparator)
12271                    throws NoSuchArticleException, SystemException {
12272                    JournalArticle journalArticle = fetchByG_ST_First(groupId, status,
12273                                    orderByComparator);
12274    
12275                    if (journalArticle != null) {
12276                            return journalArticle;
12277                    }
12278    
12279                    StringBundler msg = new StringBundler(6);
12280    
12281                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12282    
12283                    msg.append("groupId=");
12284                    msg.append(groupId);
12285    
12286                    msg.append(", status=");
12287                    msg.append(status);
12288    
12289                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12290    
12291                    throw new NoSuchArticleException(msg.toString());
12292            }
12293    
12294            /**
12295             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
12296             *
12297             * @param groupId the group ID
12298             * @param status the status
12299             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12300             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12301             * @throws SystemException if a system exception occurred
12302             */
12303            public JournalArticle fetchByG_ST_First(long groupId, int status,
12304                    OrderByComparator orderByComparator) throws SystemException {
12305                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
12306                                    orderByComparator);
12307    
12308                    if (!list.isEmpty()) {
12309                            return list.get(0);
12310                    }
12311    
12312                    return null;
12313            }
12314    
12315            /**
12316             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
12317             *
12318             * @param groupId the group ID
12319             * @param status the status
12320             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12321             * @return the last matching journal article
12322             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12323             * @throws SystemException if a system exception occurred
12324             */
12325            public JournalArticle findByG_ST_Last(long groupId, int status,
12326                    OrderByComparator orderByComparator)
12327                    throws NoSuchArticleException, SystemException {
12328                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
12329                                    orderByComparator);
12330    
12331                    if (journalArticle != null) {
12332                            return journalArticle;
12333                    }
12334    
12335                    StringBundler msg = new StringBundler(6);
12336    
12337                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12338    
12339                    msg.append("groupId=");
12340                    msg.append(groupId);
12341    
12342                    msg.append(", status=");
12343                    msg.append(status);
12344    
12345                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12346    
12347                    throw new NoSuchArticleException(msg.toString());
12348            }
12349    
12350            /**
12351             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
12352             *
12353             * @param groupId the group ID
12354             * @param status the status
12355             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12356             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12357             * @throws SystemException if a system exception occurred
12358             */
12359            public JournalArticle fetchByG_ST_Last(long groupId, int status,
12360                    OrderByComparator orderByComparator) throws SystemException {
12361                    int count = countByG_ST(groupId, status);
12362    
12363                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
12364                                    count, orderByComparator);
12365    
12366                    if (!list.isEmpty()) {
12367                            return list.get(0);
12368                    }
12369    
12370                    return null;
12371            }
12372    
12373            /**
12374             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
12375             *
12376             * @param id the primary key of the current journal article
12377             * @param groupId the group ID
12378             * @param status the status
12379             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12380             * @return the previous, current, and next journal article
12381             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12382             * @throws SystemException if a system exception occurred
12383             */
12384            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
12385                    int status, OrderByComparator orderByComparator)
12386                    throws NoSuchArticleException, SystemException {
12387                    JournalArticle journalArticle = findByPrimaryKey(id);
12388    
12389                    Session session = null;
12390    
12391                    try {
12392                            session = openSession();
12393    
12394                            JournalArticle[] array = new JournalArticleImpl[3];
12395    
12396                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
12397                                            status, orderByComparator, true);
12398    
12399                            array[1] = journalArticle;
12400    
12401                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
12402                                            status, orderByComparator, false);
12403    
12404                            return array;
12405                    }
12406                    catch (Exception e) {
12407                            throw processException(e);
12408                    }
12409                    finally {
12410                            closeSession(session);
12411                    }
12412            }
12413    
12414            protected JournalArticle getByG_ST_PrevAndNext(Session session,
12415                    JournalArticle journalArticle, long groupId, int status,
12416                    OrderByComparator orderByComparator, boolean previous) {
12417                    StringBundler query = null;
12418    
12419                    if (orderByComparator != null) {
12420                            query = new StringBundler(6 +
12421                                            (orderByComparator.getOrderByFields().length * 6));
12422                    }
12423                    else {
12424                            query = new StringBundler(3);
12425                    }
12426    
12427                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12428    
12429                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
12430    
12431                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
12432    
12433                    if (orderByComparator != null) {
12434                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12435    
12436                            if (orderByConditionFields.length > 0) {
12437                                    query.append(WHERE_AND);
12438                            }
12439    
12440                            for (int i = 0; i < orderByConditionFields.length; i++) {
12441                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12442                                    query.append(orderByConditionFields[i]);
12443    
12444                                    if ((i + 1) < orderByConditionFields.length) {
12445                                            if (orderByComparator.isAscending() ^ previous) {
12446                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12447                                            }
12448                                            else {
12449                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12450                                            }
12451                                    }
12452                                    else {
12453                                            if (orderByComparator.isAscending() ^ previous) {
12454                                                    query.append(WHERE_GREATER_THAN);
12455                                            }
12456                                            else {
12457                                                    query.append(WHERE_LESSER_THAN);
12458                                            }
12459                                    }
12460                            }
12461    
12462                            query.append(ORDER_BY_CLAUSE);
12463    
12464                            String[] orderByFields = orderByComparator.getOrderByFields();
12465    
12466                            for (int i = 0; i < orderByFields.length; i++) {
12467                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12468                                    query.append(orderByFields[i]);
12469    
12470                                    if ((i + 1) < orderByFields.length) {
12471                                            if (orderByComparator.isAscending() ^ previous) {
12472                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12473                                            }
12474                                            else {
12475                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12476                                            }
12477                                    }
12478                                    else {
12479                                            if (orderByComparator.isAscending() ^ previous) {
12480                                                    query.append(ORDER_BY_ASC);
12481                                            }
12482                                            else {
12483                                                    query.append(ORDER_BY_DESC);
12484                                            }
12485                                    }
12486                            }
12487                    }
12488    
12489                    else {
12490                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12491                    }
12492    
12493                    String sql = query.toString();
12494    
12495                    Query q = session.createQuery(sql);
12496    
12497                    q.setFirstResult(0);
12498                    q.setMaxResults(2);
12499    
12500                    QueryPos qPos = QueryPos.getInstance(q);
12501    
12502                    qPos.add(groupId);
12503    
12504                    qPos.add(status);
12505    
12506                    if (orderByComparator != null) {
12507                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12508    
12509                            for (Object value : values) {
12510                                    qPos.add(value);
12511                            }
12512                    }
12513    
12514                    List<JournalArticle> list = q.list();
12515    
12516                    if (list.size() == 2) {
12517                            return list.get(1);
12518                    }
12519                    else {
12520                            return null;
12521                    }
12522            }
12523    
12524            /**
12525             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
12526             *
12527             * @param groupId the group ID
12528             * @param status the status
12529             * @return the matching journal articles that the user has permission to view
12530             * @throws SystemException if a system exception occurred
12531             */
12532            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
12533                    throws SystemException {
12534                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
12535                            QueryUtil.ALL_POS, null);
12536            }
12537    
12538            /**
12539             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
12540             *
12541             * <p>
12542             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12543             * </p>
12544             *
12545             * @param groupId the group ID
12546             * @param status the status
12547             * @param start the lower bound of the range of journal articles
12548             * @param end the upper bound of the range of journal articles (not inclusive)
12549             * @return the range of matching journal articles that the user has permission to view
12550             * @throws SystemException if a system exception occurred
12551             */
12552            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
12553                    int start, int end) throws SystemException {
12554                    return filterFindByG_ST(groupId, status, start, end, null);
12555            }
12556    
12557            /**
12558             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
12559             *
12560             * <p>
12561             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12562             * </p>
12563             *
12564             * @param groupId the group ID
12565             * @param status the status
12566             * @param start the lower bound of the range of journal articles
12567             * @param end the upper bound of the range of journal articles (not inclusive)
12568             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12569             * @return the ordered range of matching journal articles that the user has permission to view
12570             * @throws SystemException if a system exception occurred
12571             */
12572            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
12573                    int start, int end, OrderByComparator orderByComparator)
12574                    throws SystemException {
12575                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12576                            return findByG_ST(groupId, status, start, end, orderByComparator);
12577                    }
12578    
12579                    StringBundler query = null;
12580    
12581                    if (orderByComparator != null) {
12582                            query = new StringBundler(4 +
12583                                            (orderByComparator.getOrderByFields().length * 3));
12584                    }
12585                    else {
12586                            query = new StringBundler(4);
12587                    }
12588    
12589                    if (getDB().isSupportsInlineDistinct()) {
12590                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12591                    }
12592                    else {
12593                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12594                    }
12595    
12596                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
12597    
12598                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
12599    
12600                    if (!getDB().isSupportsInlineDistinct()) {
12601                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12602                    }
12603    
12604                    if (orderByComparator != null) {
12605                            if (getDB().isSupportsInlineDistinct()) {
12606                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12607                                            orderByComparator);
12608                            }
12609                            else {
12610                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12611                                            orderByComparator);
12612                            }
12613                    }
12614    
12615                    else {
12616                            if (getDB().isSupportsInlineDistinct()) {
12617                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12618                            }
12619                            else {
12620                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12621                            }
12622                    }
12623    
12624                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12625                                    JournalArticle.class.getName(),
12626                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12627    
12628                    Session session = null;
12629    
12630                    try {
12631                            session = openSession();
12632    
12633                            SQLQuery q = session.createSQLQuery(sql);
12634    
12635                            if (getDB().isSupportsInlineDistinct()) {
12636                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12637                            }
12638                            else {
12639                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12640                            }
12641    
12642                            QueryPos qPos = QueryPos.getInstance(q);
12643    
12644                            qPos.add(groupId);
12645    
12646                            qPos.add(status);
12647    
12648                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12649                                    end);
12650                    }
12651                    catch (Exception e) {
12652                            throw processException(e);
12653                    }
12654                    finally {
12655                            closeSession(session);
12656                    }
12657            }
12658    
12659            /**
12660             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
12661             *
12662             * @param id the primary key of the current journal article
12663             * @param groupId the group ID
12664             * @param status the status
12665             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12666             * @return the previous, current, and next journal article
12667             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12668             * @throws SystemException if a system exception occurred
12669             */
12670            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
12671                    int status, OrderByComparator orderByComparator)
12672                    throws NoSuchArticleException, SystemException {
12673                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12674                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
12675                    }
12676    
12677                    JournalArticle journalArticle = findByPrimaryKey(id);
12678    
12679                    Session session = null;
12680    
12681                    try {
12682                            session = openSession();
12683    
12684                            JournalArticle[] array = new JournalArticleImpl[3];
12685    
12686                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
12687                                            groupId, status, orderByComparator, true);
12688    
12689                            array[1] = journalArticle;
12690    
12691                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
12692                                            groupId, status, orderByComparator, false);
12693    
12694                            return array;
12695                    }
12696                    catch (Exception e) {
12697                            throw processException(e);
12698                    }
12699                    finally {
12700                            closeSession(session);
12701                    }
12702            }
12703    
12704            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
12705                    JournalArticle journalArticle, long groupId, int status,
12706                    OrderByComparator orderByComparator, boolean previous) {
12707                    StringBundler query = null;
12708    
12709                    if (orderByComparator != null) {
12710                            query = new StringBundler(6 +
12711                                            (orderByComparator.getOrderByFields().length * 6));
12712                    }
12713                    else {
12714                            query = new StringBundler(3);
12715                    }
12716    
12717                    if (getDB().isSupportsInlineDistinct()) {
12718                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12719                    }
12720                    else {
12721                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12722                    }
12723    
12724                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
12725    
12726                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
12727    
12728                    if (!getDB().isSupportsInlineDistinct()) {
12729                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12730                    }
12731    
12732                    if (orderByComparator != null) {
12733                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12734    
12735                            if (orderByConditionFields.length > 0) {
12736                                    query.append(WHERE_AND);
12737                            }
12738    
12739                            for (int i = 0; i < orderByConditionFields.length; i++) {
12740                                    if (getDB().isSupportsInlineDistinct()) {
12741                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12742                                    }
12743                                    else {
12744                                            query.append(_ORDER_BY_ENTITY_TABLE);
12745                                    }
12746    
12747                                    query.append(orderByConditionFields[i]);
12748    
12749                                    if ((i + 1) < orderByConditionFields.length) {
12750                                            if (orderByComparator.isAscending() ^ previous) {
12751                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12752                                            }
12753                                            else {
12754                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12755                                            }
12756                                    }
12757                                    else {
12758                                            if (orderByComparator.isAscending() ^ previous) {
12759                                                    query.append(WHERE_GREATER_THAN);
12760                                            }
12761                                            else {
12762                                                    query.append(WHERE_LESSER_THAN);
12763                                            }
12764                                    }
12765                            }
12766    
12767                            query.append(ORDER_BY_CLAUSE);
12768    
12769                            String[] orderByFields = orderByComparator.getOrderByFields();
12770    
12771                            for (int i = 0; i < orderByFields.length; i++) {
12772                                    if (getDB().isSupportsInlineDistinct()) {
12773                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12774                                    }
12775                                    else {
12776                                            query.append(_ORDER_BY_ENTITY_TABLE);
12777                                    }
12778    
12779                                    query.append(orderByFields[i]);
12780    
12781                                    if ((i + 1) < orderByFields.length) {
12782                                            if (orderByComparator.isAscending() ^ previous) {
12783                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12784                                            }
12785                                            else {
12786                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12787                                            }
12788                                    }
12789                                    else {
12790                                            if (orderByComparator.isAscending() ^ previous) {
12791                                                    query.append(ORDER_BY_ASC);
12792                                            }
12793                                            else {
12794                                                    query.append(ORDER_BY_DESC);
12795                                            }
12796                                    }
12797                            }
12798                    }
12799    
12800                    else {
12801                            if (getDB().isSupportsInlineDistinct()) {
12802                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12803                            }
12804                            else {
12805                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12806                            }
12807                    }
12808    
12809                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12810                                    JournalArticle.class.getName(),
12811                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12812    
12813                    SQLQuery q = session.createSQLQuery(sql);
12814    
12815                    q.setFirstResult(0);
12816                    q.setMaxResults(2);
12817    
12818                    if (getDB().isSupportsInlineDistinct()) {
12819                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12820                    }
12821                    else {
12822                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12823                    }
12824    
12825                    QueryPos qPos = QueryPos.getInstance(q);
12826    
12827                    qPos.add(groupId);
12828    
12829                    qPos.add(status);
12830    
12831                    if (orderByComparator != null) {
12832                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12833    
12834                            for (Object value : values) {
12835                                    qPos.add(value);
12836                            }
12837                    }
12838    
12839                    List<JournalArticle> list = q.list();
12840    
12841                    if (list.size() == 2) {
12842                            return list.get(1);
12843                    }
12844                    else {
12845                            return null;
12846                    }
12847            }
12848    
12849            /**
12850             * Returns all the journal articles where companyId = &#63; and version = &#63;.
12851             *
12852             * @param companyId the company ID
12853             * @param version the version
12854             * @return the matching journal articles
12855             * @throws SystemException if a system exception occurred
12856             */
12857            public List<JournalArticle> findByC_V(long companyId, double version)
12858                    throws SystemException {
12859                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
12860                            QueryUtil.ALL_POS, null);
12861            }
12862    
12863            /**
12864             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
12865             *
12866             * <p>
12867             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12868             * </p>
12869             *
12870             * @param companyId the company ID
12871             * @param version the version
12872             * @param start the lower bound of the range of journal articles
12873             * @param end the upper bound of the range of journal articles (not inclusive)
12874             * @return the range of matching journal articles
12875             * @throws SystemException if a system exception occurred
12876             */
12877            public List<JournalArticle> findByC_V(long companyId, double version,
12878                    int start, int end) throws SystemException {
12879                    return findByC_V(companyId, version, start, end, null);
12880            }
12881    
12882            /**
12883             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
12884             *
12885             * <p>
12886             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12887             * </p>
12888             *
12889             * @param companyId the company ID
12890             * @param version the version
12891             * @param start the lower bound of the range of journal articles
12892             * @param end the upper bound of the range of journal articles (not inclusive)
12893             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12894             * @return the ordered range of matching journal articles
12895             * @throws SystemException if a system exception occurred
12896             */
12897            public List<JournalArticle> findByC_V(long companyId, double version,
12898                    int start, int end, OrderByComparator orderByComparator)
12899                    throws SystemException {
12900                    FinderPath finderPath = null;
12901                    Object[] finderArgs = null;
12902    
12903                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12904                                    (orderByComparator == null)) {
12905                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
12906                            finderArgs = new Object[] { companyId, version };
12907                    }
12908                    else {
12909                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
12910                            finderArgs = new Object[] {
12911                                            companyId, version,
12912                                            
12913                                            start, end, orderByComparator
12914                                    };
12915                    }
12916    
12917                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12918                                    finderArgs, this);
12919    
12920                    if ((list != null) && !list.isEmpty()) {
12921                            for (JournalArticle journalArticle : list) {
12922                                    if ((companyId != journalArticle.getCompanyId()) ||
12923                                                    (version != journalArticle.getVersion())) {
12924                                            list = null;
12925    
12926                                            break;
12927                                    }
12928                            }
12929                    }
12930    
12931                    if (list == null) {
12932                            StringBundler query = null;
12933    
12934                            if (orderByComparator != null) {
12935                                    query = new StringBundler(4 +
12936                                                    (orderByComparator.getOrderByFields().length * 3));
12937                            }
12938                            else {
12939                                    query = new StringBundler(4);
12940                            }
12941    
12942                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12943    
12944                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
12945    
12946                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
12947    
12948                            if (orderByComparator != null) {
12949                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12950                                            orderByComparator);
12951                            }
12952    
12953                            else {
12954                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12955                            }
12956    
12957                            String sql = query.toString();
12958    
12959                            Session session = null;
12960    
12961                            try {
12962                                    session = openSession();
12963    
12964                                    Query q = session.createQuery(sql);
12965    
12966                                    QueryPos qPos = QueryPos.getInstance(q);
12967    
12968                                    qPos.add(companyId);
12969    
12970                                    qPos.add(version);
12971    
12972                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
12973                                                    start, end);
12974                            }
12975                            catch (Exception e) {
12976                                    throw processException(e);
12977                            }
12978                            finally {
12979                                    if (list == null) {
12980                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
12981                                    }
12982                                    else {
12983                                            cacheResult(list);
12984    
12985                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12986                                    }
12987    
12988                                    closeSession(session);
12989                            }
12990                    }
12991    
12992                    return list;
12993            }
12994    
12995            /**
12996             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
12997             *
12998             * @param companyId the company ID
12999             * @param version the version
13000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13001             * @return the first matching journal article
13002             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13003             * @throws SystemException if a system exception occurred
13004             */
13005            public JournalArticle findByC_V_First(long companyId, double version,
13006                    OrderByComparator orderByComparator)
13007                    throws NoSuchArticleException, SystemException {
13008                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
13009                                    orderByComparator);
13010    
13011                    if (journalArticle != null) {
13012                            return journalArticle;
13013                    }
13014    
13015                    StringBundler msg = new StringBundler(6);
13016    
13017                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13018    
13019                    msg.append("companyId=");
13020                    msg.append(companyId);
13021    
13022                    msg.append(", version=");
13023                    msg.append(version);
13024    
13025                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13026    
13027                    throw new NoSuchArticleException(msg.toString());
13028            }
13029    
13030            /**
13031             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
13032             *
13033             * @param companyId the company ID
13034             * @param version the version
13035             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13036             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13037             * @throws SystemException if a system exception occurred
13038             */
13039            public JournalArticle fetchByC_V_First(long companyId, double version,
13040                    OrderByComparator orderByComparator) throws SystemException {
13041                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
13042                                    orderByComparator);
13043    
13044                    if (!list.isEmpty()) {
13045                            return list.get(0);
13046                    }
13047    
13048                    return null;
13049            }
13050    
13051            /**
13052             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
13053             *
13054             * @param companyId the company ID
13055             * @param version the version
13056             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13057             * @return the last matching journal article
13058             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13059             * @throws SystemException if a system exception occurred
13060             */
13061            public JournalArticle findByC_V_Last(long companyId, double version,
13062                    OrderByComparator orderByComparator)
13063                    throws NoSuchArticleException, SystemException {
13064                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
13065                                    orderByComparator);
13066    
13067                    if (journalArticle != null) {
13068                            return journalArticle;
13069                    }
13070    
13071                    StringBundler msg = new StringBundler(6);
13072    
13073                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13074    
13075                    msg.append("companyId=");
13076                    msg.append(companyId);
13077    
13078                    msg.append(", version=");
13079                    msg.append(version);
13080    
13081                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13082    
13083                    throw new NoSuchArticleException(msg.toString());
13084            }
13085    
13086            /**
13087             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
13088             *
13089             * @param companyId the company ID
13090             * @param version the version
13091             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13092             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13093             * @throws SystemException if a system exception occurred
13094             */
13095            public JournalArticle fetchByC_V_Last(long companyId, double version,
13096                    OrderByComparator orderByComparator) throws SystemException {
13097                    int count = countByC_V(companyId, version);
13098    
13099                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
13100                                    count, orderByComparator);
13101    
13102                    if (!list.isEmpty()) {
13103                            return list.get(0);
13104                    }
13105    
13106                    return null;
13107            }
13108    
13109            /**
13110             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
13111             *
13112             * @param id the primary key of the current journal article
13113             * @param companyId the company ID
13114             * @param version the version
13115             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13116             * @return the previous, current, and next journal article
13117             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13118             * @throws SystemException if a system exception occurred
13119             */
13120            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
13121                    double version, OrderByComparator orderByComparator)
13122                    throws NoSuchArticleException, SystemException {
13123                    JournalArticle journalArticle = findByPrimaryKey(id);
13124    
13125                    Session session = null;
13126    
13127                    try {
13128                            session = openSession();
13129    
13130                            JournalArticle[] array = new JournalArticleImpl[3];
13131    
13132                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
13133                                            version, orderByComparator, true);
13134    
13135                            array[1] = journalArticle;
13136    
13137                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
13138                                            version, orderByComparator, false);
13139    
13140                            return array;
13141                    }
13142                    catch (Exception e) {
13143                            throw processException(e);
13144                    }
13145                    finally {
13146                            closeSession(session);
13147                    }
13148            }
13149    
13150            protected JournalArticle getByC_V_PrevAndNext(Session session,
13151                    JournalArticle journalArticle, long companyId, double version,
13152                    OrderByComparator orderByComparator, boolean previous) {
13153                    StringBundler query = null;
13154    
13155                    if (orderByComparator != null) {
13156                            query = new StringBundler(6 +
13157                                            (orderByComparator.getOrderByFields().length * 6));
13158                    }
13159                    else {
13160                            query = new StringBundler(3);
13161                    }
13162    
13163                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13164    
13165                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
13166    
13167                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
13168    
13169                    if (orderByComparator != null) {
13170                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13171    
13172                            if (orderByConditionFields.length > 0) {
13173                                    query.append(WHERE_AND);
13174                            }
13175    
13176                            for (int i = 0; i < orderByConditionFields.length; i++) {
13177                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13178                                    query.append(orderByConditionFields[i]);
13179    
13180                                    if ((i + 1) < orderByConditionFields.length) {
13181                                            if (orderByComparator.isAscending() ^ previous) {
13182                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13183                                            }
13184                                            else {
13185                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13186                                            }
13187                                    }
13188                                    else {
13189                                            if (orderByComparator.isAscending() ^ previous) {
13190                                                    query.append(WHERE_GREATER_THAN);
13191                                            }
13192                                            else {
13193                                                    query.append(WHERE_LESSER_THAN);
13194                                            }
13195                                    }
13196                            }
13197    
13198                            query.append(ORDER_BY_CLAUSE);
13199    
13200                            String[] orderByFields = orderByComparator.getOrderByFields();
13201    
13202                            for (int i = 0; i < orderByFields.length; i++) {
13203                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13204                                    query.append(orderByFields[i]);
13205    
13206                                    if ((i + 1) < orderByFields.length) {
13207                                            if (orderByComparator.isAscending() ^ previous) {
13208                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13209                                            }
13210                                            else {
13211                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13212                                            }
13213                                    }
13214                                    else {
13215                                            if (orderByComparator.isAscending() ^ previous) {
13216                                                    query.append(ORDER_BY_ASC);
13217                                            }
13218                                            else {
13219                                                    query.append(ORDER_BY_DESC);
13220                                            }
13221                                    }
13222                            }
13223                    }
13224    
13225                    else {
13226                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13227                    }
13228    
13229                    String sql = query.toString();
13230    
13231                    Query q = session.createQuery(sql);
13232    
13233                    q.setFirstResult(0);
13234                    q.setMaxResults(2);
13235    
13236                    QueryPos qPos = QueryPos.getInstance(q);
13237    
13238                    qPos.add(companyId);
13239    
13240                    qPos.add(version);
13241    
13242                    if (orderByComparator != null) {
13243                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13244    
13245                            for (Object value : values) {
13246                                    qPos.add(value);
13247                            }
13248                    }
13249    
13250                    List<JournalArticle> list = q.list();
13251    
13252                    if (list.size() == 2) {
13253                            return list.get(1);
13254                    }
13255                    else {
13256                            return null;
13257                    }
13258            }
13259    
13260            /**
13261             * Returns all the journal articles where companyId = &#63; and status = &#63;.
13262             *
13263             * @param companyId the company ID
13264             * @param status the status
13265             * @return the matching journal articles
13266             * @throws SystemException if a system exception occurred
13267             */
13268            public List<JournalArticle> findByC_ST(long companyId, int status)
13269                    throws SystemException {
13270                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
13271                            QueryUtil.ALL_POS, null);
13272            }
13273    
13274            /**
13275             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
13276             *
13277             * <p>
13278             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13279             * </p>
13280             *
13281             * @param companyId the company ID
13282             * @param status the status
13283             * @param start the lower bound of the range of journal articles
13284             * @param end the upper bound of the range of journal articles (not inclusive)
13285             * @return the range of matching journal articles
13286             * @throws SystemException if a system exception occurred
13287             */
13288            public List<JournalArticle> findByC_ST(long companyId, int status,
13289                    int start, int end) throws SystemException {
13290                    return findByC_ST(companyId, status, start, end, null);
13291            }
13292    
13293            /**
13294             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
13295             *
13296             * <p>
13297             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13298             * </p>
13299             *
13300             * @param companyId the company ID
13301             * @param status the status
13302             * @param start the lower bound of the range of journal articles
13303             * @param end the upper bound of the range of journal articles (not inclusive)
13304             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13305             * @return the ordered range of matching journal articles
13306             * @throws SystemException if a system exception occurred
13307             */
13308            public List<JournalArticle> findByC_ST(long companyId, int status,
13309                    int start, int end, OrderByComparator orderByComparator)
13310                    throws SystemException {
13311                    FinderPath finderPath = null;
13312                    Object[] finderArgs = null;
13313    
13314                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13315                                    (orderByComparator == null)) {
13316                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
13317                            finderArgs = new Object[] { companyId, status };
13318                    }
13319                    else {
13320                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
13321                            finderArgs = new Object[] {
13322                                            companyId, status,
13323                                            
13324                                            start, end, orderByComparator
13325                                    };
13326                    }
13327    
13328                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13329                                    finderArgs, this);
13330    
13331                    if ((list != null) && !list.isEmpty()) {
13332                            for (JournalArticle journalArticle : list) {
13333                                    if ((companyId != journalArticle.getCompanyId()) ||
13334                                                    (status != journalArticle.getStatus())) {
13335                                            list = null;
13336    
13337                                            break;
13338                                    }
13339                            }
13340                    }
13341    
13342                    if (list == null) {
13343                            StringBundler query = null;
13344    
13345                            if (orderByComparator != null) {
13346                                    query = new StringBundler(4 +
13347                                                    (orderByComparator.getOrderByFields().length * 3));
13348                            }
13349                            else {
13350                                    query = new StringBundler(4);
13351                            }
13352    
13353                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13354    
13355                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
13356    
13357                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
13358    
13359                            if (orderByComparator != null) {
13360                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13361                                            orderByComparator);
13362                            }
13363    
13364                            else {
13365                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13366                            }
13367    
13368                            String sql = query.toString();
13369    
13370                            Session session = null;
13371    
13372                            try {
13373                                    session = openSession();
13374    
13375                                    Query q = session.createQuery(sql);
13376    
13377                                    QueryPos qPos = QueryPos.getInstance(q);
13378    
13379                                    qPos.add(companyId);
13380    
13381                                    qPos.add(status);
13382    
13383                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
13384                                                    start, end);
13385                            }
13386                            catch (Exception e) {
13387                                    throw processException(e);
13388                            }
13389                            finally {
13390                                    if (list == null) {
13391                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
13392                                    }
13393                                    else {
13394                                            cacheResult(list);
13395    
13396                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
13397                                    }
13398    
13399                                    closeSession(session);
13400                            }
13401                    }
13402    
13403                    return list;
13404            }
13405    
13406            /**
13407             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
13408             *
13409             * @param companyId the company ID
13410             * @param status the status
13411             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13412             * @return the first matching journal article
13413             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13414             * @throws SystemException if a system exception occurred
13415             */
13416            public JournalArticle findByC_ST_First(long companyId, int status,
13417                    OrderByComparator orderByComparator)
13418                    throws NoSuchArticleException, SystemException {
13419                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
13420                                    orderByComparator);
13421    
13422                    if (journalArticle != null) {
13423                            return journalArticle;
13424                    }
13425    
13426                    StringBundler msg = new StringBundler(6);
13427    
13428                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13429    
13430                    msg.append("companyId=");
13431                    msg.append(companyId);
13432    
13433                    msg.append(", status=");
13434                    msg.append(status);
13435    
13436                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13437    
13438                    throw new NoSuchArticleException(msg.toString());
13439            }
13440    
13441            /**
13442             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
13443             *
13444             * @param companyId the company ID
13445             * @param status the status
13446             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13447             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13448             * @throws SystemException if a system exception occurred
13449             */
13450            public JournalArticle fetchByC_ST_First(long companyId, int status,
13451                    OrderByComparator orderByComparator) throws SystemException {
13452                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
13453                                    orderByComparator);
13454    
13455                    if (!list.isEmpty()) {
13456                            return list.get(0);
13457                    }
13458    
13459                    return null;
13460            }
13461    
13462            /**
13463             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
13464             *
13465             * @param companyId the company ID
13466             * @param status the status
13467             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13468             * @return the last matching journal article
13469             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13470             * @throws SystemException if a system exception occurred
13471             */
13472            public JournalArticle findByC_ST_Last(long companyId, int status,
13473                    OrderByComparator orderByComparator)
13474                    throws NoSuchArticleException, SystemException {
13475                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
13476                                    orderByComparator);
13477    
13478                    if (journalArticle != null) {
13479                            return journalArticle;
13480                    }
13481    
13482                    StringBundler msg = new StringBundler(6);
13483    
13484                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13485    
13486                    msg.append("companyId=");
13487                    msg.append(companyId);
13488    
13489                    msg.append(", status=");
13490                    msg.append(status);
13491    
13492                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13493    
13494                    throw new NoSuchArticleException(msg.toString());
13495            }
13496    
13497            /**
13498             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
13499             *
13500             * @param companyId the company ID
13501             * @param status the status
13502             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13503             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13504             * @throws SystemException if a system exception occurred
13505             */
13506            public JournalArticle fetchByC_ST_Last(long companyId, int status,
13507                    OrderByComparator orderByComparator) throws SystemException {
13508                    int count = countByC_ST(companyId, status);
13509    
13510                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
13511                                    count, orderByComparator);
13512    
13513                    if (!list.isEmpty()) {
13514                            return list.get(0);
13515                    }
13516    
13517                    return null;
13518            }
13519    
13520            /**
13521             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
13522             *
13523             * @param id the primary key of the current journal article
13524             * @param companyId the company ID
13525             * @param status the status
13526             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13527             * @return the previous, current, and next journal article
13528             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13529             * @throws SystemException if a system exception occurred
13530             */
13531            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
13532                    int status, OrderByComparator orderByComparator)
13533                    throws NoSuchArticleException, SystemException {
13534                    JournalArticle journalArticle = findByPrimaryKey(id);
13535    
13536                    Session session = null;
13537    
13538                    try {
13539                            session = openSession();
13540    
13541                            JournalArticle[] array = new JournalArticleImpl[3];
13542    
13543                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
13544                                            companyId, status, orderByComparator, true);
13545    
13546                            array[1] = journalArticle;
13547    
13548                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
13549                                            companyId, status, orderByComparator, false);
13550    
13551                            return array;
13552                    }
13553                    catch (Exception e) {
13554                            throw processException(e);
13555                    }
13556                    finally {
13557                            closeSession(session);
13558                    }
13559            }
13560    
13561            protected JournalArticle getByC_ST_PrevAndNext(Session session,
13562                    JournalArticle journalArticle, long companyId, int status,
13563                    OrderByComparator orderByComparator, boolean previous) {
13564                    StringBundler query = null;
13565    
13566                    if (orderByComparator != null) {
13567                            query = new StringBundler(6 +
13568                                            (orderByComparator.getOrderByFields().length * 6));
13569                    }
13570                    else {
13571                            query = new StringBundler(3);
13572                    }
13573    
13574                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13575    
13576                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
13577    
13578                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
13579    
13580                    if (orderByComparator != null) {
13581                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13582    
13583                            if (orderByConditionFields.length > 0) {
13584                                    query.append(WHERE_AND);
13585                            }
13586    
13587                            for (int i = 0; i < orderByConditionFields.length; i++) {
13588                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13589                                    query.append(orderByConditionFields[i]);
13590    
13591                                    if ((i + 1) < orderByConditionFields.length) {
13592                                            if (orderByComparator.isAscending() ^ previous) {
13593                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13594                                            }
13595                                            else {
13596                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13597                                            }
13598                                    }
13599                                    else {
13600                                            if (orderByComparator.isAscending() ^ previous) {
13601                                                    query.append(WHERE_GREATER_THAN);
13602                                            }
13603                                            else {
13604                                                    query.append(WHERE_LESSER_THAN);
13605                                            }
13606                                    }
13607                            }
13608    
13609                            query.append(ORDER_BY_CLAUSE);
13610    
13611                            String[] orderByFields = orderByComparator.getOrderByFields();
13612    
13613                            for (int i = 0; i < orderByFields.length; i++) {
13614                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13615                                    query.append(orderByFields[i]);
13616    
13617                                    if ((i + 1) < orderByFields.length) {
13618                                            if (orderByComparator.isAscending() ^ previous) {
13619                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13620                                            }
13621                                            else {
13622                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13623                                            }
13624                                    }
13625                                    else {
13626                                            if (orderByComparator.isAscending() ^ previous) {
13627                                                    query.append(ORDER_BY_ASC);
13628                                            }
13629                                            else {
13630                                                    query.append(ORDER_BY_DESC);
13631                                            }
13632                                    }
13633                            }
13634                    }
13635    
13636                    else {
13637                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13638                    }
13639    
13640                    String sql = query.toString();
13641    
13642                    Query q = session.createQuery(sql);
13643    
13644                    q.setFirstResult(0);
13645                    q.setMaxResults(2);
13646    
13647                    QueryPos qPos = QueryPos.getInstance(q);
13648    
13649                    qPos.add(companyId);
13650    
13651                    qPos.add(status);
13652    
13653                    if (orderByComparator != null) {
13654                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13655    
13656                            for (Object value : values) {
13657                                    qPos.add(value);
13658                            }
13659                    }
13660    
13661                    List<JournalArticle> list = q.list();
13662    
13663                    if (list.size() == 2) {
13664                            return list.get(1);
13665                    }
13666                    else {
13667                            return null;
13668                    }
13669            }
13670    
13671            /**
13672             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
13673             *
13674             * @param groupId the group ID
13675             * @param folderId the folder ID
13676             * @param status the status
13677             * @return the matching journal articles
13678             * @throws SystemException if a system exception occurred
13679             */
13680            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
13681                    int status) throws SystemException {
13682                    return findByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
13683                            QueryUtil.ALL_POS, null);
13684            }
13685    
13686            /**
13687             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
13688             *
13689             * <p>
13690             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13691             * </p>
13692             *
13693             * @param groupId the group ID
13694             * @param folderId the folder ID
13695             * @param status the status
13696             * @param start the lower bound of the range of journal articles
13697             * @param end the upper bound of the range of journal articles (not inclusive)
13698             * @return the range of matching journal articles
13699             * @throws SystemException if a system exception occurred
13700             */
13701            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
13702                    int status, int start, int end) throws SystemException {
13703                    return findByG_F_ST(groupId, folderId, status, start, end, null);
13704            }
13705    
13706            /**
13707             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
13708             *
13709             * <p>
13710             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13711             * </p>
13712             *
13713             * @param groupId the group ID
13714             * @param folderId the folder ID
13715             * @param status the status
13716             * @param start the lower bound of the range of journal articles
13717             * @param end the upper bound of the range of journal articles (not inclusive)
13718             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13719             * @return the ordered range of matching journal articles
13720             * @throws SystemException if a system exception occurred
13721             */
13722            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
13723                    int status, int start, int end, OrderByComparator orderByComparator)
13724                    throws SystemException {
13725                    FinderPath finderPath = null;
13726                    Object[] finderArgs = null;
13727    
13728                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13729                                    (orderByComparator == null)) {
13730                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_ST;
13731                            finderArgs = new Object[] { groupId, folderId, status };
13732                    }
13733                    else {
13734                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
13735                            finderArgs = new Object[] {
13736                                            groupId, folderId, status,
13737                                            
13738                                            start, end, orderByComparator
13739                                    };
13740                    }
13741    
13742                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13743                                    finderArgs, this);
13744    
13745                    if ((list != null) && !list.isEmpty()) {
13746                            for (JournalArticle journalArticle : list) {
13747                                    if ((groupId != journalArticle.getGroupId()) ||
13748                                                    (folderId != journalArticle.getFolderId()) ||
13749                                                    (status != journalArticle.getStatus())) {
13750                                            list = null;
13751    
13752                                            break;
13753                                    }
13754                            }
13755                    }
13756    
13757                    if (list == null) {
13758                            StringBundler query = null;
13759    
13760                            if (orderByComparator != null) {
13761                                    query = new StringBundler(5 +
13762                                                    (orderByComparator.getOrderByFields().length * 3));
13763                            }
13764                            else {
13765                                    query = new StringBundler(5);
13766                            }
13767    
13768                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13769    
13770                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
13771    
13772                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
13773    
13774                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
13775    
13776                            if (orderByComparator != null) {
13777                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13778                                            orderByComparator);
13779                            }
13780    
13781                            else {
13782                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13783                            }
13784    
13785                            String sql = query.toString();
13786    
13787                            Session session = null;
13788    
13789                            try {
13790                                    session = openSession();
13791    
13792                                    Query q = session.createQuery(sql);
13793    
13794                                    QueryPos qPos = QueryPos.getInstance(q);
13795    
13796                                    qPos.add(groupId);
13797    
13798                                    qPos.add(folderId);
13799    
13800                                    qPos.add(status);
13801    
13802                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
13803                                                    start, end);
13804                            }
13805                            catch (Exception e) {
13806                                    throw processException(e);
13807                            }
13808                            finally {
13809                                    if (list == null) {
13810                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
13811                                    }
13812                                    else {
13813                                            cacheResult(list);
13814    
13815                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
13816                                    }
13817    
13818                                    closeSession(session);
13819                            }
13820                    }
13821    
13822                    return list;
13823            }
13824    
13825            /**
13826             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
13827             *
13828             * @param groupId the group ID
13829             * @param folderId the folder ID
13830             * @param status the status
13831             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13832             * @return the first matching journal article
13833             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13834             * @throws SystemException if a system exception occurred
13835             */
13836            public JournalArticle findByG_F_ST_First(long groupId, long folderId,
13837                    int status, OrderByComparator orderByComparator)
13838                    throws NoSuchArticleException, SystemException {
13839                    JournalArticle journalArticle = fetchByG_F_ST_First(groupId, folderId,
13840                                    status, orderByComparator);
13841    
13842                    if (journalArticle != null) {
13843                            return journalArticle;
13844                    }
13845    
13846                    StringBundler msg = new StringBundler(8);
13847    
13848                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13849    
13850                    msg.append("groupId=");
13851                    msg.append(groupId);
13852    
13853                    msg.append(", folderId=");
13854                    msg.append(folderId);
13855    
13856                    msg.append(", status=");
13857                    msg.append(status);
13858    
13859                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13860    
13861                    throw new NoSuchArticleException(msg.toString());
13862            }
13863    
13864            /**
13865             * Returns the first journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
13866             *
13867             * @param groupId the group ID
13868             * @param folderId the folder ID
13869             * @param status the status
13870             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13871             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13872             * @throws SystemException if a system exception occurred
13873             */
13874            public JournalArticle fetchByG_F_ST_First(long groupId, long folderId,
13875                    int status, OrderByComparator orderByComparator)
13876                    throws SystemException {
13877                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status, 0,
13878                                    1, orderByComparator);
13879    
13880                    if (!list.isEmpty()) {
13881                            return list.get(0);
13882                    }
13883    
13884                    return null;
13885            }
13886    
13887            /**
13888             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
13889             *
13890             * @param groupId the group ID
13891             * @param folderId the folder ID
13892             * @param status the status
13893             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13894             * @return the last matching journal article
13895             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13896             * @throws SystemException if a system exception occurred
13897             */
13898            public JournalArticle findByG_F_ST_Last(long groupId, long folderId,
13899                    int status, OrderByComparator orderByComparator)
13900                    throws NoSuchArticleException, SystemException {
13901                    JournalArticle journalArticle = fetchByG_F_ST_Last(groupId, folderId,
13902                                    status, orderByComparator);
13903    
13904                    if (journalArticle != null) {
13905                            return journalArticle;
13906                    }
13907    
13908                    StringBundler msg = new StringBundler(8);
13909    
13910                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13911    
13912                    msg.append("groupId=");
13913                    msg.append(groupId);
13914    
13915                    msg.append(", folderId=");
13916                    msg.append(folderId);
13917    
13918                    msg.append(", status=");
13919                    msg.append(status);
13920    
13921                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13922    
13923                    throw new NoSuchArticleException(msg.toString());
13924            }
13925    
13926            /**
13927             * Returns the last journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
13928             *
13929             * @param groupId the group ID
13930             * @param folderId the folder ID
13931             * @param status the status
13932             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13933             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13934             * @throws SystemException if a system exception occurred
13935             */
13936            public JournalArticle fetchByG_F_ST_Last(long groupId, long folderId,
13937                    int status, OrderByComparator orderByComparator)
13938                    throws SystemException {
13939                    int count = countByG_F_ST(groupId, folderId, status);
13940    
13941                    List<JournalArticle> list = findByG_F_ST(groupId, folderId, status,
13942                                    count - 1, count, orderByComparator);
13943    
13944                    if (!list.isEmpty()) {
13945                            return list.get(0);
13946                    }
13947    
13948                    return null;
13949            }
13950    
13951            /**
13952             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
13953             *
13954             * @param id the primary key of the current journal article
13955             * @param groupId the group ID
13956             * @param folderId the folder ID
13957             * @param status the status
13958             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13959             * @return the previous, current, and next journal article
13960             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13961             * @throws SystemException if a system exception occurred
13962             */
13963            public JournalArticle[] findByG_F_ST_PrevAndNext(long id, long groupId,
13964                    long folderId, int status, OrderByComparator orderByComparator)
13965                    throws NoSuchArticleException, SystemException {
13966                    JournalArticle journalArticle = findByPrimaryKey(id);
13967    
13968                    Session session = null;
13969    
13970                    try {
13971                            session = openSession();
13972    
13973                            JournalArticle[] array = new JournalArticleImpl[3];
13974    
13975                            array[0] = getByG_F_ST_PrevAndNext(session, journalArticle,
13976                                            groupId, folderId, status, orderByComparator, true);
13977    
13978                            array[1] = journalArticle;
13979    
13980                            array[2] = getByG_F_ST_PrevAndNext(session, journalArticle,
13981                                            groupId, folderId, status, orderByComparator, false);
13982    
13983                            return array;
13984                    }
13985                    catch (Exception e) {
13986                            throw processException(e);
13987                    }
13988                    finally {
13989                            closeSession(session);
13990                    }
13991            }
13992    
13993            protected JournalArticle getByG_F_ST_PrevAndNext(Session session,
13994                    JournalArticle journalArticle, long groupId, long folderId, int status,
13995                    OrderByComparator orderByComparator, boolean previous) {
13996                    StringBundler query = null;
13997    
13998                    if (orderByComparator != null) {
13999                            query = new StringBundler(6 +
14000                                            (orderByComparator.getOrderByFields().length * 6));
14001                    }
14002                    else {
14003                            query = new StringBundler(3);
14004                    }
14005    
14006                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14007    
14008                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
14009    
14010                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
14011    
14012                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
14013    
14014                    if (orderByComparator != null) {
14015                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14016    
14017                            if (orderByConditionFields.length > 0) {
14018                                    query.append(WHERE_AND);
14019                            }
14020    
14021                            for (int i = 0; i < orderByConditionFields.length; i++) {
14022                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14023                                    query.append(orderByConditionFields[i]);
14024    
14025                                    if ((i + 1) < orderByConditionFields.length) {
14026                                            if (orderByComparator.isAscending() ^ previous) {
14027                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14028                                            }
14029                                            else {
14030                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14031                                            }
14032                                    }
14033                                    else {
14034                                            if (orderByComparator.isAscending() ^ previous) {
14035                                                    query.append(WHERE_GREATER_THAN);
14036                                            }
14037                                            else {
14038                                                    query.append(WHERE_LESSER_THAN);
14039                                            }
14040                                    }
14041                            }
14042    
14043                            query.append(ORDER_BY_CLAUSE);
14044    
14045                            String[] orderByFields = orderByComparator.getOrderByFields();
14046    
14047                            for (int i = 0; i < orderByFields.length; i++) {
14048                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14049                                    query.append(orderByFields[i]);
14050    
14051                                    if ((i + 1) < orderByFields.length) {
14052                                            if (orderByComparator.isAscending() ^ previous) {
14053                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14054                                            }
14055                                            else {
14056                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14057                                            }
14058                                    }
14059                                    else {
14060                                            if (orderByComparator.isAscending() ^ previous) {
14061                                                    query.append(ORDER_BY_ASC);
14062                                            }
14063                                            else {
14064                                                    query.append(ORDER_BY_DESC);
14065                                            }
14066                                    }
14067                            }
14068                    }
14069    
14070                    else {
14071                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14072                    }
14073    
14074                    String sql = query.toString();
14075    
14076                    Query q = session.createQuery(sql);
14077    
14078                    q.setFirstResult(0);
14079                    q.setMaxResults(2);
14080    
14081                    QueryPos qPos = QueryPos.getInstance(q);
14082    
14083                    qPos.add(groupId);
14084    
14085                    qPos.add(folderId);
14086    
14087                    qPos.add(status);
14088    
14089                    if (orderByComparator != null) {
14090                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14091    
14092                            for (Object value : values) {
14093                                    qPos.add(value);
14094                            }
14095                    }
14096    
14097                    List<JournalArticle> list = q.list();
14098    
14099                    if (list.size() == 2) {
14100                            return list.get(1);
14101                    }
14102                    else {
14103                            return null;
14104                    }
14105            }
14106    
14107            /**
14108             * Returns all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
14109             *
14110             * <p>
14111             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14112             * </p>
14113             *
14114             * @param groupId the group ID
14115             * @param folderId the folder ID
14116             * @param statuses the statuses
14117             * @return the matching journal articles
14118             * @throws SystemException if a system exception occurred
14119             */
14120            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
14121                    int[] statuses) throws SystemException {
14122                    return findByG_F_ST(groupId, folderId, statuses, QueryUtil.ALL_POS,
14123                            QueryUtil.ALL_POS, null);
14124            }
14125    
14126            /**
14127             * Returns a range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
14128             *
14129             * <p>
14130             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14131             * </p>
14132             *
14133             * @param groupId the group ID
14134             * @param folderId the folder ID
14135             * @param statuses the statuses
14136             * @param start the lower bound of the range of journal articles
14137             * @param end the upper bound of the range of journal articles (not inclusive)
14138             * @return the range of matching journal articles
14139             * @throws SystemException if a system exception occurred
14140             */
14141            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
14142                    int[] statuses, int start, int end) throws SystemException {
14143                    return findByG_F_ST(groupId, folderId, statuses, start, end, null);
14144            }
14145    
14146            /**
14147             * Returns an ordered range of all the journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
14148             *
14149             * <p>
14150             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14151             * </p>
14152             *
14153             * @param groupId the group ID
14154             * @param folderId the folder ID
14155             * @param statuses the statuses
14156             * @param start the lower bound of the range of journal articles
14157             * @param end the upper bound of the range of journal articles (not inclusive)
14158             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14159             * @return the ordered range of matching journal articles
14160             * @throws SystemException if a system exception occurred
14161             */
14162            public List<JournalArticle> findByG_F_ST(long groupId, long folderId,
14163                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
14164                    throws SystemException {
14165                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_ST;
14166                    Object[] finderArgs = null;
14167    
14168                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14169                                    (orderByComparator == null)) {
14170                            finderArgs = new Object[] {
14171                                            groupId, folderId, StringUtil.merge(statuses)
14172                                    };
14173                    }
14174                    else {
14175                            finderArgs = new Object[] {
14176                                            groupId, folderId, StringUtil.merge(statuses),
14177                                            
14178                                            start, end, orderByComparator
14179                                    };
14180                    }
14181    
14182                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14183                                    finderArgs, this);
14184    
14185                    if ((list != null) && !list.isEmpty()) {
14186                            for (JournalArticle journalArticle : list) {
14187                                    if ((groupId != journalArticle.getGroupId()) ||
14188                                                    (folderId != journalArticle.getFolderId()) ||
14189                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
14190                                            list = null;
14191    
14192                                            break;
14193                                    }
14194                            }
14195                    }
14196    
14197                    if (list == null) {
14198                            StringBundler query = new StringBundler();
14199    
14200                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14201    
14202                            boolean conjunctionable = false;
14203    
14204                            if (conjunctionable) {
14205                                    query.append(WHERE_AND);
14206                            }
14207    
14208                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
14209    
14210                            conjunctionable = true;
14211    
14212                            if (conjunctionable) {
14213                                    query.append(WHERE_AND);
14214                            }
14215    
14216                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
14217    
14218                            conjunctionable = true;
14219    
14220                            if ((statuses == null) || (statuses.length > 0)) {
14221                                    if (conjunctionable) {
14222                                            query.append(WHERE_AND);
14223                                    }
14224    
14225                                    query.append(StringPool.OPEN_PARENTHESIS);
14226    
14227                                    for (int i = 0; i < statuses.length; i++) {
14228                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
14229    
14230                                            if ((i + 1) < statuses.length) {
14231                                                    query.append(WHERE_OR);
14232                                            }
14233                                    }
14234    
14235                                    query.append(StringPool.CLOSE_PARENTHESIS);
14236    
14237                                    conjunctionable = true;
14238                            }
14239    
14240                            if (orderByComparator != null) {
14241                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14242                                            orderByComparator);
14243                            }
14244    
14245                            else {
14246                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14247                            }
14248    
14249                            String sql = query.toString();
14250    
14251                            Session session = null;
14252    
14253                            try {
14254                                    session = openSession();
14255    
14256                                    Query q = session.createQuery(sql);
14257    
14258                                    QueryPos qPos = QueryPos.getInstance(q);
14259    
14260                                    qPos.add(groupId);
14261    
14262                                    qPos.add(folderId);
14263    
14264                                    if (statuses != null) {
14265                                            qPos.add(statuses);
14266                                    }
14267    
14268                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
14269                                                    start, end);
14270                            }
14271                            catch (Exception e) {
14272                                    throw processException(e);
14273                            }
14274                            finally {
14275                                    if (list == null) {
14276                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
14277                                    }
14278                                    else {
14279                                            cacheResult(list);
14280    
14281                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
14282                                    }
14283    
14284                                    closeSession(session);
14285                            }
14286                    }
14287    
14288                    return list;
14289            }
14290    
14291            /**
14292             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
14293             *
14294             * @param groupId the group ID
14295             * @param folderId the folder ID
14296             * @param status the status
14297             * @return the matching journal articles that the user has permission to view
14298             * @throws SystemException if a system exception occurred
14299             */
14300            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
14301                    int status) throws SystemException {
14302                    return filterFindByG_F_ST(groupId, folderId, status, QueryUtil.ALL_POS,
14303                            QueryUtil.ALL_POS, null);
14304            }
14305    
14306            /**
14307             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
14308             *
14309             * <p>
14310             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14311             * </p>
14312             *
14313             * @param groupId the group ID
14314             * @param folderId the folder ID
14315             * @param status the status
14316             * @param start the lower bound of the range of journal articles
14317             * @param end the upper bound of the range of journal articles (not inclusive)
14318             * @return the range of matching journal articles that the user has permission to view
14319             * @throws SystemException if a system exception occurred
14320             */
14321            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
14322                    int status, int start, int end) throws SystemException {
14323                    return filterFindByG_F_ST(groupId, folderId, status, start, end, null);
14324            }
14325    
14326            /**
14327             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and folderId = &#63; and status = &#63;.
14328             *
14329             * <p>
14330             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14331             * </p>
14332             *
14333             * @param groupId the group ID
14334             * @param folderId the folder ID
14335             * @param status the status
14336             * @param start the lower bound of the range of journal articles
14337             * @param end the upper bound of the range of journal articles (not inclusive)
14338             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14339             * @return the ordered range of matching journal articles that the user has permission to view
14340             * @throws SystemException if a system exception occurred
14341             */
14342            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
14343                    int status, int start, int end, OrderByComparator orderByComparator)
14344                    throws SystemException {
14345                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14346                            return findByG_F_ST(groupId, folderId, status, start, end,
14347                                    orderByComparator);
14348                    }
14349    
14350                    StringBundler query = null;
14351    
14352                    if (orderByComparator != null) {
14353                            query = new StringBundler(5 +
14354                                            (orderByComparator.getOrderByFields().length * 3));
14355                    }
14356                    else {
14357                            query = new StringBundler(5);
14358                    }
14359    
14360                    if (getDB().isSupportsInlineDistinct()) {
14361                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14362                    }
14363                    else {
14364                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14365                    }
14366    
14367                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
14368    
14369                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
14370    
14371                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
14372    
14373                    if (!getDB().isSupportsInlineDistinct()) {
14374                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14375                    }
14376    
14377                    if (orderByComparator != null) {
14378                            if (getDB().isSupportsInlineDistinct()) {
14379                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14380                                            orderByComparator);
14381                            }
14382                            else {
14383                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14384                                            orderByComparator);
14385                            }
14386                    }
14387    
14388                    else {
14389                            if (getDB().isSupportsInlineDistinct()) {
14390                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14391                            }
14392                            else {
14393                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14394                            }
14395                    }
14396    
14397                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14398                                    JournalArticle.class.getName(),
14399                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14400    
14401                    Session session = null;
14402    
14403                    try {
14404                            session = openSession();
14405    
14406                            SQLQuery q = session.createSQLQuery(sql);
14407    
14408                            if (getDB().isSupportsInlineDistinct()) {
14409                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14410                            }
14411                            else {
14412                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14413                            }
14414    
14415                            QueryPos qPos = QueryPos.getInstance(q);
14416    
14417                            qPos.add(groupId);
14418    
14419                            qPos.add(folderId);
14420    
14421                            qPos.add(status);
14422    
14423                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14424                                    end);
14425                    }
14426                    catch (Exception e) {
14427                            throw processException(e);
14428                    }
14429                    finally {
14430                            closeSession(session);
14431                    }
14432            }
14433    
14434            /**
14435             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
14436             *
14437             * @param id the primary key of the current journal article
14438             * @param groupId the group ID
14439             * @param folderId the folder ID
14440             * @param status the status
14441             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14442             * @return the previous, current, and next journal article
14443             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14444             * @throws SystemException if a system exception occurred
14445             */
14446            public JournalArticle[] filterFindByG_F_ST_PrevAndNext(long id,
14447                    long groupId, long folderId, int status,
14448                    OrderByComparator orderByComparator)
14449                    throws NoSuchArticleException, SystemException {
14450                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14451                            return findByG_F_ST_PrevAndNext(id, groupId, folderId, status,
14452                                    orderByComparator);
14453                    }
14454    
14455                    JournalArticle journalArticle = findByPrimaryKey(id);
14456    
14457                    Session session = null;
14458    
14459                    try {
14460                            session = openSession();
14461    
14462                            JournalArticle[] array = new JournalArticleImpl[3];
14463    
14464                            array[0] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
14465                                            groupId, folderId, status, orderByComparator, true);
14466    
14467                            array[1] = journalArticle;
14468    
14469                            array[2] = filterGetByG_F_ST_PrevAndNext(session, journalArticle,
14470                                            groupId, folderId, status, orderByComparator, false);
14471    
14472                            return array;
14473                    }
14474                    catch (Exception e) {
14475                            throw processException(e);
14476                    }
14477                    finally {
14478                            closeSession(session);
14479                    }
14480            }
14481    
14482            protected JournalArticle filterGetByG_F_ST_PrevAndNext(Session session,
14483                    JournalArticle journalArticle, long groupId, long folderId, int status,
14484                    OrderByComparator orderByComparator, boolean previous) {
14485                    StringBundler query = null;
14486    
14487                    if (orderByComparator != null) {
14488                            query = new StringBundler(6 +
14489                                            (orderByComparator.getOrderByFields().length * 6));
14490                    }
14491                    else {
14492                            query = new StringBundler(3);
14493                    }
14494    
14495                    if (getDB().isSupportsInlineDistinct()) {
14496                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14497                    }
14498                    else {
14499                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14500                    }
14501    
14502                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
14503    
14504                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
14505    
14506                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
14507    
14508                    if (!getDB().isSupportsInlineDistinct()) {
14509                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14510                    }
14511    
14512                    if (orderByComparator != null) {
14513                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14514    
14515                            if (orderByConditionFields.length > 0) {
14516                                    query.append(WHERE_AND);
14517                            }
14518    
14519                            for (int i = 0; i < orderByConditionFields.length; i++) {
14520                                    if (getDB().isSupportsInlineDistinct()) {
14521                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14522                                    }
14523                                    else {
14524                                            query.append(_ORDER_BY_ENTITY_TABLE);
14525                                    }
14526    
14527                                    query.append(orderByConditionFields[i]);
14528    
14529                                    if ((i + 1) < orderByConditionFields.length) {
14530                                            if (orderByComparator.isAscending() ^ previous) {
14531                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14532                                            }
14533                                            else {
14534                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14535                                            }
14536                                    }
14537                                    else {
14538                                            if (orderByComparator.isAscending() ^ previous) {
14539                                                    query.append(WHERE_GREATER_THAN);
14540                                            }
14541                                            else {
14542                                                    query.append(WHERE_LESSER_THAN);
14543                                            }
14544                                    }
14545                            }
14546    
14547                            query.append(ORDER_BY_CLAUSE);
14548    
14549                            String[] orderByFields = orderByComparator.getOrderByFields();
14550    
14551                            for (int i = 0; i < orderByFields.length; i++) {
14552                                    if (getDB().isSupportsInlineDistinct()) {
14553                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14554                                    }
14555                                    else {
14556                                            query.append(_ORDER_BY_ENTITY_TABLE);
14557                                    }
14558    
14559                                    query.append(orderByFields[i]);
14560    
14561                                    if ((i + 1) < orderByFields.length) {
14562                                            if (orderByComparator.isAscending() ^ previous) {
14563                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14564                                            }
14565                                            else {
14566                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14567                                            }
14568                                    }
14569                                    else {
14570                                            if (orderByComparator.isAscending() ^ previous) {
14571                                                    query.append(ORDER_BY_ASC);
14572                                            }
14573                                            else {
14574                                                    query.append(ORDER_BY_DESC);
14575                                            }
14576                                    }
14577                            }
14578                    }
14579    
14580                    else {
14581                            if (getDB().isSupportsInlineDistinct()) {
14582                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14583                            }
14584                            else {
14585                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14586                            }
14587                    }
14588    
14589                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14590                                    JournalArticle.class.getName(),
14591                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14592    
14593                    SQLQuery q = session.createSQLQuery(sql);
14594    
14595                    q.setFirstResult(0);
14596                    q.setMaxResults(2);
14597    
14598                    if (getDB().isSupportsInlineDistinct()) {
14599                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14600                    }
14601                    else {
14602                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14603                    }
14604    
14605                    QueryPos qPos = QueryPos.getInstance(q);
14606    
14607                    qPos.add(groupId);
14608    
14609                    qPos.add(folderId);
14610    
14611                    qPos.add(status);
14612    
14613                    if (orderByComparator != null) {
14614                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14615    
14616                            for (Object value : values) {
14617                                    qPos.add(value);
14618                            }
14619                    }
14620    
14621                    List<JournalArticle> list = q.list();
14622    
14623                    if (list.size() == 2) {
14624                            return list.get(1);
14625                    }
14626                    else {
14627                            return null;
14628                    }
14629            }
14630    
14631            /**
14632             * Returns all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
14633             *
14634             * @param groupId the group ID
14635             * @param folderId the folder ID
14636             * @param statuses the statuses
14637             * @return the matching journal articles that the user has permission to view
14638             * @throws SystemException if a system exception occurred
14639             */
14640            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
14641                    int[] statuses) throws SystemException {
14642                    return filterFindByG_F_ST(groupId, folderId, statuses,
14643                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14644            }
14645    
14646            /**
14647             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
14648             *
14649             * <p>
14650             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14651             * </p>
14652             *
14653             * @param groupId the group ID
14654             * @param folderId the folder ID
14655             * @param statuses the statuses
14656             * @param start the lower bound of the range of journal articles
14657             * @param end the upper bound of the range of journal articles (not inclusive)
14658             * @return the range of matching journal articles that the user has permission to view
14659             * @throws SystemException if a system exception occurred
14660             */
14661            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
14662                    int[] statuses, int start, int end) throws SystemException {
14663                    return filterFindByG_F_ST(groupId, folderId, statuses, start, end, null);
14664            }
14665    
14666            /**
14667             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
14668             *
14669             * <p>
14670             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14671             * </p>
14672             *
14673             * @param groupId the group ID
14674             * @param folderId the folder ID
14675             * @param statuses the statuses
14676             * @param start the lower bound of the range of journal articles
14677             * @param end the upper bound of the range of journal articles (not inclusive)
14678             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14679             * @return the ordered range of matching journal articles that the user has permission to view
14680             * @throws SystemException if a system exception occurred
14681             */
14682            public List<JournalArticle> filterFindByG_F_ST(long groupId, long folderId,
14683                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
14684                    throws SystemException {
14685                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14686                            return findByG_F_ST(groupId, folderId, statuses, start, end,
14687                                    orderByComparator);
14688                    }
14689    
14690                    StringBundler query = new StringBundler();
14691    
14692                    if (getDB().isSupportsInlineDistinct()) {
14693                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14694                    }
14695                    else {
14696                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14697                    }
14698    
14699                    boolean conjunctionable = false;
14700    
14701                    if (conjunctionable) {
14702                            query.append(WHERE_AND);
14703                    }
14704    
14705                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
14706    
14707                    conjunctionable = true;
14708    
14709                    if (conjunctionable) {
14710                            query.append(WHERE_AND);
14711                    }
14712    
14713                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
14714    
14715                    conjunctionable = true;
14716    
14717                    if ((statuses == null) || (statuses.length > 0)) {
14718                            if (conjunctionable) {
14719                                    query.append(WHERE_AND);
14720                            }
14721    
14722                            query.append(StringPool.OPEN_PARENTHESIS);
14723    
14724                            for (int i = 0; i < statuses.length; i++) {
14725                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
14726    
14727                                    if ((i + 1) < statuses.length) {
14728                                            query.append(WHERE_OR);
14729                                    }
14730                            }
14731    
14732                            query.append(StringPool.CLOSE_PARENTHESIS);
14733    
14734                            conjunctionable = true;
14735                    }
14736    
14737                    if (!getDB().isSupportsInlineDistinct()) {
14738                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14739                    }
14740    
14741                    if (orderByComparator != null) {
14742                            if (getDB().isSupportsInlineDistinct()) {
14743                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14744                                            orderByComparator);
14745                            }
14746                            else {
14747                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14748                                            orderByComparator);
14749                            }
14750                    }
14751    
14752                    else {
14753                            if (getDB().isSupportsInlineDistinct()) {
14754                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14755                            }
14756                            else {
14757                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14758                            }
14759                    }
14760    
14761                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14762                                    JournalArticle.class.getName(),
14763                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14764    
14765                    Session session = null;
14766    
14767                    try {
14768                            session = openSession();
14769    
14770                            SQLQuery q = session.createSQLQuery(sql);
14771    
14772                            if (getDB().isSupportsInlineDistinct()) {
14773                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14774                            }
14775                            else {
14776                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14777                            }
14778    
14779                            QueryPos qPos = QueryPos.getInstance(q);
14780    
14781                            qPos.add(groupId);
14782    
14783                            qPos.add(folderId);
14784    
14785                            if (statuses != null) {
14786                                    qPos.add(statuses);
14787                            }
14788    
14789                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14790                                    end);
14791                    }
14792                    catch (Exception e) {
14793                            throw processException(e);
14794                    }
14795                    finally {
14796                            closeSession(session);
14797                    }
14798            }
14799    
14800            /**
14801             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
14802             *
14803             * @param groupId the group ID
14804             * @param classNameId the class name ID
14805             * @param classPK the class p k
14806             * @return the matching journal articles
14807             * @throws SystemException if a system exception occurred
14808             */
14809            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
14810                    long classPK) throws SystemException {
14811                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
14812                            QueryUtil.ALL_POS, null);
14813            }
14814    
14815            /**
14816             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
14817             *
14818             * <p>
14819             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14820             * </p>
14821             *
14822             * @param groupId the group ID
14823             * @param classNameId the class name ID
14824             * @param classPK the class p k
14825             * @param start the lower bound of the range of journal articles
14826             * @param end the upper bound of the range of journal articles (not inclusive)
14827             * @return the range of matching journal articles
14828             * @throws SystemException if a system exception occurred
14829             */
14830            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
14831                    long classPK, int start, int end) throws SystemException {
14832                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
14833            }
14834    
14835            /**
14836             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
14837             *
14838             * <p>
14839             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14840             * </p>
14841             *
14842             * @param groupId the group ID
14843             * @param classNameId the class name ID
14844             * @param classPK the class p k
14845             * @param start the lower bound of the range of journal articles
14846             * @param end the upper bound of the range of journal articles (not inclusive)
14847             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14848             * @return the ordered range of matching journal articles
14849             * @throws SystemException if a system exception occurred
14850             */
14851            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
14852                    long classPK, int start, int end, OrderByComparator orderByComparator)
14853                    throws SystemException {
14854                    FinderPath finderPath = null;
14855                    Object[] finderArgs = null;
14856    
14857                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14858                                    (orderByComparator == null)) {
14859                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
14860                            finderArgs = new Object[] { groupId, classNameId, classPK };
14861                    }
14862                    else {
14863                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
14864                            finderArgs = new Object[] {
14865                                            groupId, classNameId, classPK,
14866                                            
14867                                            start, end, orderByComparator
14868                                    };
14869                    }
14870    
14871                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14872                                    finderArgs, this);
14873    
14874                    if ((list != null) && !list.isEmpty()) {
14875                            for (JournalArticle journalArticle : list) {
14876                                    if ((groupId != journalArticle.getGroupId()) ||
14877                                                    (classNameId != journalArticle.getClassNameId()) ||
14878                                                    (classPK != journalArticle.getClassPK())) {
14879                                            list = null;
14880    
14881                                            break;
14882                                    }
14883                            }
14884                    }
14885    
14886                    if (list == null) {
14887                            StringBundler query = null;
14888    
14889                            if (orderByComparator != null) {
14890                                    query = new StringBundler(5 +
14891                                                    (orderByComparator.getOrderByFields().length * 3));
14892                            }
14893                            else {
14894                                    query = new StringBundler(5);
14895                            }
14896    
14897                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14898    
14899                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
14900    
14901                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
14902    
14903                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
14904    
14905                            if (orderByComparator != null) {
14906                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14907                                            orderByComparator);
14908                            }
14909    
14910                            else {
14911                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14912                            }
14913    
14914                            String sql = query.toString();
14915    
14916                            Session session = null;
14917    
14918                            try {
14919                                    session = openSession();
14920    
14921                                    Query q = session.createQuery(sql);
14922    
14923                                    QueryPos qPos = QueryPos.getInstance(q);
14924    
14925                                    qPos.add(groupId);
14926    
14927                                    qPos.add(classNameId);
14928    
14929                                    qPos.add(classPK);
14930    
14931                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
14932                                                    start, end);
14933                            }
14934                            catch (Exception e) {
14935                                    throw processException(e);
14936                            }
14937                            finally {
14938                                    if (list == null) {
14939                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
14940                                    }
14941                                    else {
14942                                            cacheResult(list);
14943    
14944                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
14945                                    }
14946    
14947                                    closeSession(session);
14948                            }
14949                    }
14950    
14951                    return list;
14952            }
14953    
14954            /**
14955             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
14956             *
14957             * @param groupId the group ID
14958             * @param classNameId the class name ID
14959             * @param classPK the class p k
14960             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14961             * @return the first matching journal article
14962             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14963             * @throws SystemException if a system exception occurred
14964             */
14965            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
14966                    long classPK, OrderByComparator orderByComparator)
14967                    throws NoSuchArticleException, SystemException {
14968                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
14969                                    classNameId, classPK, orderByComparator);
14970    
14971                    if (journalArticle != null) {
14972                            return journalArticle;
14973                    }
14974    
14975                    StringBundler msg = new StringBundler(8);
14976    
14977                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14978    
14979                    msg.append("groupId=");
14980                    msg.append(groupId);
14981    
14982                    msg.append(", classNameId=");
14983                    msg.append(classNameId);
14984    
14985                    msg.append(", classPK=");
14986                    msg.append(classPK);
14987    
14988                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14989    
14990                    throw new NoSuchArticleException(msg.toString());
14991            }
14992    
14993            /**
14994             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
14995             *
14996             * @param groupId the group ID
14997             * @param classNameId the class name ID
14998             * @param classPK the class p k
14999             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15000             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15001             * @throws SystemException if a system exception occurred
15002             */
15003            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
15004                    long classPK, OrderByComparator orderByComparator)
15005                    throws SystemException {
15006                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
15007                                    0, 1, orderByComparator);
15008    
15009                    if (!list.isEmpty()) {
15010                            return list.get(0);
15011                    }
15012    
15013                    return null;
15014            }
15015    
15016            /**
15017             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
15018             *
15019             * @param groupId the group ID
15020             * @param classNameId the class name ID
15021             * @param classPK the class p k
15022             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15023             * @return the last matching journal article
15024             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15025             * @throws SystemException if a system exception occurred
15026             */
15027            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
15028                    long classPK, OrderByComparator orderByComparator)
15029                    throws NoSuchArticleException, SystemException {
15030                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
15031                                    classPK, orderByComparator);
15032    
15033                    if (journalArticle != null) {
15034                            return journalArticle;
15035                    }
15036    
15037                    StringBundler msg = new StringBundler(8);
15038    
15039                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15040    
15041                    msg.append("groupId=");
15042                    msg.append(groupId);
15043    
15044                    msg.append(", classNameId=");
15045                    msg.append(classNameId);
15046    
15047                    msg.append(", classPK=");
15048                    msg.append(classPK);
15049    
15050                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15051    
15052                    throw new NoSuchArticleException(msg.toString());
15053            }
15054    
15055            /**
15056             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
15057             *
15058             * @param groupId the group ID
15059             * @param classNameId the class name ID
15060             * @param classPK the class p k
15061             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15062             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15063             * @throws SystemException if a system exception occurred
15064             */
15065            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
15066                    long classPK, OrderByComparator orderByComparator)
15067                    throws SystemException {
15068                    int count = countByG_C_C(groupId, classNameId, classPK);
15069    
15070                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
15071                                    count - 1, count, orderByComparator);
15072    
15073                    if (!list.isEmpty()) {
15074                            return list.get(0);
15075                    }
15076    
15077                    return null;
15078            }
15079    
15080            /**
15081             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
15082             *
15083             * @param id the primary key of the current journal article
15084             * @param groupId the group ID
15085             * @param classNameId the class name ID
15086             * @param classPK the class p k
15087             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15088             * @return the previous, current, and next journal article
15089             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15090             * @throws SystemException if a system exception occurred
15091             */
15092            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
15093                    long classNameId, long classPK, OrderByComparator orderByComparator)
15094                    throws NoSuchArticleException, SystemException {
15095                    JournalArticle journalArticle = findByPrimaryKey(id);
15096    
15097                    Session session = null;
15098    
15099                    try {
15100                            session = openSession();
15101    
15102                            JournalArticle[] array = new JournalArticleImpl[3];
15103    
15104                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
15105                                            classNameId, classPK, orderByComparator, true);
15106    
15107                            array[1] = journalArticle;
15108    
15109                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
15110                                            classNameId, classPK, orderByComparator, false);
15111    
15112                            return array;
15113                    }
15114                    catch (Exception e) {
15115                            throw processException(e);
15116                    }
15117                    finally {
15118                            closeSession(session);
15119                    }
15120            }
15121    
15122            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
15123                    JournalArticle journalArticle, long groupId, long classNameId,
15124                    long classPK, OrderByComparator orderByComparator, boolean previous) {
15125                    StringBundler query = null;
15126    
15127                    if (orderByComparator != null) {
15128                            query = new StringBundler(6 +
15129                                            (orderByComparator.getOrderByFields().length * 6));
15130                    }
15131                    else {
15132                            query = new StringBundler(3);
15133                    }
15134    
15135                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15136    
15137                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
15138    
15139                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
15140    
15141                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
15142    
15143                    if (orderByComparator != null) {
15144                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15145    
15146                            if (orderByConditionFields.length > 0) {
15147                                    query.append(WHERE_AND);
15148                            }
15149    
15150                            for (int i = 0; i < orderByConditionFields.length; i++) {
15151                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15152                                    query.append(orderByConditionFields[i]);
15153    
15154                                    if ((i + 1) < orderByConditionFields.length) {
15155                                            if (orderByComparator.isAscending() ^ previous) {
15156                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15157                                            }
15158                                            else {
15159                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15160                                            }
15161                                    }
15162                                    else {
15163                                            if (orderByComparator.isAscending() ^ previous) {
15164                                                    query.append(WHERE_GREATER_THAN);
15165                                            }
15166                                            else {
15167                                                    query.append(WHERE_LESSER_THAN);
15168                                            }
15169                                    }
15170                            }
15171    
15172                            query.append(ORDER_BY_CLAUSE);
15173    
15174                            String[] orderByFields = orderByComparator.getOrderByFields();
15175    
15176                            for (int i = 0; i < orderByFields.length; i++) {
15177                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15178                                    query.append(orderByFields[i]);
15179    
15180                                    if ((i + 1) < orderByFields.length) {
15181                                            if (orderByComparator.isAscending() ^ previous) {
15182                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15183                                            }
15184                                            else {
15185                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15186                                            }
15187                                    }
15188                                    else {
15189                                            if (orderByComparator.isAscending() ^ previous) {
15190                                                    query.append(ORDER_BY_ASC);
15191                                            }
15192                                            else {
15193                                                    query.append(ORDER_BY_DESC);
15194                                            }
15195                                    }
15196                            }
15197                    }
15198    
15199                    else {
15200                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15201                    }
15202    
15203                    String sql = query.toString();
15204    
15205                    Query q = session.createQuery(sql);
15206    
15207                    q.setFirstResult(0);
15208                    q.setMaxResults(2);
15209    
15210                    QueryPos qPos = QueryPos.getInstance(q);
15211    
15212                    qPos.add(groupId);
15213    
15214                    qPos.add(classNameId);
15215    
15216                    qPos.add(classPK);
15217    
15218                    if (orderByComparator != null) {
15219                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15220    
15221                            for (Object value : values) {
15222                                    qPos.add(value);
15223                            }
15224                    }
15225    
15226                    List<JournalArticle> list = q.list();
15227    
15228                    if (list.size() == 2) {
15229                            return list.get(1);
15230                    }
15231                    else {
15232                            return null;
15233                    }
15234            }
15235    
15236            /**
15237             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
15238             *
15239             * @param groupId the group ID
15240             * @param classNameId the class name ID
15241             * @param classPK the class p k
15242             * @return the matching journal articles that the user has permission to view
15243             * @throws SystemException if a system exception occurred
15244             */
15245            public List<JournalArticle> filterFindByG_C_C(long groupId,
15246                    long classNameId, long classPK) throws SystemException {
15247                    return filterFindByG_C_C(groupId, classNameId, classPK,
15248                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15249            }
15250    
15251            /**
15252             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
15253             *
15254             * <p>
15255             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15256             * </p>
15257             *
15258             * @param groupId the group ID
15259             * @param classNameId the class name ID
15260             * @param classPK the class p k
15261             * @param start the lower bound of the range of journal articles
15262             * @param end the upper bound of the range of journal articles (not inclusive)
15263             * @return the range of matching journal articles that the user has permission to view
15264             * @throws SystemException if a system exception occurred
15265             */
15266            public List<JournalArticle> filterFindByG_C_C(long groupId,
15267                    long classNameId, long classPK, int start, int end)
15268                    throws SystemException {
15269                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
15270            }
15271    
15272            /**
15273             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
15274             *
15275             * <p>
15276             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15277             * </p>
15278             *
15279             * @param groupId the group ID
15280             * @param classNameId the class name ID
15281             * @param classPK the class p k
15282             * @param start the lower bound of the range of journal articles
15283             * @param end the upper bound of the range of journal articles (not inclusive)
15284             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15285             * @return the ordered range of matching journal articles that the user has permission to view
15286             * @throws SystemException if a system exception occurred
15287             */
15288            public List<JournalArticle> filterFindByG_C_C(long groupId,
15289                    long classNameId, long classPK, int start, int end,
15290                    OrderByComparator orderByComparator) throws SystemException {
15291                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15292                            return findByG_C_C(groupId, classNameId, classPK, start, end,
15293                                    orderByComparator);
15294                    }
15295    
15296                    StringBundler query = null;
15297    
15298                    if (orderByComparator != null) {
15299                            query = new StringBundler(5 +
15300                                            (orderByComparator.getOrderByFields().length * 3));
15301                    }
15302                    else {
15303                            query = new StringBundler(5);
15304                    }
15305    
15306                    if (getDB().isSupportsInlineDistinct()) {
15307                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15308                    }
15309                    else {
15310                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15311                    }
15312    
15313                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
15314    
15315                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
15316    
15317                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
15318    
15319                    if (!getDB().isSupportsInlineDistinct()) {
15320                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15321                    }
15322    
15323                    if (orderByComparator != null) {
15324                            if (getDB().isSupportsInlineDistinct()) {
15325                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15326                                            orderByComparator);
15327                            }
15328                            else {
15329                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15330                                            orderByComparator);
15331                            }
15332                    }
15333    
15334                    else {
15335                            if (getDB().isSupportsInlineDistinct()) {
15336                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15337                            }
15338                            else {
15339                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15340                            }
15341                    }
15342    
15343                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15344                                    JournalArticle.class.getName(),
15345                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15346    
15347                    Session session = null;
15348    
15349                    try {
15350                            session = openSession();
15351    
15352                            SQLQuery q = session.createSQLQuery(sql);
15353    
15354                            if (getDB().isSupportsInlineDistinct()) {
15355                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15356                            }
15357                            else {
15358                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15359                            }
15360    
15361                            QueryPos qPos = QueryPos.getInstance(q);
15362    
15363                            qPos.add(groupId);
15364    
15365                            qPos.add(classNameId);
15366    
15367                            qPos.add(classPK);
15368    
15369                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
15370                                    end);
15371                    }
15372                    catch (Exception e) {
15373                            throw processException(e);
15374                    }
15375                    finally {
15376                            closeSession(session);
15377                    }
15378            }
15379    
15380            /**
15381             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
15382             *
15383             * @param id the primary key of the current journal article
15384             * @param groupId the group ID
15385             * @param classNameId the class name ID
15386             * @param classPK the class p k
15387             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15388             * @return the previous, current, and next journal article
15389             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15390             * @throws SystemException if a system exception occurred
15391             */
15392            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
15393                    long groupId, long classNameId, long classPK,
15394                    OrderByComparator orderByComparator)
15395                    throws NoSuchArticleException, SystemException {
15396                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15397                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
15398                                    orderByComparator);
15399                    }
15400    
15401                    JournalArticle journalArticle = findByPrimaryKey(id);
15402    
15403                    Session session = null;
15404    
15405                    try {
15406                            session = openSession();
15407    
15408                            JournalArticle[] array = new JournalArticleImpl[3];
15409    
15410                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
15411                                            groupId, classNameId, classPK, orderByComparator, true);
15412    
15413                            array[1] = journalArticle;
15414    
15415                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
15416                                            groupId, classNameId, classPK, orderByComparator, false);
15417    
15418                            return array;
15419                    }
15420                    catch (Exception e) {
15421                            throw processException(e);
15422                    }
15423                    finally {
15424                            closeSession(session);
15425                    }
15426            }
15427    
15428            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
15429                    JournalArticle journalArticle, long groupId, long classNameId,
15430                    long classPK, OrderByComparator orderByComparator, boolean previous) {
15431                    StringBundler query = null;
15432    
15433                    if (orderByComparator != null) {
15434                            query = new StringBundler(6 +
15435                                            (orderByComparator.getOrderByFields().length * 6));
15436                    }
15437                    else {
15438                            query = new StringBundler(3);
15439                    }
15440    
15441                    if (getDB().isSupportsInlineDistinct()) {
15442                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15443                    }
15444                    else {
15445                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15446                    }
15447    
15448                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
15449    
15450                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
15451    
15452                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
15453    
15454                    if (!getDB().isSupportsInlineDistinct()) {
15455                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15456                    }
15457    
15458                    if (orderByComparator != null) {
15459                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15460    
15461                            if (orderByConditionFields.length > 0) {
15462                                    query.append(WHERE_AND);
15463                            }
15464    
15465                            for (int i = 0; i < orderByConditionFields.length; i++) {
15466                                    if (getDB().isSupportsInlineDistinct()) {
15467                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15468                                    }
15469                                    else {
15470                                            query.append(_ORDER_BY_ENTITY_TABLE);
15471                                    }
15472    
15473                                    query.append(orderByConditionFields[i]);
15474    
15475                                    if ((i + 1) < orderByConditionFields.length) {
15476                                            if (orderByComparator.isAscending() ^ previous) {
15477                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15478                                            }
15479                                            else {
15480                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15481                                            }
15482                                    }
15483                                    else {
15484                                            if (orderByComparator.isAscending() ^ previous) {
15485                                                    query.append(WHERE_GREATER_THAN);
15486                                            }
15487                                            else {
15488                                                    query.append(WHERE_LESSER_THAN);
15489                                            }
15490                                    }
15491                            }
15492    
15493                            query.append(ORDER_BY_CLAUSE);
15494    
15495                            String[] orderByFields = orderByComparator.getOrderByFields();
15496    
15497                            for (int i = 0; i < orderByFields.length; i++) {
15498                                    if (getDB().isSupportsInlineDistinct()) {
15499                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15500                                    }
15501                                    else {
15502                                            query.append(_ORDER_BY_ENTITY_TABLE);
15503                                    }
15504    
15505                                    query.append(orderByFields[i]);
15506    
15507                                    if ((i + 1) < orderByFields.length) {
15508                                            if (orderByComparator.isAscending() ^ previous) {
15509                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15510                                            }
15511                                            else {
15512                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15513                                            }
15514                                    }
15515                                    else {
15516                                            if (orderByComparator.isAscending() ^ previous) {
15517                                                    query.append(ORDER_BY_ASC);
15518                                            }
15519                                            else {
15520                                                    query.append(ORDER_BY_DESC);
15521                                            }
15522                                    }
15523                            }
15524                    }
15525    
15526                    else {
15527                            if (getDB().isSupportsInlineDistinct()) {
15528                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15529                            }
15530                            else {
15531                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15532                            }
15533                    }
15534    
15535                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15536                                    JournalArticle.class.getName(),
15537                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15538    
15539                    SQLQuery q = session.createSQLQuery(sql);
15540    
15541                    q.setFirstResult(0);
15542                    q.setMaxResults(2);
15543    
15544                    if (getDB().isSupportsInlineDistinct()) {
15545                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15546                    }
15547                    else {
15548                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15549                    }
15550    
15551                    QueryPos qPos = QueryPos.getInstance(q);
15552    
15553                    qPos.add(groupId);
15554    
15555                    qPos.add(classNameId);
15556    
15557                    qPos.add(classPK);
15558    
15559                    if (orderByComparator != null) {
15560                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15561    
15562                            for (Object value : values) {
15563                                    qPos.add(value);
15564                            }
15565                    }
15566    
15567                    List<JournalArticle> list = q.list();
15568    
15569                    if (list.size() == 2) {
15570                            return list.get(1);
15571                    }
15572                    else {
15573                            return null;
15574                    }
15575            }
15576    
15577            /**
15578             * Returns the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
15579             *
15580             * @param groupId the group ID
15581             * @param classNameId the class name ID
15582             * @param structureId the structure ID
15583             * @return the matching journal article
15584             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15585             * @throws SystemException if a system exception occurred
15586             */
15587            public JournalArticle findByG_C_S(long groupId, long classNameId,
15588                    String structureId) throws NoSuchArticleException, SystemException {
15589                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
15590                                    structureId);
15591    
15592                    if (journalArticle == null) {
15593                            StringBundler msg = new StringBundler(8);
15594    
15595                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15596    
15597                            msg.append("groupId=");
15598                            msg.append(groupId);
15599    
15600                            msg.append(", classNameId=");
15601                            msg.append(classNameId);
15602    
15603                            msg.append(", structureId=");
15604                            msg.append(structureId);
15605    
15606                            msg.append(StringPool.CLOSE_CURLY_BRACE);
15607    
15608                            if (_log.isWarnEnabled()) {
15609                                    _log.warn(msg.toString());
15610                            }
15611    
15612                            throw new NoSuchArticleException(msg.toString());
15613                    }
15614    
15615                    return journalArticle;
15616            }
15617    
15618            /**
15619             * Returns the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
15620             *
15621             * @param groupId the group ID
15622             * @param classNameId the class name ID
15623             * @param structureId the structure ID
15624             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
15625             * @throws SystemException if a system exception occurred
15626             */
15627            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
15628                    String structureId) throws SystemException {
15629                    return fetchByG_C_S(groupId, classNameId, structureId, true);
15630            }
15631    
15632            /**
15633             * Returns the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
15634             *
15635             * @param groupId the group ID
15636             * @param classNameId the class name ID
15637             * @param structureId the structure ID
15638             * @param retrieveFromCache whether to use the finder cache
15639             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
15640             * @throws SystemException if a system exception occurred
15641             */
15642            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
15643                    String structureId, boolean retrieveFromCache)
15644                    throws SystemException {
15645                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
15646    
15647                    Object result = null;
15648    
15649                    if (retrieveFromCache) {
15650                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
15651                                            finderArgs, this);
15652                    }
15653    
15654                    if (result instanceof JournalArticle) {
15655                            JournalArticle journalArticle = (JournalArticle)result;
15656    
15657                            if ((groupId != journalArticle.getGroupId()) ||
15658                                            (classNameId != journalArticle.getClassNameId()) ||
15659                                            !Validator.equals(structureId,
15660                                                    journalArticle.getStructureId())) {
15661                                    result = null;
15662                            }
15663                    }
15664    
15665                    if (result == null) {
15666                            StringBundler query = new StringBundler(5);
15667    
15668                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15669    
15670                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
15671    
15672                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
15673    
15674                            if (structureId == null) {
15675                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
15676                            }
15677                            else {
15678                                    if (structureId.equals(StringPool.BLANK)) {
15679                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
15680                                    }
15681                                    else {
15682                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
15683                                    }
15684                            }
15685    
15686                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15687    
15688                            String sql = query.toString();
15689    
15690                            Session session = null;
15691    
15692                            try {
15693                                    session = openSession();
15694    
15695                                    Query q = session.createQuery(sql);
15696    
15697                                    QueryPos qPos = QueryPos.getInstance(q);
15698    
15699                                    qPos.add(groupId);
15700    
15701                                    qPos.add(classNameId);
15702    
15703                                    if (structureId != null) {
15704                                            qPos.add(structureId);
15705                                    }
15706    
15707                                    List<JournalArticle> list = q.list();
15708    
15709                                    result = list;
15710    
15711                                    JournalArticle journalArticle = null;
15712    
15713                                    if (list.isEmpty()) {
15714                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
15715                                                    finderArgs, list);
15716                                    }
15717                                    else {
15718                                            journalArticle = list.get(0);
15719    
15720                                            cacheResult(journalArticle);
15721    
15722                                            if ((journalArticle.getGroupId() != groupId) ||
15723                                                            (journalArticle.getClassNameId() != classNameId) ||
15724                                                            (journalArticle.getStructureId() == null) ||
15725                                                            !journalArticle.getStructureId().equals(structureId)) {
15726                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
15727                                                            finderArgs, journalArticle);
15728                                            }
15729                                    }
15730    
15731                                    return journalArticle;
15732                            }
15733                            catch (Exception e) {
15734                                    throw processException(e);
15735                            }
15736                            finally {
15737                                    if (result == null) {
15738                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
15739                                                    finderArgs);
15740                                    }
15741    
15742                                    closeSession(session);
15743                            }
15744                    }
15745                    else {
15746                            if (result instanceof List<?>) {
15747                                    return null;
15748                            }
15749                            else {
15750                                    return (JournalArticle)result;
15751                            }
15752                    }
15753            }
15754    
15755            /**
15756             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
15757             *
15758             * @param groupId the group ID
15759             * @param classNameId the class name ID
15760             * @param templateId the template ID
15761             * @return the matching journal articles
15762             * @throws SystemException if a system exception occurred
15763             */
15764            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
15765                    String templateId) throws SystemException {
15766                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
15767                            QueryUtil.ALL_POS, null);
15768            }
15769    
15770            /**
15771             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
15772             *
15773             * <p>
15774             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15775             * </p>
15776             *
15777             * @param groupId the group ID
15778             * @param classNameId the class name ID
15779             * @param templateId the template ID
15780             * @param start the lower bound of the range of journal articles
15781             * @param end the upper bound of the range of journal articles (not inclusive)
15782             * @return the range of matching journal articles
15783             * @throws SystemException if a system exception occurred
15784             */
15785            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
15786                    String templateId, int start, int end) throws SystemException {
15787                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
15788            }
15789    
15790            /**
15791             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
15792             *
15793             * <p>
15794             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15795             * </p>
15796             *
15797             * @param groupId the group ID
15798             * @param classNameId the class name ID
15799             * @param templateId the template ID
15800             * @param start the lower bound of the range of journal articles
15801             * @param end the upper bound of the range of journal articles (not inclusive)
15802             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15803             * @return the ordered range of matching journal articles
15804             * @throws SystemException if a system exception occurred
15805             */
15806            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
15807                    String templateId, int start, int end,
15808                    OrderByComparator orderByComparator) throws SystemException {
15809                    FinderPath finderPath = null;
15810                    Object[] finderArgs = null;
15811    
15812                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15813                                    (orderByComparator == null)) {
15814                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
15815                            finderArgs = new Object[] { groupId, classNameId, templateId };
15816                    }
15817                    else {
15818                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
15819                            finderArgs = new Object[] {
15820                                            groupId, classNameId, templateId,
15821                                            
15822                                            start, end, orderByComparator
15823                                    };
15824                    }
15825    
15826                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15827                                    finderArgs, this);
15828    
15829                    if ((list != null) && !list.isEmpty()) {
15830                            for (JournalArticle journalArticle : list) {
15831                                    if ((groupId != journalArticle.getGroupId()) ||
15832                                                    (classNameId != journalArticle.getClassNameId()) ||
15833                                                    !Validator.equals(templateId,
15834                                                            journalArticle.getTemplateId())) {
15835                                            list = null;
15836    
15837                                            break;
15838                                    }
15839                            }
15840                    }
15841    
15842                    if (list == null) {
15843                            StringBundler query = null;
15844    
15845                            if (orderByComparator != null) {
15846                                    query = new StringBundler(5 +
15847                                                    (orderByComparator.getOrderByFields().length * 3));
15848                            }
15849                            else {
15850                                    query = new StringBundler(5);
15851                            }
15852    
15853                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15854    
15855                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
15856    
15857                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
15858    
15859                            if (templateId == null) {
15860                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
15861                            }
15862                            else {
15863                                    if (templateId.equals(StringPool.BLANK)) {
15864                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
15865                                    }
15866                                    else {
15867                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
15868                                    }
15869                            }
15870    
15871                            if (orderByComparator != null) {
15872                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15873                                            orderByComparator);
15874                            }
15875    
15876                            else {
15877                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15878                            }
15879    
15880                            String sql = query.toString();
15881    
15882                            Session session = null;
15883    
15884                            try {
15885                                    session = openSession();
15886    
15887                                    Query q = session.createQuery(sql);
15888    
15889                                    QueryPos qPos = QueryPos.getInstance(q);
15890    
15891                                    qPos.add(groupId);
15892    
15893                                    qPos.add(classNameId);
15894    
15895                                    if (templateId != null) {
15896                                            qPos.add(templateId);
15897                                    }
15898    
15899                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
15900                                                    start, end);
15901                            }
15902                            catch (Exception e) {
15903                                    throw processException(e);
15904                            }
15905                            finally {
15906                                    if (list == null) {
15907                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
15908                                    }
15909                                    else {
15910                                            cacheResult(list);
15911    
15912                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
15913                                    }
15914    
15915                                    closeSession(session);
15916                            }
15917                    }
15918    
15919                    return list;
15920            }
15921    
15922            /**
15923             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
15924             *
15925             * @param groupId the group ID
15926             * @param classNameId the class name ID
15927             * @param templateId the template ID
15928             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15929             * @return the first matching journal article
15930             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15931             * @throws SystemException if a system exception occurred
15932             */
15933            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
15934                    String templateId, OrderByComparator orderByComparator)
15935                    throws NoSuchArticleException, SystemException {
15936                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
15937                                    classNameId, templateId, orderByComparator);
15938    
15939                    if (journalArticle != null) {
15940                            return journalArticle;
15941                    }
15942    
15943                    StringBundler msg = new StringBundler(8);
15944    
15945                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15946    
15947                    msg.append("groupId=");
15948                    msg.append(groupId);
15949    
15950                    msg.append(", classNameId=");
15951                    msg.append(classNameId);
15952    
15953                    msg.append(", templateId=");
15954                    msg.append(templateId);
15955    
15956                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15957    
15958                    throw new NoSuchArticleException(msg.toString());
15959            }
15960    
15961            /**
15962             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
15963             *
15964             * @param groupId the group ID
15965             * @param classNameId the class name ID
15966             * @param templateId the template ID
15967             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15968             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15969             * @throws SystemException if a system exception occurred
15970             */
15971            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
15972                    String templateId, OrderByComparator orderByComparator)
15973                    throws SystemException {
15974                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
15975                                    templateId, 0, 1, orderByComparator);
15976    
15977                    if (!list.isEmpty()) {
15978                            return list.get(0);
15979                    }
15980    
15981                    return null;
15982            }
15983    
15984            /**
15985             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
15986             *
15987             * @param groupId the group ID
15988             * @param classNameId the class name ID
15989             * @param templateId the template ID
15990             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15991             * @return the last matching journal article
15992             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15993             * @throws SystemException if a system exception occurred
15994             */
15995            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
15996                    String templateId, OrderByComparator orderByComparator)
15997                    throws NoSuchArticleException, SystemException {
15998                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
15999                                    templateId, orderByComparator);
16000    
16001                    if (journalArticle != null) {
16002                            return journalArticle;
16003                    }
16004    
16005                    StringBundler msg = new StringBundler(8);
16006    
16007                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16008    
16009                    msg.append("groupId=");
16010                    msg.append(groupId);
16011    
16012                    msg.append(", classNameId=");
16013                    msg.append(classNameId);
16014    
16015                    msg.append(", templateId=");
16016                    msg.append(templateId);
16017    
16018                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16019    
16020                    throw new NoSuchArticleException(msg.toString());
16021            }
16022    
16023            /**
16024             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
16025             *
16026             * @param groupId the group ID
16027             * @param classNameId the class name ID
16028             * @param templateId the template ID
16029             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16030             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16031             * @throws SystemException if a system exception occurred
16032             */
16033            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
16034                    String templateId, OrderByComparator orderByComparator)
16035                    throws SystemException {
16036                    int count = countByG_C_T(groupId, classNameId, templateId);
16037    
16038                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
16039                                    templateId, count - 1, count, orderByComparator);
16040    
16041                    if (!list.isEmpty()) {
16042                            return list.get(0);
16043                    }
16044    
16045                    return null;
16046            }
16047    
16048            /**
16049             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
16050             *
16051             * @param id the primary key of the current journal article
16052             * @param groupId the group ID
16053             * @param classNameId the class name ID
16054             * @param templateId the template ID
16055             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16056             * @return the previous, current, and next journal article
16057             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16058             * @throws SystemException if a system exception occurred
16059             */
16060            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
16061                    long classNameId, String templateId, OrderByComparator orderByComparator)
16062                    throws NoSuchArticleException, SystemException {
16063                    JournalArticle journalArticle = findByPrimaryKey(id);
16064    
16065                    Session session = null;
16066    
16067                    try {
16068                            session = openSession();
16069    
16070                            JournalArticle[] array = new JournalArticleImpl[3];
16071    
16072                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
16073                                            classNameId, templateId, orderByComparator, true);
16074    
16075                            array[1] = journalArticle;
16076    
16077                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
16078                                            classNameId, templateId, orderByComparator, false);
16079    
16080                            return array;
16081                    }
16082                    catch (Exception e) {
16083                            throw processException(e);
16084                    }
16085                    finally {
16086                            closeSession(session);
16087                    }
16088            }
16089    
16090            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
16091                    JournalArticle journalArticle, long groupId, long classNameId,
16092                    String templateId, OrderByComparator orderByComparator, boolean previous) {
16093                    StringBundler query = null;
16094    
16095                    if (orderByComparator != null) {
16096                            query = new StringBundler(6 +
16097                                            (orderByComparator.getOrderByFields().length * 6));
16098                    }
16099                    else {
16100                            query = new StringBundler(3);
16101                    }
16102    
16103                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16104    
16105                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
16106    
16107                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
16108    
16109                    if (templateId == null) {
16110                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
16111                    }
16112                    else {
16113                            if (templateId.equals(StringPool.BLANK)) {
16114                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
16115                            }
16116                            else {
16117                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
16118                            }
16119                    }
16120    
16121                    if (orderByComparator != null) {
16122                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16123    
16124                            if (orderByConditionFields.length > 0) {
16125                                    query.append(WHERE_AND);
16126                            }
16127    
16128                            for (int i = 0; i < orderByConditionFields.length; i++) {
16129                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16130                                    query.append(orderByConditionFields[i]);
16131    
16132                                    if ((i + 1) < orderByConditionFields.length) {
16133                                            if (orderByComparator.isAscending() ^ previous) {
16134                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16135                                            }
16136                                            else {
16137                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16138                                            }
16139                                    }
16140                                    else {
16141                                            if (orderByComparator.isAscending() ^ previous) {
16142                                                    query.append(WHERE_GREATER_THAN);
16143                                            }
16144                                            else {
16145                                                    query.append(WHERE_LESSER_THAN);
16146                                            }
16147                                    }
16148                            }
16149    
16150                            query.append(ORDER_BY_CLAUSE);
16151    
16152                            String[] orderByFields = orderByComparator.getOrderByFields();
16153    
16154                            for (int i = 0; i < orderByFields.length; i++) {
16155                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16156                                    query.append(orderByFields[i]);
16157    
16158                                    if ((i + 1) < orderByFields.length) {
16159                                            if (orderByComparator.isAscending() ^ previous) {
16160                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16161                                            }
16162                                            else {
16163                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16164                                            }
16165                                    }
16166                                    else {
16167                                            if (orderByComparator.isAscending() ^ previous) {
16168                                                    query.append(ORDER_BY_ASC);
16169                                            }
16170                                            else {
16171                                                    query.append(ORDER_BY_DESC);
16172                                            }
16173                                    }
16174                            }
16175                    }
16176    
16177                    else {
16178                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16179                    }
16180    
16181                    String sql = query.toString();
16182    
16183                    Query q = session.createQuery(sql);
16184    
16185                    q.setFirstResult(0);
16186                    q.setMaxResults(2);
16187    
16188                    QueryPos qPos = QueryPos.getInstance(q);
16189    
16190                    qPos.add(groupId);
16191    
16192                    qPos.add(classNameId);
16193    
16194                    if (templateId != null) {
16195                            qPos.add(templateId);
16196                    }
16197    
16198                    if (orderByComparator != null) {
16199                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16200    
16201                            for (Object value : values) {
16202                                    qPos.add(value);
16203                            }
16204                    }
16205    
16206                    List<JournalArticle> list = q.list();
16207    
16208                    if (list.size() == 2) {
16209                            return list.get(1);
16210                    }
16211                    else {
16212                            return null;
16213                    }
16214            }
16215    
16216            /**
16217             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
16218             *
16219             * @param groupId the group ID
16220             * @param classNameId the class name ID
16221             * @param templateId the template ID
16222             * @return the matching journal articles that the user has permission to view
16223             * @throws SystemException if a system exception occurred
16224             */
16225            public List<JournalArticle> filterFindByG_C_T(long groupId,
16226                    long classNameId, String templateId) throws SystemException {
16227                    return filterFindByG_C_T(groupId, classNameId, templateId,
16228                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16229            }
16230    
16231            /**
16232             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
16233             *
16234             * <p>
16235             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
16236             * </p>
16237             *
16238             * @param groupId the group ID
16239             * @param classNameId the class name ID
16240             * @param templateId the template ID
16241             * @param start the lower bound of the range of journal articles
16242             * @param end the upper bound of the range of journal articles (not inclusive)
16243             * @return the range of matching journal articles that the user has permission to view
16244             * @throws SystemException if a system exception occurred
16245             */
16246            public List<JournalArticle> filterFindByG_C_T(long groupId,
16247                    long classNameId, String templateId, int start, int end)
16248                    throws SystemException {
16249                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
16250                            null);
16251            }
16252    
16253            /**
16254             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
16255             *
16256             * <p>
16257             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
16258             * </p>
16259             *
16260             * @param groupId the group ID
16261             * @param classNameId the class name ID
16262             * @param templateId the template ID
16263             * @param start the lower bound of the range of journal articles
16264             * @param end the upper bound of the range of journal articles (not inclusive)
16265             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16266             * @return the ordered range of matching journal articles that the user has permission to view
16267             * @throws SystemException if a system exception occurred
16268             */
16269            public List<JournalArticle> filterFindByG_C_T(long groupId,
16270                    long classNameId, String templateId, int start, int end,
16271                    OrderByComparator orderByComparator) throws SystemException {
16272                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16273                            return findByG_C_T(groupId, classNameId, templateId, start, end,
16274                                    orderByComparator);
16275                    }
16276    
16277                    StringBundler query = null;
16278    
16279                    if (orderByComparator != null) {
16280                            query = new StringBundler(5 +
16281                                            (orderByComparator.getOrderByFields().length * 3));
16282                    }
16283                    else {
16284                            query = new StringBundler(5);
16285                    }
16286    
16287                    if (getDB().isSupportsInlineDistinct()) {
16288                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
16289                    }
16290                    else {
16291                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
16292                    }
16293    
16294                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
16295    
16296                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
16297    
16298                    if (templateId == null) {
16299                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
16300                    }
16301                    else {
16302                            if (templateId.equals(StringPool.BLANK)) {
16303                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
16304                            }
16305                            else {
16306                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
16307                            }
16308                    }
16309    
16310                    if (!getDB().isSupportsInlineDistinct()) {
16311                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
16312                    }
16313    
16314                    if (orderByComparator != null) {
16315                            if (getDB().isSupportsInlineDistinct()) {
16316                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16317                                            orderByComparator);
16318                            }
16319                            else {
16320                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16321                                            orderByComparator);
16322                            }
16323                    }
16324    
16325                    else {
16326                            if (getDB().isSupportsInlineDistinct()) {
16327                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16328                            }
16329                            else {
16330                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
16331                            }
16332                    }
16333    
16334                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16335                                    JournalArticle.class.getName(),
16336                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16337    
16338                    Session session = null;
16339    
16340                    try {
16341                            session = openSession();
16342    
16343                            SQLQuery q = session.createSQLQuery(sql);
16344    
16345                            if (getDB().isSupportsInlineDistinct()) {
16346                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
16347                            }
16348                            else {
16349                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
16350                            }
16351    
16352                            QueryPos qPos = QueryPos.getInstance(q);
16353    
16354                            qPos.add(groupId);
16355    
16356                            qPos.add(classNameId);
16357    
16358                            if (templateId != null) {
16359                                    qPos.add(templateId);
16360                            }
16361    
16362                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
16363                                    end);
16364                    }
16365                    catch (Exception e) {
16366                            throw processException(e);
16367                    }
16368                    finally {
16369                            closeSession(session);
16370                    }
16371            }
16372    
16373            /**
16374             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
16375             *
16376             * @param id the primary key of the current journal article
16377             * @param groupId the group ID
16378             * @param classNameId the class name ID
16379             * @param templateId the template ID
16380             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16381             * @return the previous, current, and next journal article
16382             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16383             * @throws SystemException if a system exception occurred
16384             */
16385            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
16386                    long groupId, long classNameId, String templateId,
16387                    OrderByComparator orderByComparator)
16388                    throws NoSuchArticleException, SystemException {
16389                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16390                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
16391                                    templateId, orderByComparator);
16392                    }
16393    
16394                    JournalArticle journalArticle = findByPrimaryKey(id);
16395    
16396                    Session session = null;
16397    
16398                    try {
16399                            session = openSession();
16400    
16401                            JournalArticle[] array = new JournalArticleImpl[3];
16402    
16403                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
16404                                            groupId, classNameId, templateId, orderByComparator, true);
16405    
16406                            array[1] = journalArticle;
16407    
16408                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
16409                                            groupId, classNameId, templateId, orderByComparator, false);
16410    
16411                            return array;
16412                    }
16413                    catch (Exception e) {
16414                            throw processException(e);
16415                    }
16416                    finally {
16417                            closeSession(session);
16418                    }
16419            }
16420    
16421            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
16422                    JournalArticle journalArticle, long groupId, long classNameId,
16423                    String templateId, OrderByComparator orderByComparator, boolean previous) {
16424                    StringBundler query = null;
16425    
16426                    if (orderByComparator != null) {
16427                            query = new StringBundler(6 +
16428                                            (orderByComparator.getOrderByFields().length * 6));
16429                    }
16430                    else {
16431                            query = new StringBundler(3);
16432                    }
16433    
16434                    if (getDB().isSupportsInlineDistinct()) {
16435                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
16436                    }
16437                    else {
16438                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
16439                    }
16440    
16441                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
16442    
16443                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
16444    
16445                    if (templateId == null) {
16446                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
16447                    }
16448                    else {
16449                            if (templateId.equals(StringPool.BLANK)) {
16450                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
16451                            }
16452                            else {
16453                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
16454                            }
16455                    }
16456    
16457                    if (!getDB().isSupportsInlineDistinct()) {
16458                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
16459                    }
16460    
16461                    if (orderByComparator != null) {
16462                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16463    
16464                            if (orderByConditionFields.length > 0) {
16465                                    query.append(WHERE_AND);
16466                            }
16467    
16468                            for (int i = 0; i < orderByConditionFields.length; i++) {
16469                                    if (getDB().isSupportsInlineDistinct()) {
16470                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16471                                    }
16472                                    else {
16473                                            query.append(_ORDER_BY_ENTITY_TABLE);
16474                                    }
16475    
16476                                    query.append(orderByConditionFields[i]);
16477    
16478                                    if ((i + 1) < orderByConditionFields.length) {
16479                                            if (orderByComparator.isAscending() ^ previous) {
16480                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16481                                            }
16482                                            else {
16483                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16484                                            }
16485                                    }
16486                                    else {
16487                                            if (orderByComparator.isAscending() ^ previous) {
16488                                                    query.append(WHERE_GREATER_THAN);
16489                                            }
16490                                            else {
16491                                                    query.append(WHERE_LESSER_THAN);
16492                                            }
16493                                    }
16494                            }
16495    
16496                            query.append(ORDER_BY_CLAUSE);
16497    
16498                            String[] orderByFields = orderByComparator.getOrderByFields();
16499    
16500                            for (int i = 0; i < orderByFields.length; i++) {
16501                                    if (getDB().isSupportsInlineDistinct()) {
16502                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16503                                    }
16504                                    else {
16505                                            query.append(_ORDER_BY_ENTITY_TABLE);
16506                                    }
16507    
16508                                    query.append(orderByFields[i]);
16509    
16510                                    if ((i + 1) < orderByFields.length) {
16511                                            if (orderByComparator.isAscending() ^ previous) {
16512                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16513                                            }
16514                                            else {
16515                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16516                                            }
16517                                    }
16518                                    else {
16519                                            if (orderByComparator.isAscending() ^ previous) {
16520                                                    query.append(ORDER_BY_ASC);
16521                                            }
16522                                            else {
16523                                                    query.append(ORDER_BY_DESC);
16524                                            }
16525                                    }
16526                            }
16527                    }
16528    
16529                    else {
16530                            if (getDB().isSupportsInlineDistinct()) {
16531                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16532                            }
16533                            else {
16534                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
16535                            }
16536                    }
16537    
16538                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16539                                    JournalArticle.class.getName(),
16540                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16541    
16542                    SQLQuery q = session.createSQLQuery(sql);
16543    
16544                    q.setFirstResult(0);
16545                    q.setMaxResults(2);
16546    
16547                    if (getDB().isSupportsInlineDistinct()) {
16548                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
16549                    }
16550                    else {
16551                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
16552                    }
16553    
16554                    QueryPos qPos = QueryPos.getInstance(q);
16555    
16556                    qPos.add(groupId);
16557    
16558                    qPos.add(classNameId);
16559    
16560                    if (templateId != null) {
16561                            qPos.add(templateId);
16562                    }
16563    
16564                    if (orderByComparator != null) {
16565                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16566    
16567                            for (Object value : values) {
16568                                    qPos.add(value);
16569                            }
16570                    }
16571    
16572                    List<JournalArticle> list = q.list();
16573    
16574                    if (list.size() == 2) {
16575                            return list.get(1);
16576                    }
16577                    else {
16578                            return null;
16579                    }
16580            }
16581    
16582            /**
16583             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16584             *
16585             * @param groupId the group ID
16586             * @param classNameId the class name ID
16587             * @param layoutUuid the layout uuid
16588             * @return the matching journal articles
16589             * @throws SystemException if a system exception occurred
16590             */
16591            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
16592                    String layoutUuid) throws SystemException {
16593                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
16594                            QueryUtil.ALL_POS, null);
16595            }
16596    
16597            /**
16598             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16599             *
16600             * <p>
16601             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
16602             * </p>
16603             *
16604             * @param groupId the group ID
16605             * @param classNameId the class name ID
16606             * @param layoutUuid the layout uuid
16607             * @param start the lower bound of the range of journal articles
16608             * @param end the upper bound of the range of journal articles (not inclusive)
16609             * @return the range of matching journal articles
16610             * @throws SystemException if a system exception occurred
16611             */
16612            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
16613                    String layoutUuid, int start, int end) throws SystemException {
16614                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
16615            }
16616    
16617            /**
16618             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16619             *
16620             * <p>
16621             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
16622             * </p>
16623             *
16624             * @param groupId the group ID
16625             * @param classNameId the class name ID
16626             * @param layoutUuid the layout uuid
16627             * @param start the lower bound of the range of journal articles
16628             * @param end the upper bound of the range of journal articles (not inclusive)
16629             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16630             * @return the ordered range of matching journal articles
16631             * @throws SystemException if a system exception occurred
16632             */
16633            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
16634                    String layoutUuid, int start, int end,
16635                    OrderByComparator orderByComparator) throws SystemException {
16636                    FinderPath finderPath = null;
16637                    Object[] finderArgs = null;
16638    
16639                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16640                                    (orderByComparator == null)) {
16641                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
16642                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
16643                    }
16644                    else {
16645                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
16646                            finderArgs = new Object[] {
16647                                            groupId, classNameId, layoutUuid,
16648                                            
16649                                            start, end, orderByComparator
16650                                    };
16651                    }
16652    
16653                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16654                                    finderArgs, this);
16655    
16656                    if ((list != null) && !list.isEmpty()) {
16657                            for (JournalArticle journalArticle : list) {
16658                                    if ((groupId != journalArticle.getGroupId()) ||
16659                                                    (classNameId != journalArticle.getClassNameId()) ||
16660                                                    !Validator.equals(layoutUuid,
16661                                                            journalArticle.getLayoutUuid())) {
16662                                            list = null;
16663    
16664                                            break;
16665                                    }
16666                            }
16667                    }
16668    
16669                    if (list == null) {
16670                            StringBundler query = null;
16671    
16672                            if (orderByComparator != null) {
16673                                    query = new StringBundler(5 +
16674                                                    (orderByComparator.getOrderByFields().length * 3));
16675                            }
16676                            else {
16677                                    query = new StringBundler(5);
16678                            }
16679    
16680                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16681    
16682                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
16683    
16684                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
16685    
16686                            if (layoutUuid == null) {
16687                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
16688                            }
16689                            else {
16690                                    if (layoutUuid.equals(StringPool.BLANK)) {
16691                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
16692                                    }
16693                                    else {
16694                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
16695                                    }
16696                            }
16697    
16698                            if (orderByComparator != null) {
16699                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16700                                            orderByComparator);
16701                            }
16702    
16703                            else {
16704                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16705                            }
16706    
16707                            String sql = query.toString();
16708    
16709                            Session session = null;
16710    
16711                            try {
16712                                    session = openSession();
16713    
16714                                    Query q = session.createQuery(sql);
16715    
16716                                    QueryPos qPos = QueryPos.getInstance(q);
16717    
16718                                    qPos.add(groupId);
16719    
16720                                    qPos.add(classNameId);
16721    
16722                                    if (layoutUuid != null) {
16723                                            qPos.add(layoutUuid);
16724                                    }
16725    
16726                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
16727                                                    start, end);
16728                            }
16729                            catch (Exception e) {
16730                                    throw processException(e);
16731                            }
16732                            finally {
16733                                    if (list == null) {
16734                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
16735                                    }
16736                                    else {
16737                                            cacheResult(list);
16738    
16739                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
16740                                    }
16741    
16742                                    closeSession(session);
16743                            }
16744                    }
16745    
16746                    return list;
16747            }
16748    
16749            /**
16750             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16751             *
16752             * @param groupId the group ID
16753             * @param classNameId the class name ID
16754             * @param layoutUuid the layout uuid
16755             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16756             * @return the first matching journal article
16757             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16758             * @throws SystemException if a system exception occurred
16759             */
16760            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
16761                    String layoutUuid, OrderByComparator orderByComparator)
16762                    throws NoSuchArticleException, SystemException {
16763                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
16764                                    classNameId, layoutUuid, orderByComparator);
16765    
16766                    if (journalArticle != null) {
16767                            return journalArticle;
16768                    }
16769    
16770                    StringBundler msg = new StringBundler(8);
16771    
16772                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16773    
16774                    msg.append("groupId=");
16775                    msg.append(groupId);
16776    
16777                    msg.append(", classNameId=");
16778                    msg.append(classNameId);
16779    
16780                    msg.append(", layoutUuid=");
16781                    msg.append(layoutUuid);
16782    
16783                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16784    
16785                    throw new NoSuchArticleException(msg.toString());
16786            }
16787    
16788            /**
16789             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16790             *
16791             * @param groupId the group ID
16792             * @param classNameId the class name ID
16793             * @param layoutUuid the layout uuid
16794             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16795             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
16796             * @throws SystemException if a system exception occurred
16797             */
16798            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
16799                    String layoutUuid, OrderByComparator orderByComparator)
16800                    throws SystemException {
16801                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
16802                                    layoutUuid, 0, 1, orderByComparator);
16803    
16804                    if (!list.isEmpty()) {
16805                            return list.get(0);
16806                    }
16807    
16808                    return null;
16809            }
16810    
16811            /**
16812             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16813             *
16814             * @param groupId the group ID
16815             * @param classNameId the class name ID
16816             * @param layoutUuid the layout uuid
16817             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16818             * @return the last matching journal article
16819             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
16820             * @throws SystemException if a system exception occurred
16821             */
16822            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
16823                    String layoutUuid, OrderByComparator orderByComparator)
16824                    throws NoSuchArticleException, SystemException {
16825                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
16826                                    layoutUuid, orderByComparator);
16827    
16828                    if (journalArticle != null) {
16829                            return journalArticle;
16830                    }
16831    
16832                    StringBundler msg = new StringBundler(8);
16833    
16834                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16835    
16836                    msg.append("groupId=");
16837                    msg.append(groupId);
16838    
16839                    msg.append(", classNameId=");
16840                    msg.append(classNameId);
16841    
16842                    msg.append(", layoutUuid=");
16843                    msg.append(layoutUuid);
16844    
16845                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16846    
16847                    throw new NoSuchArticleException(msg.toString());
16848            }
16849    
16850            /**
16851             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16852             *
16853             * @param groupId the group ID
16854             * @param classNameId the class name ID
16855             * @param layoutUuid the layout uuid
16856             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16857             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
16858             * @throws SystemException if a system exception occurred
16859             */
16860            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
16861                    String layoutUuid, OrderByComparator orderByComparator)
16862                    throws SystemException {
16863                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
16864    
16865                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
16866                                    layoutUuid, count - 1, count, orderByComparator);
16867    
16868                    if (!list.isEmpty()) {
16869                            return list.get(0);
16870                    }
16871    
16872                    return null;
16873            }
16874    
16875            /**
16876             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16877             *
16878             * @param id the primary key of the current journal article
16879             * @param groupId the group ID
16880             * @param classNameId the class name ID
16881             * @param layoutUuid the layout uuid
16882             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16883             * @return the previous, current, and next journal article
16884             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
16885             * @throws SystemException if a system exception occurred
16886             */
16887            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
16888                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
16889                    throws NoSuchArticleException, SystemException {
16890                    JournalArticle journalArticle = findByPrimaryKey(id);
16891    
16892                    Session session = null;
16893    
16894                    try {
16895                            session = openSession();
16896    
16897                            JournalArticle[] array = new JournalArticleImpl[3];
16898    
16899                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
16900                                            classNameId, layoutUuid, orderByComparator, true);
16901    
16902                            array[1] = journalArticle;
16903    
16904                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
16905                                            classNameId, layoutUuid, orderByComparator, false);
16906    
16907                            return array;
16908                    }
16909                    catch (Exception e) {
16910                            throw processException(e);
16911                    }
16912                    finally {
16913                            closeSession(session);
16914                    }
16915            }
16916    
16917            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
16918                    JournalArticle journalArticle, long groupId, long classNameId,
16919                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
16920                    StringBundler query = null;
16921    
16922                    if (orderByComparator != null) {
16923                            query = new StringBundler(6 +
16924                                            (orderByComparator.getOrderByFields().length * 6));
16925                    }
16926                    else {
16927                            query = new StringBundler(3);
16928                    }
16929    
16930                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
16931    
16932                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
16933    
16934                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
16935    
16936                    if (layoutUuid == null) {
16937                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
16938                    }
16939                    else {
16940                            if (layoutUuid.equals(StringPool.BLANK)) {
16941                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
16942                            }
16943                            else {
16944                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
16945                            }
16946                    }
16947    
16948                    if (orderByComparator != null) {
16949                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16950    
16951                            if (orderByConditionFields.length > 0) {
16952                                    query.append(WHERE_AND);
16953                            }
16954    
16955                            for (int i = 0; i < orderByConditionFields.length; i++) {
16956                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16957                                    query.append(orderByConditionFields[i]);
16958    
16959                                    if ((i + 1) < orderByConditionFields.length) {
16960                                            if (orderByComparator.isAscending() ^ previous) {
16961                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16962                                            }
16963                                            else {
16964                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16965                                            }
16966                                    }
16967                                    else {
16968                                            if (orderByComparator.isAscending() ^ previous) {
16969                                                    query.append(WHERE_GREATER_THAN);
16970                                            }
16971                                            else {
16972                                                    query.append(WHERE_LESSER_THAN);
16973                                            }
16974                                    }
16975                            }
16976    
16977                            query.append(ORDER_BY_CLAUSE);
16978    
16979                            String[] orderByFields = orderByComparator.getOrderByFields();
16980    
16981                            for (int i = 0; i < orderByFields.length; i++) {
16982                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16983                                    query.append(orderByFields[i]);
16984    
16985                                    if ((i + 1) < orderByFields.length) {
16986                                            if (orderByComparator.isAscending() ^ previous) {
16987                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16988                                            }
16989                                            else {
16990                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16991                                            }
16992                                    }
16993                                    else {
16994                                            if (orderByComparator.isAscending() ^ previous) {
16995                                                    query.append(ORDER_BY_ASC);
16996                                            }
16997                                            else {
16998                                                    query.append(ORDER_BY_DESC);
16999                                            }
17000                                    }
17001                            }
17002                    }
17003    
17004                    else {
17005                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17006                    }
17007    
17008                    String sql = query.toString();
17009    
17010                    Query q = session.createQuery(sql);
17011    
17012                    q.setFirstResult(0);
17013                    q.setMaxResults(2);
17014    
17015                    QueryPos qPos = QueryPos.getInstance(q);
17016    
17017                    qPos.add(groupId);
17018    
17019                    qPos.add(classNameId);
17020    
17021                    if (layoutUuid != null) {
17022                            qPos.add(layoutUuid);
17023                    }
17024    
17025                    if (orderByComparator != null) {
17026                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17027    
17028                            for (Object value : values) {
17029                                    qPos.add(value);
17030                            }
17031                    }
17032    
17033                    List<JournalArticle> list = q.list();
17034    
17035                    if (list.size() == 2) {
17036                            return list.get(1);
17037                    }
17038                    else {
17039                            return null;
17040                    }
17041            }
17042    
17043            /**
17044             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
17045             *
17046             * @param groupId the group ID
17047             * @param classNameId the class name ID
17048             * @param layoutUuid the layout uuid
17049             * @return the matching journal articles that the user has permission to view
17050             * @throws SystemException if a system exception occurred
17051             */
17052            public List<JournalArticle> filterFindByG_C_L(long groupId,
17053                    long classNameId, String layoutUuid) throws SystemException {
17054                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
17055                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17056            }
17057    
17058            /**
17059             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
17060             *
17061             * <p>
17062             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
17063             * </p>
17064             *
17065             * @param groupId the group ID
17066             * @param classNameId the class name ID
17067             * @param layoutUuid the layout uuid
17068             * @param start the lower bound of the range of journal articles
17069             * @param end the upper bound of the range of journal articles (not inclusive)
17070             * @return the range of matching journal articles that the user has permission to view
17071             * @throws SystemException if a system exception occurred
17072             */
17073            public List<JournalArticle> filterFindByG_C_L(long groupId,
17074                    long classNameId, String layoutUuid, int start, int end)
17075                    throws SystemException {
17076                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
17077                            null);
17078            }
17079    
17080            /**
17081             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
17082             *
17083             * <p>
17084             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
17085             * </p>
17086             *
17087             * @param groupId the group ID
17088             * @param classNameId the class name ID
17089             * @param layoutUuid the layout uuid
17090             * @param start the lower bound of the range of journal articles
17091             * @param end the upper bound of the range of journal articles (not inclusive)
17092             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17093             * @return the ordered range of matching journal articles that the user has permission to view
17094             * @throws SystemException if a system exception occurred
17095             */
17096            public List<JournalArticle> filterFindByG_C_L(long groupId,
17097                    long classNameId, String layoutUuid, int start, int end,
17098                    OrderByComparator orderByComparator) throws SystemException {
17099                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17100                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
17101                                    orderByComparator);
17102                    }
17103    
17104                    StringBundler query = null;
17105    
17106                    if (orderByComparator != null) {
17107                            query = new StringBundler(5 +
17108                                            (orderByComparator.getOrderByFields().length * 3));
17109                    }
17110                    else {
17111                            query = new StringBundler(5);
17112                    }
17113    
17114                    if (getDB().isSupportsInlineDistinct()) {
17115                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
17116                    }
17117                    else {
17118                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
17119                    }
17120    
17121                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
17122    
17123                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
17124    
17125                    if (layoutUuid == null) {
17126                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
17127                    }
17128                    else {
17129                            if (layoutUuid.equals(StringPool.BLANK)) {
17130                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
17131                            }
17132                            else {
17133                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
17134                            }
17135                    }
17136    
17137                    if (!getDB().isSupportsInlineDistinct()) {
17138                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
17139                    }
17140    
17141                    if (orderByComparator != null) {
17142                            if (getDB().isSupportsInlineDistinct()) {
17143                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17144                                            orderByComparator);
17145                            }
17146                            else {
17147                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17148                                            orderByComparator);
17149                            }
17150                    }
17151    
17152                    else {
17153                            if (getDB().isSupportsInlineDistinct()) {
17154                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17155                            }
17156                            else {
17157                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
17158                            }
17159                    }
17160    
17161                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17162                                    JournalArticle.class.getName(),
17163                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17164    
17165                    Session session = null;
17166    
17167                    try {
17168                            session = openSession();
17169    
17170                            SQLQuery q = session.createSQLQuery(sql);
17171    
17172                            if (getDB().isSupportsInlineDistinct()) {
17173                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
17174                            }
17175                            else {
17176                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
17177                            }
17178    
17179                            QueryPos qPos = QueryPos.getInstance(q);
17180    
17181                            qPos.add(groupId);
17182    
17183                            qPos.add(classNameId);
17184    
17185                            if (layoutUuid != null) {
17186                                    qPos.add(layoutUuid);
17187                            }
17188    
17189                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
17190                                    end);
17191                    }
17192                    catch (Exception e) {
17193                            throw processException(e);
17194                    }
17195                    finally {
17196                            closeSession(session);
17197                    }
17198            }
17199    
17200            /**
17201             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
17202             *
17203             * @param id the primary key of the current journal article
17204             * @param groupId the group ID
17205             * @param classNameId the class name ID
17206             * @param layoutUuid the layout uuid
17207             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17208             * @return the previous, current, and next journal article
17209             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17210             * @throws SystemException if a system exception occurred
17211             */
17212            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
17213                    long groupId, long classNameId, String layoutUuid,
17214                    OrderByComparator orderByComparator)
17215                    throws NoSuchArticleException, SystemException {
17216                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17217                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
17218                                    layoutUuid, orderByComparator);
17219                    }
17220    
17221                    JournalArticle journalArticle = findByPrimaryKey(id);
17222    
17223                    Session session = null;
17224    
17225                    try {
17226                            session = openSession();
17227    
17228                            JournalArticle[] array = new JournalArticleImpl[3];
17229    
17230                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
17231                                            groupId, classNameId, layoutUuid, orderByComparator, true);
17232    
17233                            array[1] = journalArticle;
17234    
17235                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
17236                                            groupId, classNameId, layoutUuid, orderByComparator, false);
17237    
17238                            return array;
17239                    }
17240                    catch (Exception e) {
17241                            throw processException(e);
17242                    }
17243                    finally {
17244                            closeSession(session);
17245                    }
17246            }
17247    
17248            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
17249                    JournalArticle journalArticle, long groupId, long classNameId,
17250                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
17251                    StringBundler query = null;
17252    
17253                    if (orderByComparator != null) {
17254                            query = new StringBundler(6 +
17255                                            (orderByComparator.getOrderByFields().length * 6));
17256                    }
17257                    else {
17258                            query = new StringBundler(3);
17259                    }
17260    
17261                    if (getDB().isSupportsInlineDistinct()) {
17262                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
17263                    }
17264                    else {
17265                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
17266                    }
17267    
17268                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
17269    
17270                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
17271    
17272                    if (layoutUuid == null) {
17273                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
17274                    }
17275                    else {
17276                            if (layoutUuid.equals(StringPool.BLANK)) {
17277                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
17278                            }
17279                            else {
17280                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
17281                            }
17282                    }
17283    
17284                    if (!getDB().isSupportsInlineDistinct()) {
17285                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
17286                    }
17287    
17288                    if (orderByComparator != null) {
17289                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17290    
17291                            if (orderByConditionFields.length > 0) {
17292                                    query.append(WHERE_AND);
17293                            }
17294    
17295                            for (int i = 0; i < orderByConditionFields.length; i++) {
17296                                    if (getDB().isSupportsInlineDistinct()) {
17297                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17298                                    }
17299                                    else {
17300                                            query.append(_ORDER_BY_ENTITY_TABLE);
17301                                    }
17302    
17303                                    query.append(orderByConditionFields[i]);
17304    
17305                                    if ((i + 1) < orderByConditionFields.length) {
17306                                            if (orderByComparator.isAscending() ^ previous) {
17307                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17308                                            }
17309                                            else {
17310                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17311                                            }
17312                                    }
17313                                    else {
17314                                            if (orderByComparator.isAscending() ^ previous) {
17315                                                    query.append(WHERE_GREATER_THAN);
17316                                            }
17317                                            else {
17318                                                    query.append(WHERE_LESSER_THAN);
17319                                            }
17320                                    }
17321                            }
17322    
17323                            query.append(ORDER_BY_CLAUSE);
17324    
17325                            String[] orderByFields = orderByComparator.getOrderByFields();
17326    
17327                            for (int i = 0; i < orderByFields.length; i++) {
17328                                    if (getDB().isSupportsInlineDistinct()) {
17329                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17330                                    }
17331                                    else {
17332                                            query.append(_ORDER_BY_ENTITY_TABLE);
17333                                    }
17334    
17335                                    query.append(orderByFields[i]);
17336    
17337                                    if ((i + 1) < orderByFields.length) {
17338                                            if (orderByComparator.isAscending() ^ previous) {
17339                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17340                                            }
17341                                            else {
17342                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17343                                            }
17344                                    }
17345                                    else {
17346                                            if (orderByComparator.isAscending() ^ previous) {
17347                                                    query.append(ORDER_BY_ASC);
17348                                            }
17349                                            else {
17350                                                    query.append(ORDER_BY_DESC);
17351                                            }
17352                                    }
17353                            }
17354                    }
17355    
17356                    else {
17357                            if (getDB().isSupportsInlineDistinct()) {
17358                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17359                            }
17360                            else {
17361                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
17362                            }
17363                    }
17364    
17365                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17366                                    JournalArticle.class.getName(),
17367                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17368    
17369                    SQLQuery q = session.createSQLQuery(sql);
17370    
17371                    q.setFirstResult(0);
17372                    q.setMaxResults(2);
17373    
17374                    if (getDB().isSupportsInlineDistinct()) {
17375                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
17376                    }
17377                    else {
17378                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
17379                    }
17380    
17381                    QueryPos qPos = QueryPos.getInstance(q);
17382    
17383                    qPos.add(groupId);
17384    
17385                    qPos.add(classNameId);
17386    
17387                    if (layoutUuid != null) {
17388                            qPos.add(layoutUuid);
17389                    }
17390    
17391                    if (orderByComparator != null) {
17392                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
17393    
17394                            for (Object value : values) {
17395                                    qPos.add(value);
17396                            }
17397                    }
17398    
17399                    List<JournalArticle> list = q.list();
17400    
17401                    if (list.size() == 2) {
17402                            return list.get(1);
17403                    }
17404                    else {
17405                            return null;
17406                    }
17407            }
17408    
17409            /**
17410             * Returns the journal article where groupId = &#63; and articleId = &#63; and version = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
17411             *
17412             * @param groupId the group ID
17413             * @param articleId the article ID
17414             * @param version the version
17415             * @return the matching journal article
17416             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17417             * @throws SystemException if a system exception occurred
17418             */
17419            public JournalArticle findByG_A_V(long groupId, String articleId,
17420                    double version) throws NoSuchArticleException, SystemException {
17421                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
17422    
17423                    if (journalArticle == null) {
17424                            StringBundler msg = new StringBundler(8);
17425    
17426                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17427    
17428                            msg.append("groupId=");
17429                            msg.append(groupId);
17430    
17431                            msg.append(", articleId=");
17432                            msg.append(articleId);
17433    
17434                            msg.append(", version=");
17435                            msg.append(version);
17436    
17437                            msg.append(StringPool.CLOSE_CURLY_BRACE);
17438    
17439                            if (_log.isWarnEnabled()) {
17440                                    _log.warn(msg.toString());
17441                            }
17442    
17443                            throw new NoSuchArticleException(msg.toString());
17444                    }
17445    
17446                    return journalArticle;
17447            }
17448    
17449            /**
17450             * Returns the journal article where groupId = &#63; and articleId = &#63; and version = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
17451             *
17452             * @param groupId the group ID
17453             * @param articleId the article ID
17454             * @param version the version
17455             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
17456             * @throws SystemException if a system exception occurred
17457             */
17458            public JournalArticle fetchByG_A_V(long groupId, String articleId,
17459                    double version) throws SystemException {
17460                    return fetchByG_A_V(groupId, articleId, version, true);
17461            }
17462    
17463            /**
17464             * Returns the journal article where groupId = &#63; and articleId = &#63; and version = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
17465             *
17466             * @param groupId the group ID
17467             * @param articleId the article ID
17468             * @param version the version
17469             * @param retrieveFromCache whether to use the finder cache
17470             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
17471             * @throws SystemException if a system exception occurred
17472             */
17473            public JournalArticle fetchByG_A_V(long groupId, String articleId,
17474                    double version, boolean retrieveFromCache) throws SystemException {
17475                    Object[] finderArgs = new Object[] { groupId, articleId, version };
17476    
17477                    Object result = null;
17478    
17479                    if (retrieveFromCache) {
17480                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
17481                                            finderArgs, this);
17482                    }
17483    
17484                    if (result instanceof JournalArticle) {
17485                            JournalArticle journalArticle = (JournalArticle)result;
17486    
17487                            if ((groupId != journalArticle.getGroupId()) ||
17488                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
17489                                            (version != journalArticle.getVersion())) {
17490                                    result = null;
17491                            }
17492                    }
17493    
17494                    if (result == null) {
17495                            StringBundler query = new StringBundler(5);
17496    
17497                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17498    
17499                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
17500    
17501                            if (articleId == null) {
17502                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
17503                            }
17504                            else {
17505                                    if (articleId.equals(StringPool.BLANK)) {
17506                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
17507                                    }
17508                                    else {
17509                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
17510                                    }
17511                            }
17512    
17513                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
17514    
17515                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17516    
17517                            String sql = query.toString();
17518    
17519                            Session session = null;
17520    
17521                            try {
17522                                    session = openSession();
17523    
17524                                    Query q = session.createQuery(sql);
17525    
17526                                    QueryPos qPos = QueryPos.getInstance(q);
17527    
17528                                    qPos.add(groupId);
17529    
17530                                    if (articleId != null) {
17531                                            qPos.add(articleId);
17532                                    }
17533    
17534                                    qPos.add(version);
17535    
17536                                    List<JournalArticle> list = q.list();
17537    
17538                                    result = list;
17539    
17540                                    JournalArticle journalArticle = null;
17541    
17542                                    if (list.isEmpty()) {
17543                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
17544                                                    finderArgs, list);
17545                                    }
17546                                    else {
17547                                            journalArticle = list.get(0);
17548    
17549                                            cacheResult(journalArticle);
17550    
17551                                            if ((journalArticle.getGroupId() != groupId) ||
17552                                                            (journalArticle.getArticleId() == null) ||
17553                                                            !journalArticle.getArticleId().equals(articleId) ||
17554                                                            (journalArticle.getVersion() != version)) {
17555                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
17556                                                            finderArgs, journalArticle);
17557                                            }
17558                                    }
17559    
17560                                    return journalArticle;
17561                            }
17562                            catch (Exception e) {
17563                                    throw processException(e);
17564                            }
17565                            finally {
17566                                    if (result == null) {
17567                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
17568                                                    finderArgs);
17569                                    }
17570    
17571                                    closeSession(session);
17572                            }
17573                    }
17574                    else {
17575                            if (result instanceof List<?>) {
17576                                    return null;
17577                            }
17578                            else {
17579                                    return (JournalArticle)result;
17580                            }
17581                    }
17582            }
17583    
17584            /**
17585             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
17586             *
17587             * @param groupId the group ID
17588             * @param articleId the article ID
17589             * @param status the status
17590             * @return the matching journal articles
17591             * @throws SystemException if a system exception occurred
17592             */
17593            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
17594                    int status) throws SystemException {
17595                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
17596                            QueryUtil.ALL_POS, null);
17597            }
17598    
17599            /**
17600             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
17601             *
17602             * <p>
17603             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
17604             * </p>
17605             *
17606             * @param groupId the group ID
17607             * @param articleId the article ID
17608             * @param status the status
17609             * @param start the lower bound of the range of journal articles
17610             * @param end the upper bound of the range of journal articles (not inclusive)
17611             * @return the range of matching journal articles
17612             * @throws SystemException if a system exception occurred
17613             */
17614            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
17615                    int status, int start, int end) throws SystemException {
17616                    return findByG_A_ST(groupId, articleId, status, start, end, null);
17617            }
17618    
17619            /**
17620             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
17621             *
17622             * <p>
17623             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
17624             * </p>
17625             *
17626             * @param groupId the group ID
17627             * @param articleId the article ID
17628             * @param status the status
17629             * @param start the lower bound of the range of journal articles
17630             * @param end the upper bound of the range of journal articles (not inclusive)
17631             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17632             * @return the ordered range of matching journal articles
17633             * @throws SystemException if a system exception occurred
17634             */
17635            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
17636                    int status, int start, int end, OrderByComparator orderByComparator)
17637                    throws SystemException {
17638                    FinderPath finderPath = null;
17639                    Object[] finderArgs = null;
17640    
17641                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
17642                                    (orderByComparator == null)) {
17643                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
17644                            finderArgs = new Object[] { groupId, articleId, status };
17645                    }
17646                    else {
17647                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
17648                            finderArgs = new Object[] {
17649                                            groupId, articleId, status,
17650                                            
17651                                            start, end, orderByComparator
17652                                    };
17653                    }
17654    
17655                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
17656                                    finderArgs, this);
17657    
17658                    if ((list != null) && !list.isEmpty()) {
17659                            for (JournalArticle journalArticle : list) {
17660                                    if ((groupId != journalArticle.getGroupId()) ||
17661                                                    !Validator.equals(articleId,
17662                                                            journalArticle.getArticleId()) ||
17663                                                    (status != journalArticle.getStatus())) {
17664                                            list = null;
17665    
17666                                            break;
17667                                    }
17668                            }
17669                    }
17670    
17671                    if (list == null) {
17672                            StringBundler query = null;
17673    
17674                            if (orderByComparator != null) {
17675                                    query = new StringBundler(5 +
17676                                                    (orderByComparator.getOrderByFields().length * 3));
17677                            }
17678                            else {
17679                                    query = new StringBundler(5);
17680                            }
17681    
17682                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17683    
17684                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
17685    
17686                            if (articleId == null) {
17687                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
17688                            }
17689                            else {
17690                                    if (articleId.equals(StringPool.BLANK)) {
17691                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
17692                                    }
17693                                    else {
17694                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
17695                                    }
17696                            }
17697    
17698                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
17699    
17700                            if (orderByComparator != null) {
17701                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17702                                            orderByComparator);
17703                            }
17704    
17705                            else {
17706                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
17707                            }
17708    
17709                            String sql = query.toString();
17710    
17711                            Session session = null;
17712    
17713                            try {
17714                                    session = openSession();
17715    
17716                                    Query q = session.createQuery(sql);
17717    
17718                                    QueryPos qPos = QueryPos.getInstance(q);
17719    
17720                                    qPos.add(groupId);
17721    
17722                                    if (articleId != null) {
17723                                            qPos.add(articleId);
17724                                    }
17725    
17726                                    qPos.add(status);
17727    
17728                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
17729                                                    start, end);
17730                            }
17731                            catch (Exception e) {
17732                                    throw processException(e);
17733                            }
17734                            finally {
17735                                    if (list == null) {
17736                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
17737                                    }
17738                                    else {
17739                                            cacheResult(list);
17740    
17741                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
17742                                    }
17743    
17744                                    closeSession(session);
17745                            }
17746                    }
17747    
17748                    return list;
17749            }
17750    
17751            /**
17752             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
17753             *
17754             * @param groupId the group ID
17755             * @param articleId the article ID
17756             * @param status the status
17757             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17758             * @return the first matching journal article
17759             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17760             * @throws SystemException if a system exception occurred
17761             */
17762            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
17763                    int status, OrderByComparator orderByComparator)
17764                    throws NoSuchArticleException, SystemException {
17765                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
17766                                    status, orderByComparator);
17767    
17768                    if (journalArticle != null) {
17769                            return journalArticle;
17770                    }
17771    
17772                    StringBundler msg = new StringBundler(8);
17773    
17774                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17775    
17776                    msg.append("groupId=");
17777                    msg.append(groupId);
17778    
17779                    msg.append(", articleId=");
17780                    msg.append(articleId);
17781    
17782                    msg.append(", status=");
17783                    msg.append(status);
17784    
17785                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17786    
17787                    throw new NoSuchArticleException(msg.toString());
17788            }
17789    
17790            /**
17791             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
17792             *
17793             * @param groupId the group ID
17794             * @param articleId the article ID
17795             * @param status the status
17796             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17797             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
17798             * @throws SystemException if a system exception occurred
17799             */
17800            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
17801                    int status, OrderByComparator orderByComparator)
17802                    throws SystemException {
17803                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
17804                                    1, orderByComparator);
17805    
17806                    if (!list.isEmpty()) {
17807                            return list.get(0);
17808                    }
17809    
17810                    return null;
17811            }
17812    
17813            /**
17814             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
17815             *
17816             * @param groupId the group ID
17817             * @param articleId the article ID
17818             * @param status the status
17819             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17820             * @return the last matching journal article
17821             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
17822             * @throws SystemException if a system exception occurred
17823             */
17824            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
17825                    int status, OrderByComparator orderByComparator)
17826                    throws NoSuchArticleException, SystemException {
17827                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
17828                                    status, orderByComparator);
17829    
17830                    if (journalArticle != null) {
17831                            return journalArticle;
17832                    }
17833    
17834                    StringBundler msg = new StringBundler(8);
17835    
17836                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17837    
17838                    msg.append("groupId=");
17839                    msg.append(groupId);
17840    
17841                    msg.append(", articleId=");
17842                    msg.append(articleId);
17843    
17844                    msg.append(", status=");
17845                    msg.append(status);
17846    
17847                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17848    
17849                    throw new NoSuchArticleException(msg.toString());
17850            }
17851    
17852            /**
17853             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
17854             *
17855             * @param groupId the group ID
17856             * @param articleId the article ID
17857             * @param status the status
17858             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17859             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
17860             * @throws SystemException if a system exception occurred
17861             */
17862            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
17863                    int status, OrderByComparator orderByComparator)
17864                    throws SystemException {
17865                    int count = countByG_A_ST(groupId, articleId, status);
17866    
17867                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
17868                                    count - 1, count, orderByComparator);
17869    
17870                    if (!list.isEmpty()) {
17871                            return list.get(0);
17872                    }
17873    
17874                    return null;
17875            }
17876    
17877            /**
17878             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
17879             *
17880             * @param id the primary key of the current journal article
17881             * @param groupId the group ID
17882             * @param articleId the article ID
17883             * @param status the status
17884             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17885             * @return the previous, current, and next journal article
17886             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
17887             * @throws SystemException if a system exception occurred
17888             */
17889            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
17890                    String articleId, int status, OrderByComparator orderByComparator)
17891                    throws NoSuchArticleException, SystemException {
17892                    JournalArticle journalArticle = findByPrimaryKey(id);
17893    
17894                    Session session = null;
17895    
17896                    try {
17897                            session = openSession();
17898    
17899                            JournalArticle[] array = new JournalArticleImpl[3];
17900    
17901                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
17902                                            groupId, articleId, status, orderByComparator, true);
17903    
17904                            array[1] = journalArticle;
17905    
17906                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
17907                                            groupId, articleId, status, orderByComparator, false);
17908    
17909                            return array;
17910                    }
17911                    catch (Exception e) {
17912                            throw processException(e);
17913                    }
17914                    finally {
17915                            closeSession(session);
17916                    }
17917            }
17918    
17919            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
17920                    JournalArticle journalArticle, long groupId, String articleId,
17921                    int status, OrderByComparator orderByComparator, boolean previous) {
17922                    StringBundler query = null;
17923    
17924                    if (orderByComparator != null) {
17925                            query = new StringBundler(6 +
17926                                            (orderByComparator.getOrderByFields().length * 6));
17927                    }
17928                    else {
17929                            query = new StringBundler(3);
17930                    }
17931    
17932                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
17933    
17934                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
17935    
17936                    if (articleId == null) {
17937                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
17938                    }
17939                    else {
17940                            if (articleId.equals(StringPool.BLANK)) {
17941                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
17942                            }
17943                            else {
17944                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
17945                            }
17946                    }
17947    
17948                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
17949    
17950                    if (orderByComparator != null) {
17951                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17952    
17953                            if (orderByConditionFields.length > 0) {
17954                                    query.append(WHERE_AND);
17955                            }
17956    
17957                            for (int i = 0; i < orderByConditionFields.length; i++) {
17958                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17959                                    query.append(orderByConditionFields[i]);
17960    
17961                                    if ((i + 1) < orderByConditionFields.length) {
17962                                            if (orderByComparator.isAscending() ^ previous) {
17963                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17964                                            }
17965                                            else {
17966                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17967                                            }
17968                                    }
17969                                    else {
17970                                            if (orderByComparator.isAscending() ^ previous) {
17971                                                    query.append(WHERE_GREATER_THAN);
17972                                            }
17973                                            else {
17974                                                    query.append(WHERE_LESSER_THAN);
17975                                            }
17976                                    }
17977                            }
17978    
17979                            query.append(ORDER_BY_CLAUSE);
17980    
17981                            String[] orderByFields = orderByComparator.getOrderByFields();
17982    
17983                            for (int i = 0; i < orderByFields.length; i++) {
17984                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17985                                    query.append(orderByFields[i]);
17986    
17987                                    if ((i + 1) < orderByFields.length) {
17988                                            if (orderByComparator.isAscending() ^ previous) {
17989                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17990                                            }
17991                                            else {
17992                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17993                                            }
17994                                    }
17995                                    else {
17996                                            if (orderByComparator.isAscending() ^ previous) {
17997                                                    query.append(ORDER_BY_ASC);
17998                                            }
17999                                            else {
18000                                                    query.append(ORDER_BY_DESC);
18001                                            }
18002                                    }
18003                            }
18004                    }
18005    
18006                    else {
18007                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18008                    }
18009    
18010                    String sql = query.toString();
18011    
18012                    Query q = session.createQuery(sql);
18013    
18014                    q.setFirstResult(0);
18015                    q.setMaxResults(2);
18016    
18017                    QueryPos qPos = QueryPos.getInstance(q);
18018    
18019                    qPos.add(groupId);
18020    
18021                    if (articleId != null) {
18022                            qPos.add(articleId);
18023                    }
18024    
18025                    qPos.add(status);
18026    
18027                    if (orderByComparator != null) {
18028                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18029    
18030                            for (Object value : values) {
18031                                    qPos.add(value);
18032                            }
18033                    }
18034    
18035                    List<JournalArticle> list = q.list();
18036    
18037                    if (list.size() == 2) {
18038                            return list.get(1);
18039                    }
18040                    else {
18041                            return null;
18042                    }
18043            }
18044    
18045            /**
18046             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
18047             *
18048             * <p>
18049             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
18050             * </p>
18051             *
18052             * @param groupId the group ID
18053             * @param articleId the article ID
18054             * @param statuses the statuses
18055             * @return the matching journal articles
18056             * @throws SystemException if a system exception occurred
18057             */
18058            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
18059                    int[] statuses) throws SystemException {
18060                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
18061                            QueryUtil.ALL_POS, null);
18062            }
18063    
18064            /**
18065             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
18066             *
18067             * <p>
18068             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
18069             * </p>
18070             *
18071             * @param groupId the group ID
18072             * @param articleId the article ID
18073             * @param statuses the statuses
18074             * @param start the lower bound of the range of journal articles
18075             * @param end the upper bound of the range of journal articles (not inclusive)
18076             * @return the range of matching journal articles
18077             * @throws SystemException if a system exception occurred
18078             */
18079            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
18080                    int[] statuses, int start, int end) throws SystemException {
18081                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
18082            }
18083    
18084            /**
18085             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
18086             *
18087             * <p>
18088             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
18089             * </p>
18090             *
18091             * @param groupId the group ID
18092             * @param articleId the article ID
18093             * @param statuses the statuses
18094             * @param start the lower bound of the range of journal articles
18095             * @param end the upper bound of the range of journal articles (not inclusive)
18096             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18097             * @return the ordered range of matching journal articles
18098             * @throws SystemException if a system exception occurred
18099             */
18100            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
18101                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
18102                    throws SystemException {
18103                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
18104                    Object[] finderArgs = null;
18105    
18106                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18107                                    (orderByComparator == null)) {
18108                            finderArgs = new Object[] {
18109                                            groupId, articleId, StringUtil.merge(statuses)
18110                                    };
18111                    }
18112                    else {
18113                            finderArgs = new Object[] {
18114                                            groupId, articleId, StringUtil.merge(statuses),
18115                                            
18116                                            start, end, orderByComparator
18117                                    };
18118                    }
18119    
18120                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18121                                    finderArgs, this);
18122    
18123                    if ((list != null) && !list.isEmpty()) {
18124                            for (JournalArticle journalArticle : list) {
18125                                    if ((groupId != journalArticle.getGroupId()) ||
18126                                                    !Validator.equals(articleId,
18127                                                            journalArticle.getArticleId()) ||
18128                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
18129                                            list = null;
18130    
18131                                            break;
18132                                    }
18133                            }
18134                    }
18135    
18136                    if (list == null) {
18137                            StringBundler query = new StringBundler();
18138    
18139                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18140    
18141                            boolean conjunctionable = false;
18142    
18143                            if (conjunctionable) {
18144                                    query.append(WHERE_AND);
18145                            }
18146    
18147                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
18148    
18149                            conjunctionable = true;
18150    
18151                            if (conjunctionable) {
18152                                    query.append(WHERE_AND);
18153                            }
18154    
18155                            if (articleId == null) {
18156                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
18157                            }
18158                            else {
18159                                    if (articleId.equals(StringPool.BLANK)) {
18160                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
18161                                    }
18162                                    else {
18163                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
18164                                    }
18165                            }
18166    
18167                            conjunctionable = true;
18168    
18169                            if ((statuses == null) || (statuses.length > 0)) {
18170                                    if (conjunctionable) {
18171                                            query.append(WHERE_AND);
18172                                    }
18173    
18174                                    query.append(StringPool.OPEN_PARENTHESIS);
18175    
18176                                    for (int i = 0; i < statuses.length; i++) {
18177                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
18178    
18179                                            if ((i + 1) < statuses.length) {
18180                                                    query.append(WHERE_OR);
18181                                            }
18182                                    }
18183    
18184                                    query.append(StringPool.CLOSE_PARENTHESIS);
18185    
18186                                    conjunctionable = true;
18187                            }
18188    
18189                            if (orderByComparator != null) {
18190                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18191                                            orderByComparator);
18192                            }
18193    
18194                            else {
18195                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18196                            }
18197    
18198                            String sql = query.toString();
18199    
18200                            Session session = null;
18201    
18202                            try {
18203                                    session = openSession();
18204    
18205                                    Query q = session.createQuery(sql);
18206    
18207                                    QueryPos qPos = QueryPos.getInstance(q);
18208    
18209                                    qPos.add(groupId);
18210    
18211                                    if (articleId != null) {
18212                                            qPos.add(articleId);
18213                                    }
18214    
18215                                    if (statuses != null) {
18216                                            qPos.add(statuses);
18217                                    }
18218    
18219                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
18220                                                    start, end);
18221                            }
18222                            catch (Exception e) {
18223                                    throw processException(e);
18224                            }
18225                            finally {
18226                                    if (list == null) {
18227                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
18228                                    }
18229                                    else {
18230                                            cacheResult(list);
18231    
18232                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
18233                                    }
18234    
18235                                    closeSession(session);
18236                            }
18237                    }
18238    
18239                    return list;
18240            }
18241    
18242            /**
18243             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
18244             *
18245             * @param groupId the group ID
18246             * @param articleId the article ID
18247             * @param status the status
18248             * @return the matching journal articles that the user has permission to view
18249             * @throws SystemException if a system exception occurred
18250             */
18251            public List<JournalArticle> filterFindByG_A_ST(long groupId,
18252                    String articleId, int status) throws SystemException {
18253                    return filterFindByG_A_ST(groupId, articleId, status,
18254                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18255            }
18256    
18257            /**
18258             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
18259             *
18260             * <p>
18261             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
18262             * </p>
18263             *
18264             * @param groupId the group ID
18265             * @param articleId the article ID
18266             * @param status the status
18267             * @param start the lower bound of the range of journal articles
18268             * @param end the upper bound of the range of journal articles (not inclusive)
18269             * @return the range of matching journal articles that the user has permission to view
18270             * @throws SystemException if a system exception occurred
18271             */
18272            public List<JournalArticle> filterFindByG_A_ST(long groupId,
18273                    String articleId, int status, int start, int end)
18274                    throws SystemException {
18275                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
18276            }
18277    
18278            /**
18279             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63; and status = &#63;.
18280             *
18281             * <p>
18282             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
18283             * </p>
18284             *
18285             * @param groupId the group ID
18286             * @param articleId the article ID
18287             * @param status the status
18288             * @param start the lower bound of the range of journal articles
18289             * @param end the upper bound of the range of journal articles (not inclusive)
18290             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18291             * @return the ordered range of matching journal articles that the user has permission to view
18292             * @throws SystemException if a system exception occurred
18293             */
18294            public List<JournalArticle> filterFindByG_A_ST(long groupId,
18295                    String articleId, int status, int start, int end,
18296                    OrderByComparator orderByComparator) throws SystemException {
18297                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18298                            return findByG_A_ST(groupId, articleId, status, start, end,
18299                                    orderByComparator);
18300                    }
18301    
18302                    StringBundler query = null;
18303    
18304                    if (orderByComparator != null) {
18305                            query = new StringBundler(5 +
18306                                            (orderByComparator.getOrderByFields().length * 3));
18307                    }
18308                    else {
18309                            query = new StringBundler(5);
18310                    }
18311    
18312                    if (getDB().isSupportsInlineDistinct()) {
18313                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18314                    }
18315                    else {
18316                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18317                    }
18318    
18319                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
18320    
18321                    if (articleId == null) {
18322                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
18323                    }
18324                    else {
18325                            if (articleId.equals(StringPool.BLANK)) {
18326                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
18327                            }
18328                            else {
18329                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
18330                            }
18331                    }
18332    
18333                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
18334    
18335                    if (!getDB().isSupportsInlineDistinct()) {
18336                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18337                    }
18338    
18339                    if (orderByComparator != null) {
18340                            if (getDB().isSupportsInlineDistinct()) {
18341                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18342                                            orderByComparator);
18343                            }
18344                            else {
18345                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18346                                            orderByComparator);
18347                            }
18348                    }
18349    
18350                    else {
18351                            if (getDB().isSupportsInlineDistinct()) {
18352                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18353                            }
18354                            else {
18355                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18356                            }
18357                    }
18358    
18359                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18360                                    JournalArticle.class.getName(),
18361                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18362    
18363                    Session session = null;
18364    
18365                    try {
18366                            session = openSession();
18367    
18368                            SQLQuery q = session.createSQLQuery(sql);
18369    
18370                            if (getDB().isSupportsInlineDistinct()) {
18371                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18372                            }
18373                            else {
18374                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18375                            }
18376    
18377                            QueryPos qPos = QueryPos.getInstance(q);
18378    
18379                            qPos.add(groupId);
18380    
18381                            if (articleId != null) {
18382                                    qPos.add(articleId);
18383                            }
18384    
18385                            qPos.add(status);
18386    
18387                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
18388                                    end);
18389                    }
18390                    catch (Exception e) {
18391                            throw processException(e);
18392                    }
18393                    finally {
18394                            closeSession(session);
18395                    }
18396            }
18397    
18398            /**
18399             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
18400             *
18401             * @param id the primary key of the current journal article
18402             * @param groupId the group ID
18403             * @param articleId the article ID
18404             * @param status the status
18405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18406             * @return the previous, current, and next journal article
18407             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
18408             * @throws SystemException if a system exception occurred
18409             */
18410            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
18411                    long groupId, String articleId, int status,
18412                    OrderByComparator orderByComparator)
18413                    throws NoSuchArticleException, SystemException {
18414                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18415                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
18416                                    orderByComparator);
18417                    }
18418    
18419                    JournalArticle journalArticle = findByPrimaryKey(id);
18420    
18421                    Session session = null;
18422    
18423                    try {
18424                            session = openSession();
18425    
18426                            JournalArticle[] array = new JournalArticleImpl[3];
18427    
18428                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
18429                                            groupId, articleId, status, orderByComparator, true);
18430    
18431                            array[1] = journalArticle;
18432    
18433                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
18434                                            groupId, articleId, status, orderByComparator, false);
18435    
18436                            return array;
18437                    }
18438                    catch (Exception e) {
18439                            throw processException(e);
18440                    }
18441                    finally {
18442                            closeSession(session);
18443                    }
18444            }
18445    
18446            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
18447                    JournalArticle journalArticle, long groupId, String articleId,
18448                    int status, OrderByComparator orderByComparator, boolean previous) {
18449                    StringBundler query = null;
18450    
18451                    if (orderByComparator != null) {
18452                            query = new StringBundler(6 +
18453                                            (orderByComparator.getOrderByFields().length * 6));
18454                    }
18455                    else {
18456                            query = new StringBundler(3);
18457                    }
18458    
18459                    if (getDB().isSupportsInlineDistinct()) {
18460                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18461                    }
18462                    else {
18463                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18464                    }
18465    
18466                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
18467    
18468                    if (articleId == null) {
18469                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
18470                    }
18471                    else {
18472                            if (articleId.equals(StringPool.BLANK)) {
18473                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
18474                            }
18475                            else {
18476                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
18477                            }
18478                    }
18479    
18480                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
18481    
18482                    if (!getDB().isSupportsInlineDistinct()) {
18483                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18484                    }
18485    
18486                    if (orderByComparator != null) {
18487                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18488    
18489                            if (orderByConditionFields.length > 0) {
18490                                    query.append(WHERE_AND);
18491                            }
18492    
18493                            for (int i = 0; i < orderByConditionFields.length; i++) {
18494                                    if (getDB().isSupportsInlineDistinct()) {
18495                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18496                                    }
18497                                    else {
18498                                            query.append(_ORDER_BY_ENTITY_TABLE);
18499                                    }
18500    
18501                                    query.append(orderByConditionFields[i]);
18502    
18503                                    if ((i + 1) < orderByConditionFields.length) {
18504                                            if (orderByComparator.isAscending() ^ previous) {
18505                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18506                                            }
18507                                            else {
18508                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18509                                            }
18510                                    }
18511                                    else {
18512                                            if (orderByComparator.isAscending() ^ previous) {
18513                                                    query.append(WHERE_GREATER_THAN);
18514                                            }
18515                                            else {
18516                                                    query.append(WHERE_LESSER_THAN);
18517                                            }
18518                                    }
18519                            }
18520    
18521                            query.append(ORDER_BY_CLAUSE);
18522    
18523                            String[] orderByFields = orderByComparator.getOrderByFields();
18524    
18525                            for (int i = 0; i < orderByFields.length; i++) {
18526                                    if (getDB().isSupportsInlineDistinct()) {
18527                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18528                                    }
18529                                    else {
18530                                            query.append(_ORDER_BY_ENTITY_TABLE);
18531                                    }
18532    
18533                                    query.append(orderByFields[i]);
18534    
18535                                    if ((i + 1) < orderByFields.length) {
18536                                            if (orderByComparator.isAscending() ^ previous) {
18537                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18538                                            }
18539                                            else {
18540                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18541                                            }
18542                                    }
18543                                    else {
18544                                            if (orderByComparator.isAscending() ^ previous) {
18545                                                    query.append(ORDER_BY_ASC);
18546                                            }
18547                                            else {
18548                                                    query.append(ORDER_BY_DESC);
18549                                            }
18550                                    }
18551                            }
18552                    }
18553    
18554                    else {
18555                            if (getDB().isSupportsInlineDistinct()) {
18556                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18557                            }
18558                            else {
18559                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18560                            }
18561                    }
18562    
18563                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18564                                    JournalArticle.class.getName(),
18565                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18566    
18567                    SQLQuery q = session.createSQLQuery(sql);
18568    
18569                    q.setFirstResult(0);
18570                    q.setMaxResults(2);
18571    
18572                    if (getDB().isSupportsInlineDistinct()) {
18573                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18574                    }
18575                    else {
18576                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18577                    }
18578    
18579                    QueryPos qPos = QueryPos.getInstance(q);
18580    
18581                    qPos.add(groupId);
18582    
18583                    if (articleId != null) {
18584                            qPos.add(articleId);
18585                    }
18586    
18587                    qPos.add(status);
18588    
18589                    if (orderByComparator != null) {
18590                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
18591    
18592                            for (Object value : values) {
18593                                    qPos.add(value);
18594                            }
18595                    }
18596    
18597                    List<JournalArticle> list = q.list();
18598    
18599                    if (list.size() == 2) {
18600                            return list.get(1);
18601                    }
18602                    else {
18603                            return null;
18604                    }
18605            }
18606    
18607            /**
18608             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
18609             *
18610             * @param groupId the group ID
18611             * @param articleId the article ID
18612             * @param statuses the statuses
18613             * @return the matching journal articles that the user has permission to view
18614             * @throws SystemException if a system exception occurred
18615             */
18616            public List<JournalArticle> filterFindByG_A_ST(long groupId,
18617                    String articleId, int[] statuses) throws SystemException {
18618                    return filterFindByG_A_ST(groupId, articleId, statuses,
18619                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18620            }
18621    
18622            /**
18623             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
18624             *
18625             * <p>
18626             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
18627             * </p>
18628             *
18629             * @param groupId the group ID
18630             * @param articleId the article ID
18631             * @param statuses the statuses
18632             * @param start the lower bound of the range of journal articles
18633             * @param end the upper bound of the range of journal articles (not inclusive)
18634             * @return the range of matching journal articles that the user has permission to view
18635             * @throws SystemException if a system exception occurred
18636             */
18637            public List<JournalArticle> filterFindByG_A_ST(long groupId,
18638                    String articleId, int[] statuses, int start, int end)
18639                    throws SystemException {
18640                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
18641            }
18642    
18643            /**
18644             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
18645             *
18646             * <p>
18647             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
18648             * </p>
18649             *
18650             * @param groupId the group ID
18651             * @param articleId the article ID
18652             * @param statuses the statuses
18653             * @param start the lower bound of the range of journal articles
18654             * @param end the upper bound of the range of journal articles (not inclusive)
18655             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18656             * @return the ordered range of matching journal articles that the user has permission to view
18657             * @throws SystemException if a system exception occurred
18658             */
18659            public List<JournalArticle> filterFindByG_A_ST(long groupId,
18660                    String articleId, int[] statuses, int start, int end,
18661                    OrderByComparator orderByComparator) throws SystemException {
18662                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18663                            return findByG_A_ST(groupId, articleId, statuses, start, end,
18664                                    orderByComparator);
18665                    }
18666    
18667                    StringBundler query = new StringBundler();
18668    
18669                    if (getDB().isSupportsInlineDistinct()) {
18670                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
18671                    }
18672                    else {
18673                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
18674                    }
18675    
18676                    boolean conjunctionable = false;
18677    
18678                    if (conjunctionable) {
18679                            query.append(WHERE_AND);
18680                    }
18681    
18682                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
18683    
18684                    conjunctionable = true;
18685    
18686                    if (conjunctionable) {
18687                            query.append(WHERE_AND);
18688                    }
18689    
18690                    if (articleId == null) {
18691                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
18692                    }
18693                    else {
18694                            if (articleId.equals(StringPool.BLANK)) {
18695                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
18696                            }
18697                            else {
18698                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
18699                            }
18700                    }
18701    
18702                    conjunctionable = true;
18703    
18704                    if ((statuses == null) || (statuses.length > 0)) {
18705                            if (conjunctionable) {
18706                                    query.append(WHERE_AND);
18707                            }
18708    
18709                            query.append(StringPool.OPEN_PARENTHESIS);
18710    
18711                            for (int i = 0; i < statuses.length; i++) {
18712                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
18713    
18714                                    if ((i + 1) < statuses.length) {
18715                                            query.append(WHERE_OR);
18716                                    }
18717                            }
18718    
18719                            query.append(StringPool.CLOSE_PARENTHESIS);
18720    
18721                            conjunctionable = true;
18722                    }
18723    
18724                    if (!getDB().isSupportsInlineDistinct()) {
18725                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
18726                    }
18727    
18728                    if (orderByComparator != null) {
18729                            if (getDB().isSupportsInlineDistinct()) {
18730                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18731                                            orderByComparator);
18732                            }
18733                            else {
18734                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18735                                            orderByComparator);
18736                            }
18737                    }
18738    
18739                    else {
18740                            if (getDB().isSupportsInlineDistinct()) {
18741                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18742                            }
18743                            else {
18744                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
18745                            }
18746                    }
18747    
18748                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18749                                    JournalArticle.class.getName(),
18750                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18751    
18752                    Session session = null;
18753    
18754                    try {
18755                            session = openSession();
18756    
18757                            SQLQuery q = session.createSQLQuery(sql);
18758    
18759                            if (getDB().isSupportsInlineDistinct()) {
18760                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
18761                            }
18762                            else {
18763                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
18764                            }
18765    
18766                            QueryPos qPos = QueryPos.getInstance(q);
18767    
18768                            qPos.add(groupId);
18769    
18770                            if (articleId != null) {
18771                                    qPos.add(articleId);
18772                            }
18773    
18774                            if (statuses != null) {
18775                                    qPos.add(statuses);
18776                            }
18777    
18778                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
18779                                    end);
18780                    }
18781                    catch (Exception e) {
18782                            throw processException(e);
18783                    }
18784                    finally {
18785                            closeSession(session);
18786                    }
18787            }
18788    
18789            /**
18790             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
18791             *
18792             * @param groupId the group ID
18793             * @param urlTitle the url title
18794             * @param status the status
18795             * @return the matching journal articles
18796             * @throws SystemException if a system exception occurred
18797             */
18798            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
18799                    int status) throws SystemException {
18800                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
18801                            QueryUtil.ALL_POS, null);
18802            }
18803    
18804            /**
18805             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
18806             *
18807             * <p>
18808             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
18809             * </p>
18810             *
18811             * @param groupId the group ID
18812             * @param urlTitle the url title
18813             * @param status the status
18814             * @param start the lower bound of the range of journal articles
18815             * @param end the upper bound of the range of journal articles (not inclusive)
18816             * @return the range of matching journal articles
18817             * @throws SystemException if a system exception occurred
18818             */
18819            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
18820                    int status, int start, int end) throws SystemException {
18821                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
18822            }
18823    
18824            /**
18825             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
18826             *
18827             * <p>
18828             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
18829             * </p>
18830             *
18831             * @param groupId the group ID
18832             * @param urlTitle the url title
18833             * @param status the status
18834             * @param start the lower bound of the range of journal articles
18835             * @param end the upper bound of the range of journal articles (not inclusive)
18836             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18837             * @return the ordered range of matching journal articles
18838             * @throws SystemException if a system exception occurred
18839             */
18840            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
18841                    int status, int start, int end, OrderByComparator orderByComparator)
18842                    throws SystemException {
18843                    FinderPath finderPath = null;
18844                    Object[] finderArgs = null;
18845    
18846                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18847                                    (orderByComparator == null)) {
18848                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
18849                            finderArgs = new Object[] { groupId, urlTitle, status };
18850                    }
18851                    else {
18852                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
18853                            finderArgs = new Object[] {
18854                                            groupId, urlTitle, status,
18855                                            
18856                                            start, end, orderByComparator
18857                                    };
18858                    }
18859    
18860                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
18861                                    finderArgs, this);
18862    
18863                    if ((list != null) && !list.isEmpty()) {
18864                            for (JournalArticle journalArticle : list) {
18865                                    if ((groupId != journalArticle.getGroupId()) ||
18866                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
18867                                                    (status != journalArticle.getStatus())) {
18868                                            list = null;
18869    
18870                                            break;
18871                                    }
18872                            }
18873                    }
18874    
18875                    if (list == null) {
18876                            StringBundler query = null;
18877    
18878                            if (orderByComparator != null) {
18879                                    query = new StringBundler(5 +
18880                                                    (orderByComparator.getOrderByFields().length * 3));
18881                            }
18882                            else {
18883                                    query = new StringBundler(5);
18884                            }
18885    
18886                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
18887    
18888                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
18889    
18890                            if (urlTitle == null) {
18891                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
18892                            }
18893                            else {
18894                                    if (urlTitle.equals(StringPool.BLANK)) {
18895                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
18896                                    }
18897                                    else {
18898                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
18899                                    }
18900                            }
18901    
18902                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
18903    
18904                            if (orderByComparator != null) {
18905                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18906                                            orderByComparator);
18907                            }
18908    
18909                            else {
18910                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
18911                            }
18912    
18913                            String sql = query.toString();
18914    
18915                            Session session = null;
18916    
18917                            try {
18918                                    session = openSession();
18919    
18920                                    Query q = session.createQuery(sql);
18921    
18922                                    QueryPos qPos = QueryPos.getInstance(q);
18923    
18924                                    qPos.add(groupId);
18925    
18926                                    if (urlTitle != null) {
18927                                            qPos.add(urlTitle);
18928                                    }
18929    
18930                                    qPos.add(status);
18931    
18932                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
18933                                                    start, end);
18934                            }
18935                            catch (Exception e) {
18936                                    throw processException(e);
18937                            }
18938                            finally {
18939                                    if (list == null) {
18940                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
18941                                    }
18942                                    else {
18943                                            cacheResult(list);
18944    
18945                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
18946                                    }
18947    
18948                                    closeSession(session);
18949                            }
18950                    }
18951    
18952                    return list;
18953            }
18954    
18955            /**
18956             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
18957             *
18958             * @param groupId the group ID
18959             * @param urlTitle the url title
18960             * @param status the status
18961             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18962             * @return the first matching journal article
18963             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
18964             * @throws SystemException if a system exception occurred
18965             */
18966            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
18967                    int status, OrderByComparator orderByComparator)
18968                    throws NoSuchArticleException, SystemException {
18969                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
18970                                    status, orderByComparator);
18971    
18972                    if (journalArticle != null) {
18973                            return journalArticle;
18974                    }
18975    
18976                    StringBundler msg = new StringBundler(8);
18977    
18978                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
18979    
18980                    msg.append("groupId=");
18981                    msg.append(groupId);
18982    
18983                    msg.append(", urlTitle=");
18984                    msg.append(urlTitle);
18985    
18986                    msg.append(", status=");
18987                    msg.append(status);
18988    
18989                    msg.append(StringPool.CLOSE_CURLY_BRACE);
18990    
18991                    throw new NoSuchArticleException(msg.toString());
18992            }
18993    
18994            /**
18995             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
18996             *
18997             * @param groupId the group ID
18998             * @param urlTitle the url title
18999             * @param status the status
19000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19001             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19002             * @throws SystemException if a system exception occurred
19003             */
19004            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
19005                    int status, OrderByComparator orderByComparator)
19006                    throws SystemException {
19007                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
19008                                    1, orderByComparator);
19009    
19010                    if (!list.isEmpty()) {
19011                            return list.get(0);
19012                    }
19013    
19014                    return null;
19015            }
19016    
19017            /**
19018             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
19019             *
19020             * @param groupId the group ID
19021             * @param urlTitle the url title
19022             * @param status the status
19023             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19024             * @return the last matching journal article
19025             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19026             * @throws SystemException if a system exception occurred
19027             */
19028            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
19029                    int status, OrderByComparator orderByComparator)
19030                    throws NoSuchArticleException, SystemException {
19031                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
19032                                    status, orderByComparator);
19033    
19034                    if (journalArticle != null) {
19035                            return journalArticle;
19036                    }
19037    
19038                    StringBundler msg = new StringBundler(8);
19039    
19040                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19041    
19042                    msg.append("groupId=");
19043                    msg.append(groupId);
19044    
19045                    msg.append(", urlTitle=");
19046                    msg.append(urlTitle);
19047    
19048                    msg.append(", status=");
19049                    msg.append(status);
19050    
19051                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19052    
19053                    throw new NoSuchArticleException(msg.toString());
19054            }
19055    
19056            /**
19057             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
19058             *
19059             * @param groupId the group ID
19060             * @param urlTitle the url title
19061             * @param status the status
19062             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19063             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19064             * @throws SystemException if a system exception occurred
19065             */
19066            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
19067                    int status, OrderByComparator orderByComparator)
19068                    throws SystemException {
19069                    int count = countByG_UT_ST(groupId, urlTitle, status);
19070    
19071                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
19072                                    count - 1, count, orderByComparator);
19073    
19074                    if (!list.isEmpty()) {
19075                            return list.get(0);
19076                    }
19077    
19078                    return null;
19079            }
19080    
19081            /**
19082             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
19083             *
19084             * @param id the primary key of the current journal article
19085             * @param groupId the group ID
19086             * @param urlTitle the url title
19087             * @param status the status
19088             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19089             * @return the previous, current, and next journal article
19090             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19091             * @throws SystemException if a system exception occurred
19092             */
19093            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
19094                    String urlTitle, int status, OrderByComparator orderByComparator)
19095                    throws NoSuchArticleException, SystemException {
19096                    JournalArticle journalArticle = findByPrimaryKey(id);
19097    
19098                    Session session = null;
19099    
19100                    try {
19101                            session = openSession();
19102    
19103                            JournalArticle[] array = new JournalArticleImpl[3];
19104    
19105                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
19106                                            groupId, urlTitle, status, orderByComparator, true);
19107    
19108                            array[1] = journalArticle;
19109    
19110                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
19111                                            groupId, urlTitle, status, orderByComparator, false);
19112    
19113                            return array;
19114                    }
19115                    catch (Exception e) {
19116                            throw processException(e);
19117                    }
19118                    finally {
19119                            closeSession(session);
19120                    }
19121            }
19122    
19123            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
19124                    JournalArticle journalArticle, long groupId, String urlTitle,
19125                    int status, OrderByComparator orderByComparator, boolean previous) {
19126                    StringBundler query = null;
19127    
19128                    if (orderByComparator != null) {
19129                            query = new StringBundler(6 +
19130                                            (orderByComparator.getOrderByFields().length * 6));
19131                    }
19132                    else {
19133                            query = new StringBundler(3);
19134                    }
19135    
19136                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19137    
19138                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
19139    
19140                    if (urlTitle == null) {
19141                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
19142                    }
19143                    else {
19144                            if (urlTitle.equals(StringPool.BLANK)) {
19145                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
19146                            }
19147                            else {
19148                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
19149                            }
19150                    }
19151    
19152                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
19153    
19154                    if (orderByComparator != null) {
19155                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19156    
19157                            if (orderByConditionFields.length > 0) {
19158                                    query.append(WHERE_AND);
19159                            }
19160    
19161                            for (int i = 0; i < orderByConditionFields.length; i++) {
19162                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19163                                    query.append(orderByConditionFields[i]);
19164    
19165                                    if ((i + 1) < orderByConditionFields.length) {
19166                                            if (orderByComparator.isAscending() ^ previous) {
19167                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19168                                            }
19169                                            else {
19170                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19171                                            }
19172                                    }
19173                                    else {
19174                                            if (orderByComparator.isAscending() ^ previous) {
19175                                                    query.append(WHERE_GREATER_THAN);
19176                                            }
19177                                            else {
19178                                                    query.append(WHERE_LESSER_THAN);
19179                                            }
19180                                    }
19181                            }
19182    
19183                            query.append(ORDER_BY_CLAUSE);
19184    
19185                            String[] orderByFields = orderByComparator.getOrderByFields();
19186    
19187                            for (int i = 0; i < orderByFields.length; i++) {
19188                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19189                                    query.append(orderByFields[i]);
19190    
19191                                    if ((i + 1) < orderByFields.length) {
19192                                            if (orderByComparator.isAscending() ^ previous) {
19193                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19194                                            }
19195                                            else {
19196                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19197                                            }
19198                                    }
19199                                    else {
19200                                            if (orderByComparator.isAscending() ^ previous) {
19201                                                    query.append(ORDER_BY_ASC);
19202                                            }
19203                                            else {
19204                                                    query.append(ORDER_BY_DESC);
19205                                            }
19206                                    }
19207                            }
19208                    }
19209    
19210                    else {
19211                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19212                    }
19213    
19214                    String sql = query.toString();
19215    
19216                    Query q = session.createQuery(sql);
19217    
19218                    q.setFirstResult(0);
19219                    q.setMaxResults(2);
19220    
19221                    QueryPos qPos = QueryPos.getInstance(q);
19222    
19223                    qPos.add(groupId);
19224    
19225                    if (urlTitle != null) {
19226                            qPos.add(urlTitle);
19227                    }
19228    
19229                    qPos.add(status);
19230    
19231                    if (orderByComparator != null) {
19232                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19233    
19234                            for (Object value : values) {
19235                                    qPos.add(value);
19236                            }
19237                    }
19238    
19239                    List<JournalArticle> list = q.list();
19240    
19241                    if (list.size() == 2) {
19242                            return list.get(1);
19243                    }
19244                    else {
19245                            return null;
19246                    }
19247            }
19248    
19249            /**
19250             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
19251             *
19252             * @param groupId the group ID
19253             * @param urlTitle the url title
19254             * @param status the status
19255             * @return the matching journal articles that the user has permission to view
19256             * @throws SystemException if a system exception occurred
19257             */
19258            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
19259                    String urlTitle, int status) throws SystemException {
19260                    return filterFindByG_UT_ST(groupId, urlTitle, status,
19261                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19262            }
19263    
19264            /**
19265             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
19266             *
19267             * <p>
19268             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
19269             * </p>
19270             *
19271             * @param groupId the group ID
19272             * @param urlTitle the url title
19273             * @param status the status
19274             * @param start the lower bound of the range of journal articles
19275             * @param end the upper bound of the range of journal articles (not inclusive)
19276             * @return the range of matching journal articles that the user has permission to view
19277             * @throws SystemException if a system exception occurred
19278             */
19279            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
19280                    String urlTitle, int status, int start, int end)
19281                    throws SystemException {
19282                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
19283            }
19284    
19285            /**
19286             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
19287             *
19288             * <p>
19289             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
19290             * </p>
19291             *
19292             * @param groupId the group ID
19293             * @param urlTitle the url title
19294             * @param status the status
19295             * @param start the lower bound of the range of journal articles
19296             * @param end the upper bound of the range of journal articles (not inclusive)
19297             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19298             * @return the ordered range of matching journal articles that the user has permission to view
19299             * @throws SystemException if a system exception occurred
19300             */
19301            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
19302                    String urlTitle, int status, int start, int end,
19303                    OrderByComparator orderByComparator) throws SystemException {
19304                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19305                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
19306                                    orderByComparator);
19307                    }
19308    
19309                    StringBundler query = null;
19310    
19311                    if (orderByComparator != null) {
19312                            query = new StringBundler(5 +
19313                                            (orderByComparator.getOrderByFields().length * 3));
19314                    }
19315                    else {
19316                            query = new StringBundler(5);
19317                    }
19318    
19319                    if (getDB().isSupportsInlineDistinct()) {
19320                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19321                    }
19322                    else {
19323                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19324                    }
19325    
19326                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
19327    
19328                    if (urlTitle == null) {
19329                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
19330                    }
19331                    else {
19332                            if (urlTitle.equals(StringPool.BLANK)) {
19333                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
19334                            }
19335                            else {
19336                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
19337                            }
19338                    }
19339    
19340                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
19341    
19342                    if (!getDB().isSupportsInlineDistinct()) {
19343                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19344                    }
19345    
19346                    if (orderByComparator != null) {
19347                            if (getDB().isSupportsInlineDistinct()) {
19348                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19349                                            orderByComparator);
19350                            }
19351                            else {
19352                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
19353                                            orderByComparator);
19354                            }
19355                    }
19356    
19357                    else {
19358                            if (getDB().isSupportsInlineDistinct()) {
19359                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19360                            }
19361                            else {
19362                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19363                            }
19364                    }
19365    
19366                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19367                                    JournalArticle.class.getName(),
19368                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19369    
19370                    Session session = null;
19371    
19372                    try {
19373                            session = openSession();
19374    
19375                            SQLQuery q = session.createSQLQuery(sql);
19376    
19377                            if (getDB().isSupportsInlineDistinct()) {
19378                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19379                            }
19380                            else {
19381                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19382                            }
19383    
19384                            QueryPos qPos = QueryPos.getInstance(q);
19385    
19386                            qPos.add(groupId);
19387    
19388                            if (urlTitle != null) {
19389                                    qPos.add(urlTitle);
19390                            }
19391    
19392                            qPos.add(status);
19393    
19394                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
19395                                    end);
19396                    }
19397                    catch (Exception e) {
19398                            throw processException(e);
19399                    }
19400                    finally {
19401                            closeSession(session);
19402                    }
19403            }
19404    
19405            /**
19406             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
19407             *
19408             * @param id the primary key of the current journal article
19409             * @param groupId the group ID
19410             * @param urlTitle the url title
19411             * @param status the status
19412             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19413             * @return the previous, current, and next journal article
19414             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19415             * @throws SystemException if a system exception occurred
19416             */
19417            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
19418                    long groupId, String urlTitle, int status,
19419                    OrderByComparator orderByComparator)
19420                    throws NoSuchArticleException, SystemException {
19421                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19422                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
19423                                    orderByComparator);
19424                    }
19425    
19426                    JournalArticle journalArticle = findByPrimaryKey(id);
19427    
19428                    Session session = null;
19429    
19430                    try {
19431                            session = openSession();
19432    
19433                            JournalArticle[] array = new JournalArticleImpl[3];
19434    
19435                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
19436                                            groupId, urlTitle, status, orderByComparator, true);
19437    
19438                            array[1] = journalArticle;
19439    
19440                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
19441                                            groupId, urlTitle, status, orderByComparator, false);
19442    
19443                            return array;
19444                    }
19445                    catch (Exception e) {
19446                            throw processException(e);
19447                    }
19448                    finally {
19449                            closeSession(session);
19450                    }
19451            }
19452    
19453            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
19454                    JournalArticle journalArticle, long groupId, String urlTitle,
19455                    int status, OrderByComparator orderByComparator, boolean previous) {
19456                    StringBundler query = null;
19457    
19458                    if (orderByComparator != null) {
19459                            query = new StringBundler(6 +
19460                                            (orderByComparator.getOrderByFields().length * 6));
19461                    }
19462                    else {
19463                            query = new StringBundler(3);
19464                    }
19465    
19466                    if (getDB().isSupportsInlineDistinct()) {
19467                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
19468                    }
19469                    else {
19470                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
19471                    }
19472    
19473                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
19474    
19475                    if (urlTitle == null) {
19476                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
19477                    }
19478                    else {
19479                            if (urlTitle.equals(StringPool.BLANK)) {
19480                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
19481                            }
19482                            else {
19483                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
19484                            }
19485                    }
19486    
19487                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
19488    
19489                    if (!getDB().isSupportsInlineDistinct()) {
19490                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
19491                    }
19492    
19493                    if (orderByComparator != null) {
19494                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19495    
19496                            if (orderByConditionFields.length > 0) {
19497                                    query.append(WHERE_AND);
19498                            }
19499    
19500                            for (int i = 0; i < orderByConditionFields.length; i++) {
19501                                    if (getDB().isSupportsInlineDistinct()) {
19502                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19503                                    }
19504                                    else {
19505                                            query.append(_ORDER_BY_ENTITY_TABLE);
19506                                    }
19507    
19508                                    query.append(orderByConditionFields[i]);
19509    
19510                                    if ((i + 1) < orderByConditionFields.length) {
19511                                            if (orderByComparator.isAscending() ^ previous) {
19512                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19513                                            }
19514                                            else {
19515                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19516                                            }
19517                                    }
19518                                    else {
19519                                            if (orderByComparator.isAscending() ^ previous) {
19520                                                    query.append(WHERE_GREATER_THAN);
19521                                            }
19522                                            else {
19523                                                    query.append(WHERE_LESSER_THAN);
19524                                            }
19525                                    }
19526                            }
19527    
19528                            query.append(ORDER_BY_CLAUSE);
19529    
19530                            String[] orderByFields = orderByComparator.getOrderByFields();
19531    
19532                            for (int i = 0; i < orderByFields.length; i++) {
19533                                    if (getDB().isSupportsInlineDistinct()) {
19534                                            query.append(_ORDER_BY_ENTITY_ALIAS);
19535                                    }
19536                                    else {
19537                                            query.append(_ORDER_BY_ENTITY_TABLE);
19538                                    }
19539    
19540                                    query.append(orderByFields[i]);
19541    
19542                                    if ((i + 1) < orderByFields.length) {
19543                                            if (orderByComparator.isAscending() ^ previous) {
19544                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19545                                            }
19546                                            else {
19547                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
19548                                            }
19549                                    }
19550                                    else {
19551                                            if (orderByComparator.isAscending() ^ previous) {
19552                                                    query.append(ORDER_BY_ASC);
19553                                            }
19554                                            else {
19555                                                    query.append(ORDER_BY_DESC);
19556                                            }
19557                                    }
19558                            }
19559                    }
19560    
19561                    else {
19562                            if (getDB().isSupportsInlineDistinct()) {
19563                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19564                            }
19565                            else {
19566                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
19567                            }
19568                    }
19569    
19570                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19571                                    JournalArticle.class.getName(),
19572                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19573    
19574                    SQLQuery q = session.createSQLQuery(sql);
19575    
19576                    q.setFirstResult(0);
19577                    q.setMaxResults(2);
19578    
19579                    if (getDB().isSupportsInlineDistinct()) {
19580                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
19581                    }
19582                    else {
19583                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
19584                    }
19585    
19586                    QueryPos qPos = QueryPos.getInstance(q);
19587    
19588                    qPos.add(groupId);
19589    
19590                    if (urlTitle != null) {
19591                            qPos.add(urlTitle);
19592                    }
19593    
19594                    qPos.add(status);
19595    
19596                    if (orderByComparator != null) {
19597                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
19598    
19599                            for (Object value : values) {
19600                                    qPos.add(value);
19601                            }
19602                    }
19603    
19604                    List<JournalArticle> list = q.list();
19605    
19606                    if (list.size() == 2) {
19607                            return list.get(1);
19608                    }
19609                    else {
19610                            return null;
19611                    }
19612            }
19613    
19614            /**
19615             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
19616             *
19617             * @param companyId the company ID
19618             * @param version the version
19619             * @param status the status
19620             * @return the matching journal articles
19621             * @throws SystemException if a system exception occurred
19622             */
19623            public List<JournalArticle> findByC_V_ST(long companyId, double version,
19624                    int status) throws SystemException {
19625                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
19626                            QueryUtil.ALL_POS, null);
19627            }
19628    
19629            /**
19630             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
19631             *
19632             * <p>
19633             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
19634             * </p>
19635             *
19636             * @param companyId the company ID
19637             * @param version the version
19638             * @param status the status
19639             * @param start the lower bound of the range of journal articles
19640             * @param end the upper bound of the range of journal articles (not inclusive)
19641             * @return the range of matching journal articles
19642             * @throws SystemException if a system exception occurred
19643             */
19644            public List<JournalArticle> findByC_V_ST(long companyId, double version,
19645                    int status, int start, int end) throws SystemException {
19646                    return findByC_V_ST(companyId, version, status, start, end, null);
19647            }
19648    
19649            /**
19650             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
19651             *
19652             * <p>
19653             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
19654             * </p>
19655             *
19656             * @param companyId the company ID
19657             * @param version the version
19658             * @param status the status
19659             * @param start the lower bound of the range of journal articles
19660             * @param end the upper bound of the range of journal articles (not inclusive)
19661             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19662             * @return the ordered range of matching journal articles
19663             * @throws SystemException if a system exception occurred
19664             */
19665            public List<JournalArticle> findByC_V_ST(long companyId, double version,
19666                    int status, int start, int end, OrderByComparator orderByComparator)
19667                    throws SystemException {
19668                    FinderPath finderPath = null;
19669                    Object[] finderArgs = null;
19670    
19671                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19672                                    (orderByComparator == null)) {
19673                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
19674                            finderArgs = new Object[] { companyId, version, status };
19675                    }
19676                    else {
19677                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
19678                            finderArgs = new Object[] {
19679                                            companyId, version, status,
19680                                            
19681                                            start, end, orderByComparator
19682                                    };
19683                    }
19684    
19685                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
19686                                    finderArgs, this);
19687    
19688                    if ((list != null) && !list.isEmpty()) {
19689                            for (JournalArticle journalArticle : list) {
19690                                    if ((companyId != journalArticle.getCompanyId()) ||
19691                                                    (version != journalArticle.getVersion()) ||
19692                                                    (status != journalArticle.getStatus())) {
19693                                            list = null;
19694    
19695                                            break;
19696                                    }
19697                            }
19698                    }
19699    
19700                    if (list == null) {
19701                            StringBundler query = null;
19702    
19703                            if (orderByComparator != null) {
19704                                    query = new StringBundler(5 +
19705                                                    (orderByComparator.getOrderByFields().length * 3));
19706                            }
19707                            else {
19708                                    query = new StringBundler(5);
19709                            }
19710    
19711                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19712    
19713                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
19714    
19715                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
19716    
19717                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
19718    
19719                            if (orderByComparator != null) {
19720                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19721                                            orderByComparator);
19722                            }
19723    
19724                            else {
19725                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
19726                            }
19727    
19728                            String sql = query.toString();
19729    
19730                            Session session = null;
19731    
19732                            try {
19733                                    session = openSession();
19734    
19735                                    Query q = session.createQuery(sql);
19736    
19737                                    QueryPos qPos = QueryPos.getInstance(q);
19738    
19739                                    qPos.add(companyId);
19740    
19741                                    qPos.add(version);
19742    
19743                                    qPos.add(status);
19744    
19745                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
19746                                                    start, end);
19747                            }
19748                            catch (Exception e) {
19749                                    throw processException(e);
19750                            }
19751                            finally {
19752                                    if (list == null) {
19753                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
19754                                    }
19755                                    else {
19756                                            cacheResult(list);
19757    
19758                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
19759                                    }
19760    
19761                                    closeSession(session);
19762                            }
19763                    }
19764    
19765                    return list;
19766            }
19767    
19768            /**
19769             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
19770             *
19771             * @param companyId the company ID
19772             * @param version the version
19773             * @param status the status
19774             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19775             * @return the first matching journal article
19776             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19777             * @throws SystemException if a system exception occurred
19778             */
19779            public JournalArticle findByC_V_ST_First(long companyId, double version,
19780                    int status, OrderByComparator orderByComparator)
19781                    throws NoSuchArticleException, SystemException {
19782                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
19783                                    status, orderByComparator);
19784    
19785                    if (journalArticle != null) {
19786                            return journalArticle;
19787                    }
19788    
19789                    StringBundler msg = new StringBundler(8);
19790    
19791                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19792    
19793                    msg.append("companyId=");
19794                    msg.append(companyId);
19795    
19796                    msg.append(", version=");
19797                    msg.append(version);
19798    
19799                    msg.append(", status=");
19800                    msg.append(status);
19801    
19802                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19803    
19804                    throw new NoSuchArticleException(msg.toString());
19805            }
19806    
19807            /**
19808             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
19809             *
19810             * @param companyId the company ID
19811             * @param version the version
19812             * @param status the status
19813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19814             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
19815             * @throws SystemException if a system exception occurred
19816             */
19817            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
19818                    int status, OrderByComparator orderByComparator)
19819                    throws SystemException {
19820                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
19821                                    1, orderByComparator);
19822    
19823                    if (!list.isEmpty()) {
19824                            return list.get(0);
19825                    }
19826    
19827                    return null;
19828            }
19829    
19830            /**
19831             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
19832             *
19833             * @param companyId the company ID
19834             * @param version the version
19835             * @param status the status
19836             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19837             * @return the last matching journal article
19838             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
19839             * @throws SystemException if a system exception occurred
19840             */
19841            public JournalArticle findByC_V_ST_Last(long companyId, double version,
19842                    int status, OrderByComparator orderByComparator)
19843                    throws NoSuchArticleException, SystemException {
19844                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
19845                                    status, orderByComparator);
19846    
19847                    if (journalArticle != null) {
19848                            return journalArticle;
19849                    }
19850    
19851                    StringBundler msg = new StringBundler(8);
19852    
19853                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
19854    
19855                    msg.append("companyId=");
19856                    msg.append(companyId);
19857    
19858                    msg.append(", version=");
19859                    msg.append(version);
19860    
19861                    msg.append(", status=");
19862                    msg.append(status);
19863    
19864                    msg.append(StringPool.CLOSE_CURLY_BRACE);
19865    
19866                    throw new NoSuchArticleException(msg.toString());
19867            }
19868    
19869            /**
19870             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
19871             *
19872             * @param companyId the company ID
19873             * @param version the version
19874             * @param status the status
19875             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19876             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
19877             * @throws SystemException if a system exception occurred
19878             */
19879            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
19880                    int status, OrderByComparator orderByComparator)
19881                    throws SystemException {
19882                    int count = countByC_V_ST(companyId, version, status);
19883    
19884                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
19885                                    count - 1, count, orderByComparator);
19886    
19887                    if (!list.isEmpty()) {
19888                            return list.get(0);
19889                    }
19890    
19891                    return null;
19892            }
19893    
19894            /**
19895             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
19896             *
19897             * @param id the primary key of the current journal article
19898             * @param companyId the company ID
19899             * @param version the version
19900             * @param status the status
19901             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
19902             * @return the previous, current, and next journal article
19903             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
19904             * @throws SystemException if a system exception occurred
19905             */
19906            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
19907                    double version, int status, OrderByComparator orderByComparator)
19908                    throws NoSuchArticleException, SystemException {
19909                    JournalArticle journalArticle = findByPrimaryKey(id);
19910    
19911                    Session session = null;
19912    
19913                    try {
19914                            session = openSession();
19915    
19916                            JournalArticle[] array = new JournalArticleImpl[3];
19917    
19918                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
19919                                            companyId, version, status, orderByComparator, true);
19920    
19921                            array[1] = journalArticle;
19922    
19923                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
19924                                            companyId, version, status, orderByComparator, false);
19925    
19926                            return array;
19927                    }
19928                    catch (Exception e) {
19929                            throw processException(e);
19930                    }
19931                    finally {
19932                            closeSession(session);
19933                    }
19934            }
19935    
19936            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
19937                    JournalArticle journalArticle, long companyId, double version,
19938                    int status, OrderByComparator orderByComparator, boolean previous) {
19939                    StringBundler query = null;
19940    
19941                    if (orderByComparator != null) {
19942                            query = new StringBundler(6 +
19943                                            (orderByComparator.getOrderByFields().length * 6));
19944                    }
19945                    else {
19946                            query = new StringBundler(3);
19947                    }
19948    
19949                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
19950    
19951                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
19952    
19953                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
19954    
19955                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
19956    
19957                    if (orderByComparator != null) {
19958                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
19959    
19960                            if (orderByConditionFields.length > 0) {
19961                                    query.append(WHERE_AND);
19962                            }
19963    
19964                            for (int i = 0; i < orderByConditionFields.length; i++) {
19965                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19966                                    query.append(orderByConditionFields[i]);
19967    
19968                                    if ((i + 1) < orderByConditionFields.length) {
19969                                            if (orderByComparator.isAscending() ^ previous) {
19970                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
19971                                            }
19972                                            else {
19973                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
19974                                            }
19975                                    }
19976                                    else {
19977                                            if (orderByComparator.isAscending() ^ previous) {
19978                                                    query.append(WHERE_GREATER_THAN);
19979                                            }
19980                                            else {
19981                                                    query.append(WHERE_LESSER_THAN);
19982                                            }
19983                                    }
19984                            }
19985    
19986                            query.append(ORDER_BY_CLAUSE);
19987    
19988                            String[] orderByFields = orderByComparator.getOrderByFields();
19989    
19990                            for (int i = 0; i < orderByFields.length; i++) {
19991                                    query.append(_ORDER_BY_ENTITY_ALIAS);
19992                                    query.append(orderByFields[i]);
19993    
19994                                    if ((i + 1) < orderByFields.length) {
19995                                            if (orderByComparator.isAscending() ^ previous) {
19996                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
19997                                            }
19998                                            else {
19999                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
20000                                            }
20001                                    }
20002                                    else {
20003                                            if (orderByComparator.isAscending() ^ previous) {
20004                                                    query.append(ORDER_BY_ASC);
20005                                            }
20006                                            else {
20007                                                    query.append(ORDER_BY_DESC);
20008                                            }
20009                                    }
20010                            }
20011                    }
20012    
20013                    else {
20014                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
20015                    }
20016    
20017                    String sql = query.toString();
20018    
20019                    Query q = session.createQuery(sql);
20020    
20021                    q.setFirstResult(0);
20022                    q.setMaxResults(2);
20023    
20024                    QueryPos qPos = QueryPos.getInstance(q);
20025    
20026                    qPos.add(companyId);
20027    
20028                    qPos.add(version);
20029    
20030                    qPos.add(status);
20031    
20032                    if (orderByComparator != null) {
20033                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
20034    
20035                            for (Object value : values) {
20036                                    qPos.add(value);
20037                            }
20038                    }
20039    
20040                    List<JournalArticle> list = q.list();
20041    
20042                    if (list.size() == 2) {
20043                            return list.get(1);
20044                    }
20045                    else {
20046                            return null;
20047                    }
20048            }
20049    
20050            /**
20051             * Returns all the journal articles.
20052             *
20053             * @return the journal articles
20054             * @throws SystemException if a system exception occurred
20055             */
20056            public List<JournalArticle> findAll() throws SystemException {
20057                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
20058            }
20059    
20060            /**
20061             * Returns a range of all the journal articles.
20062             *
20063             * <p>
20064             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
20065             * </p>
20066             *
20067             * @param start the lower bound of the range of journal articles
20068             * @param end the upper bound of the range of journal articles (not inclusive)
20069             * @return the range of journal articles
20070             * @throws SystemException if a system exception occurred
20071             */
20072            public List<JournalArticle> findAll(int start, int end)
20073                    throws SystemException {
20074                    return findAll(start, end, null);
20075            }
20076    
20077            /**
20078             * Returns an ordered range of all the journal articles.
20079             *
20080             * <p>
20081             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
20082             * </p>
20083             *
20084             * @param start the lower bound of the range of journal articles
20085             * @param end the upper bound of the range of journal articles (not inclusive)
20086             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
20087             * @return the ordered range of journal articles
20088             * @throws SystemException if a system exception occurred
20089             */
20090            public List<JournalArticle> findAll(int start, int end,
20091                    OrderByComparator orderByComparator) throws SystemException {
20092                    FinderPath finderPath = null;
20093                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
20094    
20095                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
20096                                    (orderByComparator == null)) {
20097                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
20098                            finderArgs = FINDER_ARGS_EMPTY;
20099                    }
20100                    else {
20101                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
20102                            finderArgs = new Object[] { start, end, orderByComparator };
20103                    }
20104    
20105                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
20106                                    finderArgs, this);
20107    
20108                    if (list == null) {
20109                            StringBundler query = null;
20110                            String sql = null;
20111    
20112                            if (orderByComparator != null) {
20113                                    query = new StringBundler(2 +
20114                                                    (orderByComparator.getOrderByFields().length * 3));
20115    
20116                                    query.append(_SQL_SELECT_JOURNALARTICLE);
20117    
20118                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
20119                                            orderByComparator);
20120    
20121                                    sql = query.toString();
20122                            }
20123                            else {
20124                                    sql = _SQL_SELECT_JOURNALARTICLE.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
20125                            }
20126    
20127                            Session session = null;
20128    
20129                            try {
20130                                    session = openSession();
20131    
20132                                    Query q = session.createQuery(sql);
20133    
20134                                    if (orderByComparator == null) {
20135                                            list = (List<JournalArticle>)QueryUtil.list(q,
20136                                                            getDialect(), start, end, false);
20137    
20138                                            Collections.sort(list);
20139                                    }
20140                                    else {
20141                                            list = (List<JournalArticle>)QueryUtil.list(q,
20142                                                            getDialect(), start, end);
20143                                    }
20144                            }
20145                            catch (Exception e) {
20146                                    throw processException(e);
20147                            }
20148                            finally {
20149                                    if (list == null) {
20150                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
20151                                    }
20152                                    else {
20153                                            cacheResult(list);
20154    
20155                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
20156                                    }
20157    
20158                                    closeSession(session);
20159                            }
20160                    }
20161    
20162                    return list;
20163            }
20164    
20165            /**
20166             * Removes all the journal articles where uuid = &#63; from the database.
20167             *
20168             * @param uuid the uuid
20169             * @throws SystemException if a system exception occurred
20170             */
20171            public void removeByUuid(String uuid) throws SystemException {
20172                    for (JournalArticle journalArticle : findByUuid(uuid)) {
20173                            remove(journalArticle);
20174                    }
20175            }
20176    
20177            /**
20178             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
20179             *
20180             * @param uuid the uuid
20181             * @param groupId the group ID
20182             * @return the journal article that was removed
20183             * @throws SystemException if a system exception occurred
20184             */
20185            public JournalArticle removeByUUID_G(String uuid, long groupId)
20186                    throws NoSuchArticleException, SystemException {
20187                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
20188    
20189                    return remove(journalArticle);
20190            }
20191    
20192            /**
20193             * Removes all the journal articles where uuid = &#63; and companyId = &#63; from the database.
20194             *
20195             * @param uuid the uuid
20196             * @param companyId the company ID
20197             * @throws SystemException if a system exception occurred
20198             */
20199            public void removeByUuid_C(String uuid, long companyId)
20200                    throws SystemException {
20201                    for (JournalArticle journalArticle : findByUuid_C(uuid, companyId)) {
20202                            remove(journalArticle);
20203                    }
20204            }
20205    
20206            /**
20207             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
20208             *
20209             * @param resourcePrimKey the resource prim key
20210             * @throws SystemException if a system exception occurred
20211             */
20212            public void removeByResourcePrimKey(long resourcePrimKey)
20213                    throws SystemException {
20214                    for (JournalArticle journalArticle : findByResourcePrimKey(
20215                                    resourcePrimKey)) {
20216                            remove(journalArticle);
20217                    }
20218            }
20219    
20220            /**
20221             * Removes all the journal articles where groupId = &#63; from the database.
20222             *
20223             * @param groupId the group ID
20224             * @throws SystemException if a system exception occurred
20225             */
20226            public void removeByGroupId(long groupId) throws SystemException {
20227                    for (JournalArticle journalArticle : findByGroupId(groupId)) {
20228                            remove(journalArticle);
20229                    }
20230            }
20231    
20232            /**
20233             * Removes all the journal articles where companyId = &#63; from the database.
20234             *
20235             * @param companyId the company ID
20236             * @throws SystemException if a system exception occurred
20237             */
20238            public void removeByCompanyId(long companyId) throws SystemException {
20239                    for (JournalArticle journalArticle : findByCompanyId(companyId)) {
20240                            remove(journalArticle);
20241                    }
20242            }
20243    
20244            /**
20245             * Removes all the journal articles where structureId = &#63; from the database.
20246             *
20247             * @param structureId the structure ID
20248             * @throws SystemException if a system exception occurred
20249             */
20250            public void removeByStructureId(String structureId)
20251                    throws SystemException {
20252                    for (JournalArticle journalArticle : findByStructureId(structureId)) {
20253                            remove(journalArticle);
20254                    }
20255            }
20256    
20257            /**
20258             * Removes all the journal articles where templateId = &#63; from the database.
20259             *
20260             * @param templateId the template ID
20261             * @throws SystemException if a system exception occurred
20262             */
20263            public void removeByTemplateId(String templateId) throws SystemException {
20264                    for (JournalArticle journalArticle : findByTemplateId(templateId)) {
20265                            remove(journalArticle);
20266                    }
20267            }
20268    
20269            /**
20270             * Removes all the journal articles where layoutUuid = &#63; from the database.
20271             *
20272             * @param layoutUuid the layout uuid
20273             * @throws SystemException if a system exception occurred
20274             */
20275            public void removeByLayoutUuid(String layoutUuid) throws SystemException {
20276                    for (JournalArticle journalArticle : findByLayoutUuid(layoutUuid)) {
20277                            remove(journalArticle);
20278                    }
20279            }
20280    
20281            /**
20282             * Removes all the journal articles where smallImageId = &#63; from the database.
20283             *
20284             * @param smallImageId the small image ID
20285             * @throws SystemException if a system exception occurred
20286             */
20287            public void removeBySmallImageId(long smallImageId)
20288                    throws SystemException {
20289                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId)) {
20290                            remove(journalArticle);
20291                    }
20292            }
20293    
20294            /**
20295             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
20296             *
20297             * @param resourcePrimKey the resource prim key
20298             * @param status the status
20299             * @throws SystemException if a system exception occurred
20300             */
20301            public void removeByR_ST(long resourcePrimKey, int status)
20302                    throws SystemException {
20303                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey, status)) {
20304                            remove(journalArticle);
20305                    }
20306            }
20307    
20308            /**
20309             * Removes all the journal articles where groupId = &#63; and userId = &#63; from the database.
20310             *
20311             * @param groupId the group ID
20312             * @param userId the user ID
20313             * @throws SystemException if a system exception occurred
20314             */
20315            public void removeByG_U(long groupId, long userId)
20316                    throws SystemException {
20317                    for (JournalArticle journalArticle : findByG_U(groupId, userId)) {
20318                            remove(journalArticle);
20319                    }
20320            }
20321    
20322            /**
20323             * Removes all the journal articles where groupId = &#63; and folderId = &#63; from the database.
20324             *
20325             * @param groupId the group ID
20326             * @param folderId the folder ID
20327             * @throws SystemException if a system exception occurred
20328             */
20329            public void removeByG_F(long groupId, long folderId)
20330                    throws SystemException {
20331                    for (JournalArticle journalArticle : findByG_F(groupId, folderId)) {
20332                            remove(journalArticle);
20333                    }
20334            }
20335    
20336            /**
20337             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
20338             *
20339             * @param groupId the group ID
20340             * @param articleId the article ID
20341             * @throws SystemException if a system exception occurred
20342             */
20343            public void removeByG_A(long groupId, String articleId)
20344                    throws SystemException {
20345                    for (JournalArticle journalArticle : findByG_A(groupId, articleId)) {
20346                            remove(journalArticle);
20347                    }
20348            }
20349    
20350            /**
20351             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
20352             *
20353             * @param groupId the group ID
20354             * @param urlTitle the url title
20355             * @throws SystemException if a system exception occurred
20356             */
20357            public void removeByG_UT(long groupId, String urlTitle)
20358                    throws SystemException {
20359                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle)) {
20360                            remove(journalArticle);
20361                    }
20362            }
20363    
20364            /**
20365             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
20366             *
20367             * @param groupId the group ID
20368             * @param structureId the structure ID
20369             * @throws SystemException if a system exception occurred
20370             */
20371            public void removeByG_S(long groupId, String structureId)
20372                    throws SystemException {
20373                    for (JournalArticle journalArticle : findByG_S(groupId, structureId)) {
20374                            remove(journalArticle);
20375                    }
20376            }
20377    
20378            /**
20379             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
20380             *
20381             * @param groupId the group ID
20382             * @param templateId the template ID
20383             * @throws SystemException if a system exception occurred
20384             */
20385            public void removeByG_T(long groupId, String templateId)
20386                    throws SystemException {
20387                    for (JournalArticle journalArticle : findByG_T(groupId, templateId)) {
20388                            remove(journalArticle);
20389                    }
20390            }
20391    
20392            /**
20393             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
20394             *
20395             * @param groupId the group ID
20396             * @param layoutUuid the layout uuid
20397             * @throws SystemException if a system exception occurred
20398             */
20399            public void removeByG_L(long groupId, String layoutUuid)
20400                    throws SystemException {
20401                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid)) {
20402                            remove(journalArticle);
20403                    }
20404            }
20405    
20406            /**
20407             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
20408             *
20409             * @param groupId the group ID
20410             * @param status the status
20411             * @throws SystemException if a system exception occurred
20412             */
20413            public void removeByG_ST(long groupId, int status)
20414                    throws SystemException {
20415                    for (JournalArticle journalArticle : findByG_ST(groupId, status)) {
20416                            remove(journalArticle);
20417                    }
20418            }
20419    
20420            /**
20421             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
20422             *
20423             * @param companyId the company ID
20424             * @param version the version
20425             * @throws SystemException if a system exception occurred
20426             */
20427            public void removeByC_V(long companyId, double version)
20428                    throws SystemException {
20429                    for (JournalArticle journalArticle : findByC_V(companyId, version)) {
20430                            remove(journalArticle);
20431                    }
20432            }
20433    
20434            /**
20435             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
20436             *
20437             * @param companyId the company ID
20438             * @param status the status
20439             * @throws SystemException if a system exception occurred
20440             */
20441            public void removeByC_ST(long companyId, int status)
20442                    throws SystemException {
20443                    for (JournalArticle journalArticle : findByC_ST(companyId, status)) {
20444                            remove(journalArticle);
20445                    }
20446            }
20447    
20448            /**
20449             * Removes all the journal articles where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
20450             *
20451             * @param groupId the group ID
20452             * @param folderId the folder ID
20453             * @param status the status
20454             * @throws SystemException if a system exception occurred
20455             */
20456            public void removeByG_F_ST(long groupId, long folderId, int status)
20457                    throws SystemException {
20458                    for (JournalArticle journalArticle : findByG_F_ST(groupId, folderId,
20459                                    status)) {
20460                            remove(journalArticle);
20461                    }
20462            }
20463    
20464            /**
20465             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
20466             *
20467             * @param groupId the group ID
20468             * @param classNameId the class name ID
20469             * @param classPK the class p k
20470             * @throws SystemException if a system exception occurred
20471             */
20472            public void removeByG_C_C(long groupId, long classNameId, long classPK)
20473                    throws SystemException {
20474                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
20475                                    classPK)) {
20476                            remove(journalArticle);
20477                    }
20478            }
20479    
20480            /**
20481             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
20482             *
20483             * @param groupId the group ID
20484             * @param classNameId the class name ID
20485             * @param structureId the structure ID
20486             * @return the journal article that was removed
20487             * @throws SystemException if a system exception occurred
20488             */
20489            public JournalArticle removeByG_C_S(long groupId, long classNameId,
20490                    String structureId) throws NoSuchArticleException, SystemException {
20491                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
20492                                    structureId);
20493    
20494                    return remove(journalArticle);
20495            }
20496    
20497            /**
20498             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
20499             *
20500             * @param groupId the group ID
20501             * @param classNameId the class name ID
20502             * @param templateId the template ID
20503             * @throws SystemException if a system exception occurred
20504             */
20505            public void removeByG_C_T(long groupId, long classNameId, String templateId)
20506                    throws SystemException {
20507                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
20508                                    templateId)) {
20509                            remove(journalArticle);
20510                    }
20511            }
20512    
20513            /**
20514             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
20515             *
20516             * @param groupId the group ID
20517             * @param classNameId the class name ID
20518             * @param layoutUuid the layout uuid
20519             * @throws SystemException if a system exception occurred
20520             */
20521            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
20522                    throws SystemException {
20523                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
20524                                    layoutUuid)) {
20525                            remove(journalArticle);
20526                    }
20527            }
20528    
20529            /**
20530             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
20531             *
20532             * @param groupId the group ID
20533             * @param articleId the article ID
20534             * @param version the version
20535             * @return the journal article that was removed
20536             * @throws SystemException if a system exception occurred
20537             */
20538            public JournalArticle removeByG_A_V(long groupId, String articleId,
20539                    double version) throws NoSuchArticleException, SystemException {
20540                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
20541    
20542                    return remove(journalArticle);
20543            }
20544    
20545            /**
20546             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
20547             *
20548             * @param groupId the group ID
20549             * @param articleId the article ID
20550             * @param status the status
20551             * @throws SystemException if a system exception occurred
20552             */
20553            public void removeByG_A_ST(long groupId, String articleId, int status)
20554                    throws SystemException {
20555                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
20556                                    status)) {
20557                            remove(journalArticle);
20558                    }
20559            }
20560    
20561            /**
20562             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
20563             *
20564             * @param groupId the group ID
20565             * @param urlTitle the url title
20566             * @param status the status
20567             * @throws SystemException if a system exception occurred
20568             */
20569            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
20570                    throws SystemException {
20571                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
20572                                    status)) {
20573                            remove(journalArticle);
20574                    }
20575            }
20576    
20577            /**
20578             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
20579             *
20580             * @param companyId the company ID
20581             * @param version the version
20582             * @param status the status
20583             * @throws SystemException if a system exception occurred
20584             */
20585            public void removeByC_V_ST(long companyId, double version, int status)
20586                    throws SystemException {
20587                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
20588                                    status)) {
20589                            remove(journalArticle);
20590                    }
20591            }
20592    
20593            /**
20594             * Removes all the journal articles from the database.
20595             *
20596             * @throws SystemException if a system exception occurred
20597             */
20598            public void removeAll() throws SystemException {
20599                    for (JournalArticle journalArticle : findAll()) {
20600                            remove(journalArticle);
20601                    }
20602            }
20603    
20604            /**
20605             * Returns the number of journal articles where uuid = &#63;.
20606             *
20607             * @param uuid the uuid
20608             * @return the number of matching journal articles
20609             * @throws SystemException if a system exception occurred
20610             */
20611            public int countByUuid(String uuid) throws SystemException {
20612                    Object[] finderArgs = new Object[] { uuid };
20613    
20614                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
20615                                    finderArgs, this);
20616    
20617                    if (count == null) {
20618                            StringBundler query = new StringBundler(2);
20619    
20620                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20621    
20622                            if (uuid == null) {
20623                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
20624                            }
20625                            else {
20626                                    if (uuid.equals(StringPool.BLANK)) {
20627                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
20628                                    }
20629                                    else {
20630                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
20631                                    }
20632                            }
20633    
20634                            String sql = query.toString();
20635    
20636                            Session session = null;
20637    
20638                            try {
20639                                    session = openSession();
20640    
20641                                    Query q = session.createQuery(sql);
20642    
20643                                    QueryPos qPos = QueryPos.getInstance(q);
20644    
20645                                    if (uuid != null) {
20646                                            qPos.add(uuid);
20647                                    }
20648    
20649                                    count = (Long)q.uniqueResult();
20650                            }
20651                            catch (Exception e) {
20652                                    throw processException(e);
20653                            }
20654                            finally {
20655                                    if (count == null) {
20656                                            count = Long.valueOf(0);
20657                                    }
20658    
20659                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
20660                                            finderArgs, count);
20661    
20662                                    closeSession(session);
20663                            }
20664                    }
20665    
20666                    return count.intValue();
20667            }
20668    
20669            /**
20670             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
20671             *
20672             * @param uuid the uuid
20673             * @param groupId the group ID
20674             * @return the number of matching journal articles
20675             * @throws SystemException if a system exception occurred
20676             */
20677            public int countByUUID_G(String uuid, long groupId)
20678                    throws SystemException {
20679                    Object[] finderArgs = new Object[] { uuid, groupId };
20680    
20681                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
20682                                    finderArgs, this);
20683    
20684                    if (count == null) {
20685                            StringBundler query = new StringBundler(3);
20686    
20687                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20688    
20689                            if (uuid == null) {
20690                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
20691                            }
20692                            else {
20693                                    if (uuid.equals(StringPool.BLANK)) {
20694                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
20695                                    }
20696                                    else {
20697                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
20698                                    }
20699                            }
20700    
20701                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
20702    
20703                            String sql = query.toString();
20704    
20705                            Session session = null;
20706    
20707                            try {
20708                                    session = openSession();
20709    
20710                                    Query q = session.createQuery(sql);
20711    
20712                                    QueryPos qPos = QueryPos.getInstance(q);
20713    
20714                                    if (uuid != null) {
20715                                            qPos.add(uuid);
20716                                    }
20717    
20718                                    qPos.add(groupId);
20719    
20720                                    count = (Long)q.uniqueResult();
20721                            }
20722                            catch (Exception e) {
20723                                    throw processException(e);
20724                            }
20725                            finally {
20726                                    if (count == null) {
20727                                            count = Long.valueOf(0);
20728                                    }
20729    
20730                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
20731                                            finderArgs, count);
20732    
20733                                    closeSession(session);
20734                            }
20735                    }
20736    
20737                    return count.intValue();
20738            }
20739    
20740            /**
20741             * Returns the number of journal articles where uuid = &#63; and companyId = &#63;.
20742             *
20743             * @param uuid the uuid
20744             * @param companyId the company ID
20745             * @return the number of matching journal articles
20746             * @throws SystemException if a system exception occurred
20747             */
20748            public int countByUuid_C(String uuid, long companyId)
20749                    throws SystemException {
20750                    Object[] finderArgs = new Object[] { uuid, companyId };
20751    
20752                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
20753                                    finderArgs, this);
20754    
20755                    if (count == null) {
20756                            StringBundler query = new StringBundler(3);
20757    
20758                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20759    
20760                            if (uuid == null) {
20761                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
20762                            }
20763                            else {
20764                                    if (uuid.equals(StringPool.BLANK)) {
20765                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
20766                                    }
20767                                    else {
20768                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
20769                                    }
20770                            }
20771    
20772                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
20773    
20774                            String sql = query.toString();
20775    
20776                            Session session = null;
20777    
20778                            try {
20779                                    session = openSession();
20780    
20781                                    Query q = session.createQuery(sql);
20782    
20783                                    QueryPos qPos = QueryPos.getInstance(q);
20784    
20785                                    if (uuid != null) {
20786                                            qPos.add(uuid);
20787                                    }
20788    
20789                                    qPos.add(companyId);
20790    
20791                                    count = (Long)q.uniqueResult();
20792                            }
20793                            catch (Exception e) {
20794                                    throw processException(e);
20795                            }
20796                            finally {
20797                                    if (count == null) {
20798                                            count = Long.valueOf(0);
20799                                    }
20800    
20801                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
20802                                            finderArgs, count);
20803    
20804                                    closeSession(session);
20805                            }
20806                    }
20807    
20808                    return count.intValue();
20809            }
20810    
20811            /**
20812             * Returns the number of journal articles where resourcePrimKey = &#63;.
20813             *
20814             * @param resourcePrimKey the resource prim key
20815             * @return the number of matching journal articles
20816             * @throws SystemException if a system exception occurred
20817             */
20818            public int countByResourcePrimKey(long resourcePrimKey)
20819                    throws SystemException {
20820                    Object[] finderArgs = new Object[] { resourcePrimKey };
20821    
20822                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
20823                                    finderArgs, this);
20824    
20825                    if (count == null) {
20826                            StringBundler query = new StringBundler(2);
20827    
20828                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20829    
20830                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
20831    
20832                            String sql = query.toString();
20833    
20834                            Session session = null;
20835    
20836                            try {
20837                                    session = openSession();
20838    
20839                                    Query q = session.createQuery(sql);
20840    
20841                                    QueryPos qPos = QueryPos.getInstance(q);
20842    
20843                                    qPos.add(resourcePrimKey);
20844    
20845                                    count = (Long)q.uniqueResult();
20846                            }
20847                            catch (Exception e) {
20848                                    throw processException(e);
20849                            }
20850                            finally {
20851                                    if (count == null) {
20852                                            count = Long.valueOf(0);
20853                                    }
20854    
20855                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
20856                                            finderArgs, count);
20857    
20858                                    closeSession(session);
20859                            }
20860                    }
20861    
20862                    return count.intValue();
20863            }
20864    
20865            /**
20866             * Returns the number of journal articles where groupId = &#63;.
20867             *
20868             * @param groupId the group ID
20869             * @return the number of matching journal articles
20870             * @throws SystemException if a system exception occurred
20871             */
20872            public int countByGroupId(long groupId) throws SystemException {
20873                    Object[] finderArgs = new Object[] { groupId };
20874    
20875                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
20876                                    finderArgs, this);
20877    
20878                    if (count == null) {
20879                            StringBundler query = new StringBundler(2);
20880    
20881                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20882    
20883                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
20884    
20885                            String sql = query.toString();
20886    
20887                            Session session = null;
20888    
20889                            try {
20890                                    session = openSession();
20891    
20892                                    Query q = session.createQuery(sql);
20893    
20894                                    QueryPos qPos = QueryPos.getInstance(q);
20895    
20896                                    qPos.add(groupId);
20897    
20898                                    count = (Long)q.uniqueResult();
20899                            }
20900                            catch (Exception e) {
20901                                    throw processException(e);
20902                            }
20903                            finally {
20904                                    if (count == null) {
20905                                            count = Long.valueOf(0);
20906                                    }
20907    
20908                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
20909                                            finderArgs, count);
20910    
20911                                    closeSession(session);
20912                            }
20913                    }
20914    
20915                    return count.intValue();
20916            }
20917    
20918            /**
20919             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
20920             *
20921             * @param groupId the group ID
20922             * @return the number of matching journal articles that the user has permission to view
20923             * @throws SystemException if a system exception occurred
20924             */
20925            public int filterCountByGroupId(long groupId) throws SystemException {
20926                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
20927                            return countByGroupId(groupId);
20928                    }
20929    
20930                    StringBundler query = new StringBundler(2);
20931    
20932                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
20933    
20934                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
20935    
20936                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
20937                                    JournalArticle.class.getName(),
20938                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
20939    
20940                    Session session = null;
20941    
20942                    try {
20943                            session = openSession();
20944    
20945                            SQLQuery q = session.createSQLQuery(sql);
20946    
20947                            q.addScalar(COUNT_COLUMN_NAME,
20948                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
20949    
20950                            QueryPos qPos = QueryPos.getInstance(q);
20951    
20952                            qPos.add(groupId);
20953    
20954                            Long count = (Long)q.uniqueResult();
20955    
20956                            return count.intValue();
20957                    }
20958                    catch (Exception e) {
20959                            throw processException(e);
20960                    }
20961                    finally {
20962                            closeSession(session);
20963                    }
20964            }
20965    
20966            /**
20967             * Returns the number of journal articles where companyId = &#63;.
20968             *
20969             * @param companyId the company ID
20970             * @return the number of matching journal articles
20971             * @throws SystemException if a system exception occurred
20972             */
20973            public int countByCompanyId(long companyId) throws SystemException {
20974                    Object[] finderArgs = new Object[] { companyId };
20975    
20976                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
20977                                    finderArgs, this);
20978    
20979                    if (count == null) {
20980                            StringBundler query = new StringBundler(2);
20981    
20982                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
20983    
20984                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
20985    
20986                            String sql = query.toString();
20987    
20988                            Session session = null;
20989    
20990                            try {
20991                                    session = openSession();
20992    
20993                                    Query q = session.createQuery(sql);
20994    
20995                                    QueryPos qPos = QueryPos.getInstance(q);
20996    
20997                                    qPos.add(companyId);
20998    
20999                                    count = (Long)q.uniqueResult();
21000                            }
21001                            catch (Exception e) {
21002                                    throw processException(e);
21003                            }
21004                            finally {
21005                                    if (count == null) {
21006                                            count = Long.valueOf(0);
21007                                    }
21008    
21009                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
21010                                            finderArgs, count);
21011    
21012                                    closeSession(session);
21013                            }
21014                    }
21015    
21016                    return count.intValue();
21017            }
21018    
21019            /**
21020             * Returns the number of journal articles where structureId = &#63;.
21021             *
21022             * @param structureId the structure ID
21023             * @return the number of matching journal articles
21024             * @throws SystemException if a system exception occurred
21025             */
21026            public int countByStructureId(String structureId) throws SystemException {
21027                    Object[] finderArgs = new Object[] { structureId };
21028    
21029                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
21030                                    finderArgs, this);
21031    
21032                    if (count == null) {
21033                            StringBundler query = new StringBundler(2);
21034    
21035                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21036    
21037                            if (structureId == null) {
21038                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
21039                            }
21040                            else {
21041                                    if (structureId.equals(StringPool.BLANK)) {
21042                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
21043                                    }
21044                                    else {
21045                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
21046                                    }
21047                            }
21048    
21049                            String sql = query.toString();
21050    
21051                            Session session = null;
21052    
21053                            try {
21054                                    session = openSession();
21055    
21056                                    Query q = session.createQuery(sql);
21057    
21058                                    QueryPos qPos = QueryPos.getInstance(q);
21059    
21060                                    if (structureId != null) {
21061                                            qPos.add(structureId);
21062                                    }
21063    
21064                                    count = (Long)q.uniqueResult();
21065                            }
21066                            catch (Exception e) {
21067                                    throw processException(e);
21068                            }
21069                            finally {
21070                                    if (count == null) {
21071                                            count = Long.valueOf(0);
21072                                    }
21073    
21074                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
21075                                            finderArgs, count);
21076    
21077                                    closeSession(session);
21078                            }
21079                    }
21080    
21081                    return count.intValue();
21082            }
21083    
21084            /**
21085             * Returns the number of journal articles where templateId = &#63;.
21086             *
21087             * @param templateId the template ID
21088             * @return the number of matching journal articles
21089             * @throws SystemException if a system exception occurred
21090             */
21091            public int countByTemplateId(String templateId) throws SystemException {
21092                    Object[] finderArgs = new Object[] { templateId };
21093    
21094                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
21095                                    finderArgs, this);
21096    
21097                    if (count == null) {
21098                            StringBundler query = new StringBundler(2);
21099    
21100                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21101    
21102                            if (templateId == null) {
21103                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
21104                            }
21105                            else {
21106                                    if (templateId.equals(StringPool.BLANK)) {
21107                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
21108                                    }
21109                                    else {
21110                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
21111                                    }
21112                            }
21113    
21114                            String sql = query.toString();
21115    
21116                            Session session = null;
21117    
21118                            try {
21119                                    session = openSession();
21120    
21121                                    Query q = session.createQuery(sql);
21122    
21123                                    QueryPos qPos = QueryPos.getInstance(q);
21124    
21125                                    if (templateId != null) {
21126                                            qPos.add(templateId);
21127                                    }
21128    
21129                                    count = (Long)q.uniqueResult();
21130                            }
21131                            catch (Exception e) {
21132                                    throw processException(e);
21133                            }
21134                            finally {
21135                                    if (count == null) {
21136                                            count = Long.valueOf(0);
21137                                    }
21138    
21139                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
21140                                            finderArgs, count);
21141    
21142                                    closeSession(session);
21143                            }
21144                    }
21145    
21146                    return count.intValue();
21147            }
21148    
21149            /**
21150             * Returns the number of journal articles where layoutUuid = &#63;.
21151             *
21152             * @param layoutUuid the layout uuid
21153             * @return the number of matching journal articles
21154             * @throws SystemException if a system exception occurred
21155             */
21156            public int countByLayoutUuid(String layoutUuid) throws SystemException {
21157                    Object[] finderArgs = new Object[] { layoutUuid };
21158    
21159                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
21160                                    finderArgs, this);
21161    
21162                    if (count == null) {
21163                            StringBundler query = new StringBundler(2);
21164    
21165                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21166    
21167                            if (layoutUuid == null) {
21168                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
21169                            }
21170                            else {
21171                                    if (layoutUuid.equals(StringPool.BLANK)) {
21172                                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
21173                                    }
21174                                    else {
21175                                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
21176                                    }
21177                            }
21178    
21179                            String sql = query.toString();
21180    
21181                            Session session = null;
21182    
21183                            try {
21184                                    session = openSession();
21185    
21186                                    Query q = session.createQuery(sql);
21187    
21188                                    QueryPos qPos = QueryPos.getInstance(q);
21189    
21190                                    if (layoutUuid != null) {
21191                                            qPos.add(layoutUuid);
21192                                    }
21193    
21194                                    count = (Long)q.uniqueResult();
21195                            }
21196                            catch (Exception e) {
21197                                    throw processException(e);
21198                            }
21199                            finally {
21200                                    if (count == null) {
21201                                            count = Long.valueOf(0);
21202                                    }
21203    
21204                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LAYOUTUUID,
21205                                            finderArgs, count);
21206    
21207                                    closeSession(session);
21208                            }
21209                    }
21210    
21211                    return count.intValue();
21212            }
21213    
21214            /**
21215             * Returns the number of journal articles where smallImageId = &#63;.
21216             *
21217             * @param smallImageId the small image ID
21218             * @return the number of matching journal articles
21219             * @throws SystemException if a system exception occurred
21220             */
21221            public int countBySmallImageId(long smallImageId) throws SystemException {
21222                    Object[] finderArgs = new Object[] { smallImageId };
21223    
21224                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
21225                                    finderArgs, this);
21226    
21227                    if (count == null) {
21228                            StringBundler query = new StringBundler(2);
21229    
21230                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21231    
21232                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
21233    
21234                            String sql = query.toString();
21235    
21236                            Session session = null;
21237    
21238                            try {
21239                                    session = openSession();
21240    
21241                                    Query q = session.createQuery(sql);
21242    
21243                                    QueryPos qPos = QueryPos.getInstance(q);
21244    
21245                                    qPos.add(smallImageId);
21246    
21247                                    count = (Long)q.uniqueResult();
21248                            }
21249                            catch (Exception e) {
21250                                    throw processException(e);
21251                            }
21252                            finally {
21253                                    if (count == null) {
21254                                            count = Long.valueOf(0);
21255                                    }
21256    
21257                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
21258                                            finderArgs, count);
21259    
21260                                    closeSession(session);
21261                            }
21262                    }
21263    
21264                    return count.intValue();
21265            }
21266    
21267            /**
21268             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
21269             *
21270             * @param resourcePrimKey the resource prim key
21271             * @param status the status
21272             * @return the number of matching journal articles
21273             * @throws SystemException if a system exception occurred
21274             */
21275            public int countByR_ST(long resourcePrimKey, int status)
21276                    throws SystemException {
21277                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
21278    
21279                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_ST,
21280                                    finderArgs, this);
21281    
21282                    if (count == null) {
21283                            StringBundler query = new StringBundler(3);
21284    
21285                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21286    
21287                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
21288    
21289                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
21290    
21291                            String sql = query.toString();
21292    
21293                            Session session = null;
21294    
21295                            try {
21296                                    session = openSession();
21297    
21298                                    Query q = session.createQuery(sql);
21299    
21300                                    QueryPos qPos = QueryPos.getInstance(q);
21301    
21302                                    qPos.add(resourcePrimKey);
21303    
21304                                    qPos.add(status);
21305    
21306                                    count = (Long)q.uniqueResult();
21307                            }
21308                            catch (Exception e) {
21309                                    throw processException(e);
21310                            }
21311                            finally {
21312                                    if (count == null) {
21313                                            count = Long.valueOf(0);
21314                                    }
21315    
21316                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_ST,
21317                                            finderArgs, count);
21318    
21319                                    closeSession(session);
21320                            }
21321                    }
21322    
21323                    return count.intValue();
21324            }
21325    
21326            /**
21327             * Returns the number of journal articles where groupId = &#63; and userId = &#63;.
21328             *
21329             * @param groupId the group ID
21330             * @param userId the user ID
21331             * @return the number of matching journal articles
21332             * @throws SystemException if a system exception occurred
21333             */
21334            public int countByG_U(long groupId, long userId) throws SystemException {
21335                    Object[] finderArgs = new Object[] { groupId, userId };
21336    
21337                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
21338                                    finderArgs, this);
21339    
21340                    if (count == null) {
21341                            StringBundler query = new StringBundler(3);
21342    
21343                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21344    
21345                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
21346    
21347                            query.append(_FINDER_COLUMN_G_U_USERID_2);
21348    
21349                            String sql = query.toString();
21350    
21351                            Session session = null;
21352    
21353                            try {
21354                                    session = openSession();
21355    
21356                                    Query q = session.createQuery(sql);
21357    
21358                                    QueryPos qPos = QueryPos.getInstance(q);
21359    
21360                                    qPos.add(groupId);
21361    
21362                                    qPos.add(userId);
21363    
21364                                    count = (Long)q.uniqueResult();
21365                            }
21366                            catch (Exception e) {
21367                                    throw processException(e);
21368                            }
21369                            finally {
21370                                    if (count == null) {
21371                                            count = Long.valueOf(0);
21372                                    }
21373    
21374                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
21375                                            count);
21376    
21377                                    closeSession(session);
21378                            }
21379                    }
21380    
21381                    return count.intValue();
21382            }
21383    
21384            /**
21385             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and userId = &#63;.
21386             *
21387             * @param groupId the group ID
21388             * @param userId the user ID
21389             * @return the number of matching journal articles that the user has permission to view
21390             * @throws SystemException if a system exception occurred
21391             */
21392            public int filterCountByG_U(long groupId, long userId)
21393                    throws SystemException {
21394                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21395                            return countByG_U(groupId, userId);
21396                    }
21397    
21398                    StringBundler query = new StringBundler(3);
21399    
21400                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21401    
21402                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
21403    
21404                    query.append(_FINDER_COLUMN_G_U_USERID_2);
21405    
21406                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21407                                    JournalArticle.class.getName(),
21408                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21409    
21410                    Session session = null;
21411    
21412                    try {
21413                            session = openSession();
21414    
21415                            SQLQuery q = session.createSQLQuery(sql);
21416    
21417                            q.addScalar(COUNT_COLUMN_NAME,
21418                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21419    
21420                            QueryPos qPos = QueryPos.getInstance(q);
21421    
21422                            qPos.add(groupId);
21423    
21424                            qPos.add(userId);
21425    
21426                            Long count = (Long)q.uniqueResult();
21427    
21428                            return count.intValue();
21429                    }
21430                    catch (Exception e) {
21431                            throw processException(e);
21432                    }
21433                    finally {
21434                            closeSession(session);
21435                    }
21436            }
21437    
21438            /**
21439             * Returns the number of journal articles where groupId = &#63; and folderId = &#63;.
21440             *
21441             * @param groupId the group ID
21442             * @param folderId the folder ID
21443             * @return the number of matching journal articles
21444             * @throws SystemException if a system exception occurred
21445             */
21446            public int countByG_F(long groupId, long folderId)
21447                    throws SystemException {
21448                    Object[] finderArgs = new Object[] { groupId, folderId };
21449    
21450                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
21451                                    finderArgs, this);
21452    
21453                    if (count == null) {
21454                            StringBundler query = new StringBundler(3);
21455    
21456                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21457    
21458                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
21459    
21460                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
21461    
21462                            String sql = query.toString();
21463    
21464                            Session session = null;
21465    
21466                            try {
21467                                    session = openSession();
21468    
21469                                    Query q = session.createQuery(sql);
21470    
21471                                    QueryPos qPos = QueryPos.getInstance(q);
21472    
21473                                    qPos.add(groupId);
21474    
21475                                    qPos.add(folderId);
21476    
21477                                    count = (Long)q.uniqueResult();
21478                            }
21479                            catch (Exception e) {
21480                                    throw processException(e);
21481                            }
21482                            finally {
21483                                    if (count == null) {
21484                                            count = Long.valueOf(0);
21485                                    }
21486    
21487                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
21488                                            count);
21489    
21490                                    closeSession(session);
21491                            }
21492                    }
21493    
21494                    return count.intValue();
21495            }
21496    
21497            /**
21498             * Returns the number of journal articles where groupId = &#63; and folderId = any &#63;.
21499             *
21500             * @param groupId the group ID
21501             * @param folderIds the folder IDs
21502             * @return the number of matching journal articles
21503             * @throws SystemException if a system exception occurred
21504             */
21505            public int countByG_F(long groupId, long[] folderIds)
21506                    throws SystemException {
21507                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
21508    
21509                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
21510                                    finderArgs, this);
21511    
21512                    if (count == null) {
21513                            StringBundler query = new StringBundler();
21514    
21515                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21516    
21517                            boolean conjunctionable = false;
21518    
21519                            if (conjunctionable) {
21520                                    query.append(WHERE_AND);
21521                            }
21522    
21523                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
21524    
21525                            conjunctionable = true;
21526    
21527                            if ((folderIds == null) || (folderIds.length > 0)) {
21528                                    if (conjunctionable) {
21529                                            query.append(WHERE_AND);
21530                                    }
21531    
21532                                    query.append(StringPool.OPEN_PARENTHESIS);
21533    
21534                                    for (int i = 0; i < folderIds.length; i++) {
21535                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
21536    
21537                                            if ((i + 1) < folderIds.length) {
21538                                                    query.append(WHERE_OR);
21539                                            }
21540                                    }
21541    
21542                                    query.append(StringPool.CLOSE_PARENTHESIS);
21543    
21544                                    conjunctionable = true;
21545                            }
21546    
21547                            String sql = query.toString();
21548    
21549                            Session session = null;
21550    
21551                            try {
21552                                    session = openSession();
21553    
21554                                    Query q = session.createQuery(sql);
21555    
21556                                    QueryPos qPos = QueryPos.getInstance(q);
21557    
21558                                    qPos.add(groupId);
21559    
21560                                    if (folderIds != null) {
21561                                            qPos.add(folderIds);
21562                                    }
21563    
21564                                    count = (Long)q.uniqueResult();
21565                            }
21566                            catch (Exception e) {
21567                                    throw processException(e);
21568                            }
21569                            finally {
21570                                    if (count == null) {
21571                                            count = Long.valueOf(0);
21572                                    }
21573    
21574                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
21575                                            finderArgs, count);
21576    
21577                                    closeSession(session);
21578                            }
21579                    }
21580    
21581                    return count.intValue();
21582            }
21583    
21584            /**
21585             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63;.
21586             *
21587             * @param groupId the group ID
21588             * @param folderId the folder ID
21589             * @return the number of matching journal articles that the user has permission to view
21590             * @throws SystemException if a system exception occurred
21591             */
21592            public int filterCountByG_F(long groupId, long folderId)
21593                    throws SystemException {
21594                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21595                            return countByG_F(groupId, folderId);
21596                    }
21597    
21598                    StringBundler query = new StringBundler(3);
21599    
21600                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21601    
21602                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
21603    
21604                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
21605    
21606                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21607                                    JournalArticle.class.getName(),
21608                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21609    
21610                    Session session = null;
21611    
21612                    try {
21613                            session = openSession();
21614    
21615                            SQLQuery q = session.createSQLQuery(sql);
21616    
21617                            q.addScalar(COUNT_COLUMN_NAME,
21618                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21619    
21620                            QueryPos qPos = QueryPos.getInstance(q);
21621    
21622                            qPos.add(groupId);
21623    
21624                            qPos.add(folderId);
21625    
21626                            Long count = (Long)q.uniqueResult();
21627    
21628                            return count.intValue();
21629                    }
21630                    catch (Exception e) {
21631                            throw processException(e);
21632                    }
21633                    finally {
21634                            closeSession(session);
21635                    }
21636            }
21637    
21638            /**
21639             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = any &#63;.
21640             *
21641             * @param groupId the group ID
21642             * @param folderIds the folder IDs
21643             * @return the number of matching journal articles that the user has permission to view
21644             * @throws SystemException if a system exception occurred
21645             */
21646            public int filterCountByG_F(long groupId, long[] folderIds)
21647                    throws SystemException {
21648                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21649                            return countByG_F(groupId, folderIds);
21650                    }
21651    
21652                    StringBundler query = new StringBundler();
21653    
21654                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21655    
21656                    boolean conjunctionable = false;
21657    
21658                    if (conjunctionable) {
21659                            query.append(WHERE_AND);
21660                    }
21661    
21662                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
21663    
21664                    conjunctionable = true;
21665    
21666                    if ((folderIds == null) || (folderIds.length > 0)) {
21667                            if (conjunctionable) {
21668                                    query.append(WHERE_AND);
21669                            }
21670    
21671                            query.append(StringPool.OPEN_PARENTHESIS);
21672    
21673                            for (int i = 0; i < folderIds.length; i++) {
21674                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
21675    
21676                                    if ((i + 1) < folderIds.length) {
21677                                            query.append(WHERE_OR);
21678                                    }
21679                            }
21680    
21681                            query.append(StringPool.CLOSE_PARENTHESIS);
21682    
21683                            conjunctionable = true;
21684                    }
21685    
21686                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21687                                    JournalArticle.class.getName(),
21688                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21689    
21690                    Session session = null;
21691    
21692                    try {
21693                            session = openSession();
21694    
21695                            SQLQuery q = session.createSQLQuery(sql);
21696    
21697                            q.addScalar(COUNT_COLUMN_NAME,
21698                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21699    
21700                            QueryPos qPos = QueryPos.getInstance(q);
21701    
21702                            qPos.add(groupId);
21703    
21704                            if (folderIds != null) {
21705                                    qPos.add(folderIds);
21706                            }
21707    
21708                            Long count = (Long)q.uniqueResult();
21709    
21710                            return count.intValue();
21711                    }
21712                    catch (Exception e) {
21713                            throw processException(e);
21714                    }
21715                    finally {
21716                            closeSession(session);
21717                    }
21718            }
21719    
21720            /**
21721             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
21722             *
21723             * @param groupId the group ID
21724             * @param articleId the article ID
21725             * @return the number of matching journal articles
21726             * @throws SystemException if a system exception occurred
21727             */
21728            public int countByG_A(long groupId, String articleId)
21729                    throws SystemException {
21730                    Object[] finderArgs = new Object[] { groupId, articleId };
21731    
21732                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
21733                                    finderArgs, this);
21734    
21735                    if (count == null) {
21736                            StringBundler query = new StringBundler(3);
21737    
21738                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21739    
21740                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
21741    
21742                            if (articleId == null) {
21743                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
21744                            }
21745                            else {
21746                                    if (articleId.equals(StringPool.BLANK)) {
21747                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
21748                                    }
21749                                    else {
21750                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
21751                                    }
21752                            }
21753    
21754                            String sql = query.toString();
21755    
21756                            Session session = null;
21757    
21758                            try {
21759                                    session = openSession();
21760    
21761                                    Query q = session.createQuery(sql);
21762    
21763                                    QueryPos qPos = QueryPos.getInstance(q);
21764    
21765                                    qPos.add(groupId);
21766    
21767                                    if (articleId != null) {
21768                                            qPos.add(articleId);
21769                                    }
21770    
21771                                    count = (Long)q.uniqueResult();
21772                            }
21773                            catch (Exception e) {
21774                                    throw processException(e);
21775                            }
21776                            finally {
21777                                    if (count == null) {
21778                                            count = Long.valueOf(0);
21779                                    }
21780    
21781                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
21782                                            count);
21783    
21784                                    closeSession(session);
21785                            }
21786                    }
21787    
21788                    return count.intValue();
21789            }
21790    
21791            /**
21792             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
21793             *
21794             * @param groupId the group ID
21795             * @param articleId the article ID
21796             * @return the number of matching journal articles that the user has permission to view
21797             * @throws SystemException if a system exception occurred
21798             */
21799            public int filterCountByG_A(long groupId, String articleId)
21800                    throws SystemException {
21801                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21802                            return countByG_A(groupId, articleId);
21803                    }
21804    
21805                    StringBundler query = new StringBundler(3);
21806    
21807                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21808    
21809                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
21810    
21811                    if (articleId == null) {
21812                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
21813                    }
21814                    else {
21815                            if (articleId.equals(StringPool.BLANK)) {
21816                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
21817                            }
21818                            else {
21819                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
21820                            }
21821                    }
21822    
21823                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21824                                    JournalArticle.class.getName(),
21825                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21826    
21827                    Session session = null;
21828    
21829                    try {
21830                            session = openSession();
21831    
21832                            SQLQuery q = session.createSQLQuery(sql);
21833    
21834                            q.addScalar(COUNT_COLUMN_NAME,
21835                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21836    
21837                            QueryPos qPos = QueryPos.getInstance(q);
21838    
21839                            qPos.add(groupId);
21840    
21841                            if (articleId != null) {
21842                                    qPos.add(articleId);
21843                            }
21844    
21845                            Long count = (Long)q.uniqueResult();
21846    
21847                            return count.intValue();
21848                    }
21849                    catch (Exception e) {
21850                            throw processException(e);
21851                    }
21852                    finally {
21853                            closeSession(session);
21854                    }
21855            }
21856    
21857            /**
21858             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
21859             *
21860             * @param groupId the group ID
21861             * @param urlTitle the url title
21862             * @return the number of matching journal articles
21863             * @throws SystemException if a system exception occurred
21864             */
21865            public int countByG_UT(long groupId, String urlTitle)
21866                    throws SystemException {
21867                    Object[] finderArgs = new Object[] { groupId, urlTitle };
21868    
21869                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT,
21870                                    finderArgs, this);
21871    
21872                    if (count == null) {
21873                            StringBundler query = new StringBundler(3);
21874    
21875                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
21876    
21877                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
21878    
21879                            if (urlTitle == null) {
21880                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
21881                            }
21882                            else {
21883                                    if (urlTitle.equals(StringPool.BLANK)) {
21884                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
21885                                    }
21886                                    else {
21887                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
21888                                    }
21889                            }
21890    
21891                            String sql = query.toString();
21892    
21893                            Session session = null;
21894    
21895                            try {
21896                                    session = openSession();
21897    
21898                                    Query q = session.createQuery(sql);
21899    
21900                                    QueryPos qPos = QueryPos.getInstance(q);
21901    
21902                                    qPos.add(groupId);
21903    
21904                                    if (urlTitle != null) {
21905                                            qPos.add(urlTitle);
21906                                    }
21907    
21908                                    count = (Long)q.uniqueResult();
21909                            }
21910                            catch (Exception e) {
21911                                    throw processException(e);
21912                            }
21913                            finally {
21914                                    if (count == null) {
21915                                            count = Long.valueOf(0);
21916                                    }
21917    
21918                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT,
21919                                            finderArgs, count);
21920    
21921                                    closeSession(session);
21922                            }
21923                    }
21924    
21925                    return count.intValue();
21926            }
21927    
21928            /**
21929             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
21930             *
21931             * @param groupId the group ID
21932             * @param urlTitle the url title
21933             * @return the number of matching journal articles that the user has permission to view
21934             * @throws SystemException if a system exception occurred
21935             */
21936            public int filterCountByG_UT(long groupId, String urlTitle)
21937                    throws SystemException {
21938                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
21939                            return countByG_UT(groupId, urlTitle);
21940                    }
21941    
21942                    StringBundler query = new StringBundler(3);
21943    
21944                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
21945    
21946                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
21947    
21948                    if (urlTitle == null) {
21949                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
21950                    }
21951                    else {
21952                            if (urlTitle.equals(StringPool.BLANK)) {
21953                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
21954                            }
21955                            else {
21956                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
21957                            }
21958                    }
21959    
21960                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
21961                                    JournalArticle.class.getName(),
21962                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
21963    
21964                    Session session = null;
21965    
21966                    try {
21967                            session = openSession();
21968    
21969                            SQLQuery q = session.createSQLQuery(sql);
21970    
21971                            q.addScalar(COUNT_COLUMN_NAME,
21972                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
21973    
21974                            QueryPos qPos = QueryPos.getInstance(q);
21975    
21976                            qPos.add(groupId);
21977    
21978                            if (urlTitle != null) {
21979                                    qPos.add(urlTitle);
21980                            }
21981    
21982                            Long count = (Long)q.uniqueResult();
21983    
21984                            return count.intValue();
21985                    }
21986                    catch (Exception e) {
21987                            throw processException(e);
21988                    }
21989                    finally {
21990                            closeSession(session);
21991                    }
21992            }
21993    
21994            /**
21995             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
21996             *
21997             * @param groupId the group ID
21998             * @param structureId the structure ID
21999             * @return the number of matching journal articles
22000             * @throws SystemException if a system exception occurred
22001             */
22002            public int countByG_S(long groupId, String structureId)
22003                    throws SystemException {
22004                    Object[] finderArgs = new Object[] { groupId, structureId };
22005    
22006                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
22007                                    finderArgs, this);
22008    
22009                    if (count == null) {
22010                            StringBundler query = new StringBundler(3);
22011    
22012                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22013    
22014                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
22015    
22016                            if (structureId == null) {
22017                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
22018                            }
22019                            else {
22020                                    if (structureId.equals(StringPool.BLANK)) {
22021                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
22022                                    }
22023                                    else {
22024                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
22025                                    }
22026                            }
22027    
22028                            String sql = query.toString();
22029    
22030                            Session session = null;
22031    
22032                            try {
22033                                    session = openSession();
22034    
22035                                    Query q = session.createQuery(sql);
22036    
22037                                    QueryPos qPos = QueryPos.getInstance(q);
22038    
22039                                    qPos.add(groupId);
22040    
22041                                    if (structureId != null) {
22042                                            qPos.add(structureId);
22043                                    }
22044    
22045                                    count = (Long)q.uniqueResult();
22046                            }
22047                            catch (Exception e) {
22048                                    throw processException(e);
22049                            }
22050                            finally {
22051                                    if (count == null) {
22052                                            count = Long.valueOf(0);
22053                                    }
22054    
22055                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
22056                                            count);
22057    
22058                                    closeSession(session);
22059                            }
22060                    }
22061    
22062                    return count.intValue();
22063            }
22064    
22065            /**
22066             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
22067             *
22068             * @param groupId the group ID
22069             * @param structureId the structure ID
22070             * @return the number of matching journal articles that the user has permission to view
22071             * @throws SystemException if a system exception occurred
22072             */
22073            public int filterCountByG_S(long groupId, String structureId)
22074                    throws SystemException {
22075                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22076                            return countByG_S(groupId, structureId);
22077                    }
22078    
22079                    StringBundler query = new StringBundler(3);
22080    
22081                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22082    
22083                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
22084    
22085                    if (structureId == null) {
22086                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
22087                    }
22088                    else {
22089                            if (structureId.equals(StringPool.BLANK)) {
22090                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
22091                            }
22092                            else {
22093                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
22094                            }
22095                    }
22096    
22097                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22098                                    JournalArticle.class.getName(),
22099                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22100    
22101                    Session session = null;
22102    
22103                    try {
22104                            session = openSession();
22105    
22106                            SQLQuery q = session.createSQLQuery(sql);
22107    
22108                            q.addScalar(COUNT_COLUMN_NAME,
22109                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22110    
22111                            QueryPos qPos = QueryPos.getInstance(q);
22112    
22113                            qPos.add(groupId);
22114    
22115                            if (structureId != null) {
22116                                    qPos.add(structureId);
22117                            }
22118    
22119                            Long count = (Long)q.uniqueResult();
22120    
22121                            return count.intValue();
22122                    }
22123                    catch (Exception e) {
22124                            throw processException(e);
22125                    }
22126                    finally {
22127                            closeSession(session);
22128                    }
22129            }
22130    
22131            /**
22132             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
22133             *
22134             * @param groupId the group ID
22135             * @param templateId the template ID
22136             * @return the number of matching journal articles
22137             * @throws SystemException if a system exception occurred
22138             */
22139            public int countByG_T(long groupId, String templateId)
22140                    throws SystemException {
22141                    Object[] finderArgs = new Object[] { groupId, templateId };
22142    
22143                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T,
22144                                    finderArgs, this);
22145    
22146                    if (count == null) {
22147                            StringBundler query = new StringBundler(3);
22148    
22149                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22150    
22151                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
22152    
22153                            if (templateId == null) {
22154                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
22155                            }
22156                            else {
22157                                    if (templateId.equals(StringPool.BLANK)) {
22158                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
22159                                    }
22160                                    else {
22161                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
22162                                    }
22163                            }
22164    
22165                            String sql = query.toString();
22166    
22167                            Session session = null;
22168    
22169                            try {
22170                                    session = openSession();
22171    
22172                                    Query q = session.createQuery(sql);
22173    
22174                                    QueryPos qPos = QueryPos.getInstance(q);
22175    
22176                                    qPos.add(groupId);
22177    
22178                                    if (templateId != null) {
22179                                            qPos.add(templateId);
22180                                    }
22181    
22182                                    count = (Long)q.uniqueResult();
22183                            }
22184                            catch (Exception e) {
22185                                    throw processException(e);
22186                            }
22187                            finally {
22188                                    if (count == null) {
22189                                            count = Long.valueOf(0);
22190                                    }
22191    
22192                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_T, finderArgs,
22193                                            count);
22194    
22195                                    closeSession(session);
22196                            }
22197                    }
22198    
22199                    return count.intValue();
22200            }
22201    
22202            /**
22203             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
22204             *
22205             * @param groupId the group ID
22206             * @param templateId the template ID
22207             * @return the number of matching journal articles that the user has permission to view
22208             * @throws SystemException if a system exception occurred
22209             */
22210            public int filterCountByG_T(long groupId, String templateId)
22211                    throws SystemException {
22212                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22213                            return countByG_T(groupId, templateId);
22214                    }
22215    
22216                    StringBundler query = new StringBundler(3);
22217    
22218                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22219    
22220                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
22221    
22222                    if (templateId == null) {
22223                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
22224                    }
22225                    else {
22226                            if (templateId.equals(StringPool.BLANK)) {
22227                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
22228                            }
22229                            else {
22230                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
22231                            }
22232                    }
22233    
22234                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22235                                    JournalArticle.class.getName(),
22236                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22237    
22238                    Session session = null;
22239    
22240                    try {
22241                            session = openSession();
22242    
22243                            SQLQuery q = session.createSQLQuery(sql);
22244    
22245                            q.addScalar(COUNT_COLUMN_NAME,
22246                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22247    
22248                            QueryPos qPos = QueryPos.getInstance(q);
22249    
22250                            qPos.add(groupId);
22251    
22252                            if (templateId != null) {
22253                                    qPos.add(templateId);
22254                            }
22255    
22256                            Long count = (Long)q.uniqueResult();
22257    
22258                            return count.intValue();
22259                    }
22260                    catch (Exception e) {
22261                            throw processException(e);
22262                    }
22263                    finally {
22264                            closeSession(session);
22265                    }
22266            }
22267    
22268            /**
22269             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
22270             *
22271             * @param groupId the group ID
22272             * @param layoutUuid the layout uuid
22273             * @return the number of matching journal articles
22274             * @throws SystemException if a system exception occurred
22275             */
22276            public int countByG_L(long groupId, String layoutUuid)
22277                    throws SystemException {
22278                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
22279    
22280                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_L,
22281                                    finderArgs, this);
22282    
22283                    if (count == null) {
22284                            StringBundler query = new StringBundler(3);
22285    
22286                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22287    
22288                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
22289    
22290                            if (layoutUuid == null) {
22291                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
22292                            }
22293                            else {
22294                                    if (layoutUuid.equals(StringPool.BLANK)) {
22295                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
22296                                    }
22297                                    else {
22298                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
22299                                    }
22300                            }
22301    
22302                            String sql = query.toString();
22303    
22304                            Session session = null;
22305    
22306                            try {
22307                                    session = openSession();
22308    
22309                                    Query q = session.createQuery(sql);
22310    
22311                                    QueryPos qPos = QueryPos.getInstance(q);
22312    
22313                                    qPos.add(groupId);
22314    
22315                                    if (layoutUuid != null) {
22316                                            qPos.add(layoutUuid);
22317                                    }
22318    
22319                                    count = (Long)q.uniqueResult();
22320                            }
22321                            catch (Exception e) {
22322                                    throw processException(e);
22323                            }
22324                            finally {
22325                                    if (count == null) {
22326                                            count = Long.valueOf(0);
22327                                    }
22328    
22329                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_L, finderArgs,
22330                                            count);
22331    
22332                                    closeSession(session);
22333                            }
22334                    }
22335    
22336                    return count.intValue();
22337            }
22338    
22339            /**
22340             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
22341             *
22342             * @param groupId the group ID
22343             * @param layoutUuid the layout uuid
22344             * @return the number of matching journal articles that the user has permission to view
22345             * @throws SystemException if a system exception occurred
22346             */
22347            public int filterCountByG_L(long groupId, String layoutUuid)
22348                    throws SystemException {
22349                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22350                            return countByG_L(groupId, layoutUuid);
22351                    }
22352    
22353                    StringBundler query = new StringBundler(3);
22354    
22355                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22356    
22357                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
22358    
22359                    if (layoutUuid == null) {
22360                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
22361                    }
22362                    else {
22363                            if (layoutUuid.equals(StringPool.BLANK)) {
22364                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
22365                            }
22366                            else {
22367                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
22368                            }
22369                    }
22370    
22371                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22372                                    JournalArticle.class.getName(),
22373                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22374    
22375                    Session session = null;
22376    
22377                    try {
22378                            session = openSession();
22379    
22380                            SQLQuery q = session.createSQLQuery(sql);
22381    
22382                            q.addScalar(COUNT_COLUMN_NAME,
22383                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22384    
22385                            QueryPos qPos = QueryPos.getInstance(q);
22386    
22387                            qPos.add(groupId);
22388    
22389                            if (layoutUuid != null) {
22390                                    qPos.add(layoutUuid);
22391                            }
22392    
22393                            Long count = (Long)q.uniqueResult();
22394    
22395                            return count.intValue();
22396                    }
22397                    catch (Exception e) {
22398                            throw processException(e);
22399                    }
22400                    finally {
22401                            closeSession(session);
22402                    }
22403            }
22404    
22405            /**
22406             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
22407             *
22408             * @param groupId the group ID
22409             * @param status the status
22410             * @return the number of matching journal articles
22411             * @throws SystemException if a system exception occurred
22412             */
22413            public int countByG_ST(long groupId, int status) throws SystemException {
22414                    Object[] finderArgs = new Object[] { groupId, status };
22415    
22416                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_ST,
22417                                    finderArgs, this);
22418    
22419                    if (count == null) {
22420                            StringBundler query = new StringBundler(3);
22421    
22422                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22423    
22424                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
22425    
22426                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
22427    
22428                            String sql = query.toString();
22429    
22430                            Session session = null;
22431    
22432                            try {
22433                                    session = openSession();
22434    
22435                                    Query q = session.createQuery(sql);
22436    
22437                                    QueryPos qPos = QueryPos.getInstance(q);
22438    
22439                                    qPos.add(groupId);
22440    
22441                                    qPos.add(status);
22442    
22443                                    count = (Long)q.uniqueResult();
22444                            }
22445                            catch (Exception e) {
22446                                    throw processException(e);
22447                            }
22448                            finally {
22449                                    if (count == null) {
22450                                            count = Long.valueOf(0);
22451                                    }
22452    
22453                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_ST,
22454                                            finderArgs, count);
22455    
22456                                    closeSession(session);
22457                            }
22458                    }
22459    
22460                    return count.intValue();
22461            }
22462    
22463            /**
22464             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
22465             *
22466             * @param groupId the group ID
22467             * @param status the status
22468             * @return the number of matching journal articles that the user has permission to view
22469             * @throws SystemException if a system exception occurred
22470             */
22471            public int filterCountByG_ST(long groupId, int status)
22472                    throws SystemException {
22473                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22474                            return countByG_ST(groupId, status);
22475                    }
22476    
22477                    StringBundler query = new StringBundler(3);
22478    
22479                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22480    
22481                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
22482    
22483                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
22484    
22485                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22486                                    JournalArticle.class.getName(),
22487                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22488    
22489                    Session session = null;
22490    
22491                    try {
22492                            session = openSession();
22493    
22494                            SQLQuery q = session.createSQLQuery(sql);
22495    
22496                            q.addScalar(COUNT_COLUMN_NAME,
22497                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22498    
22499                            QueryPos qPos = QueryPos.getInstance(q);
22500    
22501                            qPos.add(groupId);
22502    
22503                            qPos.add(status);
22504    
22505                            Long count = (Long)q.uniqueResult();
22506    
22507                            return count.intValue();
22508                    }
22509                    catch (Exception e) {
22510                            throw processException(e);
22511                    }
22512                    finally {
22513                            closeSession(session);
22514                    }
22515            }
22516    
22517            /**
22518             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
22519             *
22520             * @param companyId the company ID
22521             * @param version the version
22522             * @return the number of matching journal articles
22523             * @throws SystemException if a system exception occurred
22524             */
22525            public int countByC_V(long companyId, double version)
22526                    throws SystemException {
22527                    Object[] finderArgs = new Object[] { companyId, version };
22528    
22529                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V,
22530                                    finderArgs, this);
22531    
22532                    if (count == null) {
22533                            StringBundler query = new StringBundler(3);
22534    
22535                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22536    
22537                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
22538    
22539                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
22540    
22541                            String sql = query.toString();
22542    
22543                            Session session = null;
22544    
22545                            try {
22546                                    session = openSession();
22547    
22548                                    Query q = session.createQuery(sql);
22549    
22550                                    QueryPos qPos = QueryPos.getInstance(q);
22551    
22552                                    qPos.add(companyId);
22553    
22554                                    qPos.add(version);
22555    
22556                                    count = (Long)q.uniqueResult();
22557                            }
22558                            catch (Exception e) {
22559                                    throw processException(e);
22560                            }
22561                            finally {
22562                                    if (count == null) {
22563                                            count = Long.valueOf(0);
22564                                    }
22565    
22566                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V, finderArgs,
22567                                            count);
22568    
22569                                    closeSession(session);
22570                            }
22571                    }
22572    
22573                    return count.intValue();
22574            }
22575    
22576            /**
22577             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
22578             *
22579             * @param companyId the company ID
22580             * @param status the status
22581             * @return the number of matching journal articles
22582             * @throws SystemException if a system exception occurred
22583             */
22584            public int countByC_ST(long companyId, int status)
22585                    throws SystemException {
22586                    Object[] finderArgs = new Object[] { companyId, status };
22587    
22588                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_ST,
22589                                    finderArgs, this);
22590    
22591                    if (count == null) {
22592                            StringBundler query = new StringBundler(3);
22593    
22594                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22595    
22596                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
22597    
22598                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
22599    
22600                            String sql = query.toString();
22601    
22602                            Session session = null;
22603    
22604                            try {
22605                                    session = openSession();
22606    
22607                                    Query q = session.createQuery(sql);
22608    
22609                                    QueryPos qPos = QueryPos.getInstance(q);
22610    
22611                                    qPos.add(companyId);
22612    
22613                                    qPos.add(status);
22614    
22615                                    count = (Long)q.uniqueResult();
22616                            }
22617                            catch (Exception e) {
22618                                    throw processException(e);
22619                            }
22620                            finally {
22621                                    if (count == null) {
22622                                            count = Long.valueOf(0);
22623                                    }
22624    
22625                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_ST,
22626                                            finderArgs, count);
22627    
22628                                    closeSession(session);
22629                            }
22630                    }
22631    
22632                    return count.intValue();
22633            }
22634    
22635            /**
22636             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = &#63;.
22637             *
22638             * @param groupId the group ID
22639             * @param folderId the folder ID
22640             * @param status the status
22641             * @return the number of matching journal articles
22642             * @throws SystemException if a system exception occurred
22643             */
22644            public int countByG_F_ST(long groupId, long folderId, int status)
22645                    throws SystemException {
22646                    Object[] finderArgs = new Object[] { groupId, folderId, status };
22647    
22648                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_ST,
22649                                    finderArgs, this);
22650    
22651                    if (count == null) {
22652                            StringBundler query = new StringBundler(4);
22653    
22654                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22655    
22656                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
22657    
22658                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
22659    
22660                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
22661    
22662                            String sql = query.toString();
22663    
22664                            Session session = null;
22665    
22666                            try {
22667                                    session = openSession();
22668    
22669                                    Query q = session.createQuery(sql);
22670    
22671                                    QueryPos qPos = QueryPos.getInstance(q);
22672    
22673                                    qPos.add(groupId);
22674    
22675                                    qPos.add(folderId);
22676    
22677                                    qPos.add(status);
22678    
22679                                    count = (Long)q.uniqueResult();
22680                            }
22681                            catch (Exception e) {
22682                                    throw processException(e);
22683                            }
22684                            finally {
22685                                    if (count == null) {
22686                                            count = Long.valueOf(0);
22687                                    }
22688    
22689                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_ST,
22690                                            finderArgs, count);
22691    
22692                                    closeSession(session);
22693                            }
22694                    }
22695    
22696                    return count.intValue();
22697            }
22698    
22699            /**
22700             * Returns the number of journal articles where groupId = &#63; and folderId = &#63; and status = any &#63;.
22701             *
22702             * @param groupId the group ID
22703             * @param folderId the folder ID
22704             * @param statuses the statuses
22705             * @return the number of matching journal articles
22706             * @throws SystemException if a system exception occurred
22707             */
22708            public int countByG_F_ST(long groupId, long folderId, int[] statuses)
22709                    throws SystemException {
22710                    Object[] finderArgs = new Object[] {
22711                                    groupId, folderId, StringUtil.merge(statuses)
22712                            };
22713    
22714                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
22715                                    finderArgs, this);
22716    
22717                    if (count == null) {
22718                            StringBundler query = new StringBundler();
22719    
22720                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22721    
22722                            boolean conjunctionable = false;
22723    
22724                            if (conjunctionable) {
22725                                    query.append(WHERE_AND);
22726                            }
22727    
22728                            query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
22729    
22730                            conjunctionable = true;
22731    
22732                            if (conjunctionable) {
22733                                    query.append(WHERE_AND);
22734                            }
22735    
22736                            query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
22737    
22738                            conjunctionable = true;
22739    
22740                            if ((statuses == null) || (statuses.length > 0)) {
22741                                    if (conjunctionable) {
22742                                            query.append(WHERE_AND);
22743                                    }
22744    
22745                                    query.append(StringPool.OPEN_PARENTHESIS);
22746    
22747                                    for (int i = 0; i < statuses.length; i++) {
22748                                            query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
22749    
22750                                            if ((i + 1) < statuses.length) {
22751                                                    query.append(WHERE_OR);
22752                                            }
22753                                    }
22754    
22755                                    query.append(StringPool.CLOSE_PARENTHESIS);
22756    
22757                                    conjunctionable = true;
22758                            }
22759    
22760                            String sql = query.toString();
22761    
22762                            Session session = null;
22763    
22764                            try {
22765                                    session = openSession();
22766    
22767                                    Query q = session.createQuery(sql);
22768    
22769                                    QueryPos qPos = QueryPos.getInstance(q);
22770    
22771                                    qPos.add(groupId);
22772    
22773                                    qPos.add(folderId);
22774    
22775                                    if (statuses != null) {
22776                                            qPos.add(statuses);
22777                                    }
22778    
22779                                    count = (Long)q.uniqueResult();
22780                            }
22781                            catch (Exception e) {
22782                                    throw processException(e);
22783                            }
22784                            finally {
22785                                    if (count == null) {
22786                                            count = Long.valueOf(0);
22787                                    }
22788    
22789                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_ST,
22790                                            finderArgs, count);
22791    
22792                                    closeSession(session);
22793                            }
22794                    }
22795    
22796                    return count.intValue();
22797            }
22798    
22799            /**
22800             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
22801             *
22802             * @param groupId the group ID
22803             * @param folderId the folder ID
22804             * @param status the status
22805             * @return the number of matching journal articles that the user has permission to view
22806             * @throws SystemException if a system exception occurred
22807             */
22808            public int filterCountByG_F_ST(long groupId, long folderId, int status)
22809                    throws SystemException {
22810                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22811                            return countByG_F_ST(groupId, folderId, status);
22812                    }
22813    
22814                    StringBundler query = new StringBundler(4);
22815    
22816                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22817    
22818                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_2);
22819    
22820                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_2);
22821    
22822                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_2);
22823    
22824                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22825                                    JournalArticle.class.getName(),
22826                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22827    
22828                    Session session = null;
22829    
22830                    try {
22831                            session = openSession();
22832    
22833                            SQLQuery q = session.createSQLQuery(sql);
22834    
22835                            q.addScalar(COUNT_COLUMN_NAME,
22836                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22837    
22838                            QueryPos qPos = QueryPos.getInstance(q);
22839    
22840                            qPos.add(groupId);
22841    
22842                            qPos.add(folderId);
22843    
22844                            qPos.add(status);
22845    
22846                            Long count = (Long)q.uniqueResult();
22847    
22848                            return count.intValue();
22849                    }
22850                    catch (Exception e) {
22851                            throw processException(e);
22852                    }
22853                    finally {
22854                            closeSession(session);
22855                    }
22856            }
22857    
22858            /**
22859             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and folderId = &#63; and status = any &#63;.
22860             *
22861             * @param groupId the group ID
22862             * @param folderId the folder ID
22863             * @param statuses the statuses
22864             * @return the number of matching journal articles that the user has permission to view
22865             * @throws SystemException if a system exception occurred
22866             */
22867            public int filterCountByG_F_ST(long groupId, long folderId, int[] statuses)
22868                    throws SystemException {
22869                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
22870                            return countByG_F_ST(groupId, folderId, statuses);
22871                    }
22872    
22873                    StringBundler query = new StringBundler();
22874    
22875                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
22876    
22877                    boolean conjunctionable = false;
22878    
22879                    if (conjunctionable) {
22880                            query.append(WHERE_AND);
22881                    }
22882    
22883                    query.append(_FINDER_COLUMN_G_F_ST_GROUPID_5);
22884    
22885                    conjunctionable = true;
22886    
22887                    if (conjunctionable) {
22888                            query.append(WHERE_AND);
22889                    }
22890    
22891                    query.append(_FINDER_COLUMN_G_F_ST_FOLDERID_5);
22892    
22893                    conjunctionable = true;
22894    
22895                    if ((statuses == null) || (statuses.length > 0)) {
22896                            if (conjunctionable) {
22897                                    query.append(WHERE_AND);
22898                            }
22899    
22900                            query.append(StringPool.OPEN_PARENTHESIS);
22901    
22902                            for (int i = 0; i < statuses.length; i++) {
22903                                    query.append(_FINDER_COLUMN_G_F_ST_STATUS_5);
22904    
22905                                    if ((i + 1) < statuses.length) {
22906                                            query.append(WHERE_OR);
22907                                    }
22908                            }
22909    
22910                            query.append(StringPool.CLOSE_PARENTHESIS);
22911    
22912                            conjunctionable = true;
22913                    }
22914    
22915                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
22916                                    JournalArticle.class.getName(),
22917                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
22918    
22919                    Session session = null;
22920    
22921                    try {
22922                            session = openSession();
22923    
22924                            SQLQuery q = session.createSQLQuery(sql);
22925    
22926                            q.addScalar(COUNT_COLUMN_NAME,
22927                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
22928    
22929                            QueryPos qPos = QueryPos.getInstance(q);
22930    
22931                            qPos.add(groupId);
22932    
22933                            qPos.add(folderId);
22934    
22935                            if (statuses != null) {
22936                                    qPos.add(statuses);
22937                            }
22938    
22939                            Long count = (Long)q.uniqueResult();
22940    
22941                            return count.intValue();
22942                    }
22943                    catch (Exception e) {
22944                            throw processException(e);
22945                    }
22946                    finally {
22947                            closeSession(session);
22948                    }
22949            }
22950    
22951            /**
22952             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
22953             *
22954             * @param groupId the group ID
22955             * @param classNameId the class name ID
22956             * @param classPK the class p k
22957             * @return the number of matching journal articles
22958             * @throws SystemException if a system exception occurred
22959             */
22960            public int countByG_C_C(long groupId, long classNameId, long classPK)
22961                    throws SystemException {
22962                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
22963    
22964                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C,
22965                                    finderArgs, this);
22966    
22967                    if (count == null) {
22968                            StringBundler query = new StringBundler(4);
22969    
22970                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
22971    
22972                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
22973    
22974                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
22975    
22976                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
22977    
22978                            String sql = query.toString();
22979    
22980                            Session session = null;
22981    
22982                            try {
22983                                    session = openSession();
22984    
22985                                    Query q = session.createQuery(sql);
22986    
22987                                    QueryPos qPos = QueryPos.getInstance(q);
22988    
22989                                    qPos.add(groupId);
22990    
22991                                    qPos.add(classNameId);
22992    
22993                                    qPos.add(classPK);
22994    
22995                                    count = (Long)q.uniqueResult();
22996                            }
22997                            catch (Exception e) {
22998                                    throw processException(e);
22999                            }
23000                            finally {
23001                                    if (count == null) {
23002                                            count = Long.valueOf(0);
23003                                    }
23004    
23005                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C,
23006                                            finderArgs, count);
23007    
23008                                    closeSession(session);
23009                            }
23010                    }
23011    
23012                    return count.intValue();
23013            }
23014    
23015            /**
23016             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
23017             *
23018             * @param groupId the group ID
23019             * @param classNameId the class name ID
23020             * @param classPK the class p k
23021             * @return the number of matching journal articles that the user has permission to view
23022             * @throws SystemException if a system exception occurred
23023             */
23024            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
23025                    throws SystemException {
23026                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23027                            return countByG_C_C(groupId, classNameId, classPK);
23028                    }
23029    
23030                    StringBundler query = new StringBundler(4);
23031    
23032                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23033    
23034                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
23035    
23036                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
23037    
23038                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
23039    
23040                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23041                                    JournalArticle.class.getName(),
23042                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23043    
23044                    Session session = null;
23045    
23046                    try {
23047                            session = openSession();
23048    
23049                            SQLQuery q = session.createSQLQuery(sql);
23050    
23051                            q.addScalar(COUNT_COLUMN_NAME,
23052                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23053    
23054                            QueryPos qPos = QueryPos.getInstance(q);
23055    
23056                            qPos.add(groupId);
23057    
23058                            qPos.add(classNameId);
23059    
23060                            qPos.add(classPK);
23061    
23062                            Long count = (Long)q.uniqueResult();
23063    
23064                            return count.intValue();
23065                    }
23066                    catch (Exception e) {
23067                            throw processException(e);
23068                    }
23069                    finally {
23070                            closeSession(session);
23071                    }
23072            }
23073    
23074            /**
23075             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
23076             *
23077             * @param groupId the group ID
23078             * @param classNameId the class name ID
23079             * @param structureId the structure ID
23080             * @return the number of matching journal articles
23081             * @throws SystemException if a system exception occurred
23082             */
23083            public int countByG_C_S(long groupId, long classNameId, String structureId)
23084                    throws SystemException {
23085                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
23086    
23087                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
23088                                    finderArgs, this);
23089    
23090                    if (count == null) {
23091                            StringBundler query = new StringBundler(4);
23092    
23093                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23094    
23095                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
23096    
23097                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
23098    
23099                            if (structureId == null) {
23100                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
23101                            }
23102                            else {
23103                                    if (structureId.equals(StringPool.BLANK)) {
23104                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
23105                                    }
23106                                    else {
23107                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
23108                                    }
23109                            }
23110    
23111                            String sql = query.toString();
23112    
23113                            Session session = null;
23114    
23115                            try {
23116                                    session = openSession();
23117    
23118                                    Query q = session.createQuery(sql);
23119    
23120                                    QueryPos qPos = QueryPos.getInstance(q);
23121    
23122                                    qPos.add(groupId);
23123    
23124                                    qPos.add(classNameId);
23125    
23126                                    if (structureId != null) {
23127                                            qPos.add(structureId);
23128                                    }
23129    
23130                                    count = (Long)q.uniqueResult();
23131                            }
23132                            catch (Exception e) {
23133                                    throw processException(e);
23134                            }
23135                            finally {
23136                                    if (count == null) {
23137                                            count = Long.valueOf(0);
23138                                    }
23139    
23140                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
23141                                            finderArgs, count);
23142    
23143                                    closeSession(session);
23144                            }
23145                    }
23146    
23147                    return count.intValue();
23148            }
23149    
23150            /**
23151             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23152             *
23153             * @param groupId the group ID
23154             * @param classNameId the class name ID
23155             * @param templateId the template ID
23156             * @return the number of matching journal articles
23157             * @throws SystemException if a system exception occurred
23158             */
23159            public int countByG_C_T(long groupId, long classNameId, String templateId)
23160                    throws SystemException {
23161                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
23162    
23163                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_T,
23164                                    finderArgs, this);
23165    
23166                    if (count == null) {
23167                            StringBundler query = new StringBundler(4);
23168    
23169                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23170    
23171                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23172    
23173                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23174    
23175                            if (templateId == null) {
23176                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23177                            }
23178                            else {
23179                                    if (templateId.equals(StringPool.BLANK)) {
23180                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23181                                    }
23182                                    else {
23183                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23184                                    }
23185                            }
23186    
23187                            String sql = query.toString();
23188    
23189                            Session session = null;
23190    
23191                            try {
23192                                    session = openSession();
23193    
23194                                    Query q = session.createQuery(sql);
23195    
23196                                    QueryPos qPos = QueryPos.getInstance(q);
23197    
23198                                    qPos.add(groupId);
23199    
23200                                    qPos.add(classNameId);
23201    
23202                                    if (templateId != null) {
23203                                            qPos.add(templateId);
23204                                    }
23205    
23206                                    count = (Long)q.uniqueResult();
23207                            }
23208                            catch (Exception e) {
23209                                    throw processException(e);
23210                            }
23211                            finally {
23212                                    if (count == null) {
23213                                            count = Long.valueOf(0);
23214                                    }
23215    
23216                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_T,
23217                                            finderArgs, count);
23218    
23219                                    closeSession(session);
23220                            }
23221                    }
23222    
23223                    return count.intValue();
23224            }
23225    
23226            /**
23227             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
23228             *
23229             * @param groupId the group ID
23230             * @param classNameId the class name ID
23231             * @param templateId the template ID
23232             * @return the number of matching journal articles that the user has permission to view
23233             * @throws SystemException if a system exception occurred
23234             */
23235            public int filterCountByG_C_T(long groupId, long classNameId,
23236                    String templateId) throws SystemException {
23237                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23238                            return countByG_C_T(groupId, classNameId, templateId);
23239                    }
23240    
23241                    StringBundler query = new StringBundler(4);
23242    
23243                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23244    
23245                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
23246    
23247                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
23248    
23249                    if (templateId == null) {
23250                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
23251                    }
23252                    else {
23253                            if (templateId.equals(StringPool.BLANK)) {
23254                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
23255                            }
23256                            else {
23257                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
23258                            }
23259                    }
23260    
23261                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23262                                    JournalArticle.class.getName(),
23263                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23264    
23265                    Session session = null;
23266    
23267                    try {
23268                            session = openSession();
23269    
23270                            SQLQuery q = session.createSQLQuery(sql);
23271    
23272                            q.addScalar(COUNT_COLUMN_NAME,
23273                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23274    
23275                            QueryPos qPos = QueryPos.getInstance(q);
23276    
23277                            qPos.add(groupId);
23278    
23279                            qPos.add(classNameId);
23280    
23281                            if (templateId != null) {
23282                                    qPos.add(templateId);
23283                            }
23284    
23285                            Long count = (Long)q.uniqueResult();
23286    
23287                            return count.intValue();
23288                    }
23289                    catch (Exception e) {
23290                            throw processException(e);
23291                    }
23292                    finally {
23293                            closeSession(session);
23294                    }
23295            }
23296    
23297            /**
23298             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23299             *
23300             * @param groupId the group ID
23301             * @param classNameId the class name ID
23302             * @param layoutUuid the layout uuid
23303             * @return the number of matching journal articles
23304             * @throws SystemException if a system exception occurred
23305             */
23306            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
23307                    throws SystemException {
23308                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
23309    
23310                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_L,
23311                                    finderArgs, this);
23312    
23313                    if (count == null) {
23314                            StringBundler query = new StringBundler(4);
23315    
23316                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23317    
23318                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23319    
23320                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23321    
23322                            if (layoutUuid == null) {
23323                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23324                            }
23325                            else {
23326                                    if (layoutUuid.equals(StringPool.BLANK)) {
23327                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23328                                    }
23329                                    else {
23330                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23331                                    }
23332                            }
23333    
23334                            String sql = query.toString();
23335    
23336                            Session session = null;
23337    
23338                            try {
23339                                    session = openSession();
23340    
23341                                    Query q = session.createQuery(sql);
23342    
23343                                    QueryPos qPos = QueryPos.getInstance(q);
23344    
23345                                    qPos.add(groupId);
23346    
23347                                    qPos.add(classNameId);
23348    
23349                                    if (layoutUuid != null) {
23350                                            qPos.add(layoutUuid);
23351                                    }
23352    
23353                                    count = (Long)q.uniqueResult();
23354                            }
23355                            catch (Exception e) {
23356                                    throw processException(e);
23357                            }
23358                            finally {
23359                                    if (count == null) {
23360                                            count = Long.valueOf(0);
23361                                    }
23362    
23363                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_L,
23364                                            finderArgs, count);
23365    
23366                                    closeSession(session);
23367                            }
23368                    }
23369    
23370                    return count.intValue();
23371            }
23372    
23373            /**
23374             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
23375             *
23376             * @param groupId the group ID
23377             * @param classNameId the class name ID
23378             * @param layoutUuid the layout uuid
23379             * @return the number of matching journal articles that the user has permission to view
23380             * @throws SystemException if a system exception occurred
23381             */
23382            public int filterCountByG_C_L(long groupId, long classNameId,
23383                    String layoutUuid) throws SystemException {
23384                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23385                            return countByG_C_L(groupId, classNameId, layoutUuid);
23386                    }
23387    
23388                    StringBundler query = new StringBundler(4);
23389    
23390                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23391    
23392                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
23393    
23394                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
23395    
23396                    if (layoutUuid == null) {
23397                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
23398                    }
23399                    else {
23400                            if (layoutUuid.equals(StringPool.BLANK)) {
23401                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
23402                            }
23403                            else {
23404                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
23405                            }
23406                    }
23407    
23408                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23409                                    JournalArticle.class.getName(),
23410                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23411    
23412                    Session session = null;
23413    
23414                    try {
23415                            session = openSession();
23416    
23417                            SQLQuery q = session.createSQLQuery(sql);
23418    
23419                            q.addScalar(COUNT_COLUMN_NAME,
23420                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23421    
23422                            QueryPos qPos = QueryPos.getInstance(q);
23423    
23424                            qPos.add(groupId);
23425    
23426                            qPos.add(classNameId);
23427    
23428                            if (layoutUuid != null) {
23429                                    qPos.add(layoutUuid);
23430                            }
23431    
23432                            Long count = (Long)q.uniqueResult();
23433    
23434                            return count.intValue();
23435                    }
23436                    catch (Exception e) {
23437                            throw processException(e);
23438                    }
23439                    finally {
23440                            closeSession(session);
23441                    }
23442            }
23443    
23444            /**
23445             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
23446             *
23447             * @param groupId the group ID
23448             * @param articleId the article ID
23449             * @param version the version
23450             * @return the number of matching journal articles
23451             * @throws SystemException if a system exception occurred
23452             */
23453            public int countByG_A_V(long groupId, String articleId, double version)
23454                    throws SystemException {
23455                    Object[] finderArgs = new Object[] { groupId, articleId, version };
23456    
23457                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_V,
23458                                    finderArgs, this);
23459    
23460                    if (count == null) {
23461                            StringBundler query = new StringBundler(4);
23462    
23463                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23464    
23465                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
23466    
23467                            if (articleId == null) {
23468                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
23469                            }
23470                            else {
23471                                    if (articleId.equals(StringPool.BLANK)) {
23472                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
23473                                    }
23474                                    else {
23475                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
23476                                    }
23477                            }
23478    
23479                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
23480    
23481                            String sql = query.toString();
23482    
23483                            Session session = null;
23484    
23485                            try {
23486                                    session = openSession();
23487    
23488                                    Query q = session.createQuery(sql);
23489    
23490                                    QueryPos qPos = QueryPos.getInstance(q);
23491    
23492                                    qPos.add(groupId);
23493    
23494                                    if (articleId != null) {
23495                                            qPos.add(articleId);
23496                                    }
23497    
23498                                    qPos.add(version);
23499    
23500                                    count = (Long)q.uniqueResult();
23501                            }
23502                            catch (Exception e) {
23503                                    throw processException(e);
23504                            }
23505                            finally {
23506                                    if (count == null) {
23507                                            count = Long.valueOf(0);
23508                                    }
23509    
23510                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V,
23511                                            finderArgs, count);
23512    
23513                                    closeSession(session);
23514                            }
23515                    }
23516    
23517                    return count.intValue();
23518            }
23519    
23520            /**
23521             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
23522             *
23523             * @param groupId the group ID
23524             * @param articleId the article ID
23525             * @param status the status
23526             * @return the number of matching journal articles
23527             * @throws SystemException if a system exception occurred
23528             */
23529            public int countByG_A_ST(long groupId, String articleId, int status)
23530                    throws SystemException {
23531                    Object[] finderArgs = new Object[] { groupId, articleId, status };
23532    
23533                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_ST,
23534                                    finderArgs, this);
23535    
23536                    if (count == null) {
23537                            StringBundler query = new StringBundler(4);
23538    
23539                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23540    
23541                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
23542    
23543                            if (articleId == null) {
23544                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
23545                            }
23546                            else {
23547                                    if (articleId.equals(StringPool.BLANK)) {
23548                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
23549                                    }
23550                                    else {
23551                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
23552                                    }
23553                            }
23554    
23555                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
23556    
23557                            String sql = query.toString();
23558    
23559                            Session session = null;
23560    
23561                            try {
23562                                    session = openSession();
23563    
23564                                    Query q = session.createQuery(sql);
23565    
23566                                    QueryPos qPos = QueryPos.getInstance(q);
23567    
23568                                    qPos.add(groupId);
23569    
23570                                    if (articleId != null) {
23571                                            qPos.add(articleId);
23572                                    }
23573    
23574                                    qPos.add(status);
23575    
23576                                    count = (Long)q.uniqueResult();
23577                            }
23578                            catch (Exception e) {
23579                                    throw processException(e);
23580                            }
23581                            finally {
23582                                    if (count == null) {
23583                                            count = Long.valueOf(0);
23584                                    }
23585    
23586                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_ST,
23587                                            finderArgs, count);
23588    
23589                                    closeSession(session);
23590                            }
23591                    }
23592    
23593                    return count.intValue();
23594            }
23595    
23596            /**
23597             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
23598             *
23599             * @param groupId the group ID
23600             * @param articleId the article ID
23601             * @param statuses the statuses
23602             * @return the number of matching journal articles
23603             * @throws SystemException if a system exception occurred
23604             */
23605            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
23606                    throws SystemException {
23607                    Object[] finderArgs = new Object[] {
23608                                    groupId, articleId, StringUtil.merge(statuses)
23609                            };
23610    
23611                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
23612                                    finderArgs, this);
23613    
23614                    if (count == null) {
23615                            StringBundler query = new StringBundler();
23616    
23617                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23618    
23619                            boolean conjunctionable = false;
23620    
23621                            if (conjunctionable) {
23622                                    query.append(WHERE_AND);
23623                            }
23624    
23625                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
23626    
23627                            conjunctionable = true;
23628    
23629                            if (conjunctionable) {
23630                                    query.append(WHERE_AND);
23631                            }
23632    
23633                            if (articleId == null) {
23634                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
23635                            }
23636                            else {
23637                                    if (articleId.equals(StringPool.BLANK)) {
23638                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
23639                                    }
23640                                    else {
23641                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
23642                                    }
23643                            }
23644    
23645                            conjunctionable = true;
23646    
23647                            if ((statuses == null) || (statuses.length > 0)) {
23648                                    if (conjunctionable) {
23649                                            query.append(WHERE_AND);
23650                                    }
23651    
23652                                    query.append(StringPool.OPEN_PARENTHESIS);
23653    
23654                                    for (int i = 0; i < statuses.length; i++) {
23655                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
23656    
23657                                            if ((i + 1) < statuses.length) {
23658                                                    query.append(WHERE_OR);
23659                                            }
23660                                    }
23661    
23662                                    query.append(StringPool.CLOSE_PARENTHESIS);
23663    
23664                                    conjunctionable = true;
23665                            }
23666    
23667                            String sql = query.toString();
23668    
23669                            Session session = null;
23670    
23671                            try {
23672                                    session = openSession();
23673    
23674                                    Query q = session.createQuery(sql);
23675    
23676                                    QueryPos qPos = QueryPos.getInstance(q);
23677    
23678                                    qPos.add(groupId);
23679    
23680                                    if (articleId != null) {
23681                                            qPos.add(articleId);
23682                                    }
23683    
23684                                    if (statuses != null) {
23685                                            qPos.add(statuses);
23686                                    }
23687    
23688                                    count = (Long)q.uniqueResult();
23689                            }
23690                            catch (Exception e) {
23691                                    throw processException(e);
23692                            }
23693                            finally {
23694                                    if (count == null) {
23695                                            count = Long.valueOf(0);
23696                                    }
23697    
23698                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
23699                                            finderArgs, count);
23700    
23701                                    closeSession(session);
23702                            }
23703                    }
23704    
23705                    return count.intValue();
23706            }
23707    
23708            /**
23709             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
23710             *
23711             * @param groupId the group ID
23712             * @param articleId the article ID
23713             * @param status the status
23714             * @return the number of matching journal articles that the user has permission to view
23715             * @throws SystemException if a system exception occurred
23716             */
23717            public int filterCountByG_A_ST(long groupId, String articleId, int status)
23718                    throws SystemException {
23719                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23720                            return countByG_A_ST(groupId, articleId, status);
23721                    }
23722    
23723                    StringBundler query = new StringBundler(4);
23724    
23725                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23726    
23727                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
23728    
23729                    if (articleId == null) {
23730                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
23731                    }
23732                    else {
23733                            if (articleId.equals(StringPool.BLANK)) {
23734                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
23735                            }
23736                            else {
23737                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
23738                            }
23739                    }
23740    
23741                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
23742    
23743                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23744                                    JournalArticle.class.getName(),
23745                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23746    
23747                    Session session = null;
23748    
23749                    try {
23750                            session = openSession();
23751    
23752                            SQLQuery q = session.createSQLQuery(sql);
23753    
23754                            q.addScalar(COUNT_COLUMN_NAME,
23755                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23756    
23757                            QueryPos qPos = QueryPos.getInstance(q);
23758    
23759                            qPos.add(groupId);
23760    
23761                            if (articleId != null) {
23762                                    qPos.add(articleId);
23763                            }
23764    
23765                            qPos.add(status);
23766    
23767                            Long count = (Long)q.uniqueResult();
23768    
23769                            return count.intValue();
23770                    }
23771                    catch (Exception e) {
23772                            throw processException(e);
23773                    }
23774                    finally {
23775                            closeSession(session);
23776                    }
23777            }
23778    
23779            /**
23780             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
23781             *
23782             * @param groupId the group ID
23783             * @param articleId the article ID
23784             * @param statuses the statuses
23785             * @return the number of matching journal articles that the user has permission to view
23786             * @throws SystemException if a system exception occurred
23787             */
23788            public int filterCountByG_A_ST(long groupId, String articleId,
23789                    int[] statuses) throws SystemException {
23790                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23791                            return countByG_A_ST(groupId, articleId, statuses);
23792                    }
23793    
23794                    StringBundler query = new StringBundler();
23795    
23796                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23797    
23798                    boolean conjunctionable = false;
23799    
23800                    if (conjunctionable) {
23801                            query.append(WHERE_AND);
23802                    }
23803    
23804                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
23805    
23806                    conjunctionable = true;
23807    
23808                    if (conjunctionable) {
23809                            query.append(WHERE_AND);
23810                    }
23811    
23812                    if (articleId == null) {
23813                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
23814                    }
23815                    else {
23816                            if (articleId.equals(StringPool.BLANK)) {
23817                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
23818                            }
23819                            else {
23820                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
23821                            }
23822                    }
23823    
23824                    conjunctionable = true;
23825    
23826                    if ((statuses == null) || (statuses.length > 0)) {
23827                            if (conjunctionable) {
23828                                    query.append(WHERE_AND);
23829                            }
23830    
23831                            query.append(StringPool.OPEN_PARENTHESIS);
23832    
23833                            for (int i = 0; i < statuses.length; i++) {
23834                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
23835    
23836                                    if ((i + 1) < statuses.length) {
23837                                            query.append(WHERE_OR);
23838                                    }
23839                            }
23840    
23841                            query.append(StringPool.CLOSE_PARENTHESIS);
23842    
23843                            conjunctionable = true;
23844                    }
23845    
23846                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23847                                    JournalArticle.class.getName(),
23848                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23849    
23850                    Session session = null;
23851    
23852                    try {
23853                            session = openSession();
23854    
23855                            SQLQuery q = session.createSQLQuery(sql);
23856    
23857                            q.addScalar(COUNT_COLUMN_NAME,
23858                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
23859    
23860                            QueryPos qPos = QueryPos.getInstance(q);
23861    
23862                            qPos.add(groupId);
23863    
23864                            if (articleId != null) {
23865                                    qPos.add(articleId);
23866                            }
23867    
23868                            if (statuses != null) {
23869                                    qPos.add(statuses);
23870                            }
23871    
23872                            Long count = (Long)q.uniqueResult();
23873    
23874                            return count.intValue();
23875                    }
23876                    catch (Exception e) {
23877                            throw processException(e);
23878                    }
23879                    finally {
23880                            closeSession(session);
23881                    }
23882            }
23883    
23884            /**
23885             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23886             *
23887             * @param groupId the group ID
23888             * @param urlTitle the url title
23889             * @param status the status
23890             * @return the number of matching journal articles
23891             * @throws SystemException if a system exception occurred
23892             */
23893            public int countByG_UT_ST(long groupId, String urlTitle, int status)
23894                    throws SystemException {
23895                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
23896    
23897                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT_ST,
23898                                    finderArgs, this);
23899    
23900                    if (count == null) {
23901                            StringBundler query = new StringBundler(4);
23902    
23903                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
23904    
23905                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23906    
23907                            if (urlTitle == null) {
23908                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23909                            }
23910                            else {
23911                                    if (urlTitle.equals(StringPool.BLANK)) {
23912                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23913                                    }
23914                                    else {
23915                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23916                                    }
23917                            }
23918    
23919                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23920    
23921                            String sql = query.toString();
23922    
23923                            Session session = null;
23924    
23925                            try {
23926                                    session = openSession();
23927    
23928                                    Query q = session.createQuery(sql);
23929    
23930                                    QueryPos qPos = QueryPos.getInstance(q);
23931    
23932                                    qPos.add(groupId);
23933    
23934                                    if (urlTitle != null) {
23935                                            qPos.add(urlTitle);
23936                                    }
23937    
23938                                    qPos.add(status);
23939    
23940                                    count = (Long)q.uniqueResult();
23941                            }
23942                            catch (Exception e) {
23943                                    throw processException(e);
23944                            }
23945                            finally {
23946                                    if (count == null) {
23947                                            count = Long.valueOf(0);
23948                                    }
23949    
23950                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT_ST,
23951                                            finderArgs, count);
23952    
23953                                    closeSession(session);
23954                            }
23955                    }
23956    
23957                    return count.intValue();
23958            }
23959    
23960            /**
23961             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
23962             *
23963             * @param groupId the group ID
23964             * @param urlTitle the url title
23965             * @param status the status
23966             * @return the number of matching journal articles that the user has permission to view
23967             * @throws SystemException if a system exception occurred
23968             */
23969            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
23970                    throws SystemException {
23971                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
23972                            return countByG_UT_ST(groupId, urlTitle, status);
23973                    }
23974    
23975                    StringBundler query = new StringBundler(4);
23976    
23977                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
23978    
23979                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
23980    
23981                    if (urlTitle == null) {
23982                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
23983                    }
23984                    else {
23985                            if (urlTitle.equals(StringPool.BLANK)) {
23986                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
23987                            }
23988                            else {
23989                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
23990                            }
23991                    }
23992    
23993                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
23994    
23995                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
23996                                    JournalArticle.class.getName(),
23997                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
23998    
23999                    Session session = null;
24000    
24001                    try {
24002                            session = openSession();
24003    
24004                            SQLQuery q = session.createSQLQuery(sql);
24005    
24006                            q.addScalar(COUNT_COLUMN_NAME,
24007                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
24008    
24009                            QueryPos qPos = QueryPos.getInstance(q);
24010    
24011                            qPos.add(groupId);
24012    
24013                            if (urlTitle != null) {
24014                                    qPos.add(urlTitle);
24015                            }
24016    
24017                            qPos.add(status);
24018    
24019                            Long count = (Long)q.uniqueResult();
24020    
24021                            return count.intValue();
24022                    }
24023                    catch (Exception e) {
24024                            throw processException(e);
24025                    }
24026                    finally {
24027                            closeSession(session);
24028                    }
24029            }
24030    
24031            /**
24032             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
24033             *
24034             * @param companyId the company ID
24035             * @param version the version
24036             * @param status the status
24037             * @return the number of matching journal articles
24038             * @throws SystemException if a system exception occurred
24039             */
24040            public int countByC_V_ST(long companyId, double version, int status)
24041                    throws SystemException {
24042                    Object[] finderArgs = new Object[] { companyId, version, status };
24043    
24044                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V_ST,
24045                                    finderArgs, this);
24046    
24047                    if (count == null) {
24048                            StringBundler query = new StringBundler(4);
24049    
24050                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
24051    
24052                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
24053    
24054                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
24055    
24056                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
24057    
24058                            String sql = query.toString();
24059    
24060                            Session session = null;
24061    
24062                            try {
24063                                    session = openSession();
24064    
24065                                    Query q = session.createQuery(sql);
24066    
24067                                    QueryPos qPos = QueryPos.getInstance(q);
24068    
24069                                    qPos.add(companyId);
24070    
24071                                    qPos.add(version);
24072    
24073                                    qPos.add(status);
24074    
24075                                    count = (Long)q.uniqueResult();
24076                            }
24077                            catch (Exception e) {
24078                                    throw processException(e);
24079                            }
24080                            finally {
24081                                    if (count == null) {
24082                                            count = Long.valueOf(0);
24083                                    }
24084    
24085                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V_ST,
24086                                            finderArgs, count);
24087    
24088                                    closeSession(session);
24089                            }
24090                    }
24091    
24092                    return count.intValue();
24093            }
24094    
24095            /**
24096             * Returns the number of journal articles.
24097             *
24098             * @return the number of journal articles
24099             * @throws SystemException if a system exception occurred
24100             */
24101            public int countAll() throws SystemException {
24102                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
24103                                    FINDER_ARGS_EMPTY, this);
24104    
24105                    if (count == null) {
24106                            Session session = null;
24107    
24108                            try {
24109                                    session = openSession();
24110    
24111                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
24112    
24113                                    count = (Long)q.uniqueResult();
24114                            }
24115                            catch (Exception e) {
24116                                    throw processException(e);
24117                            }
24118                            finally {
24119                                    if (count == null) {
24120                                            count = Long.valueOf(0);
24121                                    }
24122    
24123                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
24124                                            FINDER_ARGS_EMPTY, count);
24125    
24126                                    closeSession(session);
24127                            }
24128                    }
24129    
24130                    return count.intValue();
24131            }
24132    
24133            /**
24134             * Initializes the journal article persistence.
24135             */
24136            public void afterPropertiesSet() {
24137                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
24138                                            com.liferay.portal.util.PropsUtil.get(
24139                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
24140    
24141                    if (listenerClassNames.length > 0) {
24142                            try {
24143                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
24144    
24145                                    for (String listenerClassName : listenerClassNames) {
24146                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
24147                                                            listenerClassName));
24148                                    }
24149    
24150                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
24151                            }
24152                            catch (Exception e) {
24153                                    _log.error(e);
24154                            }
24155                    }
24156            }
24157    
24158            public void destroy() {
24159                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
24160                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
24161                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
24162            }
24163    
24164            @BeanReference(type = JournalArticlePersistence.class)
24165            protected JournalArticlePersistence journalArticlePersistence;
24166            @BeanReference(type = JournalArticleImagePersistence.class)
24167            protected JournalArticleImagePersistence journalArticleImagePersistence;
24168            @BeanReference(type = JournalArticleResourcePersistence.class)
24169            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
24170            @BeanReference(type = JournalContentSearchPersistence.class)
24171            protected JournalContentSearchPersistence journalContentSearchPersistence;
24172            @BeanReference(type = JournalFeedPersistence.class)
24173            protected JournalFeedPersistence journalFeedPersistence;
24174            @BeanReference(type = JournalFolderPersistence.class)
24175            protected JournalFolderPersistence journalFolderPersistence;
24176            @BeanReference(type = JournalStructurePersistence.class)
24177            protected JournalStructurePersistence journalStructurePersistence;
24178            @BeanReference(type = JournalTemplatePersistence.class)
24179            protected JournalTemplatePersistence journalTemplatePersistence;
24180            @BeanReference(type = CompanyPersistence.class)
24181            protected CompanyPersistence companyPersistence;
24182            @BeanReference(type = GroupPersistence.class)
24183            protected GroupPersistence groupPersistence;
24184            @BeanReference(type = ImagePersistence.class)
24185            protected ImagePersistence imagePersistence;
24186            @BeanReference(type = PortletPreferencesPersistence.class)
24187            protected PortletPreferencesPersistence portletPreferencesPersistence;
24188            @BeanReference(type = SubscriptionPersistence.class)
24189            protected SubscriptionPersistence subscriptionPersistence;
24190            @BeanReference(type = UserPersistence.class)
24191            protected UserPersistence userPersistence;
24192            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
24193            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
24194            @BeanReference(type = AssetCategoryPersistence.class)
24195            protected AssetCategoryPersistence assetCategoryPersistence;
24196            @BeanReference(type = AssetEntryPersistence.class)
24197            protected AssetEntryPersistence assetEntryPersistence;
24198            @BeanReference(type = AssetLinkPersistence.class)
24199            protected AssetLinkPersistence assetLinkPersistence;
24200            @BeanReference(type = AssetTagPersistence.class)
24201            protected AssetTagPersistence assetTagPersistence;
24202            @BeanReference(type = ExpandoValuePersistence.class)
24203            protected ExpandoValuePersistence expandoValuePersistence;
24204            @BeanReference(type = MBMessagePersistence.class)
24205            protected MBMessagePersistence mbMessagePersistence;
24206            @BeanReference(type = RatingsStatsPersistence.class)
24207            protected RatingsStatsPersistence ratingsStatsPersistence;
24208            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
24209            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
24210            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
24211            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
24212            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
24213            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
24214            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?)";
24215            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
24216            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
24217            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?) AND ";
24218            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
24219            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalArticle.uuid IS NULL AND ";
24220            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalArticle.uuid = ? AND ";
24221            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?) AND ";
24222            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalArticle.companyId = ?";
24223            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
24224                    "journalArticle.resourcePrimKey = ?";
24225            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
24226            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
24227            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
24228            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalArticle.structureId = ?";
24229            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
24230            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
24231            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2 = "journalArticle.templateId = ?";
24232            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
24233            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
24234            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
24235            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
24236            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
24237            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
24238            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
24239            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "journalArticle.groupId = ? AND ";
24240            private static final String _FINDER_COLUMN_G_U_USERID_2 = "journalArticle.userId = ?";
24241            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "journalArticle.groupId = ? AND ";
24242            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
24243                    _removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
24244            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "journalArticle.folderId = ?";
24245            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
24246                    _removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
24247            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
24248            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
24249            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
24250            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?)";
24251            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
24252            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
24253            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
24254            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?)";
24255            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
24256            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
24257            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
24258            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
24259            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
24260            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
24261            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
24262            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
24263            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
24264            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
24265            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
24266            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
24267            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
24268            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
24269            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
24270            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
24271            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
24272            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
24273            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
24274            private static final String _FINDER_COLUMN_G_F_ST_GROUPID_5 = "(" +
24275                    _removeConjunction(_FINDER_COLUMN_G_F_ST_GROUPID_2) + ")";
24276            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_2 = "journalArticle.folderId = ? AND ";
24277            private static final String _FINDER_COLUMN_G_F_ST_FOLDERID_5 = "(" +
24278                    _removeConjunction(_FINDER_COLUMN_G_F_ST_FOLDERID_2) + ")";
24279            private static final String _FINDER_COLUMN_G_F_ST_STATUS_2 = "journalArticle.status = ?";
24280            private static final String _FINDER_COLUMN_G_F_ST_STATUS_5 = "(" +
24281                    _removeConjunction(_FINDER_COLUMN_G_F_ST_STATUS_2) + ")";
24282            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
24283            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
24284            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
24285            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
24286            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
24287            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
24288            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
24289            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
24290            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
24291            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
24292            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
24293            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
24294            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
24295            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
24296            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
24297            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
24298            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
24299            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
24300            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
24301            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
24302            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
24303            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
24304            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
24305            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
24306            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
24307                    _removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
24308            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
24309            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
24310            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
24311            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
24312                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
24313            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
24314                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
24315            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
24316                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
24317            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
24318            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
24319                    _removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
24320            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
24321            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
24322            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
24323            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?) AND ";
24324            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
24325            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
24326            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
24327            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
24328    
24329            private static String _removeConjunction(String sql) {
24330                    int pos = sql.indexOf(" AND ");
24331    
24332                    if (pos != -1) {
24333                            sql = sql.substring(0, pos);
24334                    }
24335    
24336                    return sql;
24337            }
24338    
24339            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
24340            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
24341            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
24342                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
24343            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
24344                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
24345            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
24346            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
24347            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
24348            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
24349            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
24350            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
24351            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
24352            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
24353            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
24354            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
24355                            @Override
24356                            public Object clone() {
24357                                    return this;
24358                            }
24359    
24360                            @Override
24361                            public CacheModel<JournalArticle> toCacheModel() {
24362                                    return _nullJournalArticleCacheModel;
24363                            }
24364                    };
24365    
24366            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
24367                            public JournalArticle toEntityModel() {
24368                                    return _nullJournalArticle;
24369                            }
24370                    };
24371    }