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.BatchSessionUtil;
044    import com.liferay.portal.service.persistence.CompanyPersistence;
045    import com.liferay.portal.service.persistence.GroupPersistence;
046    import com.liferay.portal.service.persistence.ImagePersistence;
047    import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
048    import com.liferay.portal.service.persistence.ResourcePersistence;
049    import com.liferay.portal.service.persistence.SubscriptionPersistence;
050    import com.liferay.portal.service.persistence.UserPersistence;
051    import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
052    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
053    
054    import com.liferay.portlet.asset.service.persistence.AssetCategoryPersistence;
055    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
056    import com.liferay.portlet.asset.service.persistence.AssetLinkPersistence;
057    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
058    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
059    import com.liferay.portlet.journal.NoSuchArticleException;
060    import com.liferay.portlet.journal.model.JournalArticle;
061    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
062    import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
063    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
064    import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
065    
066    import java.io.Serializable;
067    
068    import java.util.ArrayList;
069    import java.util.Collections;
070    import java.util.List;
071    
072    /**
073     * The persistence implementation for the journal article service.
074     *
075     * <p>
076     * Caching information and settings can be found in <code>portal.properties</code>
077     * </p>
078     *
079     * @author Brian Wing Shun Chan
080     * @see JournalArticlePersistence
081     * @see JournalArticleUtil
082     * @generated
083     */
084    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
085            implements JournalArticlePersistence {
086            /*
087             * NOTE FOR DEVELOPERS:
088             *
089             * 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.
090             */
091            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
092            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
093                    ".List1";
094            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
095                    ".List2";
096            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
097                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
098                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
099                            "findByUuid",
100                            new String[] {
101                                    String.class.getName(),
102                                    
103                            "java.lang.Integer", "java.lang.Integer",
104                                    "com.liferay.portal.kernel.util.OrderByComparator"
105                            });
106            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
107                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
108                            JournalArticleImpl.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
110                            new String[] { String.class.getName() },
111                            JournalArticleModelImpl.UUID_COLUMN_BITMASK);
112            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
113                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
115                            new String[] { String.class.getName() });
116            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
117                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
118                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
119                            "fetchByUUID_G",
120                            new String[] { String.class.getName(), Long.class.getName() },
121                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
122                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
123            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
124                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
125                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
126                            new String[] { String.class.getName(), Long.class.getName() });
127            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
128                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
129                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
130                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
131                            "findByResourcePrimKey",
132                            new String[] {
133                                    Long.class.getName(),
134                                    
135                            "java.lang.Integer", "java.lang.Integer",
136                                    "com.liferay.portal.kernel.util.OrderByComparator"
137                            });
138            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
139                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
140                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
141                            JournalArticleImpl.class,
142                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
143                            new String[] { Long.class.getName() },
144                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK);
145            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
146                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
147                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
148                            "countByResourcePrimKey", new String[] { Long.class.getName() });
149            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
150                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
151                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
152                            "findByGroupId",
153                            new String[] {
154                                    Long.class.getName(),
155                                    
156                            "java.lang.Integer", "java.lang.Integer",
157                                    "com.liferay.portal.kernel.util.OrderByComparator"
158                            });
159            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
160                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
161                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
162                            JournalArticleImpl.class,
163                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
164                            new String[] { Long.class.getName() },
165                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
166            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
167                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
168                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
169                            new String[] { Long.class.getName() });
170            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
171                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
172                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
173                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
174                            "findByCompanyId",
175                            new String[] {
176                                    Long.class.getName(),
177                                    
178                            "java.lang.Integer", "java.lang.Integer",
179                                    "com.liferay.portal.kernel.util.OrderByComparator"
180                            });
181            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
182                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
183                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
184                            JournalArticleImpl.class,
185                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
186                            new String[] { Long.class.getName() },
187                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK);
188            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
189                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
190                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
191                            new String[] { Long.class.getName() });
192            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID =
193                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
194                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
195                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
196                            "findByStructureId",
197                            new String[] {
198                                    String.class.getName(),
199                                    
200                            "java.lang.Integer", "java.lang.Integer",
201                                    "com.liferay.portal.kernel.util.OrderByComparator"
202                            });
203            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID =
204                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
205                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
206                            JournalArticleImpl.class,
207                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStructureId",
208                            new String[] { String.class.getName() },
209                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
210            public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
211                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
212                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStructureId",
213                            new String[] { String.class.getName() });
214            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID =
215                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
216                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
217                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
218                            "findByTemplateId",
219                            new String[] {
220                                    String.class.getName(),
221                                    
222                            "java.lang.Integer", "java.lang.Integer",
223                                    "com.liferay.portal.kernel.util.OrderByComparator"
224                            });
225            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID =
226                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
227                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
228                            JournalArticleImpl.class,
229                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByTemplateId",
230                            new String[] { String.class.getName() },
231                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK);
232            public static final FinderPath FINDER_PATH_COUNT_BY_TEMPLATEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
233                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
234                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTemplateId",
235                            new String[] { String.class.getName() });
236            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
237                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
238                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
239                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
240                            "findBySmallImageId",
241                            new String[] {
242                                    Long.class.getName(),
243                                    
244                            "java.lang.Integer", "java.lang.Integer",
245                                    "com.liferay.portal.kernel.util.OrderByComparator"
246                            });
247            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
248                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
249                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
250                            JournalArticleImpl.class,
251                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
252                            new String[] { Long.class.getName() },
253                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK);
254            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
255                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
256                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
257                            new String[] { Long.class.getName() });
258            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
259                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
260                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
261                            "findByR_ST",
262                            new String[] {
263                                    Long.class.getName(), Integer.class.getName(),
264                                    
265                            "java.lang.Integer", "java.lang.Integer",
266                                    "com.liferay.portal.kernel.util.OrderByComparator"
267                            });
268            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
269                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
270                            JournalArticleImpl.class,
271                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
272                            new String[] { Long.class.getName(), Integer.class.getName() },
273                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
274                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
275            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
276                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
277                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
278                            new String[] { Long.class.getName(), Integer.class.getName() });
279            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
280                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
281                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
282                            "findByG_A",
283                            new String[] {
284                                    Long.class.getName(), String.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_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
290                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
291                            JournalArticleImpl.class,
292                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
293                            new String[] { Long.class.getName(), String.class.getName() },
294                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
295                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
296            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
297                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
298                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
299                            new String[] { Long.class.getName(), String.class.getName() });
300            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
301                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
302                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
303                            "findByG_UT",
304                            new String[] {
305                                    Long.class.getName(), String.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_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
311                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
312                            JournalArticleImpl.class,
313                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
314                            new String[] { Long.class.getName(), String.class.getName() },
315                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
316                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK);
317            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
318                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
319                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
320                            new String[] { Long.class.getName(), String.class.getName() });
321            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
322                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
323                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
324                            "findByG_S",
325                            new String[] {
326                                    Long.class.getName(), String.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_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
332                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
333                            JournalArticleImpl.class,
334                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
335                            new String[] { Long.class.getName(), String.class.getName() },
336                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
337                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
338            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
339                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
340                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
341                            new String[] { Long.class.getName(), String.class.getName() });
342            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
343                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
344                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
345                            "findByG_T",
346                            new String[] {
347                                    Long.class.getName(), String.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_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
353                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
354                            JournalArticleImpl.class,
355                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
356                            new String[] { Long.class.getName(), String.class.getName() },
357                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
358                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK);
359            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
360                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
361                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
362                            new String[] { Long.class.getName(), String.class.getName() });
363            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
364                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
365                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
366                            "findByG_L",
367                            new String[] {
368                                    Long.class.getName(), String.class.getName(),
369                                    
370                            "java.lang.Integer", "java.lang.Integer",
371                                    "com.liferay.portal.kernel.util.OrderByComparator"
372                            });
373            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
374                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
375                            JournalArticleImpl.class,
376                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
377                            new String[] { Long.class.getName(), String.class.getName() },
378                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
379                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK);
380            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
381                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
382                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
383                            new String[] { Long.class.getName(), String.class.getName() });
384            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
385                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
386                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
387                            "findByG_ST",
388                            new String[] {
389                                    Long.class.getName(), Integer.class.getName(),
390                                    
391                            "java.lang.Integer", "java.lang.Integer",
392                                    "com.liferay.portal.kernel.util.OrderByComparator"
393                            });
394            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
395                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
396                            JournalArticleImpl.class,
397                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
398                            new String[] { Long.class.getName(), Integer.class.getName() },
399                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
400                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
401            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
402                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
403                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
404                            new String[] { Long.class.getName(), Integer.class.getName() });
405            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
406                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
407                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
408                            "findByC_V",
409                            new String[] {
410                                    Long.class.getName(), Double.class.getName(),
411                                    
412                            "java.lang.Integer", "java.lang.Integer",
413                                    "com.liferay.portal.kernel.util.OrderByComparator"
414                            });
415            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
416                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
417                            JournalArticleImpl.class,
418                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
419                            new String[] { Long.class.getName(), Double.class.getName() },
420                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
421                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
422            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
423                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
424                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
425                            new String[] { Long.class.getName(), Double.class.getName() });
426            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
427                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
428                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
429                            "findByC_ST",
430                            new String[] {
431                                    Long.class.getName(), Integer.class.getName(),
432                                    
433                            "java.lang.Integer", "java.lang.Integer",
434                                    "com.liferay.portal.kernel.util.OrderByComparator"
435                            });
436            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
437                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
438                            JournalArticleImpl.class,
439                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
440                            new String[] { Long.class.getName(), Integer.class.getName() },
441                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
442                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
443            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
444                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
445                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
446                            new String[] { Long.class.getName(), Integer.class.getName() });
447            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
448                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
449                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
450                            "findByG_C_C",
451                            new String[] {
452                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
453                                    
454                            "java.lang.Integer", "java.lang.Integer",
455                                    "com.liferay.portal.kernel.util.OrderByComparator"
456                            });
457            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
458                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
459                            JournalArticleImpl.class,
460                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
461                            new String[] {
462                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
463                            },
464                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
465                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
466                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK);
467            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
468                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
469                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
470                            new String[] {
471                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
472                            });
473            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
474                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
475                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
476                            new String[] {
477                                    Long.class.getName(), Long.class.getName(),
478                                    String.class.getName()
479                            },
480                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
481                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
482                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
483            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
484                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
485                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
486                            new String[] {
487                                    Long.class.getName(), Long.class.getName(),
488                                    String.class.getName()
489                            });
490            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
491                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
492                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
493                            "findByG_C_T",
494                            new String[] {
495                                    Long.class.getName(), Long.class.getName(),
496                                    String.class.getName(),
497                                    
498                            "java.lang.Integer", "java.lang.Integer",
499                                    "com.liferay.portal.kernel.util.OrderByComparator"
500                            });
501            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
502                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
503                            JournalArticleImpl.class,
504                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
505                            new String[] {
506                                    Long.class.getName(), Long.class.getName(),
507                                    String.class.getName()
508                            },
509                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
510                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
511                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK);
512            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
513                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
514                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
515                            new String[] {
516                                    Long.class.getName(), Long.class.getName(),
517                                    String.class.getName()
518                            });
519            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
520                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
521                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
522                            "findByG_C_L",
523                            new String[] {
524                                    Long.class.getName(), Long.class.getName(),
525                                    String.class.getName(),
526                                    
527                            "java.lang.Integer", "java.lang.Integer",
528                                    "com.liferay.portal.kernel.util.OrderByComparator"
529                            });
530            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
531                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
532                            JournalArticleImpl.class,
533                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
534                            new String[] {
535                                    Long.class.getName(), Long.class.getName(),
536                                    String.class.getName()
537                            },
538                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
539                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
540                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK);
541            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
542                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
543                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
544                            new String[] {
545                                    Long.class.getName(), Long.class.getName(),
546                                    String.class.getName()
547                            });
548            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
549                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
550                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
551                            new String[] {
552                                    Long.class.getName(), String.class.getName(),
553                                    Double.class.getName()
554                            },
555                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
556                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
557                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
558            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
559                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
560                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
561                            new String[] {
562                                    Long.class.getName(), String.class.getName(),
563                                    Double.class.getName()
564                            });
565            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
566                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
567                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
568                            "findByG_A_ST",
569                            new String[] {
570                                    Long.class.getName(), String.class.getName(),
571                                    Integer.class.getName(),
572                                    
573                            "java.lang.Integer", "java.lang.Integer",
574                                    "com.liferay.portal.kernel.util.OrderByComparator"
575                            });
576            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
577                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
578                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
579                            JournalArticleImpl.class,
580                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
581                            new String[] {
582                                    Long.class.getName(), String.class.getName(),
583                                    Integer.class.getName()
584                            },
585                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
586                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
587                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
588            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
589                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
590                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
591                            new String[] {
592                                    Long.class.getName(), String.class.getName(),
593                                    Integer.class.getName()
594                            });
595            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
596                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
597                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_A_ST",
598                            new String[] {
599                                    Long.class.getName(), String.class.getName(),
600                                    Integer.class.getName()
601                            });
602            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
603                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
604                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
605                            "findByG_UT_ST",
606                            new String[] {
607                                    Long.class.getName(), String.class.getName(),
608                                    Integer.class.getName(),
609                                    
610                            "java.lang.Integer", "java.lang.Integer",
611                                    "com.liferay.portal.kernel.util.OrderByComparator"
612                            });
613            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
614                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
615                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
616                            JournalArticleImpl.class,
617                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
618                            new String[] {
619                                    Long.class.getName(), String.class.getName(),
620                                    Integer.class.getName()
621                            },
622                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
623                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
624                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
625            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
626                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
627                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
628                            new String[] {
629                                    Long.class.getName(), String.class.getName(),
630                                    Integer.class.getName()
631                            });
632            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
633                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
634                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
635                            "findByC_V_ST",
636                            new String[] {
637                                    Long.class.getName(), Double.class.getName(),
638                                    Integer.class.getName(),
639                                    
640                            "java.lang.Integer", "java.lang.Integer",
641                                    "com.liferay.portal.kernel.util.OrderByComparator"
642                            });
643            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
644                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
645                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
646                            JournalArticleImpl.class,
647                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
648                            new String[] {
649                                    Long.class.getName(), Double.class.getName(),
650                                    Integer.class.getName()
651                            },
652                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
653                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
654                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
655            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
656                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
657                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
658                            new String[] {
659                                    Long.class.getName(), Double.class.getName(),
660                                    Integer.class.getName()
661                            });
662            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
663                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
664                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
665                            "findAll", new String[0]);
666            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
667                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
668                            JournalArticleImpl.class,
669                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
670            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
671                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
672                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
673    
674            /**
675             * Caches the journal article in the entity cache if it is enabled.
676             *
677             * @param journalArticle the journal article
678             */
679            public void cacheResult(JournalArticle journalArticle) {
680                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
681                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
682                            journalArticle);
683    
684                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
685                            new Object[] {
686                                    journalArticle.getUuid(),
687                                    Long.valueOf(journalArticle.getGroupId())
688                            }, journalArticle);
689    
690                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
691                            new Object[] {
692                                    Long.valueOf(journalArticle.getGroupId()),
693                                    Long.valueOf(journalArticle.getClassNameId()),
694                                    
695                            journalArticle.getStructureId()
696                            }, journalArticle);
697    
698                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
699                            new Object[] {
700                                    Long.valueOf(journalArticle.getGroupId()),
701                                    
702                            journalArticle.getArticleId(),
703                                    Double.valueOf(journalArticle.getVersion())
704                            }, journalArticle);
705    
706                    journalArticle.resetOriginalValues();
707            }
708    
709            /**
710             * Caches the journal articles in the entity cache if it is enabled.
711             *
712             * @param journalArticles the journal articles
713             */
714            public void cacheResult(List<JournalArticle> journalArticles) {
715                    for (JournalArticle journalArticle : journalArticles) {
716                            if (EntityCacheUtil.getResult(
717                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
718                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
719                                    cacheResult(journalArticle);
720                            }
721                            else {
722                                    journalArticle.resetOriginalValues();
723                            }
724                    }
725            }
726    
727            /**
728             * Clears the cache for all journal articles.
729             *
730             * <p>
731             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
732             * </p>
733             */
734            @Override
735            public void clearCache() {
736                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
737                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
738                    }
739    
740                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
741    
742                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
743                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
744                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
745            }
746    
747            /**
748             * Clears the cache for the journal article.
749             *
750             * <p>
751             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
752             * </p>
753             */
754            @Override
755            public void clearCache(JournalArticle journalArticle) {
756                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
757                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
758    
759                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
760                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
761    
762                    clearUniqueFindersCache(journalArticle);
763            }
764    
765            @Override
766            public void clearCache(List<JournalArticle> journalArticles) {
767                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
768                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
769    
770                    for (JournalArticle journalArticle : journalArticles) {
771                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
772                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
773    
774                            clearUniqueFindersCache(journalArticle);
775                    }
776            }
777    
778            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
779                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
780                            new Object[] {
781                                    journalArticle.getUuid(),
782                                    Long.valueOf(journalArticle.getGroupId())
783                            });
784    
785                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
786                            new Object[] {
787                                    Long.valueOf(journalArticle.getGroupId()),
788                                    Long.valueOf(journalArticle.getClassNameId()),
789                                    
790                            journalArticle.getStructureId()
791                            });
792    
793                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
794                            new Object[] {
795                                    Long.valueOf(journalArticle.getGroupId()),
796                                    
797                            journalArticle.getArticleId(),
798                                    Double.valueOf(journalArticle.getVersion())
799                            });
800            }
801    
802            /**
803             * Creates a new journal article with the primary key. Does not add the journal article to the database.
804             *
805             * @param id the primary key for the new journal article
806             * @return the new journal article
807             */
808            public JournalArticle create(long id) {
809                    JournalArticle journalArticle = new JournalArticleImpl();
810    
811                    journalArticle.setNew(true);
812                    journalArticle.setPrimaryKey(id);
813    
814                    String uuid = PortalUUIDUtil.generate();
815    
816                    journalArticle.setUuid(uuid);
817    
818                    return journalArticle;
819            }
820    
821            /**
822             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
823             *
824             * @param id the primary key of the journal article
825             * @return the journal article that was removed
826             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
827             * @throws SystemException if a system exception occurred
828             */
829            public JournalArticle remove(long id)
830                    throws NoSuchArticleException, SystemException {
831                    return remove(Long.valueOf(id));
832            }
833    
834            /**
835             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
836             *
837             * @param primaryKey the primary key of the journal article
838             * @return the journal article that was removed
839             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
840             * @throws SystemException if a system exception occurred
841             */
842            @Override
843            public JournalArticle remove(Serializable primaryKey)
844                    throws NoSuchArticleException, SystemException {
845                    Session session = null;
846    
847                    try {
848                            session = openSession();
849    
850                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
851                                            primaryKey);
852    
853                            if (journalArticle == null) {
854                                    if (_log.isWarnEnabled()) {
855                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
856                                    }
857    
858                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
859                                            primaryKey);
860                            }
861    
862                            return remove(journalArticle);
863                    }
864                    catch (NoSuchArticleException nsee) {
865                            throw nsee;
866                    }
867                    catch (Exception e) {
868                            throw processException(e);
869                    }
870                    finally {
871                            closeSession(session);
872                    }
873            }
874    
875            @Override
876            protected JournalArticle removeImpl(JournalArticle journalArticle)
877                    throws SystemException {
878                    journalArticle = toUnwrappedModel(journalArticle);
879    
880                    Session session = null;
881    
882                    try {
883                            session = openSession();
884    
885                            BatchSessionUtil.delete(session, journalArticle);
886                    }
887                    catch (Exception e) {
888                            throw processException(e);
889                    }
890                    finally {
891                            closeSession(session);
892                    }
893    
894                    clearCache(journalArticle);
895    
896                    return journalArticle;
897            }
898    
899            @Override
900            public JournalArticle updateImpl(
901                    com.liferay.portlet.journal.model.JournalArticle journalArticle,
902                    boolean merge) throws SystemException {
903                    journalArticle = toUnwrappedModel(journalArticle);
904    
905                    boolean isNew = journalArticle.isNew();
906    
907                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
908    
909                    if (Validator.isNull(journalArticle.getUuid())) {
910                            String uuid = PortalUUIDUtil.generate();
911    
912                            journalArticle.setUuid(uuid);
913                    }
914    
915                    Session session = null;
916    
917                    try {
918                            session = openSession();
919    
920                            BatchSessionUtil.update(session, journalArticle, merge);
921    
922                            journalArticle.setNew(false);
923                    }
924                    catch (Exception e) {
925                            throw processException(e);
926                    }
927                    finally {
928                            closeSession(session);
929                    }
930    
931                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
932    
933                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
934                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
935                    }
936                    else {
937                            if ((journalArticleModelImpl.getColumnBitmask() &
938                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
939                                    Object[] args = new Object[] {
940                                                    journalArticleModelImpl.getOriginalUuid()
941                                            };
942    
943                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
944                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
945                                            args);
946    
947                                    args = new Object[] { journalArticleModelImpl.getUuid() };
948    
949                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
950                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
951                                            args);
952                            }
953    
954                            if ((journalArticleModelImpl.getColumnBitmask() &
955                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
956                                    Object[] args = new Object[] {
957                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey())
958                                            };
959    
960                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
961                                            args);
962                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
963                                            args);
964    
965                                    args = new Object[] {
966                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey())
967                                            };
968    
969                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
970                                            args);
971                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
972                                            args);
973                            }
974    
975                            if ((journalArticleModelImpl.getColumnBitmask() &
976                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
977                                    Object[] args = new Object[] {
978                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
979                                            };
980    
981                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
982                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
983                                            args);
984    
985                                    args = new Object[] {
986                                                    Long.valueOf(journalArticleModelImpl.getGroupId())
987                                            };
988    
989                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
990                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
991                                            args);
992                            }
993    
994                            if ((journalArticleModelImpl.getColumnBitmask() &
995                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
996                                    Object[] args = new Object[] {
997                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId())
998                                            };
999    
1000                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
1001                                            args);
1002                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
1003                                            args);
1004    
1005                                    args = new Object[] {
1006                                                    Long.valueOf(journalArticleModelImpl.getCompanyId())
1007                                            };
1008    
1009                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
1010                                            args);
1011                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
1012                                            args);
1013                            }
1014    
1015                            if ((journalArticleModelImpl.getColumnBitmask() &
1016                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
1017                                    Object[] args = new Object[] {
1018                                                    journalArticleModelImpl.getOriginalStructureId()
1019                                            };
1020    
1021                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1022                                            args);
1023                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
1024                                            args);
1025    
1026                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
1027    
1028                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1029                                            args);
1030                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
1031                                            args);
1032                            }
1033    
1034                            if ((journalArticleModelImpl.getColumnBitmask() &
1035                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
1036                                    Object[] args = new Object[] {
1037                                                    journalArticleModelImpl.getOriginalTemplateId()
1038                                            };
1039    
1040                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
1041                                            args);
1042                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
1043                                            args);
1044    
1045                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
1046    
1047                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
1048                                            args);
1049                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
1050                                            args);
1051                            }
1052    
1053                            if ((journalArticleModelImpl.getColumnBitmask() &
1054                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
1055                                    Object[] args = new Object[] {
1056                                                    Long.valueOf(journalArticleModelImpl.getOriginalSmallImageId())
1057                                            };
1058    
1059                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
1060                                            args);
1061                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
1062                                            args);
1063    
1064                                    args = new Object[] {
1065                                                    Long.valueOf(journalArticleModelImpl.getSmallImageId())
1066                                            };
1067    
1068                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
1069                                            args);
1070                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
1071                                            args);
1072                            }
1073    
1074                            if ((journalArticleModelImpl.getColumnBitmask() &
1075                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
1076                                    Object[] args = new Object[] {
1077                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey()),
1078                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1079                                            };
1080    
1081                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
1082                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
1083                                            args);
1084    
1085                                    args = new Object[] {
1086                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey()),
1087                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1088                                            };
1089    
1090                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
1091                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
1092                                            args);
1093                            }
1094    
1095                            if ((journalArticleModelImpl.getColumnBitmask() &
1096                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
1097                                    Object[] args = new Object[] {
1098                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1099                                                    
1100                                                    journalArticleModelImpl.getOriginalArticleId()
1101                                            };
1102    
1103                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1104                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
1105                                            args);
1106    
1107                                    args = new Object[] {
1108                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1109                                                    
1110                                                    journalArticleModelImpl.getArticleId()
1111                                            };
1112    
1113                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1114                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
1115                                            args);
1116                            }
1117    
1118                            if ((journalArticleModelImpl.getColumnBitmask() &
1119                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
1120                                    Object[] args = new Object[] {
1121                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1122                                                    
1123                                                    journalArticleModelImpl.getOriginalUrlTitle()
1124                                            };
1125    
1126                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
1127                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
1128                                            args);
1129    
1130                                    args = new Object[] {
1131                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1132                                                    
1133                                                    journalArticleModelImpl.getUrlTitle()
1134                                            };
1135    
1136                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
1137                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
1138                                            args);
1139                            }
1140    
1141                            if ((journalArticleModelImpl.getColumnBitmask() &
1142                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
1143                                    Object[] args = new Object[] {
1144                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1145                                                    
1146                                                    journalArticleModelImpl.getOriginalStructureId()
1147                                            };
1148    
1149                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1150                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1151                                            args);
1152    
1153                                    args = new Object[] {
1154                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1155                                                    
1156                                                    journalArticleModelImpl.getStructureId()
1157                                            };
1158    
1159                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1160                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1161                                            args);
1162                            }
1163    
1164                            if ((journalArticleModelImpl.getColumnBitmask() &
1165                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
1166                                    Object[] args = new Object[] {
1167                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1168                                                    
1169                                                    journalArticleModelImpl.getOriginalTemplateId()
1170                                            };
1171    
1172                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
1173                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
1174                                            args);
1175    
1176                                    args = new Object[] {
1177                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1178                                                    
1179                                                    journalArticleModelImpl.getTemplateId()
1180                                            };
1181    
1182                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
1183                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
1184                                            args);
1185                            }
1186    
1187                            if ((journalArticleModelImpl.getColumnBitmask() &
1188                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
1189                                    Object[] args = new Object[] {
1190                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1191                                                    
1192                                                    journalArticleModelImpl.getOriginalLayoutUuid()
1193                                            };
1194    
1195                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
1196                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
1197                                            args);
1198    
1199                                    args = new Object[] {
1200                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1201                                                    
1202                                                    journalArticleModelImpl.getLayoutUuid()
1203                                            };
1204    
1205                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
1206                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
1207                                            args);
1208                            }
1209    
1210                            if ((journalArticleModelImpl.getColumnBitmask() &
1211                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
1212                                    Object[] args = new Object[] {
1213                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1214                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1215                                            };
1216    
1217                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
1218                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
1219                                            args);
1220    
1221                                    args = new Object[] {
1222                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1223                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1224                                            };
1225    
1226                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
1227                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
1228                                            args);
1229                            }
1230    
1231                            if ((journalArticleModelImpl.getColumnBitmask() &
1232                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
1233                                    Object[] args = new Object[] {
1234                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1235                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion())
1236                                            };
1237    
1238                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
1239                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
1240                                            args);
1241    
1242                                    args = new Object[] {
1243                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1244                                                    Double.valueOf(journalArticleModelImpl.getVersion())
1245                                            };
1246    
1247                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
1248                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
1249                                            args);
1250                            }
1251    
1252                            if ((journalArticleModelImpl.getColumnBitmask() &
1253                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
1254                                    Object[] args = new Object[] {
1255                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1256                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1257                                            };
1258    
1259                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
1260                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
1261                                            args);
1262    
1263                                    args = new Object[] {
1264                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1265                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1266                                            };
1267    
1268                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
1269                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
1270                                            args);
1271                            }
1272    
1273                            if ((journalArticleModelImpl.getColumnBitmask() &
1274                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
1275                                    Object[] args = new Object[] {
1276                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1277                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1278                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassPK())
1279                                            };
1280    
1281                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
1282                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
1283                                            args);
1284    
1285                                    args = new Object[] {
1286                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1287                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1288                                                    Long.valueOf(journalArticleModelImpl.getClassPK())
1289                                            };
1290    
1291                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
1292                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
1293                                            args);
1294                            }
1295    
1296                            if ((journalArticleModelImpl.getColumnBitmask() &
1297                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
1298                                    Object[] args = new Object[] {
1299                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1300                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1301                                                    
1302                                                    journalArticleModelImpl.getOriginalTemplateId()
1303                                            };
1304    
1305                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1306                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1307                                            args);
1308    
1309                                    args = new Object[] {
1310                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1311                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1312                                                    
1313                                                    journalArticleModelImpl.getTemplateId()
1314                                            };
1315    
1316                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1317                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1318                                            args);
1319                            }
1320    
1321                            if ((journalArticleModelImpl.getColumnBitmask() &
1322                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
1323                                    Object[] args = new Object[] {
1324                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1325                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1326                                                    
1327                                                    journalArticleModelImpl.getOriginalLayoutUuid()
1328                                            };
1329    
1330                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
1331                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
1332                                            args);
1333    
1334                                    args = new Object[] {
1335                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1336                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1337                                                    
1338                                                    journalArticleModelImpl.getLayoutUuid()
1339                                            };
1340    
1341                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
1342                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
1343                                            args);
1344                            }
1345    
1346                            if ((journalArticleModelImpl.getColumnBitmask() &
1347                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
1348                                    Object[] args = new Object[] {
1349                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1350                                                    
1351                                                    journalArticleModelImpl.getOriginalArticleId(),
1352                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1353                                            };
1354    
1355                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
1356                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
1357                                            args);
1358    
1359                                    args = new Object[] {
1360                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1361                                                    
1362                                                    journalArticleModelImpl.getArticleId(),
1363                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1364                                            };
1365    
1366                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
1367                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
1368                                            args);
1369                            }
1370    
1371                            if ((journalArticleModelImpl.getColumnBitmask() &
1372                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
1373                                    Object[] args = new Object[] {
1374                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1375                                                    
1376                                                    journalArticleModelImpl.getOriginalUrlTitle(),
1377                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1378                                            };
1379    
1380                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
1381                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
1382                                            args);
1383    
1384                                    args = new Object[] {
1385                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1386                                                    
1387                                                    journalArticleModelImpl.getUrlTitle(),
1388                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1389                                            };
1390    
1391                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
1392                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
1393                                            args);
1394                            }
1395    
1396                            if ((journalArticleModelImpl.getColumnBitmask() &
1397                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
1398                                    Object[] args = new Object[] {
1399                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1400                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion()),
1401                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1402                                            };
1403    
1404                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
1405                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
1406                                            args);
1407    
1408                                    args = new Object[] {
1409                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1410                                                    Double.valueOf(journalArticleModelImpl.getVersion()),
1411                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1412                                            };
1413    
1414                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
1415                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
1416                                            args);
1417                            }
1418                    }
1419    
1420                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1421                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
1422                            journalArticle);
1423    
1424                    if (isNew) {
1425                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1426                                    new Object[] {
1427                                            journalArticle.getUuid(),
1428                                            Long.valueOf(journalArticle.getGroupId())
1429                                    }, journalArticle);
1430    
1431                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
1432                                    new Object[] {
1433                                            Long.valueOf(journalArticle.getGroupId()),
1434                                            Long.valueOf(journalArticle.getClassNameId()),
1435                                            
1436                                    journalArticle.getStructureId()
1437                                    }, journalArticle);
1438    
1439                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
1440                                    new Object[] {
1441                                            Long.valueOf(journalArticle.getGroupId()),
1442                                            
1443                                    journalArticle.getArticleId(),
1444                                            Double.valueOf(journalArticle.getVersion())
1445                                    }, journalArticle);
1446                    }
1447                    else {
1448                            if ((journalArticleModelImpl.getColumnBitmask() &
1449                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
1450                                    Object[] args = new Object[] {
1451                                                    journalArticleModelImpl.getOriginalUuid(),
1452                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
1453                                            };
1454    
1455                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
1456                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
1457    
1458                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1459                                            new Object[] {
1460                                                    journalArticle.getUuid(),
1461                                                    Long.valueOf(journalArticle.getGroupId())
1462                                            }, journalArticle);
1463                            }
1464    
1465                            if ((journalArticleModelImpl.getColumnBitmask() &
1466                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
1467                                    Object[] args = new Object[] {
1468                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1469                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1470                                                    
1471                                                    journalArticleModelImpl.getOriginalStructureId()
1472                                            };
1473    
1474                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
1475                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
1476    
1477                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
1478                                            new Object[] {
1479                                                    Long.valueOf(journalArticle.getGroupId()),
1480                                                    Long.valueOf(journalArticle.getClassNameId()),
1481                                                    
1482                                            journalArticle.getStructureId()
1483                                            }, journalArticle);
1484                            }
1485    
1486                            if ((journalArticleModelImpl.getColumnBitmask() &
1487                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
1488                                    Object[] args = new Object[] {
1489                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1490                                                    
1491                                                    journalArticleModelImpl.getOriginalArticleId(),
1492                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion())
1493                                            };
1494    
1495                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
1496                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
1497    
1498                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
1499                                            new Object[] {
1500                                                    Long.valueOf(journalArticle.getGroupId()),
1501                                                    
1502                                            journalArticle.getArticleId(),
1503                                                    Double.valueOf(journalArticle.getVersion())
1504                                            }, journalArticle);
1505                            }
1506                    }
1507    
1508                    return journalArticle;
1509            }
1510    
1511            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
1512                    if (journalArticle instanceof JournalArticleImpl) {
1513                            return journalArticle;
1514                    }
1515    
1516                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
1517    
1518                    journalArticleImpl.setNew(journalArticle.isNew());
1519                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
1520    
1521                    journalArticleImpl.setUuid(journalArticle.getUuid());
1522                    journalArticleImpl.setId(journalArticle.getId());
1523                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
1524                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
1525                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
1526                    journalArticleImpl.setUserId(journalArticle.getUserId());
1527                    journalArticleImpl.setUserName(journalArticle.getUserName());
1528                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
1529                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
1530                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
1531                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
1532                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
1533                    journalArticleImpl.setVersion(journalArticle.getVersion());
1534                    journalArticleImpl.setTitle(journalArticle.getTitle());
1535                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
1536                    journalArticleImpl.setDescription(journalArticle.getDescription());
1537                    journalArticleImpl.setContent(journalArticle.getContent());
1538                    journalArticleImpl.setType(journalArticle.getType());
1539                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
1540                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
1541                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
1542                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
1543                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
1544                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
1545                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
1546                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
1547                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
1548                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
1549                    journalArticleImpl.setStatus(journalArticle.getStatus());
1550                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
1551                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
1552                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
1553    
1554                    return journalArticleImpl;
1555            }
1556    
1557            /**
1558             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
1559             *
1560             * @param primaryKey the primary key of the journal article
1561             * @return the journal article
1562             * @throws com.liferay.portal.NoSuchModelException if a journal article with the primary key could not be found
1563             * @throws SystemException if a system exception occurred
1564             */
1565            @Override
1566            public JournalArticle findByPrimaryKey(Serializable primaryKey)
1567                    throws NoSuchModelException, SystemException {
1568                    return findByPrimaryKey(((Long)primaryKey).longValue());
1569            }
1570    
1571            /**
1572             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
1573             *
1574             * @param id the primary key of the journal article
1575             * @return the journal article
1576             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1577             * @throws SystemException if a system exception occurred
1578             */
1579            public JournalArticle findByPrimaryKey(long id)
1580                    throws NoSuchArticleException, SystemException {
1581                    JournalArticle journalArticle = fetchByPrimaryKey(id);
1582    
1583                    if (journalArticle == null) {
1584                            if (_log.isWarnEnabled()) {
1585                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
1586                            }
1587    
1588                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1589                                    id);
1590                    }
1591    
1592                    return journalArticle;
1593            }
1594    
1595            /**
1596             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
1597             *
1598             * @param primaryKey the primary key of the journal article
1599             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
1600             * @throws SystemException if a system exception occurred
1601             */
1602            @Override
1603            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
1604                    throws SystemException {
1605                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
1606            }
1607    
1608            /**
1609             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
1610             *
1611             * @param id the primary key of the journal article
1612             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
1613             * @throws SystemException if a system exception occurred
1614             */
1615            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
1616                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1617                                    JournalArticleImpl.class, id);
1618    
1619                    if (journalArticle == _nullJournalArticle) {
1620                            return null;
1621                    }
1622    
1623                    if (journalArticle == null) {
1624                            Session session = null;
1625    
1626                            boolean hasException = false;
1627    
1628                            try {
1629                                    session = openSession();
1630    
1631                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
1632                                                    Long.valueOf(id));
1633                            }
1634                            catch (Exception e) {
1635                                    hasException = true;
1636    
1637                                    throw processException(e);
1638                            }
1639                            finally {
1640                                    if (journalArticle != null) {
1641                                            cacheResult(journalArticle);
1642                                    }
1643                                    else if (!hasException) {
1644                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1645                                                    JournalArticleImpl.class, id, _nullJournalArticle);
1646                                    }
1647    
1648                                    closeSession(session);
1649                            }
1650                    }
1651    
1652                    return journalArticle;
1653            }
1654    
1655            /**
1656             * Returns all the journal articles where uuid = &#63;.
1657             *
1658             * @param uuid the uuid
1659             * @return the matching journal articles
1660             * @throws SystemException if a system exception occurred
1661             */
1662            public List<JournalArticle> findByUuid(String uuid)
1663                    throws SystemException {
1664                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1665            }
1666    
1667            /**
1668             * Returns a range of all the journal articles where uuid = &#63;.
1669             *
1670             * <p>
1671             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1672             * </p>
1673             *
1674             * @param uuid the uuid
1675             * @param start the lower bound of the range of journal articles
1676             * @param end the upper bound of the range of journal articles (not inclusive)
1677             * @return the range of matching journal articles
1678             * @throws SystemException if a system exception occurred
1679             */
1680            public List<JournalArticle> findByUuid(String uuid, int start, int end)
1681                    throws SystemException {
1682                    return findByUuid(uuid, start, end, null);
1683            }
1684    
1685            /**
1686             * Returns an ordered range of all the journal articles where uuid = &#63;.
1687             *
1688             * <p>
1689             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1690             * </p>
1691             *
1692             * @param uuid the uuid
1693             * @param start the lower bound of the range of journal articles
1694             * @param end the upper bound of the range of journal articles (not inclusive)
1695             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1696             * @return the ordered range of matching journal articles
1697             * @throws SystemException if a system exception occurred
1698             */
1699            public List<JournalArticle> findByUuid(String uuid, int start, int end,
1700                    OrderByComparator orderByComparator) throws SystemException {
1701                    FinderPath finderPath = null;
1702                    Object[] finderArgs = null;
1703    
1704                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1705                                    (orderByComparator == null)) {
1706                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1707                            finderArgs = new Object[] { uuid };
1708                    }
1709                    else {
1710                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1711                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1712                    }
1713    
1714                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1715                                    finderArgs, this);
1716    
1717                    if ((list != null) && !list.isEmpty()) {
1718                            for (JournalArticle journalArticle : list) {
1719                                    if (!Validator.equals(uuid, journalArticle.getUuid())) {
1720                                            list = null;
1721    
1722                                            break;
1723                                    }
1724                            }
1725                    }
1726    
1727                    if (list == null) {
1728                            StringBundler query = null;
1729    
1730                            if (orderByComparator != null) {
1731                                    query = new StringBundler(3 +
1732                                                    (orderByComparator.getOrderByFields().length * 3));
1733                            }
1734                            else {
1735                                    query = new StringBundler(3);
1736                            }
1737    
1738                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1739    
1740                            if (uuid == null) {
1741                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1742                            }
1743                            else {
1744                                    if (uuid.equals(StringPool.BLANK)) {
1745                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1746                                    }
1747                                    else {
1748                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1749                                    }
1750                            }
1751    
1752                            if (orderByComparator != null) {
1753                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1754                                            orderByComparator);
1755                            }
1756    
1757                            else {
1758                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1759                            }
1760    
1761                            String sql = query.toString();
1762    
1763                            Session session = null;
1764    
1765                            try {
1766                                    session = openSession();
1767    
1768                                    Query q = session.createQuery(sql);
1769    
1770                                    QueryPos qPos = QueryPos.getInstance(q);
1771    
1772                                    if (uuid != null) {
1773                                            qPos.add(uuid);
1774                                    }
1775    
1776                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
1777                                                    start, end);
1778                            }
1779                            catch (Exception e) {
1780                                    throw processException(e);
1781                            }
1782                            finally {
1783                                    if (list == null) {
1784                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1785                                    }
1786                                    else {
1787                                            cacheResult(list);
1788    
1789                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1790                                    }
1791    
1792                                    closeSession(session);
1793                            }
1794                    }
1795    
1796                    return list;
1797            }
1798    
1799            /**
1800             * Returns the first journal article in the ordered set where uuid = &#63;.
1801             *
1802             * <p>
1803             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1804             * </p>
1805             *
1806             * @param uuid the uuid
1807             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1808             * @return the first matching journal article
1809             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1810             * @throws SystemException if a system exception occurred
1811             */
1812            public JournalArticle findByUuid_First(String uuid,
1813                    OrderByComparator orderByComparator)
1814                    throws NoSuchArticleException, SystemException {
1815                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
1816    
1817                    if (list.isEmpty()) {
1818                            StringBundler msg = new StringBundler(4);
1819    
1820                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1821    
1822                            msg.append("uuid=");
1823                            msg.append(uuid);
1824    
1825                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1826    
1827                            throw new NoSuchArticleException(msg.toString());
1828                    }
1829                    else {
1830                            return list.get(0);
1831                    }
1832            }
1833    
1834            /**
1835             * Returns the last journal article in the ordered set where uuid = &#63;.
1836             *
1837             * <p>
1838             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1839             * </p>
1840             *
1841             * @param uuid the uuid
1842             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1843             * @return the last matching journal article
1844             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1845             * @throws SystemException if a system exception occurred
1846             */
1847            public JournalArticle findByUuid_Last(String uuid,
1848                    OrderByComparator orderByComparator)
1849                    throws NoSuchArticleException, SystemException {
1850                    int count = countByUuid(uuid);
1851    
1852                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
1853                                    orderByComparator);
1854    
1855                    if (list.isEmpty()) {
1856                            StringBundler msg = new StringBundler(4);
1857    
1858                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1859    
1860                            msg.append("uuid=");
1861                            msg.append(uuid);
1862    
1863                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1864    
1865                            throw new NoSuchArticleException(msg.toString());
1866                    }
1867                    else {
1868                            return list.get(0);
1869                    }
1870            }
1871    
1872            /**
1873             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
1874             *
1875             * <p>
1876             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1877             * </p>
1878             *
1879             * @param id the primary key of the current journal article
1880             * @param uuid the uuid
1881             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1882             * @return the previous, current, and next journal article
1883             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1884             * @throws SystemException if a system exception occurred
1885             */
1886            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
1887                    OrderByComparator orderByComparator)
1888                    throws NoSuchArticleException, SystemException {
1889                    JournalArticle journalArticle = findByPrimaryKey(id);
1890    
1891                    Session session = null;
1892    
1893                    try {
1894                            session = openSession();
1895    
1896                            JournalArticle[] array = new JournalArticleImpl[3];
1897    
1898                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
1899                                            orderByComparator, true);
1900    
1901                            array[1] = journalArticle;
1902    
1903                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
1904                                            orderByComparator, false);
1905    
1906                            return array;
1907                    }
1908                    catch (Exception e) {
1909                            throw processException(e);
1910                    }
1911                    finally {
1912                            closeSession(session);
1913                    }
1914            }
1915    
1916            protected JournalArticle getByUuid_PrevAndNext(Session session,
1917                    JournalArticle journalArticle, String uuid,
1918                    OrderByComparator orderByComparator, boolean previous) {
1919                    StringBundler query = null;
1920    
1921                    if (orderByComparator != null) {
1922                            query = new StringBundler(6 +
1923                                            (orderByComparator.getOrderByFields().length * 6));
1924                    }
1925                    else {
1926                            query = new StringBundler(3);
1927                    }
1928    
1929                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1930    
1931                    if (uuid == null) {
1932                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1933                    }
1934                    else {
1935                            if (uuid.equals(StringPool.BLANK)) {
1936                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1937                            }
1938                            else {
1939                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1940                            }
1941                    }
1942    
1943                    if (orderByComparator != null) {
1944                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1945    
1946                            if (orderByConditionFields.length > 0) {
1947                                    query.append(WHERE_AND);
1948                            }
1949    
1950                            for (int i = 0; i < orderByConditionFields.length; i++) {
1951                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1952                                    query.append(orderByConditionFields[i]);
1953    
1954                                    if ((i + 1) < orderByConditionFields.length) {
1955                                            if (orderByComparator.isAscending() ^ previous) {
1956                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1957                                            }
1958                                            else {
1959                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1960                                            }
1961                                    }
1962                                    else {
1963                                            if (orderByComparator.isAscending() ^ previous) {
1964                                                    query.append(WHERE_GREATER_THAN);
1965                                            }
1966                                            else {
1967                                                    query.append(WHERE_LESSER_THAN);
1968                                            }
1969                                    }
1970                            }
1971    
1972                            query.append(ORDER_BY_CLAUSE);
1973    
1974                            String[] orderByFields = orderByComparator.getOrderByFields();
1975    
1976                            for (int i = 0; i < orderByFields.length; i++) {
1977                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1978                                    query.append(orderByFields[i]);
1979    
1980                                    if ((i + 1) < orderByFields.length) {
1981                                            if (orderByComparator.isAscending() ^ previous) {
1982                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1983                                            }
1984                                            else {
1985                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1986                                            }
1987                                    }
1988                                    else {
1989                                            if (orderByComparator.isAscending() ^ previous) {
1990                                                    query.append(ORDER_BY_ASC);
1991                                            }
1992                                            else {
1993                                                    query.append(ORDER_BY_DESC);
1994                                            }
1995                                    }
1996                            }
1997                    }
1998    
1999                    else {
2000                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2001                    }
2002    
2003                    String sql = query.toString();
2004    
2005                    Query q = session.createQuery(sql);
2006    
2007                    q.setFirstResult(0);
2008                    q.setMaxResults(2);
2009    
2010                    QueryPos qPos = QueryPos.getInstance(q);
2011    
2012                    if (uuid != null) {
2013                            qPos.add(uuid);
2014                    }
2015    
2016                    if (orderByComparator != null) {
2017                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2018    
2019                            for (Object value : values) {
2020                                    qPos.add(value);
2021                            }
2022                    }
2023    
2024                    List<JournalArticle> list = q.list();
2025    
2026                    if (list.size() == 2) {
2027                            return list.get(1);
2028                    }
2029                    else {
2030                            return null;
2031                    }
2032            }
2033    
2034            /**
2035             * 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.
2036             *
2037             * @param uuid the uuid
2038             * @param groupId the group ID
2039             * @return the matching journal article
2040             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2041             * @throws SystemException if a system exception occurred
2042             */
2043            public JournalArticle findByUUID_G(String uuid, long groupId)
2044                    throws NoSuchArticleException, SystemException {
2045                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
2046    
2047                    if (journalArticle == null) {
2048                            StringBundler msg = new StringBundler(6);
2049    
2050                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2051    
2052                            msg.append("uuid=");
2053                            msg.append(uuid);
2054    
2055                            msg.append(", groupId=");
2056                            msg.append(groupId);
2057    
2058                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2059    
2060                            if (_log.isWarnEnabled()) {
2061                                    _log.warn(msg.toString());
2062                            }
2063    
2064                            throw new NoSuchArticleException(msg.toString());
2065                    }
2066    
2067                    return journalArticle;
2068            }
2069    
2070            /**
2071             * 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.
2072             *
2073             * @param uuid the uuid
2074             * @param groupId the group ID
2075             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
2076             * @throws SystemException if a system exception occurred
2077             */
2078            public JournalArticle fetchByUUID_G(String uuid, long groupId)
2079                    throws SystemException {
2080                    return fetchByUUID_G(uuid, groupId, true);
2081            }
2082    
2083            /**
2084             * 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.
2085             *
2086             * @param uuid the uuid
2087             * @param groupId the group ID
2088             * @param retrieveFromCache whether to use the finder cache
2089             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
2090             * @throws SystemException if a system exception occurred
2091             */
2092            public JournalArticle fetchByUUID_G(String uuid, long groupId,
2093                    boolean retrieveFromCache) throws SystemException {
2094                    Object[] finderArgs = new Object[] { uuid, groupId };
2095    
2096                    Object result = null;
2097    
2098                    if (retrieveFromCache) {
2099                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
2100                                            finderArgs, this);
2101                    }
2102    
2103                    if (result instanceof JournalArticle) {
2104                            JournalArticle journalArticle = (JournalArticle)result;
2105    
2106                            if (!Validator.equals(uuid, journalArticle.getUuid()) ||
2107                                            (groupId != journalArticle.getGroupId())) {
2108                                    result = null;
2109                            }
2110                    }
2111    
2112                    if (result == null) {
2113                            StringBundler query = new StringBundler(4);
2114    
2115                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2116    
2117                            if (uuid == null) {
2118                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2119                            }
2120                            else {
2121                                    if (uuid.equals(StringPool.BLANK)) {
2122                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2123                                    }
2124                                    else {
2125                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2126                                    }
2127                            }
2128    
2129                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2130    
2131                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2132    
2133                            String sql = query.toString();
2134    
2135                            Session session = null;
2136    
2137                            try {
2138                                    session = openSession();
2139    
2140                                    Query q = session.createQuery(sql);
2141    
2142                                    QueryPos qPos = QueryPos.getInstance(q);
2143    
2144                                    if (uuid != null) {
2145                                            qPos.add(uuid);
2146                                    }
2147    
2148                                    qPos.add(groupId);
2149    
2150                                    List<JournalArticle> list = q.list();
2151    
2152                                    result = list;
2153    
2154                                    JournalArticle journalArticle = null;
2155    
2156                                    if (list.isEmpty()) {
2157                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2158                                                    finderArgs, list);
2159                                    }
2160                                    else {
2161                                            journalArticle = list.get(0);
2162    
2163                                            cacheResult(journalArticle);
2164    
2165                                            if ((journalArticle.getUuid() == null) ||
2166                                                            !journalArticle.getUuid().equals(uuid) ||
2167                                                            (journalArticle.getGroupId() != groupId)) {
2168                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2169                                                            finderArgs, journalArticle);
2170                                            }
2171                                    }
2172    
2173                                    return journalArticle;
2174                            }
2175                            catch (Exception e) {
2176                                    throw processException(e);
2177                            }
2178                            finally {
2179                                    if (result == null) {
2180                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
2181                                                    finderArgs);
2182                                    }
2183    
2184                                    closeSession(session);
2185                            }
2186                    }
2187                    else {
2188                            if (result instanceof List<?>) {
2189                                    return null;
2190                            }
2191                            else {
2192                                    return (JournalArticle)result;
2193                            }
2194                    }
2195            }
2196    
2197            /**
2198             * Returns all the journal articles where resourcePrimKey = &#63;.
2199             *
2200             * @param resourcePrimKey the resource prim key
2201             * @return the matching journal articles
2202             * @throws SystemException if a system exception occurred
2203             */
2204            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
2205                    throws SystemException {
2206                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
2207                            QueryUtil.ALL_POS, null);
2208            }
2209    
2210            /**
2211             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
2212             *
2213             * <p>
2214             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2215             * </p>
2216             *
2217             * @param resourcePrimKey the resource prim key
2218             * @param start the lower bound of the range of journal articles
2219             * @param end the upper bound of the range of journal articles (not inclusive)
2220             * @return the range of matching journal articles
2221             * @throws SystemException if a system exception occurred
2222             */
2223            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
2224                    int start, int end) throws SystemException {
2225                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
2226            }
2227    
2228            /**
2229             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
2230             *
2231             * <p>
2232             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2233             * </p>
2234             *
2235             * @param resourcePrimKey the resource prim key
2236             * @param start the lower bound of the range of journal articles
2237             * @param end the upper bound of the range of journal articles (not inclusive)
2238             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2239             * @return the ordered range of matching journal articles
2240             * @throws SystemException if a system exception occurred
2241             */
2242            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
2243                    int start, int end, OrderByComparator orderByComparator)
2244                    throws SystemException {
2245                    FinderPath finderPath = null;
2246                    Object[] finderArgs = null;
2247    
2248                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2249                                    (orderByComparator == null)) {
2250                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
2251                            finderArgs = new Object[] { resourcePrimKey };
2252                    }
2253                    else {
2254                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
2255                            finderArgs = new Object[] {
2256                                            resourcePrimKey,
2257                                            
2258                                            start, end, orderByComparator
2259                                    };
2260                    }
2261    
2262                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2263                                    finderArgs, this);
2264    
2265                    if ((list != null) && !list.isEmpty()) {
2266                            for (JournalArticle journalArticle : list) {
2267                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey())) {
2268                                            list = null;
2269    
2270                                            break;
2271                                    }
2272                            }
2273                    }
2274    
2275                    if (list == null) {
2276                            StringBundler query = null;
2277    
2278                            if (orderByComparator != null) {
2279                                    query = new StringBundler(3 +
2280                                                    (orderByComparator.getOrderByFields().length * 3));
2281                            }
2282                            else {
2283                                    query = new StringBundler(3);
2284                            }
2285    
2286                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2287    
2288                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
2289    
2290                            if (orderByComparator != null) {
2291                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2292                                            orderByComparator);
2293                            }
2294    
2295                            else {
2296                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2297                            }
2298    
2299                            String sql = query.toString();
2300    
2301                            Session session = null;
2302    
2303                            try {
2304                                    session = openSession();
2305    
2306                                    Query q = session.createQuery(sql);
2307    
2308                                    QueryPos qPos = QueryPos.getInstance(q);
2309    
2310                                    qPos.add(resourcePrimKey);
2311    
2312                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2313                                                    start, end);
2314                            }
2315                            catch (Exception e) {
2316                                    throw processException(e);
2317                            }
2318                            finally {
2319                                    if (list == null) {
2320                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2321                                    }
2322                                    else {
2323                                            cacheResult(list);
2324    
2325                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2326                                    }
2327    
2328                                    closeSession(session);
2329                            }
2330                    }
2331    
2332                    return list;
2333            }
2334    
2335            /**
2336             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
2337             *
2338             * <p>
2339             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2340             * </p>
2341             *
2342             * @param resourcePrimKey the resource prim key
2343             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2344             * @return the first matching journal article
2345             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2346             * @throws SystemException if a system exception occurred
2347             */
2348            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
2349                    OrderByComparator orderByComparator)
2350                    throws NoSuchArticleException, SystemException {
2351                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
2352                                    1, orderByComparator);
2353    
2354                    if (list.isEmpty()) {
2355                            StringBundler msg = new StringBundler(4);
2356    
2357                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2358    
2359                            msg.append("resourcePrimKey=");
2360                            msg.append(resourcePrimKey);
2361    
2362                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2363    
2364                            throw new NoSuchArticleException(msg.toString());
2365                    }
2366                    else {
2367                            return list.get(0);
2368                    }
2369            }
2370    
2371            /**
2372             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
2373             *
2374             * <p>
2375             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2376             * </p>
2377             *
2378             * @param resourcePrimKey the resource prim key
2379             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2380             * @return the last matching journal article
2381             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2382             * @throws SystemException if a system exception occurred
2383             */
2384            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
2385                    OrderByComparator orderByComparator)
2386                    throws NoSuchArticleException, SystemException {
2387                    int count = countByResourcePrimKey(resourcePrimKey);
2388    
2389                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
2390                                    count - 1, count, orderByComparator);
2391    
2392                    if (list.isEmpty()) {
2393                            StringBundler msg = new StringBundler(4);
2394    
2395                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2396    
2397                            msg.append("resourcePrimKey=");
2398                            msg.append(resourcePrimKey);
2399    
2400                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2401    
2402                            throw new NoSuchArticleException(msg.toString());
2403                    }
2404                    else {
2405                            return list.get(0);
2406                    }
2407            }
2408    
2409            /**
2410             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
2411             *
2412             * <p>
2413             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2414             * </p>
2415             *
2416             * @param id the primary key of the current journal article
2417             * @param resourcePrimKey the resource prim key
2418             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2419             * @return the previous, current, and next journal article
2420             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2421             * @throws SystemException if a system exception occurred
2422             */
2423            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
2424                    long resourcePrimKey, OrderByComparator orderByComparator)
2425                    throws NoSuchArticleException, SystemException {
2426                    JournalArticle journalArticle = findByPrimaryKey(id);
2427    
2428                    Session session = null;
2429    
2430                    try {
2431                            session = openSession();
2432    
2433                            JournalArticle[] array = new JournalArticleImpl[3];
2434    
2435                            array[0] = getByResourcePrimKey_PrevAndNext(session,
2436                                            journalArticle, resourcePrimKey, orderByComparator, true);
2437    
2438                            array[1] = journalArticle;
2439    
2440                            array[2] = getByResourcePrimKey_PrevAndNext(session,
2441                                            journalArticle, resourcePrimKey, orderByComparator, false);
2442    
2443                            return array;
2444                    }
2445                    catch (Exception e) {
2446                            throw processException(e);
2447                    }
2448                    finally {
2449                            closeSession(session);
2450                    }
2451            }
2452    
2453            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
2454                    JournalArticle journalArticle, long resourcePrimKey,
2455                    OrderByComparator orderByComparator, boolean previous) {
2456                    StringBundler query = null;
2457    
2458                    if (orderByComparator != null) {
2459                            query = new StringBundler(6 +
2460                                            (orderByComparator.getOrderByFields().length * 6));
2461                    }
2462                    else {
2463                            query = new StringBundler(3);
2464                    }
2465    
2466                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2467    
2468                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
2469    
2470                    if (orderByComparator != null) {
2471                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2472    
2473                            if (orderByConditionFields.length > 0) {
2474                                    query.append(WHERE_AND);
2475                            }
2476    
2477                            for (int i = 0; i < orderByConditionFields.length; i++) {
2478                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2479                                    query.append(orderByConditionFields[i]);
2480    
2481                                    if ((i + 1) < orderByConditionFields.length) {
2482                                            if (orderByComparator.isAscending() ^ previous) {
2483                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2484                                            }
2485                                            else {
2486                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2487                                            }
2488                                    }
2489                                    else {
2490                                            if (orderByComparator.isAscending() ^ previous) {
2491                                                    query.append(WHERE_GREATER_THAN);
2492                                            }
2493                                            else {
2494                                                    query.append(WHERE_LESSER_THAN);
2495                                            }
2496                                    }
2497                            }
2498    
2499                            query.append(ORDER_BY_CLAUSE);
2500    
2501                            String[] orderByFields = orderByComparator.getOrderByFields();
2502    
2503                            for (int i = 0; i < orderByFields.length; i++) {
2504                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2505                                    query.append(orderByFields[i]);
2506    
2507                                    if ((i + 1) < orderByFields.length) {
2508                                            if (orderByComparator.isAscending() ^ previous) {
2509                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2510                                            }
2511                                            else {
2512                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2513                                            }
2514                                    }
2515                                    else {
2516                                            if (orderByComparator.isAscending() ^ previous) {
2517                                                    query.append(ORDER_BY_ASC);
2518                                            }
2519                                            else {
2520                                                    query.append(ORDER_BY_DESC);
2521                                            }
2522                                    }
2523                            }
2524                    }
2525    
2526                    else {
2527                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2528                    }
2529    
2530                    String sql = query.toString();
2531    
2532                    Query q = session.createQuery(sql);
2533    
2534                    q.setFirstResult(0);
2535                    q.setMaxResults(2);
2536    
2537                    QueryPos qPos = QueryPos.getInstance(q);
2538    
2539                    qPos.add(resourcePrimKey);
2540    
2541                    if (orderByComparator != null) {
2542                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2543    
2544                            for (Object value : values) {
2545                                    qPos.add(value);
2546                            }
2547                    }
2548    
2549                    List<JournalArticle> list = q.list();
2550    
2551                    if (list.size() == 2) {
2552                            return list.get(1);
2553                    }
2554                    else {
2555                            return null;
2556                    }
2557            }
2558    
2559            /**
2560             * Returns all the journal articles where groupId = &#63;.
2561             *
2562             * @param groupId the group ID
2563             * @return the matching journal articles
2564             * @throws SystemException if a system exception occurred
2565             */
2566            public List<JournalArticle> findByGroupId(long groupId)
2567                    throws SystemException {
2568                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2569            }
2570    
2571            /**
2572             * Returns a range of all the journal articles where groupId = &#63;.
2573             *
2574             * <p>
2575             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2576             * </p>
2577             *
2578             * @param groupId the group ID
2579             * @param start the lower bound of the range of journal articles
2580             * @param end the upper bound of the range of journal articles (not inclusive)
2581             * @return the range of matching journal articles
2582             * @throws SystemException if a system exception occurred
2583             */
2584            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
2585                    throws SystemException {
2586                    return findByGroupId(groupId, start, end, null);
2587            }
2588    
2589            /**
2590             * Returns an ordered range of all the journal articles where groupId = &#63;.
2591             *
2592             * <p>
2593             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2594             * </p>
2595             *
2596             * @param groupId the group ID
2597             * @param start the lower bound of the range of journal articles
2598             * @param end the upper bound of the range of journal articles (not inclusive)
2599             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2600             * @return the ordered range of matching journal articles
2601             * @throws SystemException if a system exception occurred
2602             */
2603            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
2604                    OrderByComparator orderByComparator) throws SystemException {
2605                    FinderPath finderPath = null;
2606                    Object[] finderArgs = null;
2607    
2608                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2609                                    (orderByComparator == null)) {
2610                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2611                            finderArgs = new Object[] { groupId };
2612                    }
2613                    else {
2614                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2615                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2616                    }
2617    
2618                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2619                                    finderArgs, this);
2620    
2621                    if ((list != null) && !list.isEmpty()) {
2622                            for (JournalArticle journalArticle : list) {
2623                                    if ((groupId != journalArticle.getGroupId())) {
2624                                            list = null;
2625    
2626                                            break;
2627                                    }
2628                            }
2629                    }
2630    
2631                    if (list == null) {
2632                            StringBundler query = null;
2633    
2634                            if (orderByComparator != null) {
2635                                    query = new StringBundler(3 +
2636                                                    (orderByComparator.getOrderByFields().length * 3));
2637                            }
2638                            else {
2639                                    query = new StringBundler(3);
2640                            }
2641    
2642                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2643    
2644                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2645    
2646                            if (orderByComparator != null) {
2647                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2648                                            orderByComparator);
2649                            }
2650    
2651                            else {
2652                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2653                            }
2654    
2655                            String sql = query.toString();
2656    
2657                            Session session = null;
2658    
2659                            try {
2660                                    session = openSession();
2661    
2662                                    Query q = session.createQuery(sql);
2663    
2664                                    QueryPos qPos = QueryPos.getInstance(q);
2665    
2666                                    qPos.add(groupId);
2667    
2668                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2669                                                    start, end);
2670                            }
2671                            catch (Exception e) {
2672                                    throw processException(e);
2673                            }
2674                            finally {
2675                                    if (list == null) {
2676                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2677                                    }
2678                                    else {
2679                                            cacheResult(list);
2680    
2681                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2682                                    }
2683    
2684                                    closeSession(session);
2685                            }
2686                    }
2687    
2688                    return list;
2689            }
2690    
2691            /**
2692             * Returns the first journal article in the ordered set where groupId = &#63;.
2693             *
2694             * <p>
2695             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2696             * </p>
2697             *
2698             * @param groupId the group ID
2699             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2700             * @return the first matching journal article
2701             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2702             * @throws SystemException if a system exception occurred
2703             */
2704            public JournalArticle findByGroupId_First(long groupId,
2705                    OrderByComparator orderByComparator)
2706                    throws NoSuchArticleException, SystemException {
2707                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2708                                    orderByComparator);
2709    
2710                    if (list.isEmpty()) {
2711                            StringBundler msg = new StringBundler(4);
2712    
2713                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2714    
2715                            msg.append("groupId=");
2716                            msg.append(groupId);
2717    
2718                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2719    
2720                            throw new NoSuchArticleException(msg.toString());
2721                    }
2722                    else {
2723                            return list.get(0);
2724                    }
2725            }
2726    
2727            /**
2728             * Returns the last journal article in the ordered set where groupId = &#63;.
2729             *
2730             * <p>
2731             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2732             * </p>
2733             *
2734             * @param groupId the group ID
2735             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2736             * @return the last matching journal article
2737             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2738             * @throws SystemException if a system exception occurred
2739             */
2740            public JournalArticle findByGroupId_Last(long groupId,
2741                    OrderByComparator orderByComparator)
2742                    throws NoSuchArticleException, SystemException {
2743                    int count = countByGroupId(groupId);
2744    
2745                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2746                                    orderByComparator);
2747    
2748                    if (list.isEmpty()) {
2749                            StringBundler msg = new StringBundler(4);
2750    
2751                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2752    
2753                            msg.append("groupId=");
2754                            msg.append(groupId);
2755    
2756                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2757    
2758                            throw new NoSuchArticleException(msg.toString());
2759                    }
2760                    else {
2761                            return list.get(0);
2762                    }
2763            }
2764    
2765            /**
2766             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2767             *
2768             * <p>
2769             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2770             * </p>
2771             *
2772             * @param id the primary key of the current journal article
2773             * @param groupId the group ID
2774             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2775             * @return the previous, current, and next journal article
2776             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2777             * @throws SystemException if a system exception occurred
2778             */
2779            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2780                    OrderByComparator orderByComparator)
2781                    throws NoSuchArticleException, SystemException {
2782                    JournalArticle journalArticle = findByPrimaryKey(id);
2783    
2784                    Session session = null;
2785    
2786                    try {
2787                            session = openSession();
2788    
2789                            JournalArticle[] array = new JournalArticleImpl[3];
2790    
2791                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2792                                            groupId, orderByComparator, true);
2793    
2794                            array[1] = journalArticle;
2795    
2796                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2797                                            groupId, orderByComparator, false);
2798    
2799                            return array;
2800                    }
2801                    catch (Exception e) {
2802                            throw processException(e);
2803                    }
2804                    finally {
2805                            closeSession(session);
2806                    }
2807            }
2808    
2809            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2810                    JournalArticle journalArticle, long groupId,
2811                    OrderByComparator orderByComparator, boolean previous) {
2812                    StringBundler query = null;
2813    
2814                    if (orderByComparator != null) {
2815                            query = new StringBundler(6 +
2816                                            (orderByComparator.getOrderByFields().length * 6));
2817                    }
2818                    else {
2819                            query = new StringBundler(3);
2820                    }
2821    
2822                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2823    
2824                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2825    
2826                    if (orderByComparator != null) {
2827                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2828    
2829                            if (orderByConditionFields.length > 0) {
2830                                    query.append(WHERE_AND);
2831                            }
2832    
2833                            for (int i = 0; i < orderByConditionFields.length; i++) {
2834                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2835                                    query.append(orderByConditionFields[i]);
2836    
2837                                    if ((i + 1) < orderByConditionFields.length) {
2838                                            if (orderByComparator.isAscending() ^ previous) {
2839                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2840                                            }
2841                                            else {
2842                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2843                                            }
2844                                    }
2845                                    else {
2846                                            if (orderByComparator.isAscending() ^ previous) {
2847                                                    query.append(WHERE_GREATER_THAN);
2848                                            }
2849                                            else {
2850                                                    query.append(WHERE_LESSER_THAN);
2851                                            }
2852                                    }
2853                            }
2854    
2855                            query.append(ORDER_BY_CLAUSE);
2856    
2857                            String[] orderByFields = orderByComparator.getOrderByFields();
2858    
2859                            for (int i = 0; i < orderByFields.length; i++) {
2860                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2861                                    query.append(orderByFields[i]);
2862    
2863                                    if ((i + 1) < orderByFields.length) {
2864                                            if (orderByComparator.isAscending() ^ previous) {
2865                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2866                                            }
2867                                            else {
2868                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2869                                            }
2870                                    }
2871                                    else {
2872                                            if (orderByComparator.isAscending() ^ previous) {
2873                                                    query.append(ORDER_BY_ASC);
2874                                            }
2875                                            else {
2876                                                    query.append(ORDER_BY_DESC);
2877                                            }
2878                                    }
2879                            }
2880                    }
2881    
2882                    else {
2883                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2884                    }
2885    
2886                    String sql = query.toString();
2887    
2888                    Query q = session.createQuery(sql);
2889    
2890                    q.setFirstResult(0);
2891                    q.setMaxResults(2);
2892    
2893                    QueryPos qPos = QueryPos.getInstance(q);
2894    
2895                    qPos.add(groupId);
2896    
2897                    if (orderByComparator != null) {
2898                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2899    
2900                            for (Object value : values) {
2901                                    qPos.add(value);
2902                            }
2903                    }
2904    
2905                    List<JournalArticle> list = q.list();
2906    
2907                    if (list.size() == 2) {
2908                            return list.get(1);
2909                    }
2910                    else {
2911                            return null;
2912                    }
2913            }
2914    
2915            /**
2916             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2917             *
2918             * @param groupId the group ID
2919             * @return the matching journal articles that the user has permission to view
2920             * @throws SystemException if a system exception occurred
2921             */
2922            public List<JournalArticle> filterFindByGroupId(long groupId)
2923                    throws SystemException {
2924                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2925                            QueryUtil.ALL_POS, null);
2926            }
2927    
2928            /**
2929             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
2930             *
2931             * <p>
2932             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2933             * </p>
2934             *
2935             * @param groupId the group ID
2936             * @param start the lower bound of the range of journal articles
2937             * @param end the upper bound of the range of journal articles (not inclusive)
2938             * @return the range of matching journal articles that the user has permission to view
2939             * @throws SystemException if a system exception occurred
2940             */
2941            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2942                    int end) throws SystemException {
2943                    return filterFindByGroupId(groupId, start, end, null);
2944            }
2945    
2946            /**
2947             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
2948             *
2949             * <p>
2950             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2951             * </p>
2952             *
2953             * @param groupId the group ID
2954             * @param start the lower bound of the range of journal articles
2955             * @param end the upper bound of the range of journal articles (not inclusive)
2956             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2957             * @return the ordered range of matching journal articles that the user has permission to view
2958             * @throws SystemException if a system exception occurred
2959             */
2960            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2961                    int end, OrderByComparator orderByComparator) throws SystemException {
2962                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2963                            return findByGroupId(groupId, start, end, orderByComparator);
2964                    }
2965    
2966                    StringBundler query = null;
2967    
2968                    if (orderByComparator != null) {
2969                            query = new StringBundler(3 +
2970                                            (orderByComparator.getOrderByFields().length * 3));
2971                    }
2972                    else {
2973                            query = new StringBundler(3);
2974                    }
2975    
2976                    if (getDB().isSupportsInlineDistinct()) {
2977                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2978                    }
2979                    else {
2980                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2981                    }
2982    
2983                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2984    
2985                    if (!getDB().isSupportsInlineDistinct()) {
2986                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2987                    }
2988    
2989                    if (orderByComparator != null) {
2990                            if (getDB().isSupportsInlineDistinct()) {
2991                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2992                                            orderByComparator);
2993                            }
2994                            else {
2995                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2996                                            orderByComparator);
2997                            }
2998                    }
2999    
3000                    else {
3001                            if (getDB().isSupportsInlineDistinct()) {
3002                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3003                            }
3004                            else {
3005                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
3006                            }
3007                    }
3008    
3009                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3010                                    JournalArticle.class.getName(),
3011                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3012    
3013                    Session session = null;
3014    
3015                    try {
3016                            session = openSession();
3017    
3018                            SQLQuery q = session.createSQLQuery(sql);
3019    
3020                            if (getDB().isSupportsInlineDistinct()) {
3021                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
3022                            }
3023                            else {
3024                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
3025                            }
3026    
3027                            QueryPos qPos = QueryPos.getInstance(q);
3028    
3029                            qPos.add(groupId);
3030    
3031                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
3032                                    end);
3033                    }
3034                    catch (Exception e) {
3035                            throw processException(e);
3036                    }
3037                    finally {
3038                            closeSession(session);
3039                    }
3040            }
3041    
3042            /**
3043             * 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;.
3044             *
3045             * @param id the primary key of the current journal article
3046             * @param groupId the group ID
3047             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3048             * @return the previous, current, and next journal article
3049             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3050             * @throws SystemException if a system exception occurred
3051             */
3052            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
3053                    long groupId, OrderByComparator orderByComparator)
3054                    throws NoSuchArticleException, SystemException {
3055                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3056                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
3057                    }
3058    
3059                    JournalArticle journalArticle = findByPrimaryKey(id);
3060    
3061                    Session session = null;
3062    
3063                    try {
3064                            session = openSession();
3065    
3066                            JournalArticle[] array = new JournalArticleImpl[3];
3067    
3068                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
3069                                            groupId, orderByComparator, true);
3070    
3071                            array[1] = journalArticle;
3072    
3073                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
3074                                            groupId, orderByComparator, false);
3075    
3076                            return array;
3077                    }
3078                    catch (Exception e) {
3079                            throw processException(e);
3080                    }
3081                    finally {
3082                            closeSession(session);
3083                    }
3084            }
3085    
3086            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
3087                    JournalArticle journalArticle, long groupId,
3088                    OrderByComparator orderByComparator, boolean previous) {
3089                    StringBundler query = null;
3090    
3091                    if (orderByComparator != null) {
3092                            query = new StringBundler(6 +
3093                                            (orderByComparator.getOrderByFields().length * 6));
3094                    }
3095                    else {
3096                            query = new StringBundler(3);
3097                    }
3098    
3099                    if (getDB().isSupportsInlineDistinct()) {
3100                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
3101                    }
3102                    else {
3103                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
3104                    }
3105    
3106                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3107    
3108                    if (!getDB().isSupportsInlineDistinct()) {
3109                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
3110                    }
3111    
3112                    if (orderByComparator != null) {
3113                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3114    
3115                            if (orderByConditionFields.length > 0) {
3116                                    query.append(WHERE_AND);
3117                            }
3118    
3119                            for (int i = 0; i < orderByConditionFields.length; i++) {
3120                                    if (getDB().isSupportsInlineDistinct()) {
3121                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3122                                    }
3123                                    else {
3124                                            query.append(_ORDER_BY_ENTITY_TABLE);
3125                                    }
3126    
3127                                    query.append(orderByConditionFields[i]);
3128    
3129                                    if ((i + 1) < orderByConditionFields.length) {
3130                                            if (orderByComparator.isAscending() ^ previous) {
3131                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3132                                            }
3133                                            else {
3134                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3135                                            }
3136                                    }
3137                                    else {
3138                                            if (orderByComparator.isAscending() ^ previous) {
3139                                                    query.append(WHERE_GREATER_THAN);
3140                                            }
3141                                            else {
3142                                                    query.append(WHERE_LESSER_THAN);
3143                                            }
3144                                    }
3145                            }
3146    
3147                            query.append(ORDER_BY_CLAUSE);
3148    
3149                            String[] orderByFields = orderByComparator.getOrderByFields();
3150    
3151                            for (int i = 0; i < orderByFields.length; i++) {
3152                                    if (getDB().isSupportsInlineDistinct()) {
3153                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3154                                    }
3155                                    else {
3156                                            query.append(_ORDER_BY_ENTITY_TABLE);
3157                                    }
3158    
3159                                    query.append(orderByFields[i]);
3160    
3161                                    if ((i + 1) < orderByFields.length) {
3162                                            if (orderByComparator.isAscending() ^ previous) {
3163                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3164                                            }
3165                                            else {
3166                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3167                                            }
3168                                    }
3169                                    else {
3170                                            if (orderByComparator.isAscending() ^ previous) {
3171                                                    query.append(ORDER_BY_ASC);
3172                                            }
3173                                            else {
3174                                                    query.append(ORDER_BY_DESC);
3175                                            }
3176                                    }
3177                            }
3178                    }
3179    
3180                    else {
3181                            if (getDB().isSupportsInlineDistinct()) {
3182                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3183                            }
3184                            else {
3185                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
3186                            }
3187                    }
3188    
3189                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3190                                    JournalArticle.class.getName(),
3191                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3192    
3193                    SQLQuery q = session.createSQLQuery(sql);
3194    
3195                    q.setFirstResult(0);
3196                    q.setMaxResults(2);
3197    
3198                    if (getDB().isSupportsInlineDistinct()) {
3199                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
3200                    }
3201                    else {
3202                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
3203                    }
3204    
3205                    QueryPos qPos = QueryPos.getInstance(q);
3206    
3207                    qPos.add(groupId);
3208    
3209                    if (orderByComparator != null) {
3210                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3211    
3212                            for (Object value : values) {
3213                                    qPos.add(value);
3214                            }
3215                    }
3216    
3217                    List<JournalArticle> list = q.list();
3218    
3219                    if (list.size() == 2) {
3220                            return list.get(1);
3221                    }
3222                    else {
3223                            return null;
3224                    }
3225            }
3226    
3227            /**
3228             * Returns all the journal articles where companyId = &#63;.
3229             *
3230             * @param companyId the company ID
3231             * @return the matching journal articles
3232             * @throws SystemException if a system exception occurred
3233             */
3234            public List<JournalArticle> findByCompanyId(long companyId)
3235                    throws SystemException {
3236                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3237                            null);
3238            }
3239    
3240            /**
3241             * Returns a range of all the journal articles where companyId = &#63;.
3242             *
3243             * <p>
3244             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3245             * </p>
3246             *
3247             * @param companyId the company ID
3248             * @param start the lower bound of the range of journal articles
3249             * @param end the upper bound of the range of journal articles (not inclusive)
3250             * @return the range of matching journal articles
3251             * @throws SystemException if a system exception occurred
3252             */
3253            public List<JournalArticle> findByCompanyId(long companyId, int start,
3254                    int end) throws SystemException {
3255                    return findByCompanyId(companyId, start, end, null);
3256            }
3257    
3258            /**
3259             * Returns an ordered range of all the journal articles where companyId = &#63;.
3260             *
3261             * <p>
3262             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3263             * </p>
3264             *
3265             * @param companyId the company ID
3266             * @param start the lower bound of the range of journal articles
3267             * @param end the upper bound of the range of journal articles (not inclusive)
3268             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3269             * @return the ordered range of matching journal articles
3270             * @throws SystemException if a system exception occurred
3271             */
3272            public List<JournalArticle> findByCompanyId(long companyId, int start,
3273                    int end, OrderByComparator orderByComparator) throws SystemException {
3274                    FinderPath finderPath = null;
3275                    Object[] finderArgs = null;
3276    
3277                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3278                                    (orderByComparator == null)) {
3279                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
3280                            finderArgs = new Object[] { companyId };
3281                    }
3282                    else {
3283                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
3284                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
3285                    }
3286    
3287                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3288                                    finderArgs, this);
3289    
3290                    if ((list != null) && !list.isEmpty()) {
3291                            for (JournalArticle journalArticle : list) {
3292                                    if ((companyId != journalArticle.getCompanyId())) {
3293                                            list = null;
3294    
3295                                            break;
3296                                    }
3297                            }
3298                    }
3299    
3300                    if (list == null) {
3301                            StringBundler query = null;
3302    
3303                            if (orderByComparator != null) {
3304                                    query = new StringBundler(3 +
3305                                                    (orderByComparator.getOrderByFields().length * 3));
3306                            }
3307                            else {
3308                                    query = new StringBundler(3);
3309                            }
3310    
3311                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3312    
3313                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3314    
3315                            if (orderByComparator != null) {
3316                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3317                                            orderByComparator);
3318                            }
3319    
3320                            else {
3321                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3322                            }
3323    
3324                            String sql = query.toString();
3325    
3326                            Session session = null;
3327    
3328                            try {
3329                                    session = openSession();
3330    
3331                                    Query q = session.createQuery(sql);
3332    
3333                                    QueryPos qPos = QueryPos.getInstance(q);
3334    
3335                                    qPos.add(companyId);
3336    
3337                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3338                                                    start, end);
3339                            }
3340                            catch (Exception e) {
3341                                    throw processException(e);
3342                            }
3343                            finally {
3344                                    if (list == null) {
3345                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3346                                    }
3347                                    else {
3348                                            cacheResult(list);
3349    
3350                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3351                                    }
3352    
3353                                    closeSession(session);
3354                            }
3355                    }
3356    
3357                    return list;
3358            }
3359    
3360            /**
3361             * Returns the first journal article in the ordered set where companyId = &#63;.
3362             *
3363             * <p>
3364             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3365             * </p>
3366             *
3367             * @param companyId the company ID
3368             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3369             * @return the first matching journal article
3370             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3371             * @throws SystemException if a system exception occurred
3372             */
3373            public JournalArticle findByCompanyId_First(long companyId,
3374                    OrderByComparator orderByComparator)
3375                    throws NoSuchArticleException, SystemException {
3376                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
3377                                    orderByComparator);
3378    
3379                    if (list.isEmpty()) {
3380                            StringBundler msg = new StringBundler(4);
3381    
3382                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3383    
3384                            msg.append("companyId=");
3385                            msg.append(companyId);
3386    
3387                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3388    
3389                            throw new NoSuchArticleException(msg.toString());
3390                    }
3391                    else {
3392                            return list.get(0);
3393                    }
3394            }
3395    
3396            /**
3397             * Returns the last journal article in the ordered set where companyId = &#63;.
3398             *
3399             * <p>
3400             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3401             * </p>
3402             *
3403             * @param companyId the company ID
3404             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3405             * @return the last matching journal article
3406             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3407             * @throws SystemException if a system exception occurred
3408             */
3409            public JournalArticle findByCompanyId_Last(long companyId,
3410                    OrderByComparator orderByComparator)
3411                    throws NoSuchArticleException, SystemException {
3412                    int count = countByCompanyId(companyId);
3413    
3414                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3415                                    count, orderByComparator);
3416    
3417                    if (list.isEmpty()) {
3418                            StringBundler msg = new StringBundler(4);
3419    
3420                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3421    
3422                            msg.append("companyId=");
3423                            msg.append(companyId);
3424    
3425                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3426    
3427                            throw new NoSuchArticleException(msg.toString());
3428                    }
3429                    else {
3430                            return list.get(0);
3431                    }
3432            }
3433    
3434            /**
3435             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3436             *
3437             * <p>
3438             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3439             * </p>
3440             *
3441             * @param id the primary key of the current journal article
3442             * @param companyId the company ID
3443             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3444             * @return the previous, current, and next journal article
3445             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3446             * @throws SystemException if a system exception occurred
3447             */
3448            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3449                    long companyId, OrderByComparator orderByComparator)
3450                    throws NoSuchArticleException, SystemException {
3451                    JournalArticle journalArticle = findByPrimaryKey(id);
3452    
3453                    Session session = null;
3454    
3455                    try {
3456                            session = openSession();
3457    
3458                            JournalArticle[] array = new JournalArticleImpl[3];
3459    
3460                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3461                                            companyId, orderByComparator, true);
3462    
3463                            array[1] = journalArticle;
3464    
3465                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3466                                            companyId, orderByComparator, false);
3467    
3468                            return array;
3469                    }
3470                    catch (Exception e) {
3471                            throw processException(e);
3472                    }
3473                    finally {
3474                            closeSession(session);
3475                    }
3476            }
3477    
3478            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3479                    JournalArticle journalArticle, long companyId,
3480                    OrderByComparator orderByComparator, boolean previous) {
3481                    StringBundler query = null;
3482    
3483                    if (orderByComparator != null) {
3484                            query = new StringBundler(6 +
3485                                            (orderByComparator.getOrderByFields().length * 6));
3486                    }
3487                    else {
3488                            query = new StringBundler(3);
3489                    }
3490    
3491                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3492    
3493                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3494    
3495                    if (orderByComparator != null) {
3496                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3497    
3498                            if (orderByConditionFields.length > 0) {
3499                                    query.append(WHERE_AND);
3500                            }
3501    
3502                            for (int i = 0; i < orderByConditionFields.length; i++) {
3503                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3504                                    query.append(orderByConditionFields[i]);
3505    
3506                                    if ((i + 1) < orderByConditionFields.length) {
3507                                            if (orderByComparator.isAscending() ^ previous) {
3508                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3509                                            }
3510                                            else {
3511                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3512                                            }
3513                                    }
3514                                    else {
3515                                            if (orderByComparator.isAscending() ^ previous) {
3516                                                    query.append(WHERE_GREATER_THAN);
3517                                            }
3518                                            else {
3519                                                    query.append(WHERE_LESSER_THAN);
3520                                            }
3521                                    }
3522                            }
3523    
3524                            query.append(ORDER_BY_CLAUSE);
3525    
3526                            String[] orderByFields = orderByComparator.getOrderByFields();
3527    
3528                            for (int i = 0; i < orderByFields.length; i++) {
3529                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3530                                    query.append(orderByFields[i]);
3531    
3532                                    if ((i + 1) < orderByFields.length) {
3533                                            if (orderByComparator.isAscending() ^ previous) {
3534                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3535                                            }
3536                                            else {
3537                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3538                                            }
3539                                    }
3540                                    else {
3541                                            if (orderByComparator.isAscending() ^ previous) {
3542                                                    query.append(ORDER_BY_ASC);
3543                                            }
3544                                            else {
3545                                                    query.append(ORDER_BY_DESC);
3546                                            }
3547                                    }
3548                            }
3549                    }
3550    
3551                    else {
3552                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3553                    }
3554    
3555                    String sql = query.toString();
3556    
3557                    Query q = session.createQuery(sql);
3558    
3559                    q.setFirstResult(0);
3560                    q.setMaxResults(2);
3561    
3562                    QueryPos qPos = QueryPos.getInstance(q);
3563    
3564                    qPos.add(companyId);
3565    
3566                    if (orderByComparator != null) {
3567                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3568    
3569                            for (Object value : values) {
3570                                    qPos.add(value);
3571                            }
3572                    }
3573    
3574                    List<JournalArticle> list = q.list();
3575    
3576                    if (list.size() == 2) {
3577                            return list.get(1);
3578                    }
3579                    else {
3580                            return null;
3581                    }
3582            }
3583    
3584            /**
3585             * Returns all the journal articles where structureId = &#63;.
3586             *
3587             * @param structureId the structure ID
3588             * @return the matching journal articles
3589             * @throws SystemException if a system exception occurred
3590             */
3591            public List<JournalArticle> findByStructureId(String structureId)
3592                    throws SystemException {
3593                    return findByStructureId(structureId, QueryUtil.ALL_POS,
3594                            QueryUtil.ALL_POS, null);
3595            }
3596    
3597            /**
3598             * Returns a range of all the journal articles where structureId = &#63;.
3599             *
3600             * <p>
3601             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3602             * </p>
3603             *
3604             * @param structureId the structure ID
3605             * @param start the lower bound of the range of journal articles
3606             * @param end the upper bound of the range of journal articles (not inclusive)
3607             * @return the range of matching journal articles
3608             * @throws SystemException if a system exception occurred
3609             */
3610            public List<JournalArticle> findByStructureId(String structureId,
3611                    int start, int end) throws SystemException {
3612                    return findByStructureId(structureId, start, end, null);
3613            }
3614    
3615            /**
3616             * Returns an ordered range of all the journal articles where structureId = &#63;.
3617             *
3618             * <p>
3619             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3620             * </p>
3621             *
3622             * @param structureId the structure ID
3623             * @param start the lower bound of the range of journal articles
3624             * @param end the upper bound of the range of journal articles (not inclusive)
3625             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3626             * @return the ordered range of matching journal articles
3627             * @throws SystemException if a system exception occurred
3628             */
3629            public List<JournalArticle> findByStructureId(String structureId,
3630                    int start, int end, OrderByComparator orderByComparator)
3631                    throws SystemException {
3632                    FinderPath finderPath = null;
3633                    Object[] finderArgs = null;
3634    
3635                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3636                                    (orderByComparator == null)) {
3637                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
3638                            finderArgs = new Object[] { structureId };
3639                    }
3640                    else {
3641                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
3642                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
3643                    }
3644    
3645                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3646                                    finderArgs, this);
3647    
3648                    if ((list != null) && !list.isEmpty()) {
3649                            for (JournalArticle journalArticle : list) {
3650                                    if (!Validator.equals(structureId,
3651                                                            journalArticle.getStructureId())) {
3652                                            list = null;
3653    
3654                                            break;
3655                                    }
3656                            }
3657                    }
3658    
3659                    if (list == null) {
3660                            StringBundler query = null;
3661    
3662                            if (orderByComparator != null) {
3663                                    query = new StringBundler(3 +
3664                                                    (orderByComparator.getOrderByFields().length * 3));
3665                            }
3666                            else {
3667                                    query = new StringBundler(3);
3668                            }
3669    
3670                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3671    
3672                            if (structureId == null) {
3673                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3674                            }
3675                            else {
3676                                    if (structureId.equals(StringPool.BLANK)) {
3677                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3678                                    }
3679                                    else {
3680                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3681                                    }
3682                            }
3683    
3684                            if (orderByComparator != null) {
3685                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3686                                            orderByComparator);
3687                            }
3688    
3689                            else {
3690                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3691                            }
3692    
3693                            String sql = query.toString();
3694    
3695                            Session session = null;
3696    
3697                            try {
3698                                    session = openSession();
3699    
3700                                    Query q = session.createQuery(sql);
3701    
3702                                    QueryPos qPos = QueryPos.getInstance(q);
3703    
3704                                    if (structureId != null) {
3705                                            qPos.add(structureId);
3706                                    }
3707    
3708                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3709                                                    start, end);
3710                            }
3711                            catch (Exception e) {
3712                                    throw processException(e);
3713                            }
3714                            finally {
3715                                    if (list == null) {
3716                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3717                                    }
3718                                    else {
3719                                            cacheResult(list);
3720    
3721                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3722                                    }
3723    
3724                                    closeSession(session);
3725                            }
3726                    }
3727    
3728                    return list;
3729            }
3730    
3731            /**
3732             * Returns the first journal article in the ordered set where structureId = &#63;.
3733             *
3734             * <p>
3735             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3736             * </p>
3737             *
3738             * @param structureId the structure ID
3739             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3740             * @return the first matching journal article
3741             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3742             * @throws SystemException if a system exception occurred
3743             */
3744            public JournalArticle findByStructureId_First(String structureId,
3745                    OrderByComparator orderByComparator)
3746                    throws NoSuchArticleException, SystemException {
3747                    List<JournalArticle> list = findByStructureId(structureId, 0, 1,
3748                                    orderByComparator);
3749    
3750                    if (list.isEmpty()) {
3751                            StringBundler msg = new StringBundler(4);
3752    
3753                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3754    
3755                            msg.append("structureId=");
3756                            msg.append(structureId);
3757    
3758                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3759    
3760                            throw new NoSuchArticleException(msg.toString());
3761                    }
3762                    else {
3763                            return list.get(0);
3764                    }
3765            }
3766    
3767            /**
3768             * Returns the last journal article in the ordered set where structureId = &#63;.
3769             *
3770             * <p>
3771             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3772             * </p>
3773             *
3774             * @param structureId the structure ID
3775             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3776             * @return the last matching journal article
3777             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3778             * @throws SystemException if a system exception occurred
3779             */
3780            public JournalArticle findByStructureId_Last(String structureId,
3781                    OrderByComparator orderByComparator)
3782                    throws NoSuchArticleException, SystemException {
3783                    int count = countByStructureId(structureId);
3784    
3785                    List<JournalArticle> list = findByStructureId(structureId, count - 1,
3786                                    count, orderByComparator);
3787    
3788                    if (list.isEmpty()) {
3789                            StringBundler msg = new StringBundler(4);
3790    
3791                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3792    
3793                            msg.append("structureId=");
3794                            msg.append(structureId);
3795    
3796                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3797    
3798                            throw new NoSuchArticleException(msg.toString());
3799                    }
3800                    else {
3801                            return list.get(0);
3802                    }
3803            }
3804    
3805            /**
3806             * Returns the journal articles before and after the current journal article in the ordered set where structureId = &#63;.
3807             *
3808             * <p>
3809             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3810             * </p>
3811             *
3812             * @param id the primary key of the current journal article
3813             * @param structureId the structure ID
3814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3815             * @return the previous, current, and next journal article
3816             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3817             * @throws SystemException if a system exception occurred
3818             */
3819            public JournalArticle[] findByStructureId_PrevAndNext(long id,
3820                    String structureId, OrderByComparator orderByComparator)
3821                    throws NoSuchArticleException, SystemException {
3822                    JournalArticle journalArticle = findByPrimaryKey(id);
3823    
3824                    Session session = null;
3825    
3826                    try {
3827                            session = openSession();
3828    
3829                            JournalArticle[] array = new JournalArticleImpl[3];
3830    
3831                            array[0] = getByStructureId_PrevAndNext(session, journalArticle,
3832                                            structureId, orderByComparator, true);
3833    
3834                            array[1] = journalArticle;
3835    
3836                            array[2] = getByStructureId_PrevAndNext(session, journalArticle,
3837                                            structureId, orderByComparator, false);
3838    
3839                            return array;
3840                    }
3841                    catch (Exception e) {
3842                            throw processException(e);
3843                    }
3844                    finally {
3845                            closeSession(session);
3846                    }
3847            }
3848    
3849            protected JournalArticle getByStructureId_PrevAndNext(Session session,
3850                    JournalArticle journalArticle, String structureId,
3851                    OrderByComparator orderByComparator, boolean previous) {
3852                    StringBundler query = null;
3853    
3854                    if (orderByComparator != null) {
3855                            query = new StringBundler(6 +
3856                                            (orderByComparator.getOrderByFields().length * 6));
3857                    }
3858                    else {
3859                            query = new StringBundler(3);
3860                    }
3861    
3862                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3863    
3864                    if (structureId == null) {
3865                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3866                    }
3867                    else {
3868                            if (structureId.equals(StringPool.BLANK)) {
3869                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3870                            }
3871                            else {
3872                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3873                            }
3874                    }
3875    
3876                    if (orderByComparator != null) {
3877                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3878    
3879                            if (orderByConditionFields.length > 0) {
3880                                    query.append(WHERE_AND);
3881                            }
3882    
3883                            for (int i = 0; i < orderByConditionFields.length; i++) {
3884                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3885                                    query.append(orderByConditionFields[i]);
3886    
3887                                    if ((i + 1) < orderByConditionFields.length) {
3888                                            if (orderByComparator.isAscending() ^ previous) {
3889                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3890                                            }
3891                                            else {
3892                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3893                                            }
3894                                    }
3895                                    else {
3896                                            if (orderByComparator.isAscending() ^ previous) {
3897                                                    query.append(WHERE_GREATER_THAN);
3898                                            }
3899                                            else {
3900                                                    query.append(WHERE_LESSER_THAN);
3901                                            }
3902                                    }
3903                            }
3904    
3905                            query.append(ORDER_BY_CLAUSE);
3906    
3907                            String[] orderByFields = orderByComparator.getOrderByFields();
3908    
3909                            for (int i = 0; i < orderByFields.length; i++) {
3910                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3911                                    query.append(orderByFields[i]);
3912    
3913                                    if ((i + 1) < orderByFields.length) {
3914                                            if (orderByComparator.isAscending() ^ previous) {
3915                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3916                                            }
3917                                            else {
3918                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3919                                            }
3920                                    }
3921                                    else {
3922                                            if (orderByComparator.isAscending() ^ previous) {
3923                                                    query.append(ORDER_BY_ASC);
3924                                            }
3925                                            else {
3926                                                    query.append(ORDER_BY_DESC);
3927                                            }
3928                                    }
3929                            }
3930                    }
3931    
3932                    else {
3933                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3934                    }
3935    
3936                    String sql = query.toString();
3937    
3938                    Query q = session.createQuery(sql);
3939    
3940                    q.setFirstResult(0);
3941                    q.setMaxResults(2);
3942    
3943                    QueryPos qPos = QueryPos.getInstance(q);
3944    
3945                    if (structureId != null) {
3946                            qPos.add(structureId);
3947                    }
3948    
3949                    if (orderByComparator != null) {
3950                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3951    
3952                            for (Object value : values) {
3953                                    qPos.add(value);
3954                            }
3955                    }
3956    
3957                    List<JournalArticle> list = q.list();
3958    
3959                    if (list.size() == 2) {
3960                            return list.get(1);
3961                    }
3962                    else {
3963                            return null;
3964                    }
3965            }
3966    
3967            /**
3968             * Returns all the journal articles where templateId = &#63;.
3969             *
3970             * @param templateId the template ID
3971             * @return the matching journal articles
3972             * @throws SystemException if a system exception occurred
3973             */
3974            public List<JournalArticle> findByTemplateId(String templateId)
3975                    throws SystemException {
3976                    return findByTemplateId(templateId, QueryUtil.ALL_POS,
3977                            QueryUtil.ALL_POS, null);
3978            }
3979    
3980            /**
3981             * Returns a range of all the journal articles where templateId = &#63;.
3982             *
3983             * <p>
3984             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3985             * </p>
3986             *
3987             * @param templateId the template ID
3988             * @param start the lower bound of the range of journal articles
3989             * @param end the upper bound of the range of journal articles (not inclusive)
3990             * @return the range of matching journal articles
3991             * @throws SystemException if a system exception occurred
3992             */
3993            public List<JournalArticle> findByTemplateId(String templateId, int start,
3994                    int end) throws SystemException {
3995                    return findByTemplateId(templateId, start, end, null);
3996            }
3997    
3998            /**
3999             * Returns an ordered range of all the journal articles where templateId = &#63;.
4000             *
4001             * <p>
4002             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4003             * </p>
4004             *
4005             * @param templateId the template ID
4006             * @param start the lower bound of the range of journal articles
4007             * @param end the upper bound of the range of journal articles (not inclusive)
4008             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4009             * @return the ordered range of matching journal articles
4010             * @throws SystemException if a system exception occurred
4011             */
4012            public List<JournalArticle> findByTemplateId(String templateId, int start,
4013                    int end, OrderByComparator orderByComparator) throws SystemException {
4014                    FinderPath finderPath = null;
4015                    Object[] finderArgs = null;
4016    
4017                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4018                                    (orderByComparator == null)) {
4019                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID;
4020                            finderArgs = new Object[] { templateId };
4021                    }
4022                    else {
4023                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID;
4024                            finderArgs = new Object[] { templateId, start, end, orderByComparator };
4025                    }
4026    
4027                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4028                                    finderArgs, this);
4029    
4030                    if ((list != null) && !list.isEmpty()) {
4031                            for (JournalArticle journalArticle : list) {
4032                                    if (!Validator.equals(templateId, journalArticle.getTemplateId())) {
4033                                            list = null;
4034    
4035                                            break;
4036                                    }
4037                            }
4038                    }
4039    
4040                    if (list == null) {
4041                            StringBundler query = null;
4042    
4043                            if (orderByComparator != null) {
4044                                    query = new StringBundler(3 +
4045                                                    (orderByComparator.getOrderByFields().length * 3));
4046                            }
4047                            else {
4048                                    query = new StringBundler(3);
4049                            }
4050    
4051                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4052    
4053                            if (templateId == null) {
4054                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4055                            }
4056                            else {
4057                                    if (templateId.equals(StringPool.BLANK)) {
4058                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4059                                    }
4060                                    else {
4061                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4062                                    }
4063                            }
4064    
4065                            if (orderByComparator != null) {
4066                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4067                                            orderByComparator);
4068                            }
4069    
4070                            else {
4071                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4072                            }
4073    
4074                            String sql = query.toString();
4075    
4076                            Session session = null;
4077    
4078                            try {
4079                                    session = openSession();
4080    
4081                                    Query q = session.createQuery(sql);
4082    
4083                                    QueryPos qPos = QueryPos.getInstance(q);
4084    
4085                                    if (templateId != null) {
4086                                            qPos.add(templateId);
4087                                    }
4088    
4089                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4090                                                    start, end);
4091                            }
4092                            catch (Exception e) {
4093                                    throw processException(e);
4094                            }
4095                            finally {
4096                                    if (list == null) {
4097                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4098                                    }
4099                                    else {
4100                                            cacheResult(list);
4101    
4102                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4103                                    }
4104    
4105                                    closeSession(session);
4106                            }
4107                    }
4108    
4109                    return list;
4110            }
4111    
4112            /**
4113             * Returns the first journal article in the ordered set where templateId = &#63;.
4114             *
4115             * <p>
4116             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4117             * </p>
4118             *
4119             * @param templateId the template ID
4120             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4121             * @return the first matching journal article
4122             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4123             * @throws SystemException if a system exception occurred
4124             */
4125            public JournalArticle findByTemplateId_First(String templateId,
4126                    OrderByComparator orderByComparator)
4127                    throws NoSuchArticleException, SystemException {
4128                    List<JournalArticle> list = findByTemplateId(templateId, 0, 1,
4129                                    orderByComparator);
4130    
4131                    if (list.isEmpty()) {
4132                            StringBundler msg = new StringBundler(4);
4133    
4134                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4135    
4136                            msg.append("templateId=");
4137                            msg.append(templateId);
4138    
4139                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4140    
4141                            throw new NoSuchArticleException(msg.toString());
4142                    }
4143                    else {
4144                            return list.get(0);
4145                    }
4146            }
4147    
4148            /**
4149             * Returns the last journal article in the ordered set where templateId = &#63;.
4150             *
4151             * <p>
4152             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4153             * </p>
4154             *
4155             * @param templateId the template ID
4156             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4157             * @return the last matching journal article
4158             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4159             * @throws SystemException if a system exception occurred
4160             */
4161            public JournalArticle findByTemplateId_Last(String templateId,
4162                    OrderByComparator orderByComparator)
4163                    throws NoSuchArticleException, SystemException {
4164                    int count = countByTemplateId(templateId);
4165    
4166                    List<JournalArticle> list = findByTemplateId(templateId, count - 1,
4167                                    count, orderByComparator);
4168    
4169                    if (list.isEmpty()) {
4170                            StringBundler msg = new StringBundler(4);
4171    
4172                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4173    
4174                            msg.append("templateId=");
4175                            msg.append(templateId);
4176    
4177                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4178    
4179                            throw new NoSuchArticleException(msg.toString());
4180                    }
4181                    else {
4182                            return list.get(0);
4183                    }
4184            }
4185    
4186            /**
4187             * Returns the journal articles before and after the current journal article in the ordered set where templateId = &#63;.
4188             *
4189             * <p>
4190             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4191             * </p>
4192             *
4193             * @param id the primary key of the current journal article
4194             * @param templateId the template ID
4195             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4196             * @return the previous, current, and next journal article
4197             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4198             * @throws SystemException if a system exception occurred
4199             */
4200            public JournalArticle[] findByTemplateId_PrevAndNext(long id,
4201                    String templateId, OrderByComparator orderByComparator)
4202                    throws NoSuchArticleException, SystemException {
4203                    JournalArticle journalArticle = findByPrimaryKey(id);
4204    
4205                    Session session = null;
4206    
4207                    try {
4208                            session = openSession();
4209    
4210                            JournalArticle[] array = new JournalArticleImpl[3];
4211    
4212                            array[0] = getByTemplateId_PrevAndNext(session, journalArticle,
4213                                            templateId, orderByComparator, true);
4214    
4215                            array[1] = journalArticle;
4216    
4217                            array[2] = getByTemplateId_PrevAndNext(session, journalArticle,
4218                                            templateId, orderByComparator, false);
4219    
4220                            return array;
4221                    }
4222                    catch (Exception e) {
4223                            throw processException(e);
4224                    }
4225                    finally {
4226                            closeSession(session);
4227                    }
4228            }
4229    
4230            protected JournalArticle getByTemplateId_PrevAndNext(Session session,
4231                    JournalArticle journalArticle, String templateId,
4232                    OrderByComparator orderByComparator, boolean previous) {
4233                    StringBundler query = null;
4234    
4235                    if (orderByComparator != null) {
4236                            query = new StringBundler(6 +
4237                                            (orderByComparator.getOrderByFields().length * 6));
4238                    }
4239                    else {
4240                            query = new StringBundler(3);
4241                    }
4242    
4243                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4244    
4245                    if (templateId == null) {
4246                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4247                    }
4248                    else {
4249                            if (templateId.equals(StringPool.BLANK)) {
4250                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4251                            }
4252                            else {
4253                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4254                            }
4255                    }
4256    
4257                    if (orderByComparator != null) {
4258                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4259    
4260                            if (orderByConditionFields.length > 0) {
4261                                    query.append(WHERE_AND);
4262                            }
4263    
4264                            for (int i = 0; i < orderByConditionFields.length; i++) {
4265                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4266                                    query.append(orderByConditionFields[i]);
4267    
4268                                    if ((i + 1) < orderByConditionFields.length) {
4269                                            if (orderByComparator.isAscending() ^ previous) {
4270                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4271                                            }
4272                                            else {
4273                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4274                                            }
4275                                    }
4276                                    else {
4277                                            if (orderByComparator.isAscending() ^ previous) {
4278                                                    query.append(WHERE_GREATER_THAN);
4279                                            }
4280                                            else {
4281                                                    query.append(WHERE_LESSER_THAN);
4282                                            }
4283                                    }
4284                            }
4285    
4286                            query.append(ORDER_BY_CLAUSE);
4287    
4288                            String[] orderByFields = orderByComparator.getOrderByFields();
4289    
4290                            for (int i = 0; i < orderByFields.length; i++) {
4291                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4292                                    query.append(orderByFields[i]);
4293    
4294                                    if ((i + 1) < orderByFields.length) {
4295                                            if (orderByComparator.isAscending() ^ previous) {
4296                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4297                                            }
4298                                            else {
4299                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4300                                            }
4301                                    }
4302                                    else {
4303                                            if (orderByComparator.isAscending() ^ previous) {
4304                                                    query.append(ORDER_BY_ASC);
4305                                            }
4306                                            else {
4307                                                    query.append(ORDER_BY_DESC);
4308                                            }
4309                                    }
4310                            }
4311                    }
4312    
4313                    else {
4314                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4315                    }
4316    
4317                    String sql = query.toString();
4318    
4319                    Query q = session.createQuery(sql);
4320    
4321                    q.setFirstResult(0);
4322                    q.setMaxResults(2);
4323    
4324                    QueryPos qPos = QueryPos.getInstance(q);
4325    
4326                    if (templateId != null) {
4327                            qPos.add(templateId);
4328                    }
4329    
4330                    if (orderByComparator != null) {
4331                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4332    
4333                            for (Object value : values) {
4334                                    qPos.add(value);
4335                            }
4336                    }
4337    
4338                    List<JournalArticle> list = q.list();
4339    
4340                    if (list.size() == 2) {
4341                            return list.get(1);
4342                    }
4343                    else {
4344                            return null;
4345                    }
4346            }
4347    
4348            /**
4349             * Returns all the journal articles where smallImageId = &#63;.
4350             *
4351             * @param smallImageId the small image ID
4352             * @return the matching journal articles
4353             * @throws SystemException if a system exception occurred
4354             */
4355            public List<JournalArticle> findBySmallImageId(long smallImageId)
4356                    throws SystemException {
4357                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
4358                            QueryUtil.ALL_POS, null);
4359            }
4360    
4361            /**
4362             * Returns a range of all the journal articles where smallImageId = &#63;.
4363             *
4364             * <p>
4365             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4366             * </p>
4367             *
4368             * @param smallImageId the small image ID
4369             * @param start the lower bound of the range of journal articles
4370             * @param end the upper bound of the range of journal articles (not inclusive)
4371             * @return the range of matching journal articles
4372             * @throws SystemException if a system exception occurred
4373             */
4374            public List<JournalArticle> findBySmallImageId(long smallImageId,
4375                    int start, int end) throws SystemException {
4376                    return findBySmallImageId(smallImageId, start, end, null);
4377            }
4378    
4379            /**
4380             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
4381             *
4382             * <p>
4383             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4384             * </p>
4385             *
4386             * @param smallImageId the small image ID
4387             * @param start the lower bound of the range of journal articles
4388             * @param end the upper bound of the range of journal articles (not inclusive)
4389             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4390             * @return the ordered range of matching journal articles
4391             * @throws SystemException if a system exception occurred
4392             */
4393            public List<JournalArticle> findBySmallImageId(long smallImageId,
4394                    int start, int end, OrderByComparator orderByComparator)
4395                    throws SystemException {
4396                    FinderPath finderPath = null;
4397                    Object[] finderArgs = null;
4398    
4399                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4400                                    (orderByComparator == null)) {
4401                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
4402                            finderArgs = new Object[] { smallImageId };
4403                    }
4404                    else {
4405                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
4406                            finderArgs = new Object[] {
4407                                            smallImageId,
4408                                            
4409                                            start, end, orderByComparator
4410                                    };
4411                    }
4412    
4413                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4414                                    finderArgs, this);
4415    
4416                    if ((list != null) && !list.isEmpty()) {
4417                            for (JournalArticle journalArticle : list) {
4418                                    if ((smallImageId != journalArticle.getSmallImageId())) {
4419                                            list = null;
4420    
4421                                            break;
4422                                    }
4423                            }
4424                    }
4425    
4426                    if (list == null) {
4427                            StringBundler query = null;
4428    
4429                            if (orderByComparator != null) {
4430                                    query = new StringBundler(3 +
4431                                                    (orderByComparator.getOrderByFields().length * 3));
4432                            }
4433                            else {
4434                                    query = new StringBundler(3);
4435                            }
4436    
4437                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4438    
4439                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
4440    
4441                            if (orderByComparator != null) {
4442                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4443                                            orderByComparator);
4444                            }
4445    
4446                            else {
4447                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4448                            }
4449    
4450                            String sql = query.toString();
4451    
4452                            Session session = null;
4453    
4454                            try {
4455                                    session = openSession();
4456    
4457                                    Query q = session.createQuery(sql);
4458    
4459                                    QueryPos qPos = QueryPos.getInstance(q);
4460    
4461                                    qPos.add(smallImageId);
4462    
4463                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4464                                                    start, end);
4465                            }
4466                            catch (Exception e) {
4467                                    throw processException(e);
4468                            }
4469                            finally {
4470                                    if (list == null) {
4471                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4472                                    }
4473                                    else {
4474                                            cacheResult(list);
4475    
4476                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4477                                    }
4478    
4479                                    closeSession(session);
4480                            }
4481                    }
4482    
4483                    return list;
4484            }
4485    
4486            /**
4487             * Returns the first journal article in the ordered set where smallImageId = &#63;.
4488             *
4489             * <p>
4490             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4491             * </p>
4492             *
4493             * @param smallImageId the small image ID
4494             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4495             * @return the first matching journal article
4496             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4497             * @throws SystemException if a system exception occurred
4498             */
4499            public JournalArticle findBySmallImageId_First(long smallImageId,
4500                    OrderByComparator orderByComparator)
4501                    throws NoSuchArticleException, SystemException {
4502                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
4503                                    orderByComparator);
4504    
4505                    if (list.isEmpty()) {
4506                            StringBundler msg = new StringBundler(4);
4507    
4508                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4509    
4510                            msg.append("smallImageId=");
4511                            msg.append(smallImageId);
4512    
4513                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4514    
4515                            throw new NoSuchArticleException(msg.toString());
4516                    }
4517                    else {
4518                            return list.get(0);
4519                    }
4520            }
4521    
4522            /**
4523             * Returns the last journal article in the ordered set where smallImageId = &#63;.
4524             *
4525             * <p>
4526             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4527             * </p>
4528             *
4529             * @param smallImageId the small image ID
4530             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4531             * @return the last matching journal article
4532             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4533             * @throws SystemException if a system exception occurred
4534             */
4535            public JournalArticle findBySmallImageId_Last(long smallImageId,
4536                    OrderByComparator orderByComparator)
4537                    throws NoSuchArticleException, SystemException {
4538                    int count = countBySmallImageId(smallImageId);
4539    
4540                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
4541                                    count, orderByComparator);
4542    
4543                    if (list.isEmpty()) {
4544                            StringBundler msg = new StringBundler(4);
4545    
4546                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4547    
4548                            msg.append("smallImageId=");
4549                            msg.append(smallImageId);
4550    
4551                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4552    
4553                            throw new NoSuchArticleException(msg.toString());
4554                    }
4555                    else {
4556                            return list.get(0);
4557                    }
4558            }
4559    
4560            /**
4561             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
4562             *
4563             * <p>
4564             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4565             * </p>
4566             *
4567             * @param id the primary key of the current journal article
4568             * @param smallImageId the small image ID
4569             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4570             * @return the previous, current, and next journal article
4571             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4572             * @throws SystemException if a system exception occurred
4573             */
4574            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
4575                    long smallImageId, OrderByComparator orderByComparator)
4576                    throws NoSuchArticleException, SystemException {
4577                    JournalArticle journalArticle = findByPrimaryKey(id);
4578    
4579                    Session session = null;
4580    
4581                    try {
4582                            session = openSession();
4583    
4584                            JournalArticle[] array = new JournalArticleImpl[3];
4585    
4586                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
4587                                            smallImageId, orderByComparator, true);
4588    
4589                            array[1] = journalArticle;
4590    
4591                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
4592                                            smallImageId, orderByComparator, false);
4593    
4594                            return array;
4595                    }
4596                    catch (Exception e) {
4597                            throw processException(e);
4598                    }
4599                    finally {
4600                            closeSession(session);
4601                    }
4602            }
4603    
4604            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
4605                    JournalArticle journalArticle, long smallImageId,
4606                    OrderByComparator orderByComparator, boolean previous) {
4607                    StringBundler query = null;
4608    
4609                    if (orderByComparator != null) {
4610                            query = new StringBundler(6 +
4611                                            (orderByComparator.getOrderByFields().length * 6));
4612                    }
4613                    else {
4614                            query = new StringBundler(3);
4615                    }
4616    
4617                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4618    
4619                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
4620    
4621                    if (orderByComparator != null) {
4622                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4623    
4624                            if (orderByConditionFields.length > 0) {
4625                                    query.append(WHERE_AND);
4626                            }
4627    
4628                            for (int i = 0; i < orderByConditionFields.length; i++) {
4629                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4630                                    query.append(orderByConditionFields[i]);
4631    
4632                                    if ((i + 1) < orderByConditionFields.length) {
4633                                            if (orderByComparator.isAscending() ^ previous) {
4634                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4635                                            }
4636                                            else {
4637                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4638                                            }
4639                                    }
4640                                    else {
4641                                            if (orderByComparator.isAscending() ^ previous) {
4642                                                    query.append(WHERE_GREATER_THAN);
4643                                            }
4644                                            else {
4645                                                    query.append(WHERE_LESSER_THAN);
4646                                            }
4647                                    }
4648                            }
4649    
4650                            query.append(ORDER_BY_CLAUSE);
4651    
4652                            String[] orderByFields = orderByComparator.getOrderByFields();
4653    
4654                            for (int i = 0; i < orderByFields.length; i++) {
4655                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4656                                    query.append(orderByFields[i]);
4657    
4658                                    if ((i + 1) < orderByFields.length) {
4659                                            if (orderByComparator.isAscending() ^ previous) {
4660                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4661                                            }
4662                                            else {
4663                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4664                                            }
4665                                    }
4666                                    else {
4667                                            if (orderByComparator.isAscending() ^ previous) {
4668                                                    query.append(ORDER_BY_ASC);
4669                                            }
4670                                            else {
4671                                                    query.append(ORDER_BY_DESC);
4672                                            }
4673                                    }
4674                            }
4675                    }
4676    
4677                    else {
4678                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4679                    }
4680    
4681                    String sql = query.toString();
4682    
4683                    Query q = session.createQuery(sql);
4684    
4685                    q.setFirstResult(0);
4686                    q.setMaxResults(2);
4687    
4688                    QueryPos qPos = QueryPos.getInstance(q);
4689    
4690                    qPos.add(smallImageId);
4691    
4692                    if (orderByComparator != null) {
4693                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4694    
4695                            for (Object value : values) {
4696                                    qPos.add(value);
4697                            }
4698                    }
4699    
4700                    List<JournalArticle> list = q.list();
4701    
4702                    if (list.size() == 2) {
4703                            return list.get(1);
4704                    }
4705                    else {
4706                            return null;
4707                    }
4708            }
4709    
4710            /**
4711             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
4712             *
4713             * @param resourcePrimKey the resource prim key
4714             * @param status the status
4715             * @return the matching journal articles
4716             * @throws SystemException if a system exception occurred
4717             */
4718            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
4719                    throws SystemException {
4720                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
4721                            QueryUtil.ALL_POS, null);
4722            }
4723    
4724            /**
4725             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
4726             *
4727             * <p>
4728             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4729             * </p>
4730             *
4731             * @param resourcePrimKey the resource prim key
4732             * @param status the status
4733             * @param start the lower bound of the range of journal articles
4734             * @param end the upper bound of the range of journal articles (not inclusive)
4735             * @return the range of matching journal articles
4736             * @throws SystemException if a system exception occurred
4737             */
4738            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
4739                    int start, int end) throws SystemException {
4740                    return findByR_ST(resourcePrimKey, status, start, end, null);
4741            }
4742    
4743            /**
4744             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
4745             *
4746             * <p>
4747             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4748             * </p>
4749             *
4750             * @param resourcePrimKey the resource prim key
4751             * @param status the status
4752             * @param start the lower bound of the range of journal articles
4753             * @param end the upper bound of the range of journal articles (not inclusive)
4754             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4755             * @return the ordered range of matching journal articles
4756             * @throws SystemException if a system exception occurred
4757             */
4758            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
4759                    int start, int end, OrderByComparator orderByComparator)
4760                    throws SystemException {
4761                    FinderPath finderPath = null;
4762                    Object[] finderArgs = null;
4763    
4764                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4765                                    (orderByComparator == null)) {
4766                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
4767                            finderArgs = new Object[] { resourcePrimKey, status };
4768                    }
4769                    else {
4770                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
4771                            finderArgs = new Object[] {
4772                                            resourcePrimKey, status,
4773                                            
4774                                            start, end, orderByComparator
4775                                    };
4776                    }
4777    
4778                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4779                                    finderArgs, this);
4780    
4781                    if ((list != null) && !list.isEmpty()) {
4782                            for (JournalArticle journalArticle : list) {
4783                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
4784                                                    (status != journalArticle.getStatus())) {
4785                                            list = null;
4786    
4787                                            break;
4788                                    }
4789                            }
4790                    }
4791    
4792                    if (list == null) {
4793                            StringBundler query = null;
4794    
4795                            if (orderByComparator != null) {
4796                                    query = new StringBundler(4 +
4797                                                    (orderByComparator.getOrderByFields().length * 3));
4798                            }
4799                            else {
4800                                    query = new StringBundler(4);
4801                            }
4802    
4803                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4804    
4805                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
4806    
4807                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
4808    
4809                            if (orderByComparator != null) {
4810                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4811                                            orderByComparator);
4812                            }
4813    
4814                            else {
4815                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4816                            }
4817    
4818                            String sql = query.toString();
4819    
4820                            Session session = null;
4821    
4822                            try {
4823                                    session = openSession();
4824    
4825                                    Query q = session.createQuery(sql);
4826    
4827                                    QueryPos qPos = QueryPos.getInstance(q);
4828    
4829                                    qPos.add(resourcePrimKey);
4830    
4831                                    qPos.add(status);
4832    
4833                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4834                                                    start, end);
4835                            }
4836                            catch (Exception e) {
4837                                    throw processException(e);
4838                            }
4839                            finally {
4840                                    if (list == null) {
4841                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4842                                    }
4843                                    else {
4844                                            cacheResult(list);
4845    
4846                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4847                                    }
4848    
4849                                    closeSession(session);
4850                            }
4851                    }
4852    
4853                    return list;
4854            }
4855    
4856            /**
4857             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
4858             *
4859             * <p>
4860             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4861             * </p>
4862             *
4863             * @param resourcePrimKey the resource prim key
4864             * @param status the status
4865             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4866             * @return the first matching journal article
4867             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4868             * @throws SystemException if a system exception occurred
4869             */
4870            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
4871                    OrderByComparator orderByComparator)
4872                    throws NoSuchArticleException, SystemException {
4873                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
4874                                    orderByComparator);
4875    
4876                    if (list.isEmpty()) {
4877                            StringBundler msg = new StringBundler(6);
4878    
4879                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4880    
4881                            msg.append("resourcePrimKey=");
4882                            msg.append(resourcePrimKey);
4883    
4884                            msg.append(", status=");
4885                            msg.append(status);
4886    
4887                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4888    
4889                            throw new NoSuchArticleException(msg.toString());
4890                    }
4891                    else {
4892                            return list.get(0);
4893                    }
4894            }
4895    
4896            /**
4897             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
4898             *
4899             * <p>
4900             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4901             * </p>
4902             *
4903             * @param resourcePrimKey the resource prim key
4904             * @param status the status
4905             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4906             * @return the last matching journal article
4907             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4908             * @throws SystemException if a system exception occurred
4909             */
4910            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
4911                    OrderByComparator orderByComparator)
4912                    throws NoSuchArticleException, SystemException {
4913                    int count = countByR_ST(resourcePrimKey, status);
4914    
4915                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
4916                                    count - 1, count, orderByComparator);
4917    
4918                    if (list.isEmpty()) {
4919                            StringBundler msg = new StringBundler(6);
4920    
4921                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4922    
4923                            msg.append("resourcePrimKey=");
4924                            msg.append(resourcePrimKey);
4925    
4926                            msg.append(", status=");
4927                            msg.append(status);
4928    
4929                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4930    
4931                            throw new NoSuchArticleException(msg.toString());
4932                    }
4933                    else {
4934                            return list.get(0);
4935                    }
4936            }
4937    
4938            /**
4939             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
4940             *
4941             * <p>
4942             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4943             * </p>
4944             *
4945             * @param id the primary key of the current journal article
4946             * @param resourcePrimKey the resource prim key
4947             * @param status the status
4948             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4949             * @return the previous, current, and next journal article
4950             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4951             * @throws SystemException if a system exception occurred
4952             */
4953            public JournalArticle[] findByR_ST_PrevAndNext(long id,
4954                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
4955                    throws NoSuchArticleException, SystemException {
4956                    JournalArticle journalArticle = findByPrimaryKey(id);
4957    
4958                    Session session = null;
4959    
4960                    try {
4961                            session = openSession();
4962    
4963                            JournalArticle[] array = new JournalArticleImpl[3];
4964    
4965                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
4966                                            resourcePrimKey, status, orderByComparator, true);
4967    
4968                            array[1] = journalArticle;
4969    
4970                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
4971                                            resourcePrimKey, status, orderByComparator, false);
4972    
4973                            return array;
4974                    }
4975                    catch (Exception e) {
4976                            throw processException(e);
4977                    }
4978                    finally {
4979                            closeSession(session);
4980                    }
4981            }
4982    
4983            protected JournalArticle getByR_ST_PrevAndNext(Session session,
4984                    JournalArticle journalArticle, long resourcePrimKey, int status,
4985                    OrderByComparator orderByComparator, boolean previous) {
4986                    StringBundler query = null;
4987    
4988                    if (orderByComparator != null) {
4989                            query = new StringBundler(6 +
4990                                            (orderByComparator.getOrderByFields().length * 6));
4991                    }
4992                    else {
4993                            query = new StringBundler(3);
4994                    }
4995    
4996                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4997    
4998                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
4999    
5000                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
5001    
5002                    if (orderByComparator != null) {
5003                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5004    
5005                            if (orderByConditionFields.length > 0) {
5006                                    query.append(WHERE_AND);
5007                            }
5008    
5009                            for (int i = 0; i < orderByConditionFields.length; i++) {
5010                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5011                                    query.append(orderByConditionFields[i]);
5012    
5013                                    if ((i + 1) < orderByConditionFields.length) {
5014                                            if (orderByComparator.isAscending() ^ previous) {
5015                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5016                                            }
5017                                            else {
5018                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5019                                            }
5020                                    }
5021                                    else {
5022                                            if (orderByComparator.isAscending() ^ previous) {
5023                                                    query.append(WHERE_GREATER_THAN);
5024                                            }
5025                                            else {
5026                                                    query.append(WHERE_LESSER_THAN);
5027                                            }
5028                                    }
5029                            }
5030    
5031                            query.append(ORDER_BY_CLAUSE);
5032    
5033                            String[] orderByFields = orderByComparator.getOrderByFields();
5034    
5035                            for (int i = 0; i < orderByFields.length; i++) {
5036                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5037                                    query.append(orderByFields[i]);
5038    
5039                                    if ((i + 1) < orderByFields.length) {
5040                                            if (orderByComparator.isAscending() ^ previous) {
5041                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5042                                            }
5043                                            else {
5044                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5045                                            }
5046                                    }
5047                                    else {
5048                                            if (orderByComparator.isAscending() ^ previous) {
5049                                                    query.append(ORDER_BY_ASC);
5050                                            }
5051                                            else {
5052                                                    query.append(ORDER_BY_DESC);
5053                                            }
5054                                    }
5055                            }
5056                    }
5057    
5058                    else {
5059                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5060                    }
5061    
5062                    String sql = query.toString();
5063    
5064                    Query q = session.createQuery(sql);
5065    
5066                    q.setFirstResult(0);
5067                    q.setMaxResults(2);
5068    
5069                    QueryPos qPos = QueryPos.getInstance(q);
5070    
5071                    qPos.add(resourcePrimKey);
5072    
5073                    qPos.add(status);
5074    
5075                    if (orderByComparator != null) {
5076                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5077    
5078                            for (Object value : values) {
5079                                    qPos.add(value);
5080                            }
5081                    }
5082    
5083                    List<JournalArticle> list = q.list();
5084    
5085                    if (list.size() == 2) {
5086                            return list.get(1);
5087                    }
5088                    else {
5089                            return null;
5090                    }
5091            }
5092    
5093            /**
5094             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
5095             *
5096             * @param groupId the group ID
5097             * @param articleId the article ID
5098             * @return the matching journal articles
5099             * @throws SystemException if a system exception occurred
5100             */
5101            public List<JournalArticle> findByG_A(long groupId, String articleId)
5102                    throws SystemException {
5103                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
5104                            QueryUtil.ALL_POS, null);
5105            }
5106    
5107            /**
5108             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
5109             *
5110             * <p>
5111             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5112             * </p>
5113             *
5114             * @param groupId the group ID
5115             * @param articleId the article ID
5116             * @param start the lower bound of the range of journal articles
5117             * @param end the upper bound of the range of journal articles (not inclusive)
5118             * @return the range of matching journal articles
5119             * @throws SystemException if a system exception occurred
5120             */
5121            public List<JournalArticle> findByG_A(long groupId, String articleId,
5122                    int start, int end) throws SystemException {
5123                    return findByG_A(groupId, articleId, start, end, null);
5124            }
5125    
5126            /**
5127             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
5128             *
5129             * <p>
5130             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5131             * </p>
5132             *
5133             * @param groupId the group ID
5134             * @param articleId the article ID
5135             * @param start the lower bound of the range of journal articles
5136             * @param end the upper bound of the range of journal articles (not inclusive)
5137             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5138             * @return the ordered range of matching journal articles
5139             * @throws SystemException if a system exception occurred
5140             */
5141            public List<JournalArticle> findByG_A(long groupId, String articleId,
5142                    int start, int end, OrderByComparator orderByComparator)
5143                    throws SystemException {
5144                    FinderPath finderPath = null;
5145                    Object[] finderArgs = null;
5146    
5147                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5148                                    (orderByComparator == null)) {
5149                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
5150                            finderArgs = new Object[] { groupId, articleId };
5151                    }
5152                    else {
5153                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
5154                            finderArgs = new Object[] {
5155                                            groupId, articleId,
5156                                            
5157                                            start, end, orderByComparator
5158                                    };
5159                    }
5160    
5161                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5162                                    finderArgs, this);
5163    
5164                    if ((list != null) && !list.isEmpty()) {
5165                            for (JournalArticle journalArticle : list) {
5166                                    if ((groupId != journalArticle.getGroupId()) ||
5167                                                    !Validator.equals(articleId,
5168                                                            journalArticle.getArticleId())) {
5169                                            list = null;
5170    
5171                                            break;
5172                                    }
5173                            }
5174                    }
5175    
5176                    if (list == null) {
5177                            StringBundler query = null;
5178    
5179                            if (orderByComparator != null) {
5180                                    query = new StringBundler(4 +
5181                                                    (orderByComparator.getOrderByFields().length * 3));
5182                            }
5183                            else {
5184                                    query = new StringBundler(4);
5185                            }
5186    
5187                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5188    
5189                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
5190    
5191                            if (articleId == null) {
5192                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
5193                            }
5194                            else {
5195                                    if (articleId.equals(StringPool.BLANK)) {
5196                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
5197                                    }
5198                                    else {
5199                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
5200                                    }
5201                            }
5202    
5203                            if (orderByComparator != null) {
5204                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5205                                            orderByComparator);
5206                            }
5207    
5208                            else {
5209                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5210                            }
5211    
5212                            String sql = query.toString();
5213    
5214                            Session session = null;
5215    
5216                            try {
5217                                    session = openSession();
5218    
5219                                    Query q = session.createQuery(sql);
5220    
5221                                    QueryPos qPos = QueryPos.getInstance(q);
5222    
5223                                    qPos.add(groupId);
5224    
5225                                    if (articleId != null) {
5226                                            qPos.add(articleId);
5227                                    }
5228    
5229                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5230                                                    start, end);
5231                            }
5232                            catch (Exception e) {
5233                                    throw processException(e);
5234                            }
5235                            finally {
5236                                    if (list == null) {
5237                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5238                                    }
5239                                    else {
5240                                            cacheResult(list);
5241    
5242                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5243                                    }
5244    
5245                                    closeSession(session);
5246                            }
5247                    }
5248    
5249                    return list;
5250            }
5251    
5252            /**
5253             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
5254             *
5255             * <p>
5256             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5257             * </p>
5258             *
5259             * @param groupId the group ID
5260             * @param articleId the article ID
5261             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5262             * @return the first matching journal article
5263             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5264             * @throws SystemException if a system exception occurred
5265             */
5266            public JournalArticle findByG_A_First(long groupId, String articleId,
5267                    OrderByComparator orderByComparator)
5268                    throws NoSuchArticleException, SystemException {
5269                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
5270                                    orderByComparator);
5271    
5272                    if (list.isEmpty()) {
5273                            StringBundler msg = new StringBundler(6);
5274    
5275                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5276    
5277                            msg.append("groupId=");
5278                            msg.append(groupId);
5279    
5280                            msg.append(", articleId=");
5281                            msg.append(articleId);
5282    
5283                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5284    
5285                            throw new NoSuchArticleException(msg.toString());
5286                    }
5287                    else {
5288                            return list.get(0);
5289                    }
5290            }
5291    
5292            /**
5293             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
5294             *
5295             * <p>
5296             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5297             * </p>
5298             *
5299             * @param groupId the group ID
5300             * @param articleId the article ID
5301             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5302             * @return the last matching journal article
5303             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5304             * @throws SystemException if a system exception occurred
5305             */
5306            public JournalArticle findByG_A_Last(long groupId, String articleId,
5307                    OrderByComparator orderByComparator)
5308                    throws NoSuchArticleException, SystemException {
5309                    int count = countByG_A(groupId, articleId);
5310    
5311                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
5312                                    count, orderByComparator);
5313    
5314                    if (list.isEmpty()) {
5315                            StringBundler msg = new StringBundler(6);
5316    
5317                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5318    
5319                            msg.append("groupId=");
5320                            msg.append(groupId);
5321    
5322                            msg.append(", articleId=");
5323                            msg.append(articleId);
5324    
5325                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5326    
5327                            throw new NoSuchArticleException(msg.toString());
5328                    }
5329                    else {
5330                            return list.get(0);
5331                    }
5332            }
5333    
5334            /**
5335             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
5336             *
5337             * <p>
5338             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5339             * </p>
5340             *
5341             * @param id the primary key of the current journal article
5342             * @param groupId the group ID
5343             * @param articleId the article ID
5344             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5345             * @return the previous, current, and next journal article
5346             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5347             * @throws SystemException if a system exception occurred
5348             */
5349            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
5350                    String articleId, OrderByComparator orderByComparator)
5351                    throws NoSuchArticleException, SystemException {
5352                    JournalArticle journalArticle = findByPrimaryKey(id);
5353    
5354                    Session session = null;
5355    
5356                    try {
5357                            session = openSession();
5358    
5359                            JournalArticle[] array = new JournalArticleImpl[3];
5360    
5361                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
5362                                            articleId, orderByComparator, true);
5363    
5364                            array[1] = journalArticle;
5365    
5366                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
5367                                            articleId, orderByComparator, false);
5368    
5369                            return array;
5370                    }
5371                    catch (Exception e) {
5372                            throw processException(e);
5373                    }
5374                    finally {
5375                            closeSession(session);
5376                    }
5377            }
5378    
5379            protected JournalArticle getByG_A_PrevAndNext(Session session,
5380                    JournalArticle journalArticle, long groupId, String articleId,
5381                    OrderByComparator orderByComparator, boolean previous) {
5382                    StringBundler query = null;
5383    
5384                    if (orderByComparator != null) {
5385                            query = new StringBundler(6 +
5386                                            (orderByComparator.getOrderByFields().length * 6));
5387                    }
5388                    else {
5389                            query = new StringBundler(3);
5390                    }
5391    
5392                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5393    
5394                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
5395    
5396                    if (articleId == null) {
5397                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
5398                    }
5399                    else {
5400                            if (articleId.equals(StringPool.BLANK)) {
5401                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
5402                            }
5403                            else {
5404                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
5405                            }
5406                    }
5407    
5408                    if (orderByComparator != null) {
5409                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5410    
5411                            if (orderByConditionFields.length > 0) {
5412                                    query.append(WHERE_AND);
5413                            }
5414    
5415                            for (int i = 0; i < orderByConditionFields.length; i++) {
5416                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5417                                    query.append(orderByConditionFields[i]);
5418    
5419                                    if ((i + 1) < orderByConditionFields.length) {
5420                                            if (orderByComparator.isAscending() ^ previous) {
5421                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5422                                            }
5423                                            else {
5424                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5425                                            }
5426                                    }
5427                                    else {
5428                                            if (orderByComparator.isAscending() ^ previous) {
5429                                                    query.append(WHERE_GREATER_THAN);
5430                                            }
5431                                            else {
5432                                                    query.append(WHERE_LESSER_THAN);
5433                                            }
5434                                    }
5435                            }
5436    
5437                            query.append(ORDER_BY_CLAUSE);
5438    
5439                            String[] orderByFields = orderByComparator.getOrderByFields();
5440    
5441                            for (int i = 0; i < orderByFields.length; i++) {
5442                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5443                                    query.append(orderByFields[i]);
5444    
5445                                    if ((i + 1) < orderByFields.length) {
5446                                            if (orderByComparator.isAscending() ^ previous) {
5447                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5448                                            }
5449                                            else {
5450                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5451                                            }
5452                                    }
5453                                    else {
5454                                            if (orderByComparator.isAscending() ^ previous) {
5455                                                    query.append(ORDER_BY_ASC);
5456                                            }
5457                                            else {
5458                                                    query.append(ORDER_BY_DESC);
5459                                            }
5460                                    }
5461                            }
5462                    }
5463    
5464                    else {
5465                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5466                    }
5467    
5468                    String sql = query.toString();
5469    
5470                    Query q = session.createQuery(sql);
5471    
5472                    q.setFirstResult(0);
5473                    q.setMaxResults(2);
5474    
5475                    QueryPos qPos = QueryPos.getInstance(q);
5476    
5477                    qPos.add(groupId);
5478    
5479                    if (articleId != null) {
5480                            qPos.add(articleId);
5481                    }
5482    
5483                    if (orderByComparator != null) {
5484                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5485    
5486                            for (Object value : values) {
5487                                    qPos.add(value);
5488                            }
5489                    }
5490    
5491                    List<JournalArticle> list = q.list();
5492    
5493                    if (list.size() == 2) {
5494                            return list.get(1);
5495                    }
5496                    else {
5497                            return null;
5498                    }
5499            }
5500    
5501            /**
5502             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
5503             *
5504             * @param groupId the group ID
5505             * @param articleId the article ID
5506             * @return the matching journal articles that the user has permission to view
5507             * @throws SystemException if a system exception occurred
5508             */
5509            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
5510                    throws SystemException {
5511                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
5512                            QueryUtil.ALL_POS, null);
5513            }
5514    
5515            /**
5516             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
5517             *
5518             * <p>
5519             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5520             * </p>
5521             *
5522             * @param groupId the group ID
5523             * @param articleId the article ID
5524             * @param start the lower bound of the range of journal articles
5525             * @param end the upper bound of the range of journal articles (not inclusive)
5526             * @return the range of matching journal articles that the user has permission to view
5527             * @throws SystemException if a system exception occurred
5528             */
5529            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
5530                    int start, int end) throws SystemException {
5531                    return filterFindByG_A(groupId, articleId, start, end, null);
5532            }
5533    
5534            /**
5535             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
5536             *
5537             * <p>
5538             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5539             * </p>
5540             *
5541             * @param groupId the group ID
5542             * @param articleId the article ID
5543             * @param start the lower bound of the range of journal articles
5544             * @param end the upper bound of the range of journal articles (not inclusive)
5545             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5546             * @return the ordered range of matching journal articles that the user has permission to view
5547             * @throws SystemException if a system exception occurred
5548             */
5549            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
5550                    int start, int end, OrderByComparator orderByComparator)
5551                    throws SystemException {
5552                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5553                            return findByG_A(groupId, articleId, start, end, orderByComparator);
5554                    }
5555    
5556                    StringBundler query = null;
5557    
5558                    if (orderByComparator != null) {
5559                            query = new StringBundler(4 +
5560                                            (orderByComparator.getOrderByFields().length * 3));
5561                    }
5562                    else {
5563                            query = new StringBundler(4);
5564                    }
5565    
5566                    if (getDB().isSupportsInlineDistinct()) {
5567                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
5568                    }
5569                    else {
5570                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
5571                    }
5572    
5573                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
5574    
5575                    if (articleId == null) {
5576                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
5577                    }
5578                    else {
5579                            if (articleId.equals(StringPool.BLANK)) {
5580                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
5581                            }
5582                            else {
5583                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
5584                            }
5585                    }
5586    
5587                    if (!getDB().isSupportsInlineDistinct()) {
5588                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
5589                    }
5590    
5591                    if (orderByComparator != null) {
5592                            if (getDB().isSupportsInlineDistinct()) {
5593                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5594                                            orderByComparator);
5595                            }
5596                            else {
5597                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5598                                            orderByComparator);
5599                            }
5600                    }
5601    
5602                    else {
5603                            if (getDB().isSupportsInlineDistinct()) {
5604                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5605                            }
5606                            else {
5607                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
5608                            }
5609                    }
5610    
5611                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5612                                    JournalArticle.class.getName(),
5613                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5614    
5615                    Session session = null;
5616    
5617                    try {
5618                            session = openSession();
5619    
5620                            SQLQuery q = session.createSQLQuery(sql);
5621    
5622                            if (getDB().isSupportsInlineDistinct()) {
5623                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
5624                            }
5625                            else {
5626                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
5627                            }
5628    
5629                            QueryPos qPos = QueryPos.getInstance(q);
5630    
5631                            qPos.add(groupId);
5632    
5633                            if (articleId != null) {
5634                                    qPos.add(articleId);
5635                            }
5636    
5637                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
5638                                    end);
5639                    }
5640                    catch (Exception e) {
5641                            throw processException(e);
5642                    }
5643                    finally {
5644                            closeSession(session);
5645                    }
5646            }
5647    
5648            /**
5649             * 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;.
5650             *
5651             * @param id the primary key of the current journal article
5652             * @param groupId the group ID
5653             * @param articleId the article ID
5654             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5655             * @return the previous, current, and next journal article
5656             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5657             * @throws SystemException if a system exception occurred
5658             */
5659            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
5660                    String articleId, OrderByComparator orderByComparator)
5661                    throws NoSuchArticleException, SystemException {
5662                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5663                            return findByG_A_PrevAndNext(id, groupId, articleId,
5664                                    orderByComparator);
5665                    }
5666    
5667                    JournalArticle journalArticle = findByPrimaryKey(id);
5668    
5669                    Session session = null;
5670    
5671                    try {
5672                            session = openSession();
5673    
5674                            JournalArticle[] array = new JournalArticleImpl[3];
5675    
5676                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
5677                                            groupId, articleId, orderByComparator, true);
5678    
5679                            array[1] = journalArticle;
5680    
5681                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
5682                                            groupId, articleId, orderByComparator, false);
5683    
5684                            return array;
5685                    }
5686                    catch (Exception e) {
5687                            throw processException(e);
5688                    }
5689                    finally {
5690                            closeSession(session);
5691                    }
5692            }
5693    
5694            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
5695                    JournalArticle journalArticle, long groupId, String articleId,
5696                    OrderByComparator orderByComparator, boolean previous) {
5697                    StringBundler query = null;
5698    
5699                    if (orderByComparator != null) {
5700                            query = new StringBundler(6 +
5701                                            (orderByComparator.getOrderByFields().length * 6));
5702                    }
5703                    else {
5704                            query = new StringBundler(3);
5705                    }
5706    
5707                    if (getDB().isSupportsInlineDistinct()) {
5708                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
5709                    }
5710                    else {
5711                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
5712                    }
5713    
5714                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
5715    
5716                    if (articleId == null) {
5717                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
5718                    }
5719                    else {
5720                            if (articleId.equals(StringPool.BLANK)) {
5721                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
5722                            }
5723                            else {
5724                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
5725                            }
5726                    }
5727    
5728                    if (!getDB().isSupportsInlineDistinct()) {
5729                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
5730                    }
5731    
5732                    if (orderByComparator != null) {
5733                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5734    
5735                            if (orderByConditionFields.length > 0) {
5736                                    query.append(WHERE_AND);
5737                            }
5738    
5739                            for (int i = 0; i < orderByConditionFields.length; i++) {
5740                                    if (getDB().isSupportsInlineDistinct()) {
5741                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5742                                    }
5743                                    else {
5744                                            query.append(_ORDER_BY_ENTITY_TABLE);
5745                                    }
5746    
5747                                    query.append(orderByConditionFields[i]);
5748    
5749                                    if ((i + 1) < orderByConditionFields.length) {
5750                                            if (orderByComparator.isAscending() ^ previous) {
5751                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5752                                            }
5753                                            else {
5754                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5755                                            }
5756                                    }
5757                                    else {
5758                                            if (orderByComparator.isAscending() ^ previous) {
5759                                                    query.append(WHERE_GREATER_THAN);
5760                                            }
5761                                            else {
5762                                                    query.append(WHERE_LESSER_THAN);
5763                                            }
5764                                    }
5765                            }
5766    
5767                            query.append(ORDER_BY_CLAUSE);
5768    
5769                            String[] orderByFields = orderByComparator.getOrderByFields();
5770    
5771                            for (int i = 0; i < orderByFields.length; i++) {
5772                                    if (getDB().isSupportsInlineDistinct()) {
5773                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5774                                    }
5775                                    else {
5776                                            query.append(_ORDER_BY_ENTITY_TABLE);
5777                                    }
5778    
5779                                    query.append(orderByFields[i]);
5780    
5781                                    if ((i + 1) < orderByFields.length) {
5782                                            if (orderByComparator.isAscending() ^ previous) {
5783                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5784                                            }
5785                                            else {
5786                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5787                                            }
5788                                    }
5789                                    else {
5790                                            if (orderByComparator.isAscending() ^ previous) {
5791                                                    query.append(ORDER_BY_ASC);
5792                                            }
5793                                            else {
5794                                                    query.append(ORDER_BY_DESC);
5795                                            }
5796                                    }
5797                            }
5798                    }
5799    
5800                    else {
5801                            if (getDB().isSupportsInlineDistinct()) {
5802                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5803                            }
5804                            else {
5805                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
5806                            }
5807                    }
5808    
5809                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5810                                    JournalArticle.class.getName(),
5811                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5812    
5813                    SQLQuery q = session.createSQLQuery(sql);
5814    
5815                    q.setFirstResult(0);
5816                    q.setMaxResults(2);
5817    
5818                    if (getDB().isSupportsInlineDistinct()) {
5819                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
5820                    }
5821                    else {
5822                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
5823                    }
5824    
5825                    QueryPos qPos = QueryPos.getInstance(q);
5826    
5827                    qPos.add(groupId);
5828    
5829                    if (articleId != null) {
5830                            qPos.add(articleId);
5831                    }
5832    
5833                    if (orderByComparator != null) {
5834                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5835    
5836                            for (Object value : values) {
5837                                    qPos.add(value);
5838                            }
5839                    }
5840    
5841                    List<JournalArticle> list = q.list();
5842    
5843                    if (list.size() == 2) {
5844                            return list.get(1);
5845                    }
5846                    else {
5847                            return null;
5848                    }
5849            }
5850    
5851            /**
5852             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
5853             *
5854             * @param groupId the group ID
5855             * @param urlTitle the url title
5856             * @return the matching journal articles
5857             * @throws SystemException if a system exception occurred
5858             */
5859            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
5860                    throws SystemException {
5861                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
5862                            QueryUtil.ALL_POS, null);
5863            }
5864    
5865            /**
5866             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
5867             *
5868             * <p>
5869             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5870             * </p>
5871             *
5872             * @param groupId the group ID
5873             * @param urlTitle the url title
5874             * @param start the lower bound of the range of journal articles
5875             * @param end the upper bound of the range of journal articles (not inclusive)
5876             * @return the range of matching journal articles
5877             * @throws SystemException if a system exception occurred
5878             */
5879            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
5880                    int start, int end) throws SystemException {
5881                    return findByG_UT(groupId, urlTitle, start, end, null);
5882            }
5883    
5884            /**
5885             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
5886             *
5887             * <p>
5888             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5889             * </p>
5890             *
5891             * @param groupId the group ID
5892             * @param urlTitle the url title
5893             * @param start the lower bound of the range of journal articles
5894             * @param end the upper bound of the range of journal articles (not inclusive)
5895             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5896             * @return the ordered range of matching journal articles
5897             * @throws SystemException if a system exception occurred
5898             */
5899            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
5900                    int start, int end, OrderByComparator orderByComparator)
5901                    throws SystemException {
5902                    FinderPath finderPath = null;
5903                    Object[] finderArgs = null;
5904    
5905                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5906                                    (orderByComparator == null)) {
5907                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
5908                            finderArgs = new Object[] { groupId, urlTitle };
5909                    }
5910                    else {
5911                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
5912                            finderArgs = new Object[] {
5913                                            groupId, urlTitle,
5914                                            
5915                                            start, end, orderByComparator
5916                                    };
5917                    }
5918    
5919                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5920                                    finderArgs, this);
5921    
5922                    if ((list != null) && !list.isEmpty()) {
5923                            for (JournalArticle journalArticle : list) {
5924                                    if ((groupId != journalArticle.getGroupId()) ||
5925                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
5926                                            list = null;
5927    
5928                                            break;
5929                                    }
5930                            }
5931                    }
5932    
5933                    if (list == null) {
5934                            StringBundler query = null;
5935    
5936                            if (orderByComparator != null) {
5937                                    query = new StringBundler(4 +
5938                                                    (orderByComparator.getOrderByFields().length * 3));
5939                            }
5940                            else {
5941                                    query = new StringBundler(4);
5942                            }
5943    
5944                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5945    
5946                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5947    
5948                            if (urlTitle == null) {
5949                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5950                            }
5951                            else {
5952                                    if (urlTitle.equals(StringPool.BLANK)) {
5953                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5954                                    }
5955                                    else {
5956                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5957                                    }
5958                            }
5959    
5960                            if (orderByComparator != null) {
5961                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5962                                            orderByComparator);
5963                            }
5964    
5965                            else {
5966                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5967                            }
5968    
5969                            String sql = query.toString();
5970    
5971                            Session session = null;
5972    
5973                            try {
5974                                    session = openSession();
5975    
5976                                    Query q = session.createQuery(sql);
5977    
5978                                    QueryPos qPos = QueryPos.getInstance(q);
5979    
5980                                    qPos.add(groupId);
5981    
5982                                    if (urlTitle != null) {
5983                                            qPos.add(urlTitle);
5984                                    }
5985    
5986                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5987                                                    start, end);
5988                            }
5989                            catch (Exception e) {
5990                                    throw processException(e);
5991                            }
5992                            finally {
5993                                    if (list == null) {
5994                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5995                                    }
5996                                    else {
5997                                            cacheResult(list);
5998    
5999                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6000                                    }
6001    
6002                                    closeSession(session);
6003                            }
6004                    }
6005    
6006                    return list;
6007            }
6008    
6009            /**
6010             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
6011             *
6012             * <p>
6013             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6014             * </p>
6015             *
6016             * @param groupId the group ID
6017             * @param urlTitle the url title
6018             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6019             * @return the first matching journal article
6020             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6021             * @throws SystemException if a system exception occurred
6022             */
6023            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
6024                    OrderByComparator orderByComparator)
6025                    throws NoSuchArticleException, SystemException {
6026                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
6027                                    orderByComparator);
6028    
6029                    if (list.isEmpty()) {
6030                            StringBundler msg = new StringBundler(6);
6031    
6032                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6033    
6034                            msg.append("groupId=");
6035                            msg.append(groupId);
6036    
6037                            msg.append(", urlTitle=");
6038                            msg.append(urlTitle);
6039    
6040                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6041    
6042                            throw new NoSuchArticleException(msg.toString());
6043                    }
6044                    else {
6045                            return list.get(0);
6046                    }
6047            }
6048    
6049            /**
6050             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
6051             *
6052             * <p>
6053             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6054             * </p>
6055             *
6056             * @param groupId the group ID
6057             * @param urlTitle the url title
6058             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6059             * @return the last matching journal article
6060             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6061             * @throws SystemException if a system exception occurred
6062             */
6063            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
6064                    OrderByComparator orderByComparator)
6065                    throws NoSuchArticleException, SystemException {
6066                    int count = countByG_UT(groupId, urlTitle);
6067    
6068                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
6069                                    count, orderByComparator);
6070    
6071                    if (list.isEmpty()) {
6072                            StringBundler msg = new StringBundler(6);
6073    
6074                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6075    
6076                            msg.append("groupId=");
6077                            msg.append(groupId);
6078    
6079                            msg.append(", urlTitle=");
6080                            msg.append(urlTitle);
6081    
6082                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6083    
6084                            throw new NoSuchArticleException(msg.toString());
6085                    }
6086                    else {
6087                            return list.get(0);
6088                    }
6089            }
6090    
6091            /**
6092             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
6093             *
6094             * <p>
6095             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6096             * </p>
6097             *
6098             * @param id the primary key of the current journal article
6099             * @param groupId the group ID
6100             * @param urlTitle the url title
6101             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6102             * @return the previous, current, and next journal article
6103             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6104             * @throws SystemException if a system exception occurred
6105             */
6106            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
6107                    String urlTitle, OrderByComparator orderByComparator)
6108                    throws NoSuchArticleException, SystemException {
6109                    JournalArticle journalArticle = findByPrimaryKey(id);
6110    
6111                    Session session = null;
6112    
6113                    try {
6114                            session = openSession();
6115    
6116                            JournalArticle[] array = new JournalArticleImpl[3];
6117    
6118                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
6119                                            urlTitle, orderByComparator, true);
6120    
6121                            array[1] = journalArticle;
6122    
6123                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
6124                                            urlTitle, orderByComparator, false);
6125    
6126                            return array;
6127                    }
6128                    catch (Exception e) {
6129                            throw processException(e);
6130                    }
6131                    finally {
6132                            closeSession(session);
6133                    }
6134            }
6135    
6136            protected JournalArticle getByG_UT_PrevAndNext(Session session,
6137                    JournalArticle journalArticle, long groupId, String urlTitle,
6138                    OrderByComparator orderByComparator, boolean previous) {
6139                    StringBundler query = null;
6140    
6141                    if (orderByComparator != null) {
6142                            query = new StringBundler(6 +
6143                                            (orderByComparator.getOrderByFields().length * 6));
6144                    }
6145                    else {
6146                            query = new StringBundler(3);
6147                    }
6148    
6149                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6150    
6151                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
6152    
6153                    if (urlTitle == null) {
6154                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
6155                    }
6156                    else {
6157                            if (urlTitle.equals(StringPool.BLANK)) {
6158                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
6159                            }
6160                            else {
6161                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
6162                            }
6163                    }
6164    
6165                    if (orderByComparator != null) {
6166                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6167    
6168                            if (orderByConditionFields.length > 0) {
6169                                    query.append(WHERE_AND);
6170                            }
6171    
6172                            for (int i = 0; i < orderByConditionFields.length; i++) {
6173                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6174                                    query.append(orderByConditionFields[i]);
6175    
6176                                    if ((i + 1) < orderByConditionFields.length) {
6177                                            if (orderByComparator.isAscending() ^ previous) {
6178                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6179                                            }
6180                                            else {
6181                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6182                                            }
6183                                    }
6184                                    else {
6185                                            if (orderByComparator.isAscending() ^ previous) {
6186                                                    query.append(WHERE_GREATER_THAN);
6187                                            }
6188                                            else {
6189                                                    query.append(WHERE_LESSER_THAN);
6190                                            }
6191                                    }
6192                            }
6193    
6194                            query.append(ORDER_BY_CLAUSE);
6195    
6196                            String[] orderByFields = orderByComparator.getOrderByFields();
6197    
6198                            for (int i = 0; i < orderByFields.length; i++) {
6199                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6200                                    query.append(orderByFields[i]);
6201    
6202                                    if ((i + 1) < orderByFields.length) {
6203                                            if (orderByComparator.isAscending() ^ previous) {
6204                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6205                                            }
6206                                            else {
6207                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6208                                            }
6209                                    }
6210                                    else {
6211                                            if (orderByComparator.isAscending() ^ previous) {
6212                                                    query.append(ORDER_BY_ASC);
6213                                            }
6214                                            else {
6215                                                    query.append(ORDER_BY_DESC);
6216                                            }
6217                                    }
6218                            }
6219                    }
6220    
6221                    else {
6222                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6223                    }
6224    
6225                    String sql = query.toString();
6226    
6227                    Query q = session.createQuery(sql);
6228    
6229                    q.setFirstResult(0);
6230                    q.setMaxResults(2);
6231    
6232                    QueryPos qPos = QueryPos.getInstance(q);
6233    
6234                    qPos.add(groupId);
6235    
6236                    if (urlTitle != null) {
6237                            qPos.add(urlTitle);
6238                    }
6239    
6240                    if (orderByComparator != null) {
6241                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6242    
6243                            for (Object value : values) {
6244                                    qPos.add(value);
6245                            }
6246                    }
6247    
6248                    List<JournalArticle> list = q.list();
6249    
6250                    if (list.size() == 2) {
6251                            return list.get(1);
6252                    }
6253                    else {
6254                            return null;
6255                    }
6256            }
6257    
6258            /**
6259             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
6260             *
6261             * @param groupId the group ID
6262             * @param urlTitle the url title
6263             * @return the matching journal articles that the user has permission to view
6264             * @throws SystemException if a system exception occurred
6265             */
6266            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
6267                    throws SystemException {
6268                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
6269                            QueryUtil.ALL_POS, null);
6270            }
6271    
6272            /**
6273             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
6274             *
6275             * <p>
6276             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6277             * </p>
6278             *
6279             * @param groupId the group ID
6280             * @param urlTitle the url title
6281             * @param start the lower bound of the range of journal articles
6282             * @param end the upper bound of the range of journal articles (not inclusive)
6283             * @return the range of matching journal articles that the user has permission to view
6284             * @throws SystemException if a system exception occurred
6285             */
6286            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
6287                    int start, int end) throws SystemException {
6288                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
6289            }
6290    
6291            /**
6292             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
6293             *
6294             * <p>
6295             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6296             * </p>
6297             *
6298             * @param groupId the group ID
6299             * @param urlTitle the url title
6300             * @param start the lower bound of the range of journal articles
6301             * @param end the upper bound of the range of journal articles (not inclusive)
6302             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6303             * @return the ordered range of matching journal articles that the user has permission to view
6304             * @throws SystemException if a system exception occurred
6305             */
6306            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
6307                    int start, int end, OrderByComparator orderByComparator)
6308                    throws SystemException {
6309                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6310                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
6311                    }
6312    
6313                    StringBundler query = null;
6314    
6315                    if (orderByComparator != null) {
6316                            query = new StringBundler(4 +
6317                                            (orderByComparator.getOrderByFields().length * 3));
6318                    }
6319                    else {
6320                            query = new StringBundler(4);
6321                    }
6322    
6323                    if (getDB().isSupportsInlineDistinct()) {
6324                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6325                    }
6326                    else {
6327                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6328                    }
6329    
6330                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
6331    
6332                    if (urlTitle == null) {
6333                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
6334                    }
6335                    else {
6336                            if (urlTitle.equals(StringPool.BLANK)) {
6337                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
6338                            }
6339                            else {
6340                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
6341                            }
6342                    }
6343    
6344                    if (!getDB().isSupportsInlineDistinct()) {
6345                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6346                    }
6347    
6348                    if (orderByComparator != null) {
6349                            if (getDB().isSupportsInlineDistinct()) {
6350                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6351                                            orderByComparator);
6352                            }
6353                            else {
6354                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6355                                            orderByComparator);
6356                            }
6357                    }
6358    
6359                    else {
6360                            if (getDB().isSupportsInlineDistinct()) {
6361                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6362                            }
6363                            else {
6364                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6365                            }
6366                    }
6367    
6368                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6369                                    JournalArticle.class.getName(),
6370                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6371    
6372                    Session session = null;
6373    
6374                    try {
6375                            session = openSession();
6376    
6377                            SQLQuery q = session.createSQLQuery(sql);
6378    
6379                            if (getDB().isSupportsInlineDistinct()) {
6380                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6381                            }
6382                            else {
6383                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6384                            }
6385    
6386                            QueryPos qPos = QueryPos.getInstance(q);
6387    
6388                            qPos.add(groupId);
6389    
6390                            if (urlTitle != null) {
6391                                    qPos.add(urlTitle);
6392                            }
6393    
6394                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6395                                    end);
6396                    }
6397                    catch (Exception e) {
6398                            throw processException(e);
6399                    }
6400                    finally {
6401                            closeSession(session);
6402                    }
6403            }
6404    
6405            /**
6406             * 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;.
6407             *
6408             * @param id the primary key of the current journal article
6409             * @param groupId the group ID
6410             * @param urlTitle the url title
6411             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6412             * @return the previous, current, and next journal article
6413             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6414             * @throws SystemException if a system exception occurred
6415             */
6416            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
6417                    String urlTitle, OrderByComparator orderByComparator)
6418                    throws NoSuchArticleException, SystemException {
6419                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6420                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
6421                                    orderByComparator);
6422                    }
6423    
6424                    JournalArticle journalArticle = findByPrimaryKey(id);
6425    
6426                    Session session = null;
6427    
6428                    try {
6429                            session = openSession();
6430    
6431                            JournalArticle[] array = new JournalArticleImpl[3];
6432    
6433                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
6434                                            groupId, urlTitle, orderByComparator, true);
6435    
6436                            array[1] = journalArticle;
6437    
6438                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
6439                                            groupId, urlTitle, orderByComparator, false);
6440    
6441                            return array;
6442                    }
6443                    catch (Exception e) {
6444                            throw processException(e);
6445                    }
6446                    finally {
6447                            closeSession(session);
6448                    }
6449            }
6450    
6451            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
6452                    JournalArticle journalArticle, long groupId, String urlTitle,
6453                    OrderByComparator orderByComparator, boolean previous) {
6454                    StringBundler query = null;
6455    
6456                    if (orderByComparator != null) {
6457                            query = new StringBundler(6 +
6458                                            (orderByComparator.getOrderByFields().length * 6));
6459                    }
6460                    else {
6461                            query = new StringBundler(3);
6462                    }
6463    
6464                    if (getDB().isSupportsInlineDistinct()) {
6465                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6466                    }
6467                    else {
6468                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6469                    }
6470    
6471                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
6472    
6473                    if (urlTitle == null) {
6474                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
6475                    }
6476                    else {
6477                            if (urlTitle.equals(StringPool.BLANK)) {
6478                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
6479                            }
6480                            else {
6481                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
6482                            }
6483                    }
6484    
6485                    if (!getDB().isSupportsInlineDistinct()) {
6486                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6487                    }
6488    
6489                    if (orderByComparator != null) {
6490                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6491    
6492                            if (orderByConditionFields.length > 0) {
6493                                    query.append(WHERE_AND);
6494                            }
6495    
6496                            for (int i = 0; i < orderByConditionFields.length; i++) {
6497                                    if (getDB().isSupportsInlineDistinct()) {
6498                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6499                                    }
6500                                    else {
6501                                            query.append(_ORDER_BY_ENTITY_TABLE);
6502                                    }
6503    
6504                                    query.append(orderByConditionFields[i]);
6505    
6506                                    if ((i + 1) < orderByConditionFields.length) {
6507                                            if (orderByComparator.isAscending() ^ previous) {
6508                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6509                                            }
6510                                            else {
6511                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6512                                            }
6513                                    }
6514                                    else {
6515                                            if (orderByComparator.isAscending() ^ previous) {
6516                                                    query.append(WHERE_GREATER_THAN);
6517                                            }
6518                                            else {
6519                                                    query.append(WHERE_LESSER_THAN);
6520                                            }
6521                                    }
6522                            }
6523    
6524                            query.append(ORDER_BY_CLAUSE);
6525    
6526                            String[] orderByFields = orderByComparator.getOrderByFields();
6527    
6528                            for (int i = 0; i < orderByFields.length; i++) {
6529                                    if (getDB().isSupportsInlineDistinct()) {
6530                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6531                                    }
6532                                    else {
6533                                            query.append(_ORDER_BY_ENTITY_TABLE);
6534                                    }
6535    
6536                                    query.append(orderByFields[i]);
6537    
6538                                    if ((i + 1) < orderByFields.length) {
6539                                            if (orderByComparator.isAscending() ^ previous) {
6540                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6541                                            }
6542                                            else {
6543                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6544                                            }
6545                                    }
6546                                    else {
6547                                            if (orderByComparator.isAscending() ^ previous) {
6548                                                    query.append(ORDER_BY_ASC);
6549                                            }
6550                                            else {
6551                                                    query.append(ORDER_BY_DESC);
6552                                            }
6553                                    }
6554                            }
6555                    }
6556    
6557                    else {
6558                            if (getDB().isSupportsInlineDistinct()) {
6559                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6560                            }
6561                            else {
6562                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6563                            }
6564                    }
6565    
6566                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6567                                    JournalArticle.class.getName(),
6568                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6569    
6570                    SQLQuery q = session.createSQLQuery(sql);
6571    
6572                    q.setFirstResult(0);
6573                    q.setMaxResults(2);
6574    
6575                    if (getDB().isSupportsInlineDistinct()) {
6576                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6577                    }
6578                    else {
6579                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6580                    }
6581    
6582                    QueryPos qPos = QueryPos.getInstance(q);
6583    
6584                    qPos.add(groupId);
6585    
6586                    if (urlTitle != null) {
6587                            qPos.add(urlTitle);
6588                    }
6589    
6590                    if (orderByComparator != null) {
6591                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6592    
6593                            for (Object value : values) {
6594                                    qPos.add(value);
6595                            }
6596                    }
6597    
6598                    List<JournalArticle> list = q.list();
6599    
6600                    if (list.size() == 2) {
6601                            return list.get(1);
6602                    }
6603                    else {
6604                            return null;
6605                    }
6606            }
6607    
6608            /**
6609             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
6610             *
6611             * @param groupId the group ID
6612             * @param structureId the structure ID
6613             * @return the matching journal articles
6614             * @throws SystemException if a system exception occurred
6615             */
6616            public List<JournalArticle> findByG_S(long groupId, String structureId)
6617                    throws SystemException {
6618                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
6619                            QueryUtil.ALL_POS, null);
6620            }
6621    
6622            /**
6623             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
6624             *
6625             * <p>
6626             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6627             * </p>
6628             *
6629             * @param groupId the group ID
6630             * @param structureId the structure ID
6631             * @param start the lower bound of the range of journal articles
6632             * @param end the upper bound of the range of journal articles (not inclusive)
6633             * @return the range of matching journal articles
6634             * @throws SystemException if a system exception occurred
6635             */
6636            public List<JournalArticle> findByG_S(long groupId, String structureId,
6637                    int start, int end) throws SystemException {
6638                    return findByG_S(groupId, structureId, start, end, null);
6639            }
6640    
6641            /**
6642             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
6643             *
6644             * <p>
6645             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6646             * </p>
6647             *
6648             * @param groupId the group ID
6649             * @param structureId the structure ID
6650             * @param start the lower bound of the range of journal articles
6651             * @param end the upper bound of the range of journal articles (not inclusive)
6652             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6653             * @return the ordered range of matching journal articles
6654             * @throws SystemException if a system exception occurred
6655             */
6656            public List<JournalArticle> findByG_S(long groupId, String structureId,
6657                    int start, int end, OrderByComparator orderByComparator)
6658                    throws SystemException {
6659                    FinderPath finderPath = null;
6660                    Object[] finderArgs = null;
6661    
6662                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6663                                    (orderByComparator == null)) {
6664                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
6665                            finderArgs = new Object[] { groupId, structureId };
6666                    }
6667                    else {
6668                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
6669                            finderArgs = new Object[] {
6670                                            groupId, structureId,
6671                                            
6672                                            start, end, orderByComparator
6673                                    };
6674                    }
6675    
6676                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6677                                    finderArgs, this);
6678    
6679                    if ((list != null) && !list.isEmpty()) {
6680                            for (JournalArticle journalArticle : list) {
6681                                    if ((groupId != journalArticle.getGroupId()) ||
6682                                                    !Validator.equals(structureId,
6683                                                            journalArticle.getStructureId())) {
6684                                            list = null;
6685    
6686                                            break;
6687                                    }
6688                            }
6689                    }
6690    
6691                    if (list == null) {
6692                            StringBundler query = null;
6693    
6694                            if (orderByComparator != null) {
6695                                    query = new StringBundler(4 +
6696                                                    (orderByComparator.getOrderByFields().length * 3));
6697                            }
6698                            else {
6699                                    query = new StringBundler(4);
6700                            }
6701    
6702                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6703    
6704                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6705    
6706                            if (structureId == null) {
6707                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
6708                            }
6709                            else {
6710                                    if (structureId.equals(StringPool.BLANK)) {
6711                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
6712                                    }
6713                                    else {
6714                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
6715                                    }
6716                            }
6717    
6718                            if (orderByComparator != null) {
6719                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6720                                            orderByComparator);
6721                            }
6722    
6723                            else {
6724                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6725                            }
6726    
6727                            String sql = query.toString();
6728    
6729                            Session session = null;
6730    
6731                            try {
6732                                    session = openSession();
6733    
6734                                    Query q = session.createQuery(sql);
6735    
6736                                    QueryPos qPos = QueryPos.getInstance(q);
6737    
6738                                    qPos.add(groupId);
6739    
6740                                    if (structureId != null) {
6741                                            qPos.add(structureId);
6742                                    }
6743    
6744                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
6745                                                    start, end);
6746                            }
6747                            catch (Exception e) {
6748                                    throw processException(e);
6749                            }
6750                            finally {
6751                                    if (list == null) {
6752                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6753                                    }
6754                                    else {
6755                                            cacheResult(list);
6756    
6757                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6758                                    }
6759    
6760                                    closeSession(session);
6761                            }
6762                    }
6763    
6764                    return list;
6765            }
6766    
6767            /**
6768             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
6769             *
6770             * <p>
6771             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6772             * </p>
6773             *
6774             * @param groupId the group ID
6775             * @param structureId the structure ID
6776             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6777             * @return the first matching journal article
6778             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6779             * @throws SystemException if a system exception occurred
6780             */
6781            public JournalArticle findByG_S_First(long groupId, String structureId,
6782                    OrderByComparator orderByComparator)
6783                    throws NoSuchArticleException, SystemException {
6784                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
6785                                    orderByComparator);
6786    
6787                    if (list.isEmpty()) {
6788                            StringBundler msg = new StringBundler(6);
6789    
6790                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6791    
6792                            msg.append("groupId=");
6793                            msg.append(groupId);
6794    
6795                            msg.append(", structureId=");
6796                            msg.append(structureId);
6797    
6798                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6799    
6800                            throw new NoSuchArticleException(msg.toString());
6801                    }
6802                    else {
6803                            return list.get(0);
6804                    }
6805            }
6806    
6807            /**
6808             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
6809             *
6810             * <p>
6811             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6812             * </p>
6813             *
6814             * @param groupId the group ID
6815             * @param structureId the structure ID
6816             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6817             * @return the last matching journal article
6818             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6819             * @throws SystemException if a system exception occurred
6820             */
6821            public JournalArticle findByG_S_Last(long groupId, String structureId,
6822                    OrderByComparator orderByComparator)
6823                    throws NoSuchArticleException, SystemException {
6824                    int count = countByG_S(groupId, structureId);
6825    
6826                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
6827                                    count, orderByComparator);
6828    
6829                    if (list.isEmpty()) {
6830                            StringBundler msg = new StringBundler(6);
6831    
6832                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6833    
6834                            msg.append("groupId=");
6835                            msg.append(groupId);
6836    
6837                            msg.append(", structureId=");
6838                            msg.append(structureId);
6839    
6840                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6841    
6842                            throw new NoSuchArticleException(msg.toString());
6843                    }
6844                    else {
6845                            return list.get(0);
6846                    }
6847            }
6848    
6849            /**
6850             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
6851             *
6852             * <p>
6853             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6854             * </p>
6855             *
6856             * @param id the primary key of the current journal article
6857             * @param groupId the group ID
6858             * @param structureId the structure ID
6859             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6860             * @return the previous, current, and next journal article
6861             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6862             * @throws SystemException if a system exception occurred
6863             */
6864            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
6865                    String structureId, OrderByComparator orderByComparator)
6866                    throws NoSuchArticleException, SystemException {
6867                    JournalArticle journalArticle = findByPrimaryKey(id);
6868    
6869                    Session session = null;
6870    
6871                    try {
6872                            session = openSession();
6873    
6874                            JournalArticle[] array = new JournalArticleImpl[3];
6875    
6876                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
6877                                            structureId, orderByComparator, true);
6878    
6879                            array[1] = journalArticle;
6880    
6881                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
6882                                            structureId, orderByComparator, false);
6883    
6884                            return array;
6885                    }
6886                    catch (Exception e) {
6887                            throw processException(e);
6888                    }
6889                    finally {
6890                            closeSession(session);
6891                    }
6892            }
6893    
6894            protected JournalArticle getByG_S_PrevAndNext(Session session,
6895                    JournalArticle journalArticle, long groupId, String structureId,
6896                    OrderByComparator orderByComparator, boolean previous) {
6897                    StringBundler query = null;
6898    
6899                    if (orderByComparator != null) {
6900                            query = new StringBundler(6 +
6901                                            (orderByComparator.getOrderByFields().length * 6));
6902                    }
6903                    else {
6904                            query = new StringBundler(3);
6905                    }
6906    
6907                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6908    
6909                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6910    
6911                    if (structureId == null) {
6912                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
6913                    }
6914                    else {
6915                            if (structureId.equals(StringPool.BLANK)) {
6916                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
6917                            }
6918                            else {
6919                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
6920                            }
6921                    }
6922    
6923                    if (orderByComparator != null) {
6924                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6925    
6926                            if (orderByConditionFields.length > 0) {
6927                                    query.append(WHERE_AND);
6928                            }
6929    
6930                            for (int i = 0; i < orderByConditionFields.length; i++) {
6931                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6932                                    query.append(orderByConditionFields[i]);
6933    
6934                                    if ((i + 1) < orderByConditionFields.length) {
6935                                            if (orderByComparator.isAscending() ^ previous) {
6936                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6937                                            }
6938                                            else {
6939                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6940                                            }
6941                                    }
6942                                    else {
6943                                            if (orderByComparator.isAscending() ^ previous) {
6944                                                    query.append(WHERE_GREATER_THAN);
6945                                            }
6946                                            else {
6947                                                    query.append(WHERE_LESSER_THAN);
6948                                            }
6949                                    }
6950                            }
6951    
6952                            query.append(ORDER_BY_CLAUSE);
6953    
6954                            String[] orderByFields = orderByComparator.getOrderByFields();
6955    
6956                            for (int i = 0; i < orderByFields.length; i++) {
6957                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6958                                    query.append(orderByFields[i]);
6959    
6960                                    if ((i + 1) < orderByFields.length) {
6961                                            if (orderByComparator.isAscending() ^ previous) {
6962                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6963                                            }
6964                                            else {
6965                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6966                                            }
6967                                    }
6968                                    else {
6969                                            if (orderByComparator.isAscending() ^ previous) {
6970                                                    query.append(ORDER_BY_ASC);
6971                                            }
6972                                            else {
6973                                                    query.append(ORDER_BY_DESC);
6974                                            }
6975                                    }
6976                            }
6977                    }
6978    
6979                    else {
6980                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6981                    }
6982    
6983                    String sql = query.toString();
6984    
6985                    Query q = session.createQuery(sql);
6986    
6987                    q.setFirstResult(0);
6988                    q.setMaxResults(2);
6989    
6990                    QueryPos qPos = QueryPos.getInstance(q);
6991    
6992                    qPos.add(groupId);
6993    
6994                    if (structureId != null) {
6995                            qPos.add(structureId);
6996                    }
6997    
6998                    if (orderByComparator != null) {
6999                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7000    
7001                            for (Object value : values) {
7002                                    qPos.add(value);
7003                            }
7004                    }
7005    
7006                    List<JournalArticle> list = q.list();
7007    
7008                    if (list.size() == 2) {
7009                            return list.get(1);
7010                    }
7011                    else {
7012                            return null;
7013                    }
7014            }
7015    
7016            /**
7017             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
7018             *
7019             * @param groupId the group ID
7020             * @param structureId the structure ID
7021             * @return the matching journal articles that the user has permission to view
7022             * @throws SystemException if a system exception occurred
7023             */
7024            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
7025                    throws SystemException {
7026                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
7027                            QueryUtil.ALL_POS, null);
7028            }
7029    
7030            /**
7031             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
7032             *
7033             * <p>
7034             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7035             * </p>
7036             *
7037             * @param groupId the group ID
7038             * @param structureId the structure ID
7039             * @param start the lower bound of the range of journal articles
7040             * @param end the upper bound of the range of journal articles (not inclusive)
7041             * @return the range of matching journal articles that the user has permission to view
7042             * @throws SystemException if a system exception occurred
7043             */
7044            public List<JournalArticle> filterFindByG_S(long groupId,
7045                    String structureId, int start, int end) throws SystemException {
7046                    return filterFindByG_S(groupId, structureId, start, end, null);
7047            }
7048    
7049            /**
7050             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
7051             *
7052             * <p>
7053             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7054             * </p>
7055             *
7056             * @param groupId the group ID
7057             * @param structureId the structure ID
7058             * @param start the lower bound of the range of journal articles
7059             * @param end the upper bound of the range of journal articles (not inclusive)
7060             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7061             * @return the ordered range of matching journal articles that the user has permission to view
7062             * @throws SystemException if a system exception occurred
7063             */
7064            public List<JournalArticle> filterFindByG_S(long groupId,
7065                    String structureId, int start, int end,
7066                    OrderByComparator orderByComparator) throws SystemException {
7067                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7068                            return findByG_S(groupId, structureId, start, end, orderByComparator);
7069                    }
7070    
7071                    StringBundler query = null;
7072    
7073                    if (orderByComparator != null) {
7074                            query = new StringBundler(4 +
7075                                            (orderByComparator.getOrderByFields().length * 3));
7076                    }
7077                    else {
7078                            query = new StringBundler(4);
7079                    }
7080    
7081                    if (getDB().isSupportsInlineDistinct()) {
7082                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7083                    }
7084                    else {
7085                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7086                    }
7087    
7088                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7089    
7090                    if (structureId == null) {
7091                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
7092                    }
7093                    else {
7094                            if (structureId.equals(StringPool.BLANK)) {
7095                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
7096                            }
7097                            else {
7098                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
7099                            }
7100                    }
7101    
7102                    if (!getDB().isSupportsInlineDistinct()) {
7103                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7104                    }
7105    
7106                    if (orderByComparator != null) {
7107                            if (getDB().isSupportsInlineDistinct()) {
7108                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7109                                            orderByComparator);
7110                            }
7111                            else {
7112                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7113                                            orderByComparator);
7114                            }
7115                    }
7116    
7117                    else {
7118                            if (getDB().isSupportsInlineDistinct()) {
7119                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7120                            }
7121                            else {
7122                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7123                            }
7124                    }
7125    
7126                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7127                                    JournalArticle.class.getName(),
7128                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7129    
7130                    Session session = null;
7131    
7132                    try {
7133                            session = openSession();
7134    
7135                            SQLQuery q = session.createSQLQuery(sql);
7136    
7137                            if (getDB().isSupportsInlineDistinct()) {
7138                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7139                            }
7140                            else {
7141                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7142                            }
7143    
7144                            QueryPos qPos = QueryPos.getInstance(q);
7145    
7146                            qPos.add(groupId);
7147    
7148                            if (structureId != null) {
7149                                    qPos.add(structureId);
7150                            }
7151    
7152                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7153                                    end);
7154                    }
7155                    catch (Exception e) {
7156                            throw processException(e);
7157                    }
7158                    finally {
7159                            closeSession(session);
7160                    }
7161            }
7162    
7163            /**
7164             * 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;.
7165             *
7166             * @param id the primary key of the current journal article
7167             * @param groupId the group ID
7168             * @param structureId the structure ID
7169             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7170             * @return the previous, current, and next journal article
7171             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7172             * @throws SystemException if a system exception occurred
7173             */
7174            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
7175                    String structureId, OrderByComparator orderByComparator)
7176                    throws NoSuchArticleException, SystemException {
7177                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7178                            return findByG_S_PrevAndNext(id, groupId, structureId,
7179                                    orderByComparator);
7180                    }
7181    
7182                    JournalArticle journalArticle = findByPrimaryKey(id);
7183    
7184                    Session session = null;
7185    
7186                    try {
7187                            session = openSession();
7188    
7189                            JournalArticle[] array = new JournalArticleImpl[3];
7190    
7191                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
7192                                            groupId, structureId, orderByComparator, true);
7193    
7194                            array[1] = journalArticle;
7195    
7196                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
7197                                            groupId, structureId, orderByComparator, false);
7198    
7199                            return array;
7200                    }
7201                    catch (Exception e) {
7202                            throw processException(e);
7203                    }
7204                    finally {
7205                            closeSession(session);
7206                    }
7207            }
7208    
7209            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
7210                    JournalArticle journalArticle, long groupId, String structureId,
7211                    OrderByComparator orderByComparator, boolean previous) {
7212                    StringBundler query = null;
7213    
7214                    if (orderByComparator != null) {
7215                            query = new StringBundler(6 +
7216                                            (orderByComparator.getOrderByFields().length * 6));
7217                    }
7218                    else {
7219                            query = new StringBundler(3);
7220                    }
7221    
7222                    if (getDB().isSupportsInlineDistinct()) {
7223                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7224                    }
7225                    else {
7226                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7227                    }
7228    
7229                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7230    
7231                    if (structureId == null) {
7232                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
7233                    }
7234                    else {
7235                            if (structureId.equals(StringPool.BLANK)) {
7236                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
7237                            }
7238                            else {
7239                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
7240                            }
7241                    }
7242    
7243                    if (!getDB().isSupportsInlineDistinct()) {
7244                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7245                    }
7246    
7247                    if (orderByComparator != null) {
7248                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7249    
7250                            if (orderByConditionFields.length > 0) {
7251                                    query.append(WHERE_AND);
7252                            }
7253    
7254                            for (int i = 0; i < orderByConditionFields.length; i++) {
7255                                    if (getDB().isSupportsInlineDistinct()) {
7256                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7257                                    }
7258                                    else {
7259                                            query.append(_ORDER_BY_ENTITY_TABLE);
7260                                    }
7261    
7262                                    query.append(orderByConditionFields[i]);
7263    
7264                                    if ((i + 1) < orderByConditionFields.length) {
7265                                            if (orderByComparator.isAscending() ^ previous) {
7266                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7267                                            }
7268                                            else {
7269                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7270                                            }
7271                                    }
7272                                    else {
7273                                            if (orderByComparator.isAscending() ^ previous) {
7274                                                    query.append(WHERE_GREATER_THAN);
7275                                            }
7276                                            else {
7277                                                    query.append(WHERE_LESSER_THAN);
7278                                            }
7279                                    }
7280                            }
7281    
7282                            query.append(ORDER_BY_CLAUSE);
7283    
7284                            String[] orderByFields = orderByComparator.getOrderByFields();
7285    
7286                            for (int i = 0; i < orderByFields.length; i++) {
7287                                    if (getDB().isSupportsInlineDistinct()) {
7288                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7289                                    }
7290                                    else {
7291                                            query.append(_ORDER_BY_ENTITY_TABLE);
7292                                    }
7293    
7294                                    query.append(orderByFields[i]);
7295    
7296                                    if ((i + 1) < orderByFields.length) {
7297                                            if (orderByComparator.isAscending() ^ previous) {
7298                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7299                                            }
7300                                            else {
7301                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7302                                            }
7303                                    }
7304                                    else {
7305                                            if (orderByComparator.isAscending() ^ previous) {
7306                                                    query.append(ORDER_BY_ASC);
7307                                            }
7308                                            else {
7309                                                    query.append(ORDER_BY_DESC);
7310                                            }
7311                                    }
7312                            }
7313                    }
7314    
7315                    else {
7316                            if (getDB().isSupportsInlineDistinct()) {
7317                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7318                            }
7319                            else {
7320                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7321                            }
7322                    }
7323    
7324                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7325                                    JournalArticle.class.getName(),
7326                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7327    
7328                    SQLQuery q = session.createSQLQuery(sql);
7329    
7330                    q.setFirstResult(0);
7331                    q.setMaxResults(2);
7332    
7333                    if (getDB().isSupportsInlineDistinct()) {
7334                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7335                    }
7336                    else {
7337                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7338                    }
7339    
7340                    QueryPos qPos = QueryPos.getInstance(q);
7341    
7342                    qPos.add(groupId);
7343    
7344                    if (structureId != null) {
7345                            qPos.add(structureId);
7346                    }
7347    
7348                    if (orderByComparator != null) {
7349                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7350    
7351                            for (Object value : values) {
7352                                    qPos.add(value);
7353                            }
7354                    }
7355    
7356                    List<JournalArticle> list = q.list();
7357    
7358                    if (list.size() == 2) {
7359                            return list.get(1);
7360                    }
7361                    else {
7362                            return null;
7363                    }
7364            }
7365    
7366            /**
7367             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
7368             *
7369             * @param groupId the group ID
7370             * @param templateId the template ID
7371             * @return the matching journal articles
7372             * @throws SystemException if a system exception occurred
7373             */
7374            public List<JournalArticle> findByG_T(long groupId, String templateId)
7375                    throws SystemException {
7376                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
7377                            QueryUtil.ALL_POS, null);
7378            }
7379    
7380            /**
7381             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
7382             *
7383             * <p>
7384             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7385             * </p>
7386             *
7387             * @param groupId the group ID
7388             * @param templateId the template ID
7389             * @param start the lower bound of the range of journal articles
7390             * @param end the upper bound of the range of journal articles (not inclusive)
7391             * @return the range of matching journal articles
7392             * @throws SystemException if a system exception occurred
7393             */
7394            public List<JournalArticle> findByG_T(long groupId, String templateId,
7395                    int start, int end) throws SystemException {
7396                    return findByG_T(groupId, templateId, start, end, null);
7397            }
7398    
7399            /**
7400             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
7401             *
7402             * <p>
7403             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7404             * </p>
7405             *
7406             * @param groupId the group ID
7407             * @param templateId the template ID
7408             * @param start the lower bound of the range of journal articles
7409             * @param end the upper bound of the range of journal articles (not inclusive)
7410             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7411             * @return the ordered range of matching journal articles
7412             * @throws SystemException if a system exception occurred
7413             */
7414            public List<JournalArticle> findByG_T(long groupId, String templateId,
7415                    int start, int end, OrderByComparator orderByComparator)
7416                    throws SystemException {
7417                    FinderPath finderPath = null;
7418                    Object[] finderArgs = null;
7419    
7420                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7421                                    (orderByComparator == null)) {
7422                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
7423                            finderArgs = new Object[] { groupId, templateId };
7424                    }
7425                    else {
7426                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
7427                            finderArgs = new Object[] {
7428                                            groupId, templateId,
7429                                            
7430                                            start, end, orderByComparator
7431                                    };
7432                    }
7433    
7434                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7435                                    finderArgs, this);
7436    
7437                    if ((list != null) && !list.isEmpty()) {
7438                            for (JournalArticle journalArticle : list) {
7439                                    if ((groupId != journalArticle.getGroupId()) ||
7440                                                    !Validator.equals(templateId,
7441                                                            journalArticle.getTemplateId())) {
7442                                            list = null;
7443    
7444                                            break;
7445                                    }
7446                            }
7447                    }
7448    
7449                    if (list == null) {
7450                            StringBundler query = null;
7451    
7452                            if (orderByComparator != null) {
7453                                    query = new StringBundler(4 +
7454                                                    (orderByComparator.getOrderByFields().length * 3));
7455                            }
7456                            else {
7457                                    query = new StringBundler(4);
7458                            }
7459    
7460                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7461    
7462                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
7463    
7464                            if (templateId == null) {
7465                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
7466                            }
7467                            else {
7468                                    if (templateId.equals(StringPool.BLANK)) {
7469                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
7470                                    }
7471                                    else {
7472                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
7473                                    }
7474                            }
7475    
7476                            if (orderByComparator != null) {
7477                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7478                                            orderByComparator);
7479                            }
7480    
7481                            else {
7482                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7483                            }
7484    
7485                            String sql = query.toString();
7486    
7487                            Session session = null;
7488    
7489                            try {
7490                                    session = openSession();
7491    
7492                                    Query q = session.createQuery(sql);
7493    
7494                                    QueryPos qPos = QueryPos.getInstance(q);
7495    
7496                                    qPos.add(groupId);
7497    
7498                                    if (templateId != null) {
7499                                            qPos.add(templateId);
7500                                    }
7501    
7502                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
7503                                                    start, end);
7504                            }
7505                            catch (Exception e) {
7506                                    throw processException(e);
7507                            }
7508                            finally {
7509                                    if (list == null) {
7510                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7511                                    }
7512                                    else {
7513                                            cacheResult(list);
7514    
7515                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7516                                    }
7517    
7518                                    closeSession(session);
7519                            }
7520                    }
7521    
7522                    return list;
7523            }
7524    
7525            /**
7526             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
7527             *
7528             * <p>
7529             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7530             * </p>
7531             *
7532             * @param groupId the group ID
7533             * @param templateId the template ID
7534             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7535             * @return the first matching journal article
7536             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7537             * @throws SystemException if a system exception occurred
7538             */
7539            public JournalArticle findByG_T_First(long groupId, String templateId,
7540                    OrderByComparator orderByComparator)
7541                    throws NoSuchArticleException, SystemException {
7542                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
7543                                    orderByComparator);
7544    
7545                    if (list.isEmpty()) {
7546                            StringBundler msg = new StringBundler(6);
7547    
7548                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7549    
7550                            msg.append("groupId=");
7551                            msg.append(groupId);
7552    
7553                            msg.append(", templateId=");
7554                            msg.append(templateId);
7555    
7556                            msg.append(StringPool.CLOSE_CURLY_BRACE);
7557    
7558                            throw new NoSuchArticleException(msg.toString());
7559                    }
7560                    else {
7561                            return list.get(0);
7562                    }
7563            }
7564    
7565            /**
7566             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
7567             *
7568             * <p>
7569             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7570             * </p>
7571             *
7572             * @param groupId the group ID
7573             * @param templateId the template ID
7574             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7575             * @return the last matching journal article
7576             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7577             * @throws SystemException if a system exception occurred
7578             */
7579            public JournalArticle findByG_T_Last(long groupId, String templateId,
7580                    OrderByComparator orderByComparator)
7581                    throws NoSuchArticleException, SystemException {
7582                    int count = countByG_T(groupId, templateId);
7583    
7584                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
7585                                    count, orderByComparator);
7586    
7587                    if (list.isEmpty()) {
7588                            StringBundler msg = new StringBundler(6);
7589    
7590                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7591    
7592                            msg.append("groupId=");
7593                            msg.append(groupId);
7594    
7595                            msg.append(", templateId=");
7596                            msg.append(templateId);
7597    
7598                            msg.append(StringPool.CLOSE_CURLY_BRACE);
7599    
7600                            throw new NoSuchArticleException(msg.toString());
7601                    }
7602                    else {
7603                            return list.get(0);
7604                    }
7605            }
7606    
7607            /**
7608             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
7609             *
7610             * <p>
7611             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7612             * </p>
7613             *
7614             * @param id the primary key of the current journal article
7615             * @param groupId the group ID
7616             * @param templateId the template ID
7617             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7618             * @return the previous, current, and next journal article
7619             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7620             * @throws SystemException if a system exception occurred
7621             */
7622            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
7623                    String templateId, OrderByComparator orderByComparator)
7624                    throws NoSuchArticleException, SystemException {
7625                    JournalArticle journalArticle = findByPrimaryKey(id);
7626    
7627                    Session session = null;
7628    
7629                    try {
7630                            session = openSession();
7631    
7632                            JournalArticle[] array = new JournalArticleImpl[3];
7633    
7634                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
7635                                            templateId, orderByComparator, true);
7636    
7637                            array[1] = journalArticle;
7638    
7639                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
7640                                            templateId, orderByComparator, false);
7641    
7642                            return array;
7643                    }
7644                    catch (Exception e) {
7645                            throw processException(e);
7646                    }
7647                    finally {
7648                            closeSession(session);
7649                    }
7650            }
7651    
7652            protected JournalArticle getByG_T_PrevAndNext(Session session,
7653                    JournalArticle journalArticle, long groupId, String templateId,
7654                    OrderByComparator orderByComparator, boolean previous) {
7655                    StringBundler query = null;
7656    
7657                    if (orderByComparator != null) {
7658                            query = new StringBundler(6 +
7659                                            (orderByComparator.getOrderByFields().length * 6));
7660                    }
7661                    else {
7662                            query = new StringBundler(3);
7663                    }
7664    
7665                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7666    
7667                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
7668    
7669                    if (templateId == null) {
7670                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
7671                    }
7672                    else {
7673                            if (templateId.equals(StringPool.BLANK)) {
7674                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
7675                            }
7676                            else {
7677                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
7678                            }
7679                    }
7680    
7681                    if (orderByComparator != null) {
7682                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7683    
7684                            if (orderByConditionFields.length > 0) {
7685                                    query.append(WHERE_AND);
7686                            }
7687    
7688                            for (int i = 0; i < orderByConditionFields.length; i++) {
7689                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7690                                    query.append(orderByConditionFields[i]);
7691    
7692                                    if ((i + 1) < orderByConditionFields.length) {
7693                                            if (orderByComparator.isAscending() ^ previous) {
7694                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7695                                            }
7696                                            else {
7697                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7698                                            }
7699                                    }
7700                                    else {
7701                                            if (orderByComparator.isAscending() ^ previous) {
7702                                                    query.append(WHERE_GREATER_THAN);
7703                                            }
7704                                            else {
7705                                                    query.append(WHERE_LESSER_THAN);
7706                                            }
7707                                    }
7708                            }
7709    
7710                            query.append(ORDER_BY_CLAUSE);
7711    
7712                            String[] orderByFields = orderByComparator.getOrderByFields();
7713    
7714                            for (int i = 0; i < orderByFields.length; i++) {
7715                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7716                                    query.append(orderByFields[i]);
7717    
7718                                    if ((i + 1) < orderByFields.length) {
7719                                            if (orderByComparator.isAscending() ^ previous) {
7720                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7721                                            }
7722                                            else {
7723                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7724                                            }
7725                                    }
7726                                    else {
7727                                            if (orderByComparator.isAscending() ^ previous) {
7728                                                    query.append(ORDER_BY_ASC);
7729                                            }
7730                                            else {
7731                                                    query.append(ORDER_BY_DESC);
7732                                            }
7733                                    }
7734                            }
7735                    }
7736    
7737                    else {
7738                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7739                    }
7740    
7741                    String sql = query.toString();
7742    
7743                    Query q = session.createQuery(sql);
7744    
7745                    q.setFirstResult(0);
7746                    q.setMaxResults(2);
7747    
7748                    QueryPos qPos = QueryPos.getInstance(q);
7749    
7750                    qPos.add(groupId);
7751    
7752                    if (templateId != null) {
7753                            qPos.add(templateId);
7754                    }
7755    
7756                    if (orderByComparator != null) {
7757                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7758    
7759                            for (Object value : values) {
7760                                    qPos.add(value);
7761                            }
7762                    }
7763    
7764                    List<JournalArticle> list = q.list();
7765    
7766                    if (list.size() == 2) {
7767                            return list.get(1);
7768                    }
7769                    else {
7770                            return null;
7771                    }
7772            }
7773    
7774            /**
7775             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
7776             *
7777             * @param groupId the group ID
7778             * @param templateId the template ID
7779             * @return the matching journal articles that the user has permission to view
7780             * @throws SystemException if a system exception occurred
7781             */
7782            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
7783                    throws SystemException {
7784                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
7785                            QueryUtil.ALL_POS, null);
7786            }
7787    
7788            /**
7789             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
7790             *
7791             * <p>
7792             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7793             * </p>
7794             *
7795             * @param groupId the group ID
7796             * @param templateId the template ID
7797             * @param start the lower bound of the range of journal articles
7798             * @param end the upper bound of the range of journal articles (not inclusive)
7799             * @return the range of matching journal articles that the user has permission to view
7800             * @throws SystemException if a system exception occurred
7801             */
7802            public List<JournalArticle> filterFindByG_T(long groupId,
7803                    String templateId, int start, int end) throws SystemException {
7804                    return filterFindByG_T(groupId, templateId, start, end, null);
7805            }
7806    
7807            /**
7808             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
7809             *
7810             * <p>
7811             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7812             * </p>
7813             *
7814             * @param groupId the group ID
7815             * @param templateId the template ID
7816             * @param start the lower bound of the range of journal articles
7817             * @param end the upper bound of the range of journal articles (not inclusive)
7818             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7819             * @return the ordered range of matching journal articles that the user has permission to view
7820             * @throws SystemException if a system exception occurred
7821             */
7822            public List<JournalArticle> filterFindByG_T(long groupId,
7823                    String templateId, int start, int end,
7824                    OrderByComparator orderByComparator) throws SystemException {
7825                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7826                            return findByG_T(groupId, templateId, start, end, orderByComparator);
7827                    }
7828    
7829                    StringBundler query = null;
7830    
7831                    if (orderByComparator != null) {
7832                            query = new StringBundler(4 +
7833                                            (orderByComparator.getOrderByFields().length * 3));
7834                    }
7835                    else {
7836                            query = new StringBundler(4);
7837                    }
7838    
7839                    if (getDB().isSupportsInlineDistinct()) {
7840                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7841                    }
7842                    else {
7843                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7844                    }
7845    
7846                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
7847    
7848                    if (templateId == null) {
7849                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
7850                    }
7851                    else {
7852                            if (templateId.equals(StringPool.BLANK)) {
7853                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
7854                            }
7855                            else {
7856                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
7857                            }
7858                    }
7859    
7860                    if (!getDB().isSupportsInlineDistinct()) {
7861                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7862                    }
7863    
7864                    if (orderByComparator != null) {
7865                            if (getDB().isSupportsInlineDistinct()) {
7866                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7867                                            orderByComparator);
7868                            }
7869                            else {
7870                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7871                                            orderByComparator);
7872                            }
7873                    }
7874    
7875                    else {
7876                            if (getDB().isSupportsInlineDistinct()) {
7877                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7878                            }
7879                            else {
7880                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7881                            }
7882                    }
7883    
7884                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7885                                    JournalArticle.class.getName(),
7886                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7887    
7888                    Session session = null;
7889    
7890                    try {
7891                            session = openSession();
7892    
7893                            SQLQuery q = session.createSQLQuery(sql);
7894    
7895                            if (getDB().isSupportsInlineDistinct()) {
7896                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7897                            }
7898                            else {
7899                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7900                            }
7901    
7902                            QueryPos qPos = QueryPos.getInstance(q);
7903    
7904                            qPos.add(groupId);
7905    
7906                            if (templateId != null) {
7907                                    qPos.add(templateId);
7908                            }
7909    
7910                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7911                                    end);
7912                    }
7913                    catch (Exception e) {
7914                            throw processException(e);
7915                    }
7916                    finally {
7917                            closeSession(session);
7918                    }
7919            }
7920    
7921            /**
7922             * 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;.
7923             *
7924             * @param id the primary key of the current journal article
7925             * @param groupId the group ID
7926             * @param templateId the template ID
7927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7928             * @return the previous, current, and next journal article
7929             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7930             * @throws SystemException if a system exception occurred
7931             */
7932            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
7933                    String templateId, OrderByComparator orderByComparator)
7934                    throws NoSuchArticleException, SystemException {
7935                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7936                            return findByG_T_PrevAndNext(id, groupId, templateId,
7937                                    orderByComparator);
7938                    }
7939    
7940                    JournalArticle journalArticle = findByPrimaryKey(id);
7941    
7942                    Session session = null;
7943    
7944                    try {
7945                            session = openSession();
7946    
7947                            JournalArticle[] array = new JournalArticleImpl[3];
7948    
7949                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
7950                                            groupId, templateId, orderByComparator, true);
7951    
7952                            array[1] = journalArticle;
7953    
7954                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
7955                                            groupId, templateId, orderByComparator, false);
7956    
7957                            return array;
7958                    }
7959                    catch (Exception e) {
7960                            throw processException(e);
7961                    }
7962                    finally {
7963                            closeSession(session);
7964                    }
7965            }
7966    
7967            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
7968                    JournalArticle journalArticle, long groupId, String templateId,
7969                    OrderByComparator orderByComparator, boolean previous) {
7970                    StringBundler query = null;
7971    
7972                    if (orderByComparator != null) {
7973                            query = new StringBundler(6 +
7974                                            (orderByComparator.getOrderByFields().length * 6));
7975                    }
7976                    else {
7977                            query = new StringBundler(3);
7978                    }
7979    
7980                    if (getDB().isSupportsInlineDistinct()) {
7981                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7982                    }
7983                    else {
7984                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7985                    }
7986    
7987                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
7988    
7989                    if (templateId == null) {
7990                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
7991                    }
7992                    else {
7993                            if (templateId.equals(StringPool.BLANK)) {
7994                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
7995                            }
7996                            else {
7997                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
7998                            }
7999                    }
8000    
8001                    if (!getDB().isSupportsInlineDistinct()) {
8002                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8003                    }
8004    
8005                    if (orderByComparator != null) {
8006                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8007    
8008                            if (orderByConditionFields.length > 0) {
8009                                    query.append(WHERE_AND);
8010                            }
8011    
8012                            for (int i = 0; i < orderByConditionFields.length; i++) {
8013                                    if (getDB().isSupportsInlineDistinct()) {
8014                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8015                                    }
8016                                    else {
8017                                            query.append(_ORDER_BY_ENTITY_TABLE);
8018                                    }
8019    
8020                                    query.append(orderByConditionFields[i]);
8021    
8022                                    if ((i + 1) < orderByConditionFields.length) {
8023                                            if (orderByComparator.isAscending() ^ previous) {
8024                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8025                                            }
8026                                            else {
8027                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8028                                            }
8029                                    }
8030                                    else {
8031                                            if (orderByComparator.isAscending() ^ previous) {
8032                                                    query.append(WHERE_GREATER_THAN);
8033                                            }
8034                                            else {
8035                                                    query.append(WHERE_LESSER_THAN);
8036                                            }
8037                                    }
8038                            }
8039    
8040                            query.append(ORDER_BY_CLAUSE);
8041    
8042                            String[] orderByFields = orderByComparator.getOrderByFields();
8043    
8044                            for (int i = 0; i < orderByFields.length; i++) {
8045                                    if (getDB().isSupportsInlineDistinct()) {
8046                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8047                                    }
8048                                    else {
8049                                            query.append(_ORDER_BY_ENTITY_TABLE);
8050                                    }
8051    
8052                                    query.append(orderByFields[i]);
8053    
8054                                    if ((i + 1) < orderByFields.length) {
8055                                            if (orderByComparator.isAscending() ^ previous) {
8056                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8057                                            }
8058                                            else {
8059                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8060                                            }
8061                                    }
8062                                    else {
8063                                            if (orderByComparator.isAscending() ^ previous) {
8064                                                    query.append(ORDER_BY_ASC);
8065                                            }
8066                                            else {
8067                                                    query.append(ORDER_BY_DESC);
8068                                            }
8069                                    }
8070                            }
8071                    }
8072    
8073                    else {
8074                            if (getDB().isSupportsInlineDistinct()) {
8075                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8076                            }
8077                            else {
8078                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8079                            }
8080                    }
8081    
8082                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8083                                    JournalArticle.class.getName(),
8084                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8085    
8086                    SQLQuery q = session.createSQLQuery(sql);
8087    
8088                    q.setFirstResult(0);
8089                    q.setMaxResults(2);
8090    
8091                    if (getDB().isSupportsInlineDistinct()) {
8092                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8093                    }
8094                    else {
8095                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8096                    }
8097    
8098                    QueryPos qPos = QueryPos.getInstance(q);
8099    
8100                    qPos.add(groupId);
8101    
8102                    if (templateId != null) {
8103                            qPos.add(templateId);
8104                    }
8105    
8106                    if (orderByComparator != null) {
8107                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8108    
8109                            for (Object value : values) {
8110                                    qPos.add(value);
8111                            }
8112                    }
8113    
8114                    List<JournalArticle> list = q.list();
8115    
8116                    if (list.size() == 2) {
8117                            return list.get(1);
8118                    }
8119                    else {
8120                            return null;
8121                    }
8122            }
8123    
8124            /**
8125             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
8126             *
8127             * @param groupId the group ID
8128             * @param layoutUuid the layout uuid
8129             * @return the matching journal articles
8130             * @throws SystemException if a system exception occurred
8131             */
8132            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
8133                    throws SystemException {
8134                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
8135                            QueryUtil.ALL_POS, null);
8136            }
8137    
8138            /**
8139             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
8140             *
8141             * <p>
8142             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8143             * </p>
8144             *
8145             * @param groupId the group ID
8146             * @param layoutUuid the layout uuid
8147             * @param start the lower bound of the range of journal articles
8148             * @param end the upper bound of the range of journal articles (not inclusive)
8149             * @return the range of matching journal articles
8150             * @throws SystemException if a system exception occurred
8151             */
8152            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
8153                    int start, int end) throws SystemException {
8154                    return findByG_L(groupId, layoutUuid, start, end, null);
8155            }
8156    
8157            /**
8158             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
8159             *
8160             * <p>
8161             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8162             * </p>
8163             *
8164             * @param groupId the group ID
8165             * @param layoutUuid the layout uuid
8166             * @param start the lower bound of the range of journal articles
8167             * @param end the upper bound of the range of journal articles (not inclusive)
8168             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8169             * @return the ordered range of matching journal articles
8170             * @throws SystemException if a system exception occurred
8171             */
8172            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
8173                    int start, int end, OrderByComparator orderByComparator)
8174                    throws SystemException {
8175                    FinderPath finderPath = null;
8176                    Object[] finderArgs = null;
8177    
8178                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8179                                    (orderByComparator == null)) {
8180                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
8181                            finderArgs = new Object[] { groupId, layoutUuid };
8182                    }
8183                    else {
8184                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
8185                            finderArgs = new Object[] {
8186                                            groupId, layoutUuid,
8187                                            
8188                                            start, end, orderByComparator
8189                                    };
8190                    }
8191    
8192                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8193                                    finderArgs, this);
8194    
8195                    if ((list != null) && !list.isEmpty()) {
8196                            for (JournalArticle journalArticle : list) {
8197                                    if ((groupId != journalArticle.getGroupId()) ||
8198                                                    !Validator.equals(layoutUuid,
8199                                                            journalArticle.getLayoutUuid())) {
8200                                            list = null;
8201    
8202                                            break;
8203                                    }
8204                            }
8205                    }
8206    
8207                    if (list == null) {
8208                            StringBundler query = null;
8209    
8210                            if (orderByComparator != null) {
8211                                    query = new StringBundler(4 +
8212                                                    (orderByComparator.getOrderByFields().length * 3));
8213                            }
8214                            else {
8215                                    query = new StringBundler(4);
8216                            }
8217    
8218                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8219    
8220                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
8221    
8222                            if (layoutUuid == null) {
8223                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
8224                            }
8225                            else {
8226                                    if (layoutUuid.equals(StringPool.BLANK)) {
8227                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
8228                                    }
8229                                    else {
8230                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
8231                                    }
8232                            }
8233    
8234                            if (orderByComparator != null) {
8235                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8236                                            orderByComparator);
8237                            }
8238    
8239                            else {
8240                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8241                            }
8242    
8243                            String sql = query.toString();
8244    
8245                            Session session = null;
8246    
8247                            try {
8248                                    session = openSession();
8249    
8250                                    Query q = session.createQuery(sql);
8251    
8252                                    QueryPos qPos = QueryPos.getInstance(q);
8253    
8254                                    qPos.add(groupId);
8255    
8256                                    if (layoutUuid != null) {
8257                                            qPos.add(layoutUuid);
8258                                    }
8259    
8260                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
8261                                                    start, end);
8262                            }
8263                            catch (Exception e) {
8264                                    throw processException(e);
8265                            }
8266                            finally {
8267                                    if (list == null) {
8268                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8269                                    }
8270                                    else {
8271                                            cacheResult(list);
8272    
8273                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8274                                    }
8275    
8276                                    closeSession(session);
8277                            }
8278                    }
8279    
8280                    return list;
8281            }
8282    
8283            /**
8284             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
8285             *
8286             * <p>
8287             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8288             * </p>
8289             *
8290             * @param groupId the group ID
8291             * @param layoutUuid the layout uuid
8292             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8293             * @return the first matching journal article
8294             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8295             * @throws SystemException if a system exception occurred
8296             */
8297            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
8298                    OrderByComparator orderByComparator)
8299                    throws NoSuchArticleException, SystemException {
8300                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
8301                                    orderByComparator);
8302    
8303                    if (list.isEmpty()) {
8304                            StringBundler msg = new StringBundler(6);
8305    
8306                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8307    
8308                            msg.append("groupId=");
8309                            msg.append(groupId);
8310    
8311                            msg.append(", layoutUuid=");
8312                            msg.append(layoutUuid);
8313    
8314                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8315    
8316                            throw new NoSuchArticleException(msg.toString());
8317                    }
8318                    else {
8319                            return list.get(0);
8320                    }
8321            }
8322    
8323            /**
8324             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
8325             *
8326             * <p>
8327             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8328             * </p>
8329             *
8330             * @param groupId the group ID
8331             * @param layoutUuid the layout uuid
8332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8333             * @return the last matching journal article
8334             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8335             * @throws SystemException if a system exception occurred
8336             */
8337            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
8338                    OrderByComparator orderByComparator)
8339                    throws NoSuchArticleException, SystemException {
8340                    int count = countByG_L(groupId, layoutUuid);
8341    
8342                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
8343                                    count, orderByComparator);
8344    
8345                    if (list.isEmpty()) {
8346                            StringBundler msg = new StringBundler(6);
8347    
8348                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8349    
8350                            msg.append("groupId=");
8351                            msg.append(groupId);
8352    
8353                            msg.append(", layoutUuid=");
8354                            msg.append(layoutUuid);
8355    
8356                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8357    
8358                            throw new NoSuchArticleException(msg.toString());
8359                    }
8360                    else {
8361                            return list.get(0);
8362                    }
8363            }
8364    
8365            /**
8366             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
8367             *
8368             * <p>
8369             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8370             * </p>
8371             *
8372             * @param id the primary key of the current journal article
8373             * @param groupId the group ID
8374             * @param layoutUuid the layout uuid
8375             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8376             * @return the previous, current, and next journal article
8377             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8378             * @throws SystemException if a system exception occurred
8379             */
8380            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
8381                    String layoutUuid, OrderByComparator orderByComparator)
8382                    throws NoSuchArticleException, SystemException {
8383                    JournalArticle journalArticle = findByPrimaryKey(id);
8384    
8385                    Session session = null;
8386    
8387                    try {
8388                            session = openSession();
8389    
8390                            JournalArticle[] array = new JournalArticleImpl[3];
8391    
8392                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
8393                                            layoutUuid, orderByComparator, true);
8394    
8395                            array[1] = journalArticle;
8396    
8397                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
8398                                            layoutUuid, orderByComparator, false);
8399    
8400                            return array;
8401                    }
8402                    catch (Exception e) {
8403                            throw processException(e);
8404                    }
8405                    finally {
8406                            closeSession(session);
8407                    }
8408            }
8409    
8410            protected JournalArticle getByG_L_PrevAndNext(Session session,
8411                    JournalArticle journalArticle, long groupId, String layoutUuid,
8412                    OrderByComparator orderByComparator, boolean previous) {
8413                    StringBundler query = null;
8414    
8415                    if (orderByComparator != null) {
8416                            query = new StringBundler(6 +
8417                                            (orderByComparator.getOrderByFields().length * 6));
8418                    }
8419                    else {
8420                            query = new StringBundler(3);
8421                    }
8422    
8423                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8424    
8425                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
8426    
8427                    if (layoutUuid == null) {
8428                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
8429                    }
8430                    else {
8431                            if (layoutUuid.equals(StringPool.BLANK)) {
8432                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
8433                            }
8434                            else {
8435                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
8436                            }
8437                    }
8438    
8439                    if (orderByComparator != null) {
8440                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8441    
8442                            if (orderByConditionFields.length > 0) {
8443                                    query.append(WHERE_AND);
8444                            }
8445    
8446                            for (int i = 0; i < orderByConditionFields.length; i++) {
8447                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8448                                    query.append(orderByConditionFields[i]);
8449    
8450                                    if ((i + 1) < orderByConditionFields.length) {
8451                                            if (orderByComparator.isAscending() ^ previous) {
8452                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8453                                            }
8454                                            else {
8455                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8456                                            }
8457                                    }
8458                                    else {
8459                                            if (orderByComparator.isAscending() ^ previous) {
8460                                                    query.append(WHERE_GREATER_THAN);
8461                                            }
8462                                            else {
8463                                                    query.append(WHERE_LESSER_THAN);
8464                                            }
8465                                    }
8466                            }
8467    
8468                            query.append(ORDER_BY_CLAUSE);
8469    
8470                            String[] orderByFields = orderByComparator.getOrderByFields();
8471    
8472                            for (int i = 0; i < orderByFields.length; i++) {
8473                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8474                                    query.append(orderByFields[i]);
8475    
8476                                    if ((i + 1) < orderByFields.length) {
8477                                            if (orderByComparator.isAscending() ^ previous) {
8478                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8479                                            }
8480                                            else {
8481                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8482                                            }
8483                                    }
8484                                    else {
8485                                            if (orderByComparator.isAscending() ^ previous) {
8486                                                    query.append(ORDER_BY_ASC);
8487                                            }
8488                                            else {
8489                                                    query.append(ORDER_BY_DESC);
8490                                            }
8491                                    }
8492                            }
8493                    }
8494    
8495                    else {
8496                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8497                    }
8498    
8499                    String sql = query.toString();
8500    
8501                    Query q = session.createQuery(sql);
8502    
8503                    q.setFirstResult(0);
8504                    q.setMaxResults(2);
8505    
8506                    QueryPos qPos = QueryPos.getInstance(q);
8507    
8508                    qPos.add(groupId);
8509    
8510                    if (layoutUuid != null) {
8511                            qPos.add(layoutUuid);
8512                    }
8513    
8514                    if (orderByComparator != null) {
8515                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8516    
8517                            for (Object value : values) {
8518                                    qPos.add(value);
8519                            }
8520                    }
8521    
8522                    List<JournalArticle> list = q.list();
8523    
8524                    if (list.size() == 2) {
8525                            return list.get(1);
8526                    }
8527                    else {
8528                            return null;
8529                    }
8530            }
8531    
8532            /**
8533             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
8534             *
8535             * @param groupId the group ID
8536             * @param layoutUuid the layout uuid
8537             * @return the matching journal articles that the user has permission to view
8538             * @throws SystemException if a system exception occurred
8539             */
8540            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
8541                    throws SystemException {
8542                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
8543                            QueryUtil.ALL_POS, null);
8544            }
8545    
8546            /**
8547             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
8548             *
8549             * <p>
8550             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8551             * </p>
8552             *
8553             * @param groupId the group ID
8554             * @param layoutUuid the layout uuid
8555             * @param start the lower bound of the range of journal articles
8556             * @param end the upper bound of the range of journal articles (not inclusive)
8557             * @return the range of matching journal articles that the user has permission to view
8558             * @throws SystemException if a system exception occurred
8559             */
8560            public List<JournalArticle> filterFindByG_L(long groupId,
8561                    String layoutUuid, int start, int end) throws SystemException {
8562                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
8563            }
8564    
8565            /**
8566             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
8567             *
8568             * <p>
8569             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8570             * </p>
8571             *
8572             * @param groupId the group ID
8573             * @param layoutUuid the layout uuid
8574             * @param start the lower bound of the range of journal articles
8575             * @param end the upper bound of the range of journal articles (not inclusive)
8576             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8577             * @return the ordered range of matching journal articles that the user has permission to view
8578             * @throws SystemException if a system exception occurred
8579             */
8580            public List<JournalArticle> filterFindByG_L(long groupId,
8581                    String layoutUuid, int start, int end,
8582                    OrderByComparator orderByComparator) throws SystemException {
8583                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8584                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
8585                    }
8586    
8587                    StringBundler query = null;
8588    
8589                    if (orderByComparator != null) {
8590                            query = new StringBundler(4 +
8591                                            (orderByComparator.getOrderByFields().length * 3));
8592                    }
8593                    else {
8594                            query = new StringBundler(4);
8595                    }
8596    
8597                    if (getDB().isSupportsInlineDistinct()) {
8598                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8599                    }
8600                    else {
8601                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8602                    }
8603    
8604                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
8605    
8606                    if (layoutUuid == null) {
8607                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
8608                    }
8609                    else {
8610                            if (layoutUuid.equals(StringPool.BLANK)) {
8611                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
8612                            }
8613                            else {
8614                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
8615                            }
8616                    }
8617    
8618                    if (!getDB().isSupportsInlineDistinct()) {
8619                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8620                    }
8621    
8622                    if (orderByComparator != null) {
8623                            if (getDB().isSupportsInlineDistinct()) {
8624                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8625                                            orderByComparator);
8626                            }
8627                            else {
8628                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8629                                            orderByComparator);
8630                            }
8631                    }
8632    
8633                    else {
8634                            if (getDB().isSupportsInlineDistinct()) {
8635                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8636                            }
8637                            else {
8638                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8639                            }
8640                    }
8641    
8642                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8643                                    JournalArticle.class.getName(),
8644                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8645    
8646                    Session session = null;
8647    
8648                    try {
8649                            session = openSession();
8650    
8651                            SQLQuery q = session.createSQLQuery(sql);
8652    
8653                            if (getDB().isSupportsInlineDistinct()) {
8654                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8655                            }
8656                            else {
8657                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8658                            }
8659    
8660                            QueryPos qPos = QueryPos.getInstance(q);
8661    
8662                            qPos.add(groupId);
8663    
8664                            if (layoutUuid != null) {
8665                                    qPos.add(layoutUuid);
8666                            }
8667    
8668                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8669                                    end);
8670                    }
8671                    catch (Exception e) {
8672                            throw processException(e);
8673                    }
8674                    finally {
8675                            closeSession(session);
8676                    }
8677            }
8678    
8679            /**
8680             * 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;.
8681             *
8682             * @param id the primary key of the current journal article
8683             * @param groupId the group ID
8684             * @param layoutUuid the layout uuid
8685             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8686             * @return the previous, current, and next journal article
8687             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8688             * @throws SystemException if a system exception occurred
8689             */
8690            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
8691                    String layoutUuid, OrderByComparator orderByComparator)
8692                    throws NoSuchArticleException, SystemException {
8693                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8694                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
8695                                    orderByComparator);
8696                    }
8697    
8698                    JournalArticle journalArticle = findByPrimaryKey(id);
8699    
8700                    Session session = null;
8701    
8702                    try {
8703                            session = openSession();
8704    
8705                            JournalArticle[] array = new JournalArticleImpl[3];
8706    
8707                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
8708                                            groupId, layoutUuid, orderByComparator, true);
8709    
8710                            array[1] = journalArticle;
8711    
8712                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
8713                                            groupId, layoutUuid, orderByComparator, false);
8714    
8715                            return array;
8716                    }
8717                    catch (Exception e) {
8718                            throw processException(e);
8719                    }
8720                    finally {
8721                            closeSession(session);
8722                    }
8723            }
8724    
8725            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
8726                    JournalArticle journalArticle, long groupId, String layoutUuid,
8727                    OrderByComparator orderByComparator, boolean previous) {
8728                    StringBundler query = null;
8729    
8730                    if (orderByComparator != null) {
8731                            query = new StringBundler(6 +
8732                                            (orderByComparator.getOrderByFields().length * 6));
8733                    }
8734                    else {
8735                            query = new StringBundler(3);
8736                    }
8737    
8738                    if (getDB().isSupportsInlineDistinct()) {
8739                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8740                    }
8741                    else {
8742                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8743                    }
8744    
8745                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
8746    
8747                    if (layoutUuid == null) {
8748                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
8749                    }
8750                    else {
8751                            if (layoutUuid.equals(StringPool.BLANK)) {
8752                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
8753                            }
8754                            else {
8755                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
8756                            }
8757                    }
8758    
8759                    if (!getDB().isSupportsInlineDistinct()) {
8760                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8761                    }
8762    
8763                    if (orderByComparator != null) {
8764                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8765    
8766                            if (orderByConditionFields.length > 0) {
8767                                    query.append(WHERE_AND);
8768                            }
8769    
8770                            for (int i = 0; i < orderByConditionFields.length; i++) {
8771                                    if (getDB().isSupportsInlineDistinct()) {
8772                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8773                                    }
8774                                    else {
8775                                            query.append(_ORDER_BY_ENTITY_TABLE);
8776                                    }
8777    
8778                                    query.append(orderByConditionFields[i]);
8779    
8780                                    if ((i + 1) < orderByConditionFields.length) {
8781                                            if (orderByComparator.isAscending() ^ previous) {
8782                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8783                                            }
8784                                            else {
8785                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8786                                            }
8787                                    }
8788                                    else {
8789                                            if (orderByComparator.isAscending() ^ previous) {
8790                                                    query.append(WHERE_GREATER_THAN);
8791                                            }
8792                                            else {
8793                                                    query.append(WHERE_LESSER_THAN);
8794                                            }
8795                                    }
8796                            }
8797    
8798                            query.append(ORDER_BY_CLAUSE);
8799    
8800                            String[] orderByFields = orderByComparator.getOrderByFields();
8801    
8802                            for (int i = 0; i < orderByFields.length; i++) {
8803                                    if (getDB().isSupportsInlineDistinct()) {
8804                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8805                                    }
8806                                    else {
8807                                            query.append(_ORDER_BY_ENTITY_TABLE);
8808                                    }
8809    
8810                                    query.append(orderByFields[i]);
8811    
8812                                    if ((i + 1) < orderByFields.length) {
8813                                            if (orderByComparator.isAscending() ^ previous) {
8814                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8815                                            }
8816                                            else {
8817                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8818                                            }
8819                                    }
8820                                    else {
8821                                            if (orderByComparator.isAscending() ^ previous) {
8822                                                    query.append(ORDER_BY_ASC);
8823                                            }
8824                                            else {
8825                                                    query.append(ORDER_BY_DESC);
8826                                            }
8827                                    }
8828                            }
8829                    }
8830    
8831                    else {
8832                            if (getDB().isSupportsInlineDistinct()) {
8833                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8834                            }
8835                            else {
8836                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8837                            }
8838                    }
8839    
8840                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8841                                    JournalArticle.class.getName(),
8842                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8843    
8844                    SQLQuery q = session.createSQLQuery(sql);
8845    
8846                    q.setFirstResult(0);
8847                    q.setMaxResults(2);
8848    
8849                    if (getDB().isSupportsInlineDistinct()) {
8850                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8851                    }
8852                    else {
8853                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8854                    }
8855    
8856                    QueryPos qPos = QueryPos.getInstance(q);
8857    
8858                    qPos.add(groupId);
8859    
8860                    if (layoutUuid != null) {
8861                            qPos.add(layoutUuid);
8862                    }
8863    
8864                    if (orderByComparator != null) {
8865                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8866    
8867                            for (Object value : values) {
8868                                    qPos.add(value);
8869                            }
8870                    }
8871    
8872                    List<JournalArticle> list = q.list();
8873    
8874                    if (list.size() == 2) {
8875                            return list.get(1);
8876                    }
8877                    else {
8878                            return null;
8879                    }
8880            }
8881    
8882            /**
8883             * Returns all the journal articles where groupId = &#63; and status = &#63;.
8884             *
8885             * @param groupId the group ID
8886             * @param status the status
8887             * @return the matching journal articles
8888             * @throws SystemException if a system exception occurred
8889             */
8890            public List<JournalArticle> findByG_ST(long groupId, int status)
8891                    throws SystemException {
8892                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
8893                            QueryUtil.ALL_POS, null);
8894            }
8895    
8896            /**
8897             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
8898             *
8899             * <p>
8900             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8901             * </p>
8902             *
8903             * @param groupId the group ID
8904             * @param status the status
8905             * @param start the lower bound of the range of journal articles
8906             * @param end the upper bound of the range of journal articles (not inclusive)
8907             * @return the range of matching journal articles
8908             * @throws SystemException if a system exception occurred
8909             */
8910            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
8911                    int end) throws SystemException {
8912                    return findByG_ST(groupId, status, start, end, null);
8913            }
8914    
8915            /**
8916             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
8917             *
8918             * <p>
8919             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8920             * </p>
8921             *
8922             * @param groupId the group ID
8923             * @param status the status
8924             * @param start the lower bound of the range of journal articles
8925             * @param end the upper bound of the range of journal articles (not inclusive)
8926             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8927             * @return the ordered range of matching journal articles
8928             * @throws SystemException if a system exception occurred
8929             */
8930            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
8931                    int end, OrderByComparator orderByComparator) throws SystemException {
8932                    FinderPath finderPath = null;
8933                    Object[] finderArgs = null;
8934    
8935                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8936                                    (orderByComparator == null)) {
8937                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
8938                            finderArgs = new Object[] { groupId, status };
8939                    }
8940                    else {
8941                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
8942                            finderArgs = new Object[] {
8943                                            groupId, status,
8944                                            
8945                                            start, end, orderByComparator
8946                                    };
8947                    }
8948    
8949                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8950                                    finderArgs, this);
8951    
8952                    if ((list != null) && !list.isEmpty()) {
8953                            for (JournalArticle journalArticle : list) {
8954                                    if ((groupId != journalArticle.getGroupId()) ||
8955                                                    (status != journalArticle.getStatus())) {
8956                                            list = null;
8957    
8958                                            break;
8959                                    }
8960                            }
8961                    }
8962    
8963                    if (list == null) {
8964                            StringBundler query = null;
8965    
8966                            if (orderByComparator != null) {
8967                                    query = new StringBundler(4 +
8968                                                    (orderByComparator.getOrderByFields().length * 3));
8969                            }
8970                            else {
8971                                    query = new StringBundler(4);
8972                            }
8973    
8974                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8975    
8976                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
8977    
8978                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
8979    
8980                            if (orderByComparator != null) {
8981                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8982                                            orderByComparator);
8983                            }
8984    
8985                            else {
8986                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8987                            }
8988    
8989                            String sql = query.toString();
8990    
8991                            Session session = null;
8992    
8993                            try {
8994                                    session = openSession();
8995    
8996                                    Query q = session.createQuery(sql);
8997    
8998                                    QueryPos qPos = QueryPos.getInstance(q);
8999    
9000                                    qPos.add(groupId);
9001    
9002                                    qPos.add(status);
9003    
9004                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
9005                                                    start, end);
9006                            }
9007                            catch (Exception e) {
9008                                    throw processException(e);
9009                            }
9010                            finally {
9011                                    if (list == null) {
9012                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9013                                    }
9014                                    else {
9015                                            cacheResult(list);
9016    
9017                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9018                                    }
9019    
9020                                    closeSession(session);
9021                            }
9022                    }
9023    
9024                    return list;
9025            }
9026    
9027            /**
9028             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
9029             *
9030             * <p>
9031             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9032             * </p>
9033             *
9034             * @param groupId the group ID
9035             * @param status the status
9036             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9037             * @return the first matching journal article
9038             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9039             * @throws SystemException if a system exception occurred
9040             */
9041            public JournalArticle findByG_ST_First(long groupId, int status,
9042                    OrderByComparator orderByComparator)
9043                    throws NoSuchArticleException, SystemException {
9044                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
9045                                    orderByComparator);
9046    
9047                    if (list.isEmpty()) {
9048                            StringBundler msg = new StringBundler(6);
9049    
9050                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9051    
9052                            msg.append("groupId=");
9053                            msg.append(groupId);
9054    
9055                            msg.append(", status=");
9056                            msg.append(status);
9057    
9058                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9059    
9060                            throw new NoSuchArticleException(msg.toString());
9061                    }
9062                    else {
9063                            return list.get(0);
9064                    }
9065            }
9066    
9067            /**
9068             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
9069             *
9070             * <p>
9071             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9072             * </p>
9073             *
9074             * @param groupId the group ID
9075             * @param status the status
9076             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9077             * @return the last matching journal article
9078             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9079             * @throws SystemException if a system exception occurred
9080             */
9081            public JournalArticle findByG_ST_Last(long groupId, int status,
9082                    OrderByComparator orderByComparator)
9083                    throws NoSuchArticleException, SystemException {
9084                    int count = countByG_ST(groupId, status);
9085    
9086                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
9087                                    count, orderByComparator);
9088    
9089                    if (list.isEmpty()) {
9090                            StringBundler msg = new StringBundler(6);
9091    
9092                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9093    
9094                            msg.append("groupId=");
9095                            msg.append(groupId);
9096    
9097                            msg.append(", status=");
9098                            msg.append(status);
9099    
9100                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9101    
9102                            throw new NoSuchArticleException(msg.toString());
9103                    }
9104                    else {
9105                            return list.get(0);
9106                    }
9107            }
9108    
9109            /**
9110             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
9111             *
9112             * <p>
9113             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9114             * </p>
9115             *
9116             * @param id the primary key of the current journal article
9117             * @param groupId the group ID
9118             * @param status the status
9119             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9120             * @return the previous, current, and next journal article
9121             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9122             * @throws SystemException if a system exception occurred
9123             */
9124            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
9125                    int status, OrderByComparator orderByComparator)
9126                    throws NoSuchArticleException, SystemException {
9127                    JournalArticle journalArticle = findByPrimaryKey(id);
9128    
9129                    Session session = null;
9130    
9131                    try {
9132                            session = openSession();
9133    
9134                            JournalArticle[] array = new JournalArticleImpl[3];
9135    
9136                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
9137                                            status, orderByComparator, true);
9138    
9139                            array[1] = journalArticle;
9140    
9141                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
9142                                            status, orderByComparator, false);
9143    
9144                            return array;
9145                    }
9146                    catch (Exception e) {
9147                            throw processException(e);
9148                    }
9149                    finally {
9150                            closeSession(session);
9151                    }
9152            }
9153    
9154            protected JournalArticle getByG_ST_PrevAndNext(Session session,
9155                    JournalArticle journalArticle, long groupId, int status,
9156                    OrderByComparator orderByComparator, boolean previous) {
9157                    StringBundler query = null;
9158    
9159                    if (orderByComparator != null) {
9160                            query = new StringBundler(6 +
9161                                            (orderByComparator.getOrderByFields().length * 6));
9162                    }
9163                    else {
9164                            query = new StringBundler(3);
9165                    }
9166    
9167                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9168    
9169                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
9170    
9171                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
9172    
9173                    if (orderByComparator != null) {
9174                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9175    
9176                            if (orderByConditionFields.length > 0) {
9177                                    query.append(WHERE_AND);
9178                            }
9179    
9180                            for (int i = 0; i < orderByConditionFields.length; i++) {
9181                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9182                                    query.append(orderByConditionFields[i]);
9183    
9184                                    if ((i + 1) < orderByConditionFields.length) {
9185                                            if (orderByComparator.isAscending() ^ previous) {
9186                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9187                                            }
9188                                            else {
9189                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9190                                            }
9191                                    }
9192                                    else {
9193                                            if (orderByComparator.isAscending() ^ previous) {
9194                                                    query.append(WHERE_GREATER_THAN);
9195                                            }
9196                                            else {
9197                                                    query.append(WHERE_LESSER_THAN);
9198                                            }
9199                                    }
9200                            }
9201    
9202                            query.append(ORDER_BY_CLAUSE);
9203    
9204                            String[] orderByFields = orderByComparator.getOrderByFields();
9205    
9206                            for (int i = 0; i < orderByFields.length; i++) {
9207                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9208                                    query.append(orderByFields[i]);
9209    
9210                                    if ((i + 1) < orderByFields.length) {
9211                                            if (orderByComparator.isAscending() ^ previous) {
9212                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9213                                            }
9214                                            else {
9215                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9216                                            }
9217                                    }
9218                                    else {
9219                                            if (orderByComparator.isAscending() ^ previous) {
9220                                                    query.append(ORDER_BY_ASC);
9221                                            }
9222                                            else {
9223                                                    query.append(ORDER_BY_DESC);
9224                                            }
9225                                    }
9226                            }
9227                    }
9228    
9229                    else {
9230                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9231                    }
9232    
9233                    String sql = query.toString();
9234    
9235                    Query q = session.createQuery(sql);
9236    
9237                    q.setFirstResult(0);
9238                    q.setMaxResults(2);
9239    
9240                    QueryPos qPos = QueryPos.getInstance(q);
9241    
9242                    qPos.add(groupId);
9243    
9244                    qPos.add(status);
9245    
9246                    if (orderByComparator != null) {
9247                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9248    
9249                            for (Object value : values) {
9250                                    qPos.add(value);
9251                            }
9252                    }
9253    
9254                    List<JournalArticle> list = q.list();
9255    
9256                    if (list.size() == 2) {
9257                            return list.get(1);
9258                    }
9259                    else {
9260                            return null;
9261                    }
9262            }
9263    
9264            /**
9265             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
9266             *
9267             * @param groupId the group ID
9268             * @param status the status
9269             * @return the matching journal articles that the user has permission to view
9270             * @throws SystemException if a system exception occurred
9271             */
9272            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
9273                    throws SystemException {
9274                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
9275                            QueryUtil.ALL_POS, null);
9276            }
9277    
9278            /**
9279             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
9280             *
9281             * <p>
9282             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9283             * </p>
9284             *
9285             * @param groupId the group ID
9286             * @param status the status
9287             * @param start the lower bound of the range of journal articles
9288             * @param end the upper bound of the range of journal articles (not inclusive)
9289             * @return the range of matching journal articles that the user has permission to view
9290             * @throws SystemException if a system exception occurred
9291             */
9292            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
9293                    int start, int end) throws SystemException {
9294                    return filterFindByG_ST(groupId, status, start, end, null);
9295            }
9296    
9297            /**
9298             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
9299             *
9300             * <p>
9301             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9302             * </p>
9303             *
9304             * @param groupId the group ID
9305             * @param status the status
9306             * @param start the lower bound of the range of journal articles
9307             * @param end the upper bound of the range of journal articles (not inclusive)
9308             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9309             * @return the ordered range of matching journal articles that the user has permission to view
9310             * @throws SystemException if a system exception occurred
9311             */
9312            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
9313                    int start, int end, OrderByComparator orderByComparator)
9314                    throws SystemException {
9315                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9316                            return findByG_ST(groupId, status, start, end, orderByComparator);
9317                    }
9318    
9319                    StringBundler query = null;
9320    
9321                    if (orderByComparator != null) {
9322                            query = new StringBundler(4 +
9323                                            (orderByComparator.getOrderByFields().length * 3));
9324                    }
9325                    else {
9326                            query = new StringBundler(4);
9327                    }
9328    
9329                    if (getDB().isSupportsInlineDistinct()) {
9330                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9331                    }
9332                    else {
9333                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9334                    }
9335    
9336                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
9337    
9338                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
9339    
9340                    if (!getDB().isSupportsInlineDistinct()) {
9341                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9342                    }
9343    
9344                    if (orderByComparator != null) {
9345                            if (getDB().isSupportsInlineDistinct()) {
9346                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9347                                            orderByComparator);
9348                            }
9349                            else {
9350                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9351                                            orderByComparator);
9352                            }
9353                    }
9354    
9355                    else {
9356                            if (getDB().isSupportsInlineDistinct()) {
9357                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9358                            }
9359                            else {
9360                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9361                            }
9362                    }
9363    
9364                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9365                                    JournalArticle.class.getName(),
9366                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9367    
9368                    Session session = null;
9369    
9370                    try {
9371                            session = openSession();
9372    
9373                            SQLQuery q = session.createSQLQuery(sql);
9374    
9375                            if (getDB().isSupportsInlineDistinct()) {
9376                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9377                            }
9378                            else {
9379                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9380                            }
9381    
9382                            QueryPos qPos = QueryPos.getInstance(q);
9383    
9384                            qPos.add(groupId);
9385    
9386                            qPos.add(status);
9387    
9388                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9389                                    end);
9390                    }
9391                    catch (Exception e) {
9392                            throw processException(e);
9393                    }
9394                    finally {
9395                            closeSession(session);
9396                    }
9397            }
9398    
9399            /**
9400             * 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;.
9401             *
9402             * @param id the primary key of the current journal article
9403             * @param groupId the group ID
9404             * @param status the status
9405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9406             * @return the previous, current, and next journal article
9407             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9408             * @throws SystemException if a system exception occurred
9409             */
9410            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
9411                    int status, OrderByComparator orderByComparator)
9412                    throws NoSuchArticleException, SystemException {
9413                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9414                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
9415                    }
9416    
9417                    JournalArticle journalArticle = findByPrimaryKey(id);
9418    
9419                    Session session = null;
9420    
9421                    try {
9422                            session = openSession();
9423    
9424                            JournalArticle[] array = new JournalArticleImpl[3];
9425    
9426                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
9427                                            groupId, status, orderByComparator, true);
9428    
9429                            array[1] = journalArticle;
9430    
9431                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
9432                                            groupId, status, orderByComparator, false);
9433    
9434                            return array;
9435                    }
9436                    catch (Exception e) {
9437                            throw processException(e);
9438                    }
9439                    finally {
9440                            closeSession(session);
9441                    }
9442            }
9443    
9444            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
9445                    JournalArticle journalArticle, long groupId, int status,
9446                    OrderByComparator orderByComparator, boolean previous) {
9447                    StringBundler query = null;
9448    
9449                    if (orderByComparator != null) {
9450                            query = new StringBundler(6 +
9451                                            (orderByComparator.getOrderByFields().length * 6));
9452                    }
9453                    else {
9454                            query = new StringBundler(3);
9455                    }
9456    
9457                    if (getDB().isSupportsInlineDistinct()) {
9458                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9459                    }
9460                    else {
9461                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9462                    }
9463    
9464                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
9465    
9466                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
9467    
9468                    if (!getDB().isSupportsInlineDistinct()) {
9469                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9470                    }
9471    
9472                    if (orderByComparator != null) {
9473                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9474    
9475                            if (orderByConditionFields.length > 0) {
9476                                    query.append(WHERE_AND);
9477                            }
9478    
9479                            for (int i = 0; i < orderByConditionFields.length; i++) {
9480                                    if (getDB().isSupportsInlineDistinct()) {
9481                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9482                                    }
9483                                    else {
9484                                            query.append(_ORDER_BY_ENTITY_TABLE);
9485                                    }
9486    
9487                                    query.append(orderByConditionFields[i]);
9488    
9489                                    if ((i + 1) < orderByConditionFields.length) {
9490                                            if (orderByComparator.isAscending() ^ previous) {
9491                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9492                                            }
9493                                            else {
9494                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9495                                            }
9496                                    }
9497                                    else {
9498                                            if (orderByComparator.isAscending() ^ previous) {
9499                                                    query.append(WHERE_GREATER_THAN);
9500                                            }
9501                                            else {
9502                                                    query.append(WHERE_LESSER_THAN);
9503                                            }
9504                                    }
9505                            }
9506    
9507                            query.append(ORDER_BY_CLAUSE);
9508    
9509                            String[] orderByFields = orderByComparator.getOrderByFields();
9510    
9511                            for (int i = 0; i < orderByFields.length; i++) {
9512                                    if (getDB().isSupportsInlineDistinct()) {
9513                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9514                                    }
9515                                    else {
9516                                            query.append(_ORDER_BY_ENTITY_TABLE);
9517                                    }
9518    
9519                                    query.append(orderByFields[i]);
9520    
9521                                    if ((i + 1) < orderByFields.length) {
9522                                            if (orderByComparator.isAscending() ^ previous) {
9523                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9524                                            }
9525                                            else {
9526                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9527                                            }
9528                                    }
9529                                    else {
9530                                            if (orderByComparator.isAscending() ^ previous) {
9531                                                    query.append(ORDER_BY_ASC);
9532                                            }
9533                                            else {
9534                                                    query.append(ORDER_BY_DESC);
9535                                            }
9536                                    }
9537                            }
9538                    }
9539    
9540                    else {
9541                            if (getDB().isSupportsInlineDistinct()) {
9542                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9543                            }
9544                            else {
9545                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9546                            }
9547                    }
9548    
9549                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9550                                    JournalArticle.class.getName(),
9551                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9552    
9553                    SQLQuery q = session.createSQLQuery(sql);
9554    
9555                    q.setFirstResult(0);
9556                    q.setMaxResults(2);
9557    
9558                    if (getDB().isSupportsInlineDistinct()) {
9559                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9560                    }
9561                    else {
9562                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9563                    }
9564    
9565                    QueryPos qPos = QueryPos.getInstance(q);
9566    
9567                    qPos.add(groupId);
9568    
9569                    qPos.add(status);
9570    
9571                    if (orderByComparator != null) {
9572                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9573    
9574                            for (Object value : values) {
9575                                    qPos.add(value);
9576                            }
9577                    }
9578    
9579                    List<JournalArticle> list = q.list();
9580    
9581                    if (list.size() == 2) {
9582                            return list.get(1);
9583                    }
9584                    else {
9585                            return null;
9586                    }
9587            }
9588    
9589            /**
9590             * Returns all the journal articles where companyId = &#63; and version = &#63;.
9591             *
9592             * @param companyId the company ID
9593             * @param version the version
9594             * @return the matching journal articles
9595             * @throws SystemException if a system exception occurred
9596             */
9597            public List<JournalArticle> findByC_V(long companyId, double version)
9598                    throws SystemException {
9599                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
9600                            QueryUtil.ALL_POS, null);
9601            }
9602    
9603            /**
9604             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
9605             *
9606             * <p>
9607             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9608             * </p>
9609             *
9610             * @param companyId the company ID
9611             * @param version the version
9612             * @param start the lower bound of the range of journal articles
9613             * @param end the upper bound of the range of journal articles (not inclusive)
9614             * @return the range of matching journal articles
9615             * @throws SystemException if a system exception occurred
9616             */
9617            public List<JournalArticle> findByC_V(long companyId, double version,
9618                    int start, int end) throws SystemException {
9619                    return findByC_V(companyId, version, start, end, null);
9620            }
9621    
9622            /**
9623             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
9624             *
9625             * <p>
9626             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9627             * </p>
9628             *
9629             * @param companyId the company ID
9630             * @param version the version
9631             * @param start the lower bound of the range of journal articles
9632             * @param end the upper bound of the range of journal articles (not inclusive)
9633             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9634             * @return the ordered range of matching journal articles
9635             * @throws SystemException if a system exception occurred
9636             */
9637            public List<JournalArticle> findByC_V(long companyId, double version,
9638                    int start, int end, OrderByComparator orderByComparator)
9639                    throws SystemException {
9640                    FinderPath finderPath = null;
9641                    Object[] finderArgs = null;
9642    
9643                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9644                                    (orderByComparator == null)) {
9645                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
9646                            finderArgs = new Object[] { companyId, version };
9647                    }
9648                    else {
9649                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
9650                            finderArgs = new Object[] {
9651                                            companyId, version,
9652                                            
9653                                            start, end, orderByComparator
9654                                    };
9655                    }
9656    
9657                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9658                                    finderArgs, this);
9659    
9660                    if ((list != null) && !list.isEmpty()) {
9661                            for (JournalArticle journalArticle : list) {
9662                                    if ((companyId != journalArticle.getCompanyId()) ||
9663                                                    (version != journalArticle.getVersion())) {
9664                                            list = null;
9665    
9666                                            break;
9667                                    }
9668                            }
9669                    }
9670    
9671                    if (list == null) {
9672                            StringBundler query = null;
9673    
9674                            if (orderByComparator != null) {
9675                                    query = new StringBundler(4 +
9676                                                    (orderByComparator.getOrderByFields().length * 3));
9677                            }
9678                            else {
9679                                    query = new StringBundler(4);
9680                            }
9681    
9682                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9683    
9684                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
9685    
9686                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
9687    
9688                            if (orderByComparator != null) {
9689                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9690                                            orderByComparator);
9691                            }
9692    
9693                            else {
9694                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9695                            }
9696    
9697                            String sql = query.toString();
9698    
9699                            Session session = null;
9700    
9701                            try {
9702                                    session = openSession();
9703    
9704                                    Query q = session.createQuery(sql);
9705    
9706                                    QueryPos qPos = QueryPos.getInstance(q);
9707    
9708                                    qPos.add(companyId);
9709    
9710                                    qPos.add(version);
9711    
9712                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
9713                                                    start, end);
9714                            }
9715                            catch (Exception e) {
9716                                    throw processException(e);
9717                            }
9718                            finally {
9719                                    if (list == null) {
9720                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9721                                    }
9722                                    else {
9723                                            cacheResult(list);
9724    
9725                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9726                                    }
9727    
9728                                    closeSession(session);
9729                            }
9730                    }
9731    
9732                    return list;
9733            }
9734    
9735            /**
9736             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
9737             *
9738             * <p>
9739             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9740             * </p>
9741             *
9742             * @param companyId the company ID
9743             * @param version the version
9744             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9745             * @return the first matching journal article
9746             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9747             * @throws SystemException if a system exception occurred
9748             */
9749            public JournalArticle findByC_V_First(long companyId, double version,
9750                    OrderByComparator orderByComparator)
9751                    throws NoSuchArticleException, SystemException {
9752                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
9753                                    orderByComparator);
9754    
9755                    if (list.isEmpty()) {
9756                            StringBundler msg = new StringBundler(6);
9757    
9758                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9759    
9760                            msg.append("companyId=");
9761                            msg.append(companyId);
9762    
9763                            msg.append(", version=");
9764                            msg.append(version);
9765    
9766                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9767    
9768                            throw new NoSuchArticleException(msg.toString());
9769                    }
9770                    else {
9771                            return list.get(0);
9772                    }
9773            }
9774    
9775            /**
9776             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
9777             *
9778             * <p>
9779             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9780             * </p>
9781             *
9782             * @param companyId the company ID
9783             * @param version the version
9784             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9785             * @return the last matching journal article
9786             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9787             * @throws SystemException if a system exception occurred
9788             */
9789            public JournalArticle findByC_V_Last(long companyId, double version,
9790                    OrderByComparator orderByComparator)
9791                    throws NoSuchArticleException, SystemException {
9792                    int count = countByC_V(companyId, version);
9793    
9794                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
9795                                    count, orderByComparator);
9796    
9797                    if (list.isEmpty()) {
9798                            StringBundler msg = new StringBundler(6);
9799    
9800                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9801    
9802                            msg.append("companyId=");
9803                            msg.append(companyId);
9804    
9805                            msg.append(", version=");
9806                            msg.append(version);
9807    
9808                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9809    
9810                            throw new NoSuchArticleException(msg.toString());
9811                    }
9812                    else {
9813                            return list.get(0);
9814                    }
9815            }
9816    
9817            /**
9818             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
9819             *
9820             * <p>
9821             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9822             * </p>
9823             *
9824             * @param id the primary key of the current journal article
9825             * @param companyId the company ID
9826             * @param version the version
9827             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9828             * @return the previous, current, and next journal article
9829             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9830             * @throws SystemException if a system exception occurred
9831             */
9832            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
9833                    double version, OrderByComparator orderByComparator)
9834                    throws NoSuchArticleException, SystemException {
9835                    JournalArticle journalArticle = findByPrimaryKey(id);
9836    
9837                    Session session = null;
9838    
9839                    try {
9840                            session = openSession();
9841    
9842                            JournalArticle[] array = new JournalArticleImpl[3];
9843    
9844                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
9845                                            version, orderByComparator, true);
9846    
9847                            array[1] = journalArticle;
9848    
9849                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
9850                                            version, orderByComparator, false);
9851    
9852                            return array;
9853                    }
9854                    catch (Exception e) {
9855                            throw processException(e);
9856                    }
9857                    finally {
9858                            closeSession(session);
9859                    }
9860            }
9861    
9862            protected JournalArticle getByC_V_PrevAndNext(Session session,
9863                    JournalArticle journalArticle, long companyId, double version,
9864                    OrderByComparator orderByComparator, boolean previous) {
9865                    StringBundler query = null;
9866    
9867                    if (orderByComparator != null) {
9868                            query = new StringBundler(6 +
9869                                            (orderByComparator.getOrderByFields().length * 6));
9870                    }
9871                    else {
9872                            query = new StringBundler(3);
9873                    }
9874    
9875                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9876    
9877                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
9878    
9879                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
9880    
9881                    if (orderByComparator != null) {
9882                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9883    
9884                            if (orderByConditionFields.length > 0) {
9885                                    query.append(WHERE_AND);
9886                            }
9887    
9888                            for (int i = 0; i < orderByConditionFields.length; i++) {
9889                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9890                                    query.append(orderByConditionFields[i]);
9891    
9892                                    if ((i + 1) < orderByConditionFields.length) {
9893                                            if (orderByComparator.isAscending() ^ previous) {
9894                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9895                                            }
9896                                            else {
9897                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9898                                            }
9899                                    }
9900                                    else {
9901                                            if (orderByComparator.isAscending() ^ previous) {
9902                                                    query.append(WHERE_GREATER_THAN);
9903                                            }
9904                                            else {
9905                                                    query.append(WHERE_LESSER_THAN);
9906                                            }
9907                                    }
9908                            }
9909    
9910                            query.append(ORDER_BY_CLAUSE);
9911    
9912                            String[] orderByFields = orderByComparator.getOrderByFields();
9913    
9914                            for (int i = 0; i < orderByFields.length; i++) {
9915                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9916                                    query.append(orderByFields[i]);
9917    
9918                                    if ((i + 1) < orderByFields.length) {
9919                                            if (orderByComparator.isAscending() ^ previous) {
9920                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9921                                            }
9922                                            else {
9923                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9924                                            }
9925                                    }
9926                                    else {
9927                                            if (orderByComparator.isAscending() ^ previous) {
9928                                                    query.append(ORDER_BY_ASC);
9929                                            }
9930                                            else {
9931                                                    query.append(ORDER_BY_DESC);
9932                                            }
9933                                    }
9934                            }
9935                    }
9936    
9937                    else {
9938                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9939                    }
9940    
9941                    String sql = query.toString();
9942    
9943                    Query q = session.createQuery(sql);
9944    
9945                    q.setFirstResult(0);
9946                    q.setMaxResults(2);
9947    
9948                    QueryPos qPos = QueryPos.getInstance(q);
9949    
9950                    qPos.add(companyId);
9951    
9952                    qPos.add(version);
9953    
9954                    if (orderByComparator != null) {
9955                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9956    
9957                            for (Object value : values) {
9958                                    qPos.add(value);
9959                            }
9960                    }
9961    
9962                    List<JournalArticle> list = q.list();
9963    
9964                    if (list.size() == 2) {
9965                            return list.get(1);
9966                    }
9967                    else {
9968                            return null;
9969                    }
9970            }
9971    
9972            /**
9973             * Returns all the journal articles where companyId = &#63; and status = &#63;.
9974             *
9975             * @param companyId the company ID
9976             * @param status the status
9977             * @return the matching journal articles
9978             * @throws SystemException if a system exception occurred
9979             */
9980            public List<JournalArticle> findByC_ST(long companyId, int status)
9981                    throws SystemException {
9982                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
9983                            QueryUtil.ALL_POS, null);
9984            }
9985    
9986            /**
9987             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
9988             *
9989             * <p>
9990             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9991             * </p>
9992             *
9993             * @param companyId the company ID
9994             * @param status the status
9995             * @param start the lower bound of the range of journal articles
9996             * @param end the upper bound of the range of journal articles (not inclusive)
9997             * @return the range of matching journal articles
9998             * @throws SystemException if a system exception occurred
9999             */
10000            public List<JournalArticle> findByC_ST(long companyId, int status,
10001                    int start, int end) throws SystemException {
10002                    return findByC_ST(companyId, status, start, end, null);
10003            }
10004    
10005            /**
10006             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
10007             *
10008             * <p>
10009             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10010             * </p>
10011             *
10012             * @param companyId the company ID
10013             * @param status the status
10014             * @param start the lower bound of the range of journal articles
10015             * @param end the upper bound of the range of journal articles (not inclusive)
10016             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10017             * @return the ordered range of matching journal articles
10018             * @throws SystemException if a system exception occurred
10019             */
10020            public List<JournalArticle> findByC_ST(long companyId, int status,
10021                    int start, int end, OrderByComparator orderByComparator)
10022                    throws SystemException {
10023                    FinderPath finderPath = null;
10024                    Object[] finderArgs = null;
10025    
10026                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10027                                    (orderByComparator == null)) {
10028                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
10029                            finderArgs = new Object[] { companyId, status };
10030                    }
10031                    else {
10032                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
10033                            finderArgs = new Object[] {
10034                                            companyId, status,
10035                                            
10036                                            start, end, orderByComparator
10037                                    };
10038                    }
10039    
10040                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10041                                    finderArgs, this);
10042    
10043                    if ((list != null) && !list.isEmpty()) {
10044                            for (JournalArticle journalArticle : list) {
10045                                    if ((companyId != journalArticle.getCompanyId()) ||
10046                                                    (status != journalArticle.getStatus())) {
10047                                            list = null;
10048    
10049                                            break;
10050                                    }
10051                            }
10052                    }
10053    
10054                    if (list == null) {
10055                            StringBundler query = null;
10056    
10057                            if (orderByComparator != null) {
10058                                    query = new StringBundler(4 +
10059                                                    (orderByComparator.getOrderByFields().length * 3));
10060                            }
10061                            else {
10062                                    query = new StringBundler(4);
10063                            }
10064    
10065                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10066    
10067                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
10068    
10069                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
10070    
10071                            if (orderByComparator != null) {
10072                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10073                                            orderByComparator);
10074                            }
10075    
10076                            else {
10077                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10078                            }
10079    
10080                            String sql = query.toString();
10081    
10082                            Session session = null;
10083    
10084                            try {
10085                                    session = openSession();
10086    
10087                                    Query q = session.createQuery(sql);
10088    
10089                                    QueryPos qPos = QueryPos.getInstance(q);
10090    
10091                                    qPos.add(companyId);
10092    
10093                                    qPos.add(status);
10094    
10095                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
10096                                                    start, end);
10097                            }
10098                            catch (Exception e) {
10099                                    throw processException(e);
10100                            }
10101                            finally {
10102                                    if (list == null) {
10103                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
10104                                    }
10105                                    else {
10106                                            cacheResult(list);
10107    
10108                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
10109                                    }
10110    
10111                                    closeSession(session);
10112                            }
10113                    }
10114    
10115                    return list;
10116            }
10117    
10118            /**
10119             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
10120             *
10121             * <p>
10122             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10123             * </p>
10124             *
10125             * @param companyId the company ID
10126             * @param status the status
10127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10128             * @return the first matching journal article
10129             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10130             * @throws SystemException if a system exception occurred
10131             */
10132            public JournalArticle findByC_ST_First(long companyId, int status,
10133                    OrderByComparator orderByComparator)
10134                    throws NoSuchArticleException, SystemException {
10135                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
10136                                    orderByComparator);
10137    
10138                    if (list.isEmpty()) {
10139                            StringBundler msg = new StringBundler(6);
10140    
10141                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10142    
10143                            msg.append("companyId=");
10144                            msg.append(companyId);
10145    
10146                            msg.append(", status=");
10147                            msg.append(status);
10148    
10149                            msg.append(StringPool.CLOSE_CURLY_BRACE);
10150    
10151                            throw new NoSuchArticleException(msg.toString());
10152                    }
10153                    else {
10154                            return list.get(0);
10155                    }
10156            }
10157    
10158            /**
10159             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
10160             *
10161             * <p>
10162             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10163             * </p>
10164             *
10165             * @param companyId the company ID
10166             * @param status the status
10167             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10168             * @return the last matching journal article
10169             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10170             * @throws SystemException if a system exception occurred
10171             */
10172            public JournalArticle findByC_ST_Last(long companyId, int status,
10173                    OrderByComparator orderByComparator)
10174                    throws NoSuchArticleException, SystemException {
10175                    int count = countByC_ST(companyId, status);
10176    
10177                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
10178                                    count, orderByComparator);
10179    
10180                    if (list.isEmpty()) {
10181                            StringBundler msg = new StringBundler(6);
10182    
10183                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10184    
10185                            msg.append("companyId=");
10186                            msg.append(companyId);
10187    
10188                            msg.append(", status=");
10189                            msg.append(status);
10190    
10191                            msg.append(StringPool.CLOSE_CURLY_BRACE);
10192    
10193                            throw new NoSuchArticleException(msg.toString());
10194                    }
10195                    else {
10196                            return list.get(0);
10197                    }
10198            }
10199    
10200            /**
10201             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
10202             *
10203             * <p>
10204             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10205             * </p>
10206             *
10207             * @param id the primary key of the current journal article
10208             * @param companyId the company ID
10209             * @param status the status
10210             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10211             * @return the previous, current, and next journal article
10212             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10213             * @throws SystemException if a system exception occurred
10214             */
10215            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
10216                    int status, OrderByComparator orderByComparator)
10217                    throws NoSuchArticleException, SystemException {
10218                    JournalArticle journalArticle = findByPrimaryKey(id);
10219    
10220                    Session session = null;
10221    
10222                    try {
10223                            session = openSession();
10224    
10225                            JournalArticle[] array = new JournalArticleImpl[3];
10226    
10227                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
10228                                            companyId, status, orderByComparator, true);
10229    
10230                            array[1] = journalArticle;
10231    
10232                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
10233                                            companyId, status, orderByComparator, false);
10234    
10235                            return array;
10236                    }
10237                    catch (Exception e) {
10238                            throw processException(e);
10239                    }
10240                    finally {
10241                            closeSession(session);
10242                    }
10243            }
10244    
10245            protected JournalArticle getByC_ST_PrevAndNext(Session session,
10246                    JournalArticle journalArticle, long companyId, int status,
10247                    OrderByComparator orderByComparator, boolean previous) {
10248                    StringBundler query = null;
10249    
10250                    if (orderByComparator != null) {
10251                            query = new StringBundler(6 +
10252                                            (orderByComparator.getOrderByFields().length * 6));
10253                    }
10254                    else {
10255                            query = new StringBundler(3);
10256                    }
10257    
10258                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10259    
10260                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
10261    
10262                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
10263    
10264                    if (orderByComparator != null) {
10265                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10266    
10267                            if (orderByConditionFields.length > 0) {
10268                                    query.append(WHERE_AND);
10269                            }
10270    
10271                            for (int i = 0; i < orderByConditionFields.length; i++) {
10272                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10273                                    query.append(orderByConditionFields[i]);
10274    
10275                                    if ((i + 1) < orderByConditionFields.length) {
10276                                            if (orderByComparator.isAscending() ^ previous) {
10277                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10278                                            }
10279                                            else {
10280                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10281                                            }
10282                                    }
10283                                    else {
10284                                            if (orderByComparator.isAscending() ^ previous) {
10285                                                    query.append(WHERE_GREATER_THAN);
10286                                            }
10287                                            else {
10288                                                    query.append(WHERE_LESSER_THAN);
10289                                            }
10290                                    }
10291                            }
10292    
10293                            query.append(ORDER_BY_CLAUSE);
10294    
10295                            String[] orderByFields = orderByComparator.getOrderByFields();
10296    
10297                            for (int i = 0; i < orderByFields.length; i++) {
10298                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10299                                    query.append(orderByFields[i]);
10300    
10301                                    if ((i + 1) < orderByFields.length) {
10302                                            if (orderByComparator.isAscending() ^ previous) {
10303                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10304                                            }
10305                                            else {
10306                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10307                                            }
10308                                    }
10309                                    else {
10310                                            if (orderByComparator.isAscending() ^ previous) {
10311                                                    query.append(ORDER_BY_ASC);
10312                                            }
10313                                            else {
10314                                                    query.append(ORDER_BY_DESC);
10315                                            }
10316                                    }
10317                            }
10318                    }
10319    
10320                    else {
10321                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10322                    }
10323    
10324                    String sql = query.toString();
10325    
10326                    Query q = session.createQuery(sql);
10327    
10328                    q.setFirstResult(0);
10329                    q.setMaxResults(2);
10330    
10331                    QueryPos qPos = QueryPos.getInstance(q);
10332    
10333                    qPos.add(companyId);
10334    
10335                    qPos.add(status);
10336    
10337                    if (orderByComparator != null) {
10338                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10339    
10340                            for (Object value : values) {
10341                                    qPos.add(value);
10342                            }
10343                    }
10344    
10345                    List<JournalArticle> list = q.list();
10346    
10347                    if (list.size() == 2) {
10348                            return list.get(1);
10349                    }
10350                    else {
10351                            return null;
10352                    }
10353            }
10354    
10355            /**
10356             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10357             *
10358             * @param groupId the group ID
10359             * @param classNameId the class name ID
10360             * @param classPK the class p k
10361             * @return the matching journal articles
10362             * @throws SystemException if a system exception occurred
10363             */
10364            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
10365                    long classPK) throws SystemException {
10366                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
10367                            QueryUtil.ALL_POS, null);
10368            }
10369    
10370            /**
10371             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10372             *
10373             * <p>
10374             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10375             * </p>
10376             *
10377             * @param groupId the group ID
10378             * @param classNameId the class name ID
10379             * @param classPK the class p k
10380             * @param start the lower bound of the range of journal articles
10381             * @param end the upper bound of the range of journal articles (not inclusive)
10382             * @return the range of matching journal articles
10383             * @throws SystemException if a system exception occurred
10384             */
10385            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
10386                    long classPK, int start, int end) throws SystemException {
10387                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
10388            }
10389    
10390            /**
10391             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10392             *
10393             * <p>
10394             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10395             * </p>
10396             *
10397             * @param groupId the group ID
10398             * @param classNameId the class name ID
10399             * @param classPK the class p k
10400             * @param start the lower bound of the range of journal articles
10401             * @param end the upper bound of the range of journal articles (not inclusive)
10402             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10403             * @return the ordered range of matching journal articles
10404             * @throws SystemException if a system exception occurred
10405             */
10406            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
10407                    long classPK, int start, int end, OrderByComparator orderByComparator)
10408                    throws SystemException {
10409                    FinderPath finderPath = null;
10410                    Object[] finderArgs = null;
10411    
10412                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10413                                    (orderByComparator == null)) {
10414                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
10415                            finderArgs = new Object[] { groupId, classNameId, classPK };
10416                    }
10417                    else {
10418                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
10419                            finderArgs = new Object[] {
10420                                            groupId, classNameId, classPK,
10421                                            
10422                                            start, end, orderByComparator
10423                                    };
10424                    }
10425    
10426                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10427                                    finderArgs, this);
10428    
10429                    if ((list != null) && !list.isEmpty()) {
10430                            for (JournalArticle journalArticle : list) {
10431                                    if ((groupId != journalArticle.getGroupId()) ||
10432                                                    (classNameId != journalArticle.getClassNameId()) ||
10433                                                    (classPK != journalArticle.getClassPK())) {
10434                                            list = null;
10435    
10436                                            break;
10437                                    }
10438                            }
10439                    }
10440    
10441                    if (list == null) {
10442                            StringBundler query = null;
10443    
10444                            if (orderByComparator != null) {
10445                                    query = new StringBundler(5 +
10446                                                    (orderByComparator.getOrderByFields().length * 3));
10447                            }
10448                            else {
10449                                    query = new StringBundler(5);
10450                            }
10451    
10452                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10453    
10454                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
10455    
10456                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
10457    
10458                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
10459    
10460                            if (orderByComparator != null) {
10461                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10462                                            orderByComparator);
10463                            }
10464    
10465                            else {
10466                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10467                            }
10468    
10469                            String sql = query.toString();
10470    
10471                            Session session = null;
10472    
10473                            try {
10474                                    session = openSession();
10475    
10476                                    Query q = session.createQuery(sql);
10477    
10478                                    QueryPos qPos = QueryPos.getInstance(q);
10479    
10480                                    qPos.add(groupId);
10481    
10482                                    qPos.add(classNameId);
10483    
10484                                    qPos.add(classPK);
10485    
10486                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
10487                                                    start, end);
10488                            }
10489                            catch (Exception e) {
10490                                    throw processException(e);
10491                            }
10492                            finally {
10493                                    if (list == null) {
10494                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
10495                                    }
10496                                    else {
10497                                            cacheResult(list);
10498    
10499                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
10500                                    }
10501    
10502                                    closeSession(session);
10503                            }
10504                    }
10505    
10506                    return list;
10507            }
10508    
10509            /**
10510             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10511             *
10512             * <p>
10513             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10514             * </p>
10515             *
10516             * @param groupId the group ID
10517             * @param classNameId the class name ID
10518             * @param classPK the class p k
10519             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10520             * @return the first matching journal article
10521             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10522             * @throws SystemException if a system exception occurred
10523             */
10524            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
10525                    long classPK, OrderByComparator orderByComparator)
10526                    throws NoSuchArticleException, SystemException {
10527                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
10528                                    0, 1, orderByComparator);
10529    
10530                    if (list.isEmpty()) {
10531                            StringBundler msg = new StringBundler(8);
10532    
10533                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10534    
10535                            msg.append("groupId=");
10536                            msg.append(groupId);
10537    
10538                            msg.append(", classNameId=");
10539                            msg.append(classNameId);
10540    
10541                            msg.append(", classPK=");
10542                            msg.append(classPK);
10543    
10544                            msg.append(StringPool.CLOSE_CURLY_BRACE);
10545    
10546                            throw new NoSuchArticleException(msg.toString());
10547                    }
10548                    else {
10549                            return list.get(0);
10550                    }
10551            }
10552    
10553            /**
10554             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10555             *
10556             * <p>
10557             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10558             * </p>
10559             *
10560             * @param groupId the group ID
10561             * @param classNameId the class name ID
10562             * @param classPK the class p k
10563             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10564             * @return the last matching journal article
10565             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10566             * @throws SystemException if a system exception occurred
10567             */
10568            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
10569                    long classPK, OrderByComparator orderByComparator)
10570                    throws NoSuchArticleException, SystemException {
10571                    int count = countByG_C_C(groupId, classNameId, classPK);
10572    
10573                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
10574                                    count - 1, count, orderByComparator);
10575    
10576                    if (list.isEmpty()) {
10577                            StringBundler msg = new StringBundler(8);
10578    
10579                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10580    
10581                            msg.append("groupId=");
10582                            msg.append(groupId);
10583    
10584                            msg.append(", classNameId=");
10585                            msg.append(classNameId);
10586    
10587                            msg.append(", classPK=");
10588                            msg.append(classPK);
10589    
10590                            msg.append(StringPool.CLOSE_CURLY_BRACE);
10591    
10592                            throw new NoSuchArticleException(msg.toString());
10593                    }
10594                    else {
10595                            return list.get(0);
10596                    }
10597            }
10598    
10599            /**
10600             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10601             *
10602             * <p>
10603             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10604             * </p>
10605             *
10606             * @param id the primary key of the current journal article
10607             * @param groupId the group ID
10608             * @param classNameId the class name ID
10609             * @param classPK the class p k
10610             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10611             * @return the previous, current, and next journal article
10612             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10613             * @throws SystemException if a system exception occurred
10614             */
10615            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
10616                    long classNameId, long classPK, OrderByComparator orderByComparator)
10617                    throws NoSuchArticleException, SystemException {
10618                    JournalArticle journalArticle = findByPrimaryKey(id);
10619    
10620                    Session session = null;
10621    
10622                    try {
10623                            session = openSession();
10624    
10625                            JournalArticle[] array = new JournalArticleImpl[3];
10626    
10627                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
10628                                            classNameId, classPK, orderByComparator, true);
10629    
10630                            array[1] = journalArticle;
10631    
10632                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
10633                                            classNameId, classPK, orderByComparator, false);
10634    
10635                            return array;
10636                    }
10637                    catch (Exception e) {
10638                            throw processException(e);
10639                    }
10640                    finally {
10641                            closeSession(session);
10642                    }
10643            }
10644    
10645            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
10646                    JournalArticle journalArticle, long groupId, long classNameId,
10647                    long classPK, OrderByComparator orderByComparator, boolean previous) {
10648                    StringBundler query = null;
10649    
10650                    if (orderByComparator != null) {
10651                            query = new StringBundler(6 +
10652                                            (orderByComparator.getOrderByFields().length * 6));
10653                    }
10654                    else {
10655                            query = new StringBundler(3);
10656                    }
10657    
10658                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10659    
10660                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
10661    
10662                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
10663    
10664                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
10665    
10666                    if (orderByComparator != null) {
10667                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10668    
10669                            if (orderByConditionFields.length > 0) {
10670                                    query.append(WHERE_AND);
10671                            }
10672    
10673                            for (int i = 0; i < orderByConditionFields.length; i++) {
10674                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10675                                    query.append(orderByConditionFields[i]);
10676    
10677                                    if ((i + 1) < orderByConditionFields.length) {
10678                                            if (orderByComparator.isAscending() ^ previous) {
10679                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10680                                            }
10681                                            else {
10682                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10683                                            }
10684                                    }
10685                                    else {
10686                                            if (orderByComparator.isAscending() ^ previous) {
10687                                                    query.append(WHERE_GREATER_THAN);
10688                                            }
10689                                            else {
10690                                                    query.append(WHERE_LESSER_THAN);
10691                                            }
10692                                    }
10693                            }
10694    
10695                            query.append(ORDER_BY_CLAUSE);
10696    
10697                            String[] orderByFields = orderByComparator.getOrderByFields();
10698    
10699                            for (int i = 0; i < orderByFields.length; i++) {
10700                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10701                                    query.append(orderByFields[i]);
10702    
10703                                    if ((i + 1) < orderByFields.length) {
10704                                            if (orderByComparator.isAscending() ^ previous) {
10705                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10706                                            }
10707                                            else {
10708                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10709                                            }
10710                                    }
10711                                    else {
10712                                            if (orderByComparator.isAscending() ^ previous) {
10713                                                    query.append(ORDER_BY_ASC);
10714                                            }
10715                                            else {
10716                                                    query.append(ORDER_BY_DESC);
10717                                            }
10718                                    }
10719                            }
10720                    }
10721    
10722                    else {
10723                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10724                    }
10725    
10726                    String sql = query.toString();
10727    
10728                    Query q = session.createQuery(sql);
10729    
10730                    q.setFirstResult(0);
10731                    q.setMaxResults(2);
10732    
10733                    QueryPos qPos = QueryPos.getInstance(q);
10734    
10735                    qPos.add(groupId);
10736    
10737                    qPos.add(classNameId);
10738    
10739                    qPos.add(classPK);
10740    
10741                    if (orderByComparator != null) {
10742                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10743    
10744                            for (Object value : values) {
10745                                    qPos.add(value);
10746                            }
10747                    }
10748    
10749                    List<JournalArticle> list = q.list();
10750    
10751                    if (list.size() == 2) {
10752                            return list.get(1);
10753                    }
10754                    else {
10755                            return null;
10756                    }
10757            }
10758    
10759            /**
10760             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10761             *
10762             * @param groupId the group ID
10763             * @param classNameId the class name ID
10764             * @param classPK the class p k
10765             * @return the matching journal articles that the user has permission to view
10766             * @throws SystemException if a system exception occurred
10767             */
10768            public List<JournalArticle> filterFindByG_C_C(long groupId,
10769                    long classNameId, long classPK) throws SystemException {
10770                    return filterFindByG_C_C(groupId, classNameId, classPK,
10771                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10772            }
10773    
10774            /**
10775             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10776             *
10777             * <p>
10778             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10779             * </p>
10780             *
10781             * @param groupId the group ID
10782             * @param classNameId the class name ID
10783             * @param classPK the class p k
10784             * @param start the lower bound of the range of journal articles
10785             * @param end the upper bound of the range of journal articles (not inclusive)
10786             * @return the range of matching journal articles that the user has permission to view
10787             * @throws SystemException if a system exception occurred
10788             */
10789            public List<JournalArticle> filterFindByG_C_C(long groupId,
10790                    long classNameId, long classPK, int start, int end)
10791                    throws SystemException {
10792                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
10793            }
10794    
10795            /**
10796             * 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;.
10797             *
10798             * <p>
10799             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10800             * </p>
10801             *
10802             * @param groupId the group ID
10803             * @param classNameId the class name ID
10804             * @param classPK the class p k
10805             * @param start the lower bound of the range of journal articles
10806             * @param end the upper bound of the range of journal articles (not inclusive)
10807             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10808             * @return the ordered range of matching journal articles that the user has permission to view
10809             * @throws SystemException if a system exception occurred
10810             */
10811            public List<JournalArticle> filterFindByG_C_C(long groupId,
10812                    long classNameId, long classPK, int start, int end,
10813                    OrderByComparator orderByComparator) throws SystemException {
10814                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10815                            return findByG_C_C(groupId, classNameId, classPK, start, end,
10816                                    orderByComparator);
10817                    }
10818    
10819                    StringBundler query = null;
10820    
10821                    if (orderByComparator != null) {
10822                            query = new StringBundler(5 +
10823                                            (orderByComparator.getOrderByFields().length * 3));
10824                    }
10825                    else {
10826                            query = new StringBundler(5);
10827                    }
10828    
10829                    if (getDB().isSupportsInlineDistinct()) {
10830                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10831                    }
10832                    else {
10833                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10834                    }
10835    
10836                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
10837    
10838                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
10839    
10840                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
10841    
10842                    if (!getDB().isSupportsInlineDistinct()) {
10843                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10844                    }
10845    
10846                    if (orderByComparator != null) {
10847                            if (getDB().isSupportsInlineDistinct()) {
10848                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10849                                            orderByComparator);
10850                            }
10851                            else {
10852                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10853                                            orderByComparator);
10854                            }
10855                    }
10856    
10857                    else {
10858                            if (getDB().isSupportsInlineDistinct()) {
10859                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10860                            }
10861                            else {
10862                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10863                            }
10864                    }
10865    
10866                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10867                                    JournalArticle.class.getName(),
10868                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10869    
10870                    Session session = null;
10871    
10872                    try {
10873                            session = openSession();
10874    
10875                            SQLQuery q = session.createSQLQuery(sql);
10876    
10877                            if (getDB().isSupportsInlineDistinct()) {
10878                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10879                            }
10880                            else {
10881                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10882                            }
10883    
10884                            QueryPos qPos = QueryPos.getInstance(q);
10885    
10886                            qPos.add(groupId);
10887    
10888                            qPos.add(classNameId);
10889    
10890                            qPos.add(classPK);
10891    
10892                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10893                                    end);
10894                    }
10895                    catch (Exception e) {
10896                            throw processException(e);
10897                    }
10898                    finally {
10899                            closeSession(session);
10900                    }
10901            }
10902    
10903            /**
10904             * 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;.
10905             *
10906             * @param id the primary key of the current journal article
10907             * @param groupId the group ID
10908             * @param classNameId the class name ID
10909             * @param classPK the class p k
10910             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10911             * @return the previous, current, and next journal article
10912             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10913             * @throws SystemException if a system exception occurred
10914             */
10915            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
10916                    long groupId, long classNameId, long classPK,
10917                    OrderByComparator orderByComparator)
10918                    throws NoSuchArticleException, SystemException {
10919                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10920                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
10921                                    orderByComparator);
10922                    }
10923    
10924                    JournalArticle journalArticle = findByPrimaryKey(id);
10925    
10926                    Session session = null;
10927    
10928                    try {
10929                            session = openSession();
10930    
10931                            JournalArticle[] array = new JournalArticleImpl[3];
10932    
10933                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
10934                                            groupId, classNameId, classPK, orderByComparator, true);
10935    
10936                            array[1] = journalArticle;
10937    
10938                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
10939                                            groupId, classNameId, classPK, orderByComparator, false);
10940    
10941                            return array;
10942                    }
10943                    catch (Exception e) {
10944                            throw processException(e);
10945                    }
10946                    finally {
10947                            closeSession(session);
10948                    }
10949            }
10950    
10951            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
10952                    JournalArticle journalArticle, long groupId, long classNameId,
10953                    long classPK, OrderByComparator orderByComparator, boolean previous) {
10954                    StringBundler query = null;
10955    
10956                    if (orderByComparator != null) {
10957                            query = new StringBundler(6 +
10958                                            (orderByComparator.getOrderByFields().length * 6));
10959                    }
10960                    else {
10961                            query = new StringBundler(3);
10962                    }
10963    
10964                    if (getDB().isSupportsInlineDistinct()) {
10965                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10966                    }
10967                    else {
10968                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10969                    }
10970    
10971                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
10972    
10973                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
10974    
10975                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
10976    
10977                    if (!getDB().isSupportsInlineDistinct()) {
10978                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10979                    }
10980    
10981                    if (orderByComparator != null) {
10982                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10983    
10984                            if (orderByConditionFields.length > 0) {
10985                                    query.append(WHERE_AND);
10986                            }
10987    
10988                            for (int i = 0; i < orderByConditionFields.length; i++) {
10989                                    if (getDB().isSupportsInlineDistinct()) {
10990                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10991                                    }
10992                                    else {
10993                                            query.append(_ORDER_BY_ENTITY_TABLE);
10994                                    }
10995    
10996                                    query.append(orderByConditionFields[i]);
10997    
10998                                    if ((i + 1) < orderByConditionFields.length) {
10999                                            if (orderByComparator.isAscending() ^ previous) {
11000                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11001                                            }
11002                                            else {
11003                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11004                                            }
11005                                    }
11006                                    else {
11007                                            if (orderByComparator.isAscending() ^ previous) {
11008                                                    query.append(WHERE_GREATER_THAN);
11009                                            }
11010                                            else {
11011                                                    query.append(WHERE_LESSER_THAN);
11012                                            }
11013                                    }
11014                            }
11015    
11016                            query.append(ORDER_BY_CLAUSE);
11017    
11018                            String[] orderByFields = orderByComparator.getOrderByFields();
11019    
11020                            for (int i = 0; i < orderByFields.length; i++) {
11021                                    if (getDB().isSupportsInlineDistinct()) {
11022                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11023                                    }
11024                                    else {
11025                                            query.append(_ORDER_BY_ENTITY_TABLE);
11026                                    }
11027    
11028                                    query.append(orderByFields[i]);
11029    
11030                                    if ((i + 1) < orderByFields.length) {
11031                                            if (orderByComparator.isAscending() ^ previous) {
11032                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11033                                            }
11034                                            else {
11035                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11036                                            }
11037                                    }
11038                                    else {
11039                                            if (orderByComparator.isAscending() ^ previous) {
11040                                                    query.append(ORDER_BY_ASC);
11041                                            }
11042                                            else {
11043                                                    query.append(ORDER_BY_DESC);
11044                                            }
11045                                    }
11046                            }
11047                    }
11048    
11049                    else {
11050                            if (getDB().isSupportsInlineDistinct()) {
11051                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11052                            }
11053                            else {
11054                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11055                            }
11056                    }
11057    
11058                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11059                                    JournalArticle.class.getName(),
11060                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11061    
11062                    SQLQuery q = session.createSQLQuery(sql);
11063    
11064                    q.setFirstResult(0);
11065                    q.setMaxResults(2);
11066    
11067                    if (getDB().isSupportsInlineDistinct()) {
11068                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11069                    }
11070                    else {
11071                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11072                    }
11073    
11074                    QueryPos qPos = QueryPos.getInstance(q);
11075    
11076                    qPos.add(groupId);
11077    
11078                    qPos.add(classNameId);
11079    
11080                    qPos.add(classPK);
11081    
11082                    if (orderByComparator != null) {
11083                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11084    
11085                            for (Object value : values) {
11086                                    qPos.add(value);
11087                            }
11088                    }
11089    
11090                    List<JournalArticle> list = q.list();
11091    
11092                    if (list.size() == 2) {
11093                            return list.get(1);
11094                    }
11095                    else {
11096                            return null;
11097                    }
11098            }
11099    
11100            /**
11101             * 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.
11102             *
11103             * @param groupId the group ID
11104             * @param classNameId the class name ID
11105             * @param structureId the structure ID
11106             * @return the matching journal article
11107             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11108             * @throws SystemException if a system exception occurred
11109             */
11110            public JournalArticle findByG_C_S(long groupId, long classNameId,
11111                    String structureId) throws NoSuchArticleException, SystemException {
11112                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
11113                                    structureId);
11114    
11115                    if (journalArticle == null) {
11116                            StringBundler msg = new StringBundler(8);
11117    
11118                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11119    
11120                            msg.append("groupId=");
11121                            msg.append(groupId);
11122    
11123                            msg.append(", classNameId=");
11124                            msg.append(classNameId);
11125    
11126                            msg.append(", structureId=");
11127                            msg.append(structureId);
11128    
11129                            msg.append(StringPool.CLOSE_CURLY_BRACE);
11130    
11131                            if (_log.isWarnEnabled()) {
11132                                    _log.warn(msg.toString());
11133                            }
11134    
11135                            throw new NoSuchArticleException(msg.toString());
11136                    }
11137    
11138                    return journalArticle;
11139            }
11140    
11141            /**
11142             * 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.
11143             *
11144             * @param groupId the group ID
11145             * @param classNameId the class name ID
11146             * @param structureId the structure ID
11147             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
11148             * @throws SystemException if a system exception occurred
11149             */
11150            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
11151                    String structureId) throws SystemException {
11152                    return fetchByG_C_S(groupId, classNameId, structureId, true);
11153            }
11154    
11155            /**
11156             * 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.
11157             *
11158             * @param groupId the group ID
11159             * @param classNameId the class name ID
11160             * @param structureId the structure ID
11161             * @param retrieveFromCache whether to use the finder cache
11162             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
11163             * @throws SystemException if a system exception occurred
11164             */
11165            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
11166                    String structureId, boolean retrieveFromCache)
11167                    throws SystemException {
11168                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
11169    
11170                    Object result = null;
11171    
11172                    if (retrieveFromCache) {
11173                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
11174                                            finderArgs, this);
11175                    }
11176    
11177                    if (result instanceof JournalArticle) {
11178                            JournalArticle journalArticle = (JournalArticle)result;
11179    
11180                            if ((groupId != journalArticle.getGroupId()) ||
11181                                            (classNameId != journalArticle.getClassNameId()) ||
11182                                            !Validator.equals(structureId,
11183                                                    journalArticle.getStructureId())) {
11184                                    result = null;
11185                            }
11186                    }
11187    
11188                    if (result == null) {
11189                            StringBundler query = new StringBundler(5);
11190    
11191                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11192    
11193                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
11194    
11195                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
11196    
11197                            if (structureId == null) {
11198                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
11199                            }
11200                            else {
11201                                    if (structureId.equals(StringPool.BLANK)) {
11202                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
11203                                    }
11204                                    else {
11205                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
11206                                    }
11207                            }
11208    
11209                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11210    
11211                            String sql = query.toString();
11212    
11213                            Session session = null;
11214    
11215                            try {
11216                                    session = openSession();
11217    
11218                                    Query q = session.createQuery(sql);
11219    
11220                                    QueryPos qPos = QueryPos.getInstance(q);
11221    
11222                                    qPos.add(groupId);
11223    
11224                                    qPos.add(classNameId);
11225    
11226                                    if (structureId != null) {
11227                                            qPos.add(structureId);
11228                                    }
11229    
11230                                    List<JournalArticle> list = q.list();
11231    
11232                                    result = list;
11233    
11234                                    JournalArticle journalArticle = null;
11235    
11236                                    if (list.isEmpty()) {
11237                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
11238                                                    finderArgs, list);
11239                                    }
11240                                    else {
11241                                            journalArticle = list.get(0);
11242    
11243                                            cacheResult(journalArticle);
11244    
11245                                            if ((journalArticle.getGroupId() != groupId) ||
11246                                                            (journalArticle.getClassNameId() != classNameId) ||
11247                                                            (journalArticle.getStructureId() == null) ||
11248                                                            !journalArticle.getStructureId().equals(structureId)) {
11249                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
11250                                                            finderArgs, journalArticle);
11251                                            }
11252                                    }
11253    
11254                                    return journalArticle;
11255                            }
11256                            catch (Exception e) {
11257                                    throw processException(e);
11258                            }
11259                            finally {
11260                                    if (result == null) {
11261                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
11262                                                    finderArgs);
11263                                    }
11264    
11265                                    closeSession(session);
11266                            }
11267                    }
11268                    else {
11269                            if (result instanceof List<?>) {
11270                                    return null;
11271                            }
11272                            else {
11273                                    return (JournalArticle)result;
11274                            }
11275                    }
11276            }
11277    
11278            /**
11279             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11280             *
11281             * @param groupId the group ID
11282             * @param classNameId the class name ID
11283             * @param templateId the template ID
11284             * @return the matching journal articles
11285             * @throws SystemException if a system exception occurred
11286             */
11287            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
11288                    String templateId) throws SystemException {
11289                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
11290                            QueryUtil.ALL_POS, null);
11291            }
11292    
11293            /**
11294             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11295             *
11296             * <p>
11297             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11298             * </p>
11299             *
11300             * @param groupId the group ID
11301             * @param classNameId the class name ID
11302             * @param templateId the template ID
11303             * @param start the lower bound of the range of journal articles
11304             * @param end the upper bound of the range of journal articles (not inclusive)
11305             * @return the range of matching journal articles
11306             * @throws SystemException if a system exception occurred
11307             */
11308            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
11309                    String templateId, int start, int end) throws SystemException {
11310                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
11311            }
11312    
11313            /**
11314             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11315             *
11316             * <p>
11317             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11318             * </p>
11319             *
11320             * @param groupId the group ID
11321             * @param classNameId the class name ID
11322             * @param templateId the template ID
11323             * @param start the lower bound of the range of journal articles
11324             * @param end the upper bound of the range of journal articles (not inclusive)
11325             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11326             * @return the ordered range of matching journal articles
11327             * @throws SystemException if a system exception occurred
11328             */
11329            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
11330                    String templateId, int start, int end,
11331                    OrderByComparator orderByComparator) throws SystemException {
11332                    FinderPath finderPath = null;
11333                    Object[] finderArgs = null;
11334    
11335                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11336                                    (orderByComparator == null)) {
11337                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
11338                            finderArgs = new Object[] { groupId, classNameId, templateId };
11339                    }
11340                    else {
11341                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
11342                            finderArgs = new Object[] {
11343                                            groupId, classNameId, templateId,
11344                                            
11345                                            start, end, orderByComparator
11346                                    };
11347                    }
11348    
11349                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11350                                    finderArgs, this);
11351    
11352                    if ((list != null) && !list.isEmpty()) {
11353                            for (JournalArticle journalArticle : list) {
11354                                    if ((groupId != journalArticle.getGroupId()) ||
11355                                                    (classNameId != journalArticle.getClassNameId()) ||
11356                                                    !Validator.equals(templateId,
11357                                                            journalArticle.getTemplateId())) {
11358                                            list = null;
11359    
11360                                            break;
11361                                    }
11362                            }
11363                    }
11364    
11365                    if (list == null) {
11366                            StringBundler query = null;
11367    
11368                            if (orderByComparator != null) {
11369                                    query = new StringBundler(5 +
11370                                                    (orderByComparator.getOrderByFields().length * 3));
11371                            }
11372                            else {
11373                                    query = new StringBundler(5);
11374                            }
11375    
11376                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11377    
11378                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
11379    
11380                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
11381    
11382                            if (templateId == null) {
11383                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
11384                            }
11385                            else {
11386                                    if (templateId.equals(StringPool.BLANK)) {
11387                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
11388                                    }
11389                                    else {
11390                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
11391                                    }
11392                            }
11393    
11394                            if (orderByComparator != null) {
11395                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11396                                            orderByComparator);
11397                            }
11398    
11399                            else {
11400                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11401                            }
11402    
11403                            String sql = query.toString();
11404    
11405                            Session session = null;
11406    
11407                            try {
11408                                    session = openSession();
11409    
11410                                    Query q = session.createQuery(sql);
11411    
11412                                    QueryPos qPos = QueryPos.getInstance(q);
11413    
11414                                    qPos.add(groupId);
11415    
11416                                    qPos.add(classNameId);
11417    
11418                                    if (templateId != null) {
11419                                            qPos.add(templateId);
11420                                    }
11421    
11422                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
11423                                                    start, end);
11424                            }
11425                            catch (Exception e) {
11426                                    throw processException(e);
11427                            }
11428                            finally {
11429                                    if (list == null) {
11430                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
11431                                    }
11432                                    else {
11433                                            cacheResult(list);
11434    
11435                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
11436                                    }
11437    
11438                                    closeSession(session);
11439                            }
11440                    }
11441    
11442                    return list;
11443            }
11444    
11445            /**
11446             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11447             *
11448             * <p>
11449             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11450             * </p>
11451             *
11452             * @param groupId the group ID
11453             * @param classNameId the class name ID
11454             * @param templateId the template ID
11455             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11456             * @return the first matching journal article
11457             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11458             * @throws SystemException if a system exception occurred
11459             */
11460            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
11461                    String templateId, OrderByComparator orderByComparator)
11462                    throws NoSuchArticleException, SystemException {
11463                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
11464                                    templateId, 0, 1, orderByComparator);
11465    
11466                    if (list.isEmpty()) {
11467                            StringBundler msg = new StringBundler(8);
11468    
11469                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11470    
11471                            msg.append("groupId=");
11472                            msg.append(groupId);
11473    
11474                            msg.append(", classNameId=");
11475                            msg.append(classNameId);
11476    
11477                            msg.append(", templateId=");
11478                            msg.append(templateId);
11479    
11480                            msg.append(StringPool.CLOSE_CURLY_BRACE);
11481    
11482                            throw new NoSuchArticleException(msg.toString());
11483                    }
11484                    else {
11485                            return list.get(0);
11486                    }
11487            }
11488    
11489            /**
11490             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11491             *
11492             * <p>
11493             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11494             * </p>
11495             *
11496             * @param groupId the group ID
11497             * @param classNameId the class name ID
11498             * @param templateId the template ID
11499             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11500             * @return the last matching journal article
11501             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11502             * @throws SystemException if a system exception occurred
11503             */
11504            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
11505                    String templateId, OrderByComparator orderByComparator)
11506                    throws NoSuchArticleException, SystemException {
11507                    int count = countByG_C_T(groupId, classNameId, templateId);
11508    
11509                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
11510                                    templateId, count - 1, count, orderByComparator);
11511    
11512                    if (list.isEmpty()) {
11513                            StringBundler msg = new StringBundler(8);
11514    
11515                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11516    
11517                            msg.append("groupId=");
11518                            msg.append(groupId);
11519    
11520                            msg.append(", classNameId=");
11521                            msg.append(classNameId);
11522    
11523                            msg.append(", templateId=");
11524                            msg.append(templateId);
11525    
11526                            msg.append(StringPool.CLOSE_CURLY_BRACE);
11527    
11528                            throw new NoSuchArticleException(msg.toString());
11529                    }
11530                    else {
11531                            return list.get(0);
11532                    }
11533            }
11534    
11535            /**
11536             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11537             *
11538             * <p>
11539             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11540             * </p>
11541             *
11542             * @param id the primary key of the current journal article
11543             * @param groupId the group ID
11544             * @param classNameId the class name ID
11545             * @param templateId the template ID
11546             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11547             * @return the previous, current, and next journal article
11548             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11549             * @throws SystemException if a system exception occurred
11550             */
11551            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
11552                    long classNameId, String templateId, OrderByComparator orderByComparator)
11553                    throws NoSuchArticleException, SystemException {
11554                    JournalArticle journalArticle = findByPrimaryKey(id);
11555    
11556                    Session session = null;
11557    
11558                    try {
11559                            session = openSession();
11560    
11561                            JournalArticle[] array = new JournalArticleImpl[3];
11562    
11563                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
11564                                            classNameId, templateId, orderByComparator, true);
11565    
11566                            array[1] = journalArticle;
11567    
11568                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
11569                                            classNameId, templateId, orderByComparator, false);
11570    
11571                            return array;
11572                    }
11573                    catch (Exception e) {
11574                            throw processException(e);
11575                    }
11576                    finally {
11577                            closeSession(session);
11578                    }
11579            }
11580    
11581            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
11582                    JournalArticle journalArticle, long groupId, long classNameId,
11583                    String templateId, OrderByComparator orderByComparator, boolean previous) {
11584                    StringBundler query = null;
11585    
11586                    if (orderByComparator != null) {
11587                            query = new StringBundler(6 +
11588                                            (orderByComparator.getOrderByFields().length * 6));
11589                    }
11590                    else {
11591                            query = new StringBundler(3);
11592                    }
11593    
11594                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11595    
11596                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
11597    
11598                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
11599    
11600                    if (templateId == null) {
11601                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
11602                    }
11603                    else {
11604                            if (templateId.equals(StringPool.BLANK)) {
11605                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
11606                            }
11607                            else {
11608                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
11609                            }
11610                    }
11611    
11612                    if (orderByComparator != null) {
11613                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11614    
11615                            if (orderByConditionFields.length > 0) {
11616                                    query.append(WHERE_AND);
11617                            }
11618    
11619                            for (int i = 0; i < orderByConditionFields.length; i++) {
11620                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11621                                    query.append(orderByConditionFields[i]);
11622    
11623                                    if ((i + 1) < orderByConditionFields.length) {
11624                                            if (orderByComparator.isAscending() ^ previous) {
11625                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11626                                            }
11627                                            else {
11628                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11629                                            }
11630                                    }
11631                                    else {
11632                                            if (orderByComparator.isAscending() ^ previous) {
11633                                                    query.append(WHERE_GREATER_THAN);
11634                                            }
11635                                            else {
11636                                                    query.append(WHERE_LESSER_THAN);
11637                                            }
11638                                    }
11639                            }
11640    
11641                            query.append(ORDER_BY_CLAUSE);
11642    
11643                            String[] orderByFields = orderByComparator.getOrderByFields();
11644    
11645                            for (int i = 0; i < orderByFields.length; i++) {
11646                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11647                                    query.append(orderByFields[i]);
11648    
11649                                    if ((i + 1) < orderByFields.length) {
11650                                            if (orderByComparator.isAscending() ^ previous) {
11651                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11652                                            }
11653                                            else {
11654                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11655                                            }
11656                                    }
11657                                    else {
11658                                            if (orderByComparator.isAscending() ^ previous) {
11659                                                    query.append(ORDER_BY_ASC);
11660                                            }
11661                                            else {
11662                                                    query.append(ORDER_BY_DESC);
11663                                            }
11664                                    }
11665                            }
11666                    }
11667    
11668                    else {
11669                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11670                    }
11671    
11672                    String sql = query.toString();
11673    
11674                    Query q = session.createQuery(sql);
11675    
11676                    q.setFirstResult(0);
11677                    q.setMaxResults(2);
11678    
11679                    QueryPos qPos = QueryPos.getInstance(q);
11680    
11681                    qPos.add(groupId);
11682    
11683                    qPos.add(classNameId);
11684    
11685                    if (templateId != null) {
11686                            qPos.add(templateId);
11687                    }
11688    
11689                    if (orderByComparator != null) {
11690                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11691    
11692                            for (Object value : values) {
11693                                    qPos.add(value);
11694                            }
11695                    }
11696    
11697                    List<JournalArticle> list = q.list();
11698    
11699                    if (list.size() == 2) {
11700                            return list.get(1);
11701                    }
11702                    else {
11703                            return null;
11704                    }
11705            }
11706    
11707            /**
11708             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11709             *
11710             * @param groupId the group ID
11711             * @param classNameId the class name ID
11712             * @param templateId the template ID
11713             * @return the matching journal articles that the user has permission to view
11714             * @throws SystemException if a system exception occurred
11715             */
11716            public List<JournalArticle> filterFindByG_C_T(long groupId,
11717                    long classNameId, String templateId) throws SystemException {
11718                    return filterFindByG_C_T(groupId, classNameId, templateId,
11719                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11720            }
11721    
11722            /**
11723             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11724             *
11725             * <p>
11726             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11727             * </p>
11728             *
11729             * @param groupId the group ID
11730             * @param classNameId the class name ID
11731             * @param templateId the template ID
11732             * @param start the lower bound of the range of journal articles
11733             * @param end the upper bound of the range of journal articles (not inclusive)
11734             * @return the range of matching journal articles that the user has permission to view
11735             * @throws SystemException if a system exception occurred
11736             */
11737            public List<JournalArticle> filterFindByG_C_T(long groupId,
11738                    long classNameId, String templateId, int start, int end)
11739                    throws SystemException {
11740                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
11741                            null);
11742            }
11743    
11744            /**
11745             * 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;.
11746             *
11747             * <p>
11748             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11749             * </p>
11750             *
11751             * @param groupId the group ID
11752             * @param classNameId the class name ID
11753             * @param templateId the template ID
11754             * @param start the lower bound of the range of journal articles
11755             * @param end the upper bound of the range of journal articles (not inclusive)
11756             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11757             * @return the ordered range of matching journal articles that the user has permission to view
11758             * @throws SystemException if a system exception occurred
11759             */
11760            public List<JournalArticle> filterFindByG_C_T(long groupId,
11761                    long classNameId, String templateId, int start, int end,
11762                    OrderByComparator orderByComparator) throws SystemException {
11763                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11764                            return findByG_C_T(groupId, classNameId, templateId, start, end,
11765                                    orderByComparator);
11766                    }
11767    
11768                    StringBundler query = null;
11769    
11770                    if (orderByComparator != null) {
11771                            query = new StringBundler(5 +
11772                                            (orderByComparator.getOrderByFields().length * 3));
11773                    }
11774                    else {
11775                            query = new StringBundler(5);
11776                    }
11777    
11778                    if (getDB().isSupportsInlineDistinct()) {
11779                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11780                    }
11781                    else {
11782                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11783                    }
11784    
11785                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
11786    
11787                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
11788    
11789                    if (templateId == null) {
11790                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
11791                    }
11792                    else {
11793                            if (templateId.equals(StringPool.BLANK)) {
11794                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
11795                            }
11796                            else {
11797                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
11798                            }
11799                    }
11800    
11801                    if (!getDB().isSupportsInlineDistinct()) {
11802                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11803                    }
11804    
11805                    if (orderByComparator != null) {
11806                            if (getDB().isSupportsInlineDistinct()) {
11807                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11808                                            orderByComparator);
11809                            }
11810                            else {
11811                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11812                                            orderByComparator);
11813                            }
11814                    }
11815    
11816                    else {
11817                            if (getDB().isSupportsInlineDistinct()) {
11818                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11819                            }
11820                            else {
11821                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11822                            }
11823                    }
11824    
11825                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11826                                    JournalArticle.class.getName(),
11827                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11828    
11829                    Session session = null;
11830    
11831                    try {
11832                            session = openSession();
11833    
11834                            SQLQuery q = session.createSQLQuery(sql);
11835    
11836                            if (getDB().isSupportsInlineDistinct()) {
11837                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11838                            }
11839                            else {
11840                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11841                            }
11842    
11843                            QueryPos qPos = QueryPos.getInstance(q);
11844    
11845                            qPos.add(groupId);
11846    
11847                            qPos.add(classNameId);
11848    
11849                            if (templateId != null) {
11850                                    qPos.add(templateId);
11851                            }
11852    
11853                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11854                                    end);
11855                    }
11856                    catch (Exception e) {
11857                            throw processException(e);
11858                    }
11859                    finally {
11860                            closeSession(session);
11861                    }
11862            }
11863    
11864            /**
11865             * 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;.
11866             *
11867             * @param id the primary key of the current journal article
11868             * @param groupId the group ID
11869             * @param classNameId the class name ID
11870             * @param templateId the template ID
11871             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11872             * @return the previous, current, and next journal article
11873             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11874             * @throws SystemException if a system exception occurred
11875             */
11876            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
11877                    long groupId, long classNameId, String templateId,
11878                    OrderByComparator orderByComparator)
11879                    throws NoSuchArticleException, SystemException {
11880                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11881                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
11882                                    templateId, orderByComparator);
11883                    }
11884    
11885                    JournalArticle journalArticle = findByPrimaryKey(id);
11886    
11887                    Session session = null;
11888    
11889                    try {
11890                            session = openSession();
11891    
11892                            JournalArticle[] array = new JournalArticleImpl[3];
11893    
11894                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
11895                                            groupId, classNameId, templateId, orderByComparator, true);
11896    
11897                            array[1] = journalArticle;
11898    
11899                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
11900                                            groupId, classNameId, templateId, orderByComparator, false);
11901    
11902                            return array;
11903                    }
11904                    catch (Exception e) {
11905                            throw processException(e);
11906                    }
11907                    finally {
11908                            closeSession(session);
11909                    }
11910            }
11911    
11912            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
11913                    JournalArticle journalArticle, long groupId, long classNameId,
11914                    String templateId, OrderByComparator orderByComparator, boolean previous) {
11915                    StringBundler query = null;
11916    
11917                    if (orderByComparator != null) {
11918                            query = new StringBundler(6 +
11919                                            (orderByComparator.getOrderByFields().length * 6));
11920                    }
11921                    else {
11922                            query = new StringBundler(3);
11923                    }
11924    
11925                    if (getDB().isSupportsInlineDistinct()) {
11926                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11927                    }
11928                    else {
11929                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11930                    }
11931    
11932                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
11933    
11934                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
11935    
11936                    if (templateId == null) {
11937                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
11938                    }
11939                    else {
11940                            if (templateId.equals(StringPool.BLANK)) {
11941                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
11942                            }
11943                            else {
11944                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
11945                            }
11946                    }
11947    
11948                    if (!getDB().isSupportsInlineDistinct()) {
11949                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11950                    }
11951    
11952                    if (orderByComparator != null) {
11953                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11954    
11955                            if (orderByConditionFields.length > 0) {
11956                                    query.append(WHERE_AND);
11957                            }
11958    
11959                            for (int i = 0; i < orderByConditionFields.length; i++) {
11960                                    if (getDB().isSupportsInlineDistinct()) {
11961                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11962                                    }
11963                                    else {
11964                                            query.append(_ORDER_BY_ENTITY_TABLE);
11965                                    }
11966    
11967                                    query.append(orderByConditionFields[i]);
11968    
11969                                    if ((i + 1) < orderByConditionFields.length) {
11970                                            if (orderByComparator.isAscending() ^ previous) {
11971                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11972                                            }
11973                                            else {
11974                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11975                                            }
11976                                    }
11977                                    else {
11978                                            if (orderByComparator.isAscending() ^ previous) {
11979                                                    query.append(WHERE_GREATER_THAN);
11980                                            }
11981                                            else {
11982                                                    query.append(WHERE_LESSER_THAN);
11983                                            }
11984                                    }
11985                            }
11986    
11987                            query.append(ORDER_BY_CLAUSE);
11988    
11989                            String[] orderByFields = orderByComparator.getOrderByFields();
11990    
11991                            for (int i = 0; i < orderByFields.length; i++) {
11992                                    if (getDB().isSupportsInlineDistinct()) {
11993                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11994                                    }
11995                                    else {
11996                                            query.append(_ORDER_BY_ENTITY_TABLE);
11997                                    }
11998    
11999                                    query.append(orderByFields[i]);
12000    
12001                                    if ((i + 1) < orderByFields.length) {
12002                                            if (orderByComparator.isAscending() ^ previous) {
12003                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12004                                            }
12005                                            else {
12006                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12007                                            }
12008                                    }
12009                                    else {
12010                                            if (orderByComparator.isAscending() ^ previous) {
12011                                                    query.append(ORDER_BY_ASC);
12012                                            }
12013                                            else {
12014                                                    query.append(ORDER_BY_DESC);
12015                                            }
12016                                    }
12017                            }
12018                    }
12019    
12020                    else {
12021                            if (getDB().isSupportsInlineDistinct()) {
12022                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12023                            }
12024                            else {
12025                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12026                            }
12027                    }
12028    
12029                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12030                                    JournalArticle.class.getName(),
12031                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12032    
12033                    SQLQuery q = session.createSQLQuery(sql);
12034    
12035                    q.setFirstResult(0);
12036                    q.setMaxResults(2);
12037    
12038                    if (getDB().isSupportsInlineDistinct()) {
12039                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12040                    }
12041                    else {
12042                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12043                    }
12044    
12045                    QueryPos qPos = QueryPos.getInstance(q);
12046    
12047                    qPos.add(groupId);
12048    
12049                    qPos.add(classNameId);
12050    
12051                    if (templateId != null) {
12052                            qPos.add(templateId);
12053                    }
12054    
12055                    if (orderByComparator != null) {
12056                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12057    
12058                            for (Object value : values) {
12059                                    qPos.add(value);
12060                            }
12061                    }
12062    
12063                    List<JournalArticle> list = q.list();
12064    
12065                    if (list.size() == 2) {
12066                            return list.get(1);
12067                    }
12068                    else {
12069                            return null;
12070                    }
12071            }
12072    
12073            /**
12074             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12075             *
12076             * @param groupId the group ID
12077             * @param classNameId the class name ID
12078             * @param layoutUuid the layout uuid
12079             * @return the matching journal articles
12080             * @throws SystemException if a system exception occurred
12081             */
12082            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
12083                    String layoutUuid) throws SystemException {
12084                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
12085                            QueryUtil.ALL_POS, null);
12086            }
12087    
12088            /**
12089             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12090             *
12091             * <p>
12092             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12093             * </p>
12094             *
12095             * @param groupId the group ID
12096             * @param classNameId the class name ID
12097             * @param layoutUuid the layout uuid
12098             * @param start the lower bound of the range of journal articles
12099             * @param end the upper bound of the range of journal articles (not inclusive)
12100             * @return the range of matching journal articles
12101             * @throws SystemException if a system exception occurred
12102             */
12103            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
12104                    String layoutUuid, int start, int end) throws SystemException {
12105                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
12106            }
12107    
12108            /**
12109             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12110             *
12111             * <p>
12112             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12113             * </p>
12114             *
12115             * @param groupId the group ID
12116             * @param classNameId the class name ID
12117             * @param layoutUuid the layout uuid
12118             * @param start the lower bound of the range of journal articles
12119             * @param end the upper bound of the range of journal articles (not inclusive)
12120             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12121             * @return the ordered range of matching journal articles
12122             * @throws SystemException if a system exception occurred
12123             */
12124            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
12125                    String layoutUuid, int start, int end,
12126                    OrderByComparator orderByComparator) throws SystemException {
12127                    FinderPath finderPath = null;
12128                    Object[] finderArgs = null;
12129    
12130                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12131                                    (orderByComparator == null)) {
12132                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
12133                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
12134                    }
12135                    else {
12136                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
12137                            finderArgs = new Object[] {
12138                                            groupId, classNameId, layoutUuid,
12139                                            
12140                                            start, end, orderByComparator
12141                                    };
12142                    }
12143    
12144                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12145                                    finderArgs, this);
12146    
12147                    if ((list != null) && !list.isEmpty()) {
12148                            for (JournalArticle journalArticle : list) {
12149                                    if ((groupId != journalArticle.getGroupId()) ||
12150                                                    (classNameId != journalArticle.getClassNameId()) ||
12151                                                    !Validator.equals(layoutUuid,
12152                                                            journalArticle.getLayoutUuid())) {
12153                                            list = null;
12154    
12155                                            break;
12156                                    }
12157                            }
12158                    }
12159    
12160                    if (list == null) {
12161                            StringBundler query = null;
12162    
12163                            if (orderByComparator != null) {
12164                                    query = new StringBundler(5 +
12165                                                    (orderByComparator.getOrderByFields().length * 3));
12166                            }
12167                            else {
12168                                    query = new StringBundler(5);
12169                            }
12170    
12171                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12172    
12173                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
12174    
12175                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
12176    
12177                            if (layoutUuid == null) {
12178                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
12179                            }
12180                            else {
12181                                    if (layoutUuid.equals(StringPool.BLANK)) {
12182                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
12183                                    }
12184                                    else {
12185                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
12186                                    }
12187                            }
12188    
12189                            if (orderByComparator != null) {
12190                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12191                                            orderByComparator);
12192                            }
12193    
12194                            else {
12195                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12196                            }
12197    
12198                            String sql = query.toString();
12199    
12200                            Session session = null;
12201    
12202                            try {
12203                                    session = openSession();
12204    
12205                                    Query q = session.createQuery(sql);
12206    
12207                                    QueryPos qPos = QueryPos.getInstance(q);
12208    
12209                                    qPos.add(groupId);
12210    
12211                                    qPos.add(classNameId);
12212    
12213                                    if (layoutUuid != null) {
12214                                            qPos.add(layoutUuid);
12215                                    }
12216    
12217                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
12218                                                    start, end);
12219                            }
12220                            catch (Exception e) {
12221                                    throw processException(e);
12222                            }
12223                            finally {
12224                                    if (list == null) {
12225                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
12226                                    }
12227                                    else {
12228                                            cacheResult(list);
12229    
12230                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12231                                    }
12232    
12233                                    closeSession(session);
12234                            }
12235                    }
12236    
12237                    return list;
12238            }
12239    
12240            /**
12241             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12242             *
12243             * <p>
12244             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12245             * </p>
12246             *
12247             * @param groupId the group ID
12248             * @param classNameId the class name ID
12249             * @param layoutUuid the layout uuid
12250             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12251             * @return the first matching journal article
12252             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12253             * @throws SystemException if a system exception occurred
12254             */
12255            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
12256                    String layoutUuid, OrderByComparator orderByComparator)
12257                    throws NoSuchArticleException, SystemException {
12258                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
12259                                    layoutUuid, 0, 1, orderByComparator);
12260    
12261                    if (list.isEmpty()) {
12262                            StringBundler msg = new StringBundler(8);
12263    
12264                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12265    
12266                            msg.append("groupId=");
12267                            msg.append(groupId);
12268    
12269                            msg.append(", classNameId=");
12270                            msg.append(classNameId);
12271    
12272                            msg.append(", layoutUuid=");
12273                            msg.append(layoutUuid);
12274    
12275                            msg.append(StringPool.CLOSE_CURLY_BRACE);
12276    
12277                            throw new NoSuchArticleException(msg.toString());
12278                    }
12279                    else {
12280                            return list.get(0);
12281                    }
12282            }
12283    
12284            /**
12285             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12286             *
12287             * <p>
12288             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12289             * </p>
12290             *
12291             * @param groupId the group ID
12292             * @param classNameId the class name ID
12293             * @param layoutUuid the layout uuid
12294             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12295             * @return the last matching journal article
12296             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12297             * @throws SystemException if a system exception occurred
12298             */
12299            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
12300                    String layoutUuid, OrderByComparator orderByComparator)
12301                    throws NoSuchArticleException, SystemException {
12302                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
12303    
12304                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
12305                                    layoutUuid, count - 1, count, orderByComparator);
12306    
12307                    if (list.isEmpty()) {
12308                            StringBundler msg = new StringBundler(8);
12309    
12310                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12311    
12312                            msg.append("groupId=");
12313                            msg.append(groupId);
12314    
12315                            msg.append(", classNameId=");
12316                            msg.append(classNameId);
12317    
12318                            msg.append(", layoutUuid=");
12319                            msg.append(layoutUuid);
12320    
12321                            msg.append(StringPool.CLOSE_CURLY_BRACE);
12322    
12323                            throw new NoSuchArticleException(msg.toString());
12324                    }
12325                    else {
12326                            return list.get(0);
12327                    }
12328            }
12329    
12330            /**
12331             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12332             *
12333             * <p>
12334             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12335             * </p>
12336             *
12337             * @param id the primary key of the current journal article
12338             * @param groupId the group ID
12339             * @param classNameId the class name ID
12340             * @param layoutUuid the layout uuid
12341             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12342             * @return the previous, current, and next journal article
12343             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12344             * @throws SystemException if a system exception occurred
12345             */
12346            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
12347                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
12348                    throws NoSuchArticleException, SystemException {
12349                    JournalArticle journalArticle = findByPrimaryKey(id);
12350    
12351                    Session session = null;
12352    
12353                    try {
12354                            session = openSession();
12355    
12356                            JournalArticle[] array = new JournalArticleImpl[3];
12357    
12358                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
12359                                            classNameId, layoutUuid, orderByComparator, true);
12360    
12361                            array[1] = journalArticle;
12362    
12363                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
12364                                            classNameId, layoutUuid, orderByComparator, false);
12365    
12366                            return array;
12367                    }
12368                    catch (Exception e) {
12369                            throw processException(e);
12370                    }
12371                    finally {
12372                            closeSession(session);
12373                    }
12374            }
12375    
12376            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
12377                    JournalArticle journalArticle, long groupId, long classNameId,
12378                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
12379                    StringBundler query = null;
12380    
12381                    if (orderByComparator != null) {
12382                            query = new StringBundler(6 +
12383                                            (orderByComparator.getOrderByFields().length * 6));
12384                    }
12385                    else {
12386                            query = new StringBundler(3);
12387                    }
12388    
12389                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12390    
12391                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
12392    
12393                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
12394    
12395                    if (layoutUuid == null) {
12396                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
12397                    }
12398                    else {
12399                            if (layoutUuid.equals(StringPool.BLANK)) {
12400                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
12401                            }
12402                            else {
12403                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
12404                            }
12405                    }
12406    
12407                    if (orderByComparator != null) {
12408                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12409    
12410                            if (orderByConditionFields.length > 0) {
12411                                    query.append(WHERE_AND);
12412                            }
12413    
12414                            for (int i = 0; i < orderByConditionFields.length; i++) {
12415                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12416                                    query.append(orderByConditionFields[i]);
12417    
12418                                    if ((i + 1) < orderByConditionFields.length) {
12419                                            if (orderByComparator.isAscending() ^ previous) {
12420                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12421                                            }
12422                                            else {
12423                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12424                                            }
12425                                    }
12426                                    else {
12427                                            if (orderByComparator.isAscending() ^ previous) {
12428                                                    query.append(WHERE_GREATER_THAN);
12429                                            }
12430                                            else {
12431                                                    query.append(WHERE_LESSER_THAN);
12432                                            }
12433                                    }
12434                            }
12435    
12436                            query.append(ORDER_BY_CLAUSE);
12437    
12438                            String[] orderByFields = orderByComparator.getOrderByFields();
12439    
12440                            for (int i = 0; i < orderByFields.length; i++) {
12441                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12442                                    query.append(orderByFields[i]);
12443    
12444                                    if ((i + 1) < orderByFields.length) {
12445                                            if (orderByComparator.isAscending() ^ previous) {
12446                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12447                                            }
12448                                            else {
12449                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12450                                            }
12451                                    }
12452                                    else {
12453                                            if (orderByComparator.isAscending() ^ previous) {
12454                                                    query.append(ORDER_BY_ASC);
12455                                            }
12456                                            else {
12457                                                    query.append(ORDER_BY_DESC);
12458                                            }
12459                                    }
12460                            }
12461                    }
12462    
12463                    else {
12464                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12465                    }
12466    
12467                    String sql = query.toString();
12468    
12469                    Query q = session.createQuery(sql);
12470    
12471                    q.setFirstResult(0);
12472                    q.setMaxResults(2);
12473    
12474                    QueryPos qPos = QueryPos.getInstance(q);
12475    
12476                    qPos.add(groupId);
12477    
12478                    qPos.add(classNameId);
12479    
12480                    if (layoutUuid != null) {
12481                            qPos.add(layoutUuid);
12482                    }
12483    
12484                    if (orderByComparator != null) {
12485                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12486    
12487                            for (Object value : values) {
12488                                    qPos.add(value);
12489                            }
12490                    }
12491    
12492                    List<JournalArticle> list = q.list();
12493    
12494                    if (list.size() == 2) {
12495                            return list.get(1);
12496                    }
12497                    else {
12498                            return null;
12499                    }
12500            }
12501    
12502            /**
12503             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12504             *
12505             * @param groupId the group ID
12506             * @param classNameId the class name ID
12507             * @param layoutUuid the layout uuid
12508             * @return the matching journal articles that the user has permission to view
12509             * @throws SystemException if a system exception occurred
12510             */
12511            public List<JournalArticle> filterFindByG_C_L(long groupId,
12512                    long classNameId, String layoutUuid) throws SystemException {
12513                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
12514                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12515            }
12516    
12517            /**
12518             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12519             *
12520             * <p>
12521             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12522             * </p>
12523             *
12524             * @param groupId the group ID
12525             * @param classNameId the class name ID
12526             * @param layoutUuid the layout uuid
12527             * @param start the lower bound of the range of journal articles
12528             * @param end the upper bound of the range of journal articles (not inclusive)
12529             * @return the range of matching journal articles that the user has permission to view
12530             * @throws SystemException if a system exception occurred
12531             */
12532            public List<JournalArticle> filterFindByG_C_L(long groupId,
12533                    long classNameId, String layoutUuid, int start, int end)
12534                    throws SystemException {
12535                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
12536                            null);
12537            }
12538    
12539            /**
12540             * 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;.
12541             *
12542             * <p>
12543             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12544             * </p>
12545             *
12546             * @param groupId the group ID
12547             * @param classNameId the class name ID
12548             * @param layoutUuid the layout uuid
12549             * @param start the lower bound of the range of journal articles
12550             * @param end the upper bound of the range of journal articles (not inclusive)
12551             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12552             * @return the ordered range of matching journal articles that the user has permission to view
12553             * @throws SystemException if a system exception occurred
12554             */
12555            public List<JournalArticle> filterFindByG_C_L(long groupId,
12556                    long classNameId, String layoutUuid, int start, int end,
12557                    OrderByComparator orderByComparator) throws SystemException {
12558                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12559                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
12560                                    orderByComparator);
12561                    }
12562    
12563                    StringBundler query = null;
12564    
12565                    if (orderByComparator != null) {
12566                            query = new StringBundler(5 +
12567                                            (orderByComparator.getOrderByFields().length * 3));
12568                    }
12569                    else {
12570                            query = new StringBundler(5);
12571                    }
12572    
12573                    if (getDB().isSupportsInlineDistinct()) {
12574                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12575                    }
12576                    else {
12577                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12578                    }
12579    
12580                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
12581    
12582                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
12583    
12584                    if (layoutUuid == null) {
12585                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
12586                    }
12587                    else {
12588                            if (layoutUuid.equals(StringPool.BLANK)) {
12589                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
12590                            }
12591                            else {
12592                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
12593                            }
12594                    }
12595    
12596                    if (!getDB().isSupportsInlineDistinct()) {
12597                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12598                    }
12599    
12600                    if (orderByComparator != null) {
12601                            if (getDB().isSupportsInlineDistinct()) {
12602                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12603                                            orderByComparator);
12604                            }
12605                            else {
12606                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12607                                            orderByComparator);
12608                            }
12609                    }
12610    
12611                    else {
12612                            if (getDB().isSupportsInlineDistinct()) {
12613                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12614                            }
12615                            else {
12616                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12617                            }
12618                    }
12619    
12620                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12621                                    JournalArticle.class.getName(),
12622                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12623    
12624                    Session session = null;
12625    
12626                    try {
12627                            session = openSession();
12628    
12629                            SQLQuery q = session.createSQLQuery(sql);
12630    
12631                            if (getDB().isSupportsInlineDistinct()) {
12632                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12633                            }
12634                            else {
12635                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12636                            }
12637    
12638                            QueryPos qPos = QueryPos.getInstance(q);
12639    
12640                            qPos.add(groupId);
12641    
12642                            qPos.add(classNameId);
12643    
12644                            if (layoutUuid != null) {
12645                                    qPos.add(layoutUuid);
12646                            }
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 classNameId = &#63; and layoutUuid = &#63;.
12661             *
12662             * @param id the primary key of the current journal article
12663             * @param groupId the group ID
12664             * @param classNameId the class name ID
12665             * @param layoutUuid the layout uuid
12666             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12667             * @return the previous, current, and next journal article
12668             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12669             * @throws SystemException if a system exception occurred
12670             */
12671            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
12672                    long groupId, long classNameId, String layoutUuid,
12673                    OrderByComparator orderByComparator)
12674                    throws NoSuchArticleException, SystemException {
12675                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12676                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
12677                                    layoutUuid, orderByComparator);
12678                    }
12679    
12680                    JournalArticle journalArticle = findByPrimaryKey(id);
12681    
12682                    Session session = null;
12683    
12684                    try {
12685                            session = openSession();
12686    
12687                            JournalArticle[] array = new JournalArticleImpl[3];
12688    
12689                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
12690                                            groupId, classNameId, layoutUuid, orderByComparator, true);
12691    
12692                            array[1] = journalArticle;
12693    
12694                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
12695                                            groupId, classNameId, layoutUuid, orderByComparator, false);
12696    
12697                            return array;
12698                    }
12699                    catch (Exception e) {
12700                            throw processException(e);
12701                    }
12702                    finally {
12703                            closeSession(session);
12704                    }
12705            }
12706    
12707            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
12708                    JournalArticle journalArticle, long groupId, long classNameId,
12709                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
12710                    StringBundler query = null;
12711    
12712                    if (orderByComparator != null) {
12713                            query = new StringBundler(6 +
12714                                            (orderByComparator.getOrderByFields().length * 6));
12715                    }
12716                    else {
12717                            query = new StringBundler(3);
12718                    }
12719    
12720                    if (getDB().isSupportsInlineDistinct()) {
12721                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12722                    }
12723                    else {
12724                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12725                    }
12726    
12727                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
12728    
12729                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
12730    
12731                    if (layoutUuid == null) {
12732                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
12733                    }
12734                    else {
12735                            if (layoutUuid.equals(StringPool.BLANK)) {
12736                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
12737                            }
12738                            else {
12739                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
12740                            }
12741                    }
12742    
12743                    if (!getDB().isSupportsInlineDistinct()) {
12744                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12745                    }
12746    
12747                    if (orderByComparator != null) {
12748                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12749    
12750                            if (orderByConditionFields.length > 0) {
12751                                    query.append(WHERE_AND);
12752                            }
12753    
12754                            for (int i = 0; i < orderByConditionFields.length; i++) {
12755                                    if (getDB().isSupportsInlineDistinct()) {
12756                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12757                                    }
12758                                    else {
12759                                            query.append(_ORDER_BY_ENTITY_TABLE);
12760                                    }
12761    
12762                                    query.append(orderByConditionFields[i]);
12763    
12764                                    if ((i + 1) < orderByConditionFields.length) {
12765                                            if (orderByComparator.isAscending() ^ previous) {
12766                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12767                                            }
12768                                            else {
12769                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12770                                            }
12771                                    }
12772                                    else {
12773                                            if (orderByComparator.isAscending() ^ previous) {
12774                                                    query.append(WHERE_GREATER_THAN);
12775                                            }
12776                                            else {
12777                                                    query.append(WHERE_LESSER_THAN);
12778                                            }
12779                                    }
12780                            }
12781    
12782                            query.append(ORDER_BY_CLAUSE);
12783    
12784                            String[] orderByFields = orderByComparator.getOrderByFields();
12785    
12786                            for (int i = 0; i < orderByFields.length; i++) {
12787                                    if (getDB().isSupportsInlineDistinct()) {
12788                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12789                                    }
12790                                    else {
12791                                            query.append(_ORDER_BY_ENTITY_TABLE);
12792                                    }
12793    
12794                                    query.append(orderByFields[i]);
12795    
12796                                    if ((i + 1) < orderByFields.length) {
12797                                            if (orderByComparator.isAscending() ^ previous) {
12798                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12799                                            }
12800                                            else {
12801                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12802                                            }
12803                                    }
12804                                    else {
12805                                            if (orderByComparator.isAscending() ^ previous) {
12806                                                    query.append(ORDER_BY_ASC);
12807                                            }
12808                                            else {
12809                                                    query.append(ORDER_BY_DESC);
12810                                            }
12811                                    }
12812                            }
12813                    }
12814    
12815                    else {
12816                            if (getDB().isSupportsInlineDistinct()) {
12817                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12818                            }
12819                            else {
12820                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12821                            }
12822                    }
12823    
12824                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12825                                    JournalArticle.class.getName(),
12826                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12827    
12828                    SQLQuery q = session.createSQLQuery(sql);
12829    
12830                    q.setFirstResult(0);
12831                    q.setMaxResults(2);
12832    
12833                    if (getDB().isSupportsInlineDistinct()) {
12834                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12835                    }
12836                    else {
12837                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12838                    }
12839    
12840                    QueryPos qPos = QueryPos.getInstance(q);
12841    
12842                    qPos.add(groupId);
12843    
12844                    qPos.add(classNameId);
12845    
12846                    if (layoutUuid != null) {
12847                            qPos.add(layoutUuid);
12848                    }
12849    
12850                    if (orderByComparator != null) {
12851                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12852    
12853                            for (Object value : values) {
12854                                    qPos.add(value);
12855                            }
12856                    }
12857    
12858                    List<JournalArticle> list = q.list();
12859    
12860                    if (list.size() == 2) {
12861                            return list.get(1);
12862                    }
12863                    else {
12864                            return null;
12865                    }
12866            }
12867    
12868            /**
12869             * 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.
12870             *
12871             * @param groupId the group ID
12872             * @param articleId the article ID
12873             * @param version the version
12874             * @return the matching journal article
12875             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12876             * @throws SystemException if a system exception occurred
12877             */
12878            public JournalArticle findByG_A_V(long groupId, String articleId,
12879                    double version) throws NoSuchArticleException, SystemException {
12880                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
12881    
12882                    if (journalArticle == null) {
12883                            StringBundler msg = new StringBundler(8);
12884    
12885                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12886    
12887                            msg.append("groupId=");
12888                            msg.append(groupId);
12889    
12890                            msg.append(", articleId=");
12891                            msg.append(articleId);
12892    
12893                            msg.append(", version=");
12894                            msg.append(version);
12895    
12896                            msg.append(StringPool.CLOSE_CURLY_BRACE);
12897    
12898                            if (_log.isWarnEnabled()) {
12899                                    _log.warn(msg.toString());
12900                            }
12901    
12902                            throw new NoSuchArticleException(msg.toString());
12903                    }
12904    
12905                    return journalArticle;
12906            }
12907    
12908            /**
12909             * 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.
12910             *
12911             * @param groupId the group ID
12912             * @param articleId the article ID
12913             * @param version the version
12914             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
12915             * @throws SystemException if a system exception occurred
12916             */
12917            public JournalArticle fetchByG_A_V(long groupId, String articleId,
12918                    double version) throws SystemException {
12919                    return fetchByG_A_V(groupId, articleId, version, true);
12920            }
12921    
12922            /**
12923             * 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.
12924             *
12925             * @param groupId the group ID
12926             * @param articleId the article ID
12927             * @param version the version
12928             * @param retrieveFromCache whether to use the finder cache
12929             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
12930             * @throws SystemException if a system exception occurred
12931             */
12932            public JournalArticle fetchByG_A_V(long groupId, String articleId,
12933                    double version, boolean retrieveFromCache) throws SystemException {
12934                    Object[] finderArgs = new Object[] { groupId, articleId, version };
12935    
12936                    Object result = null;
12937    
12938                    if (retrieveFromCache) {
12939                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
12940                                            finderArgs, this);
12941                    }
12942    
12943                    if (result instanceof JournalArticle) {
12944                            JournalArticle journalArticle = (JournalArticle)result;
12945    
12946                            if ((groupId != journalArticle.getGroupId()) ||
12947                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
12948                                            (version != journalArticle.getVersion())) {
12949                                    result = null;
12950                            }
12951                    }
12952    
12953                    if (result == null) {
12954                            StringBundler query = new StringBundler(5);
12955    
12956                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12957    
12958                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
12959    
12960                            if (articleId == null) {
12961                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
12962                            }
12963                            else {
12964                                    if (articleId.equals(StringPool.BLANK)) {
12965                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
12966                                    }
12967                                    else {
12968                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
12969                                    }
12970                            }
12971    
12972                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
12973    
12974                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12975    
12976                            String sql = query.toString();
12977    
12978                            Session session = null;
12979    
12980                            try {
12981                                    session = openSession();
12982    
12983                                    Query q = session.createQuery(sql);
12984    
12985                                    QueryPos qPos = QueryPos.getInstance(q);
12986    
12987                                    qPos.add(groupId);
12988    
12989                                    if (articleId != null) {
12990                                            qPos.add(articleId);
12991                                    }
12992    
12993                                    qPos.add(version);
12994    
12995                                    List<JournalArticle> list = q.list();
12996    
12997                                    result = list;
12998    
12999                                    JournalArticle journalArticle = null;
13000    
13001                                    if (list.isEmpty()) {
13002                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
13003                                                    finderArgs, list);
13004                                    }
13005                                    else {
13006                                            journalArticle = list.get(0);
13007    
13008                                            cacheResult(journalArticle);
13009    
13010                                            if ((journalArticle.getGroupId() != groupId) ||
13011                                                            (journalArticle.getArticleId() == null) ||
13012                                                            !journalArticle.getArticleId().equals(articleId) ||
13013                                                            (journalArticle.getVersion() != version)) {
13014                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
13015                                                            finderArgs, journalArticle);
13016                                            }
13017                                    }
13018    
13019                                    return journalArticle;
13020                            }
13021                            catch (Exception e) {
13022                                    throw processException(e);
13023                            }
13024                            finally {
13025                                    if (result == null) {
13026                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
13027                                                    finderArgs);
13028                                    }
13029    
13030                                    closeSession(session);
13031                            }
13032                    }
13033                    else {
13034                            if (result instanceof List<?>) {
13035                                    return null;
13036                            }
13037                            else {
13038                                    return (JournalArticle)result;
13039                            }
13040                    }
13041            }
13042    
13043            /**
13044             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
13045             *
13046             * @param groupId the group ID
13047             * @param articleId the article ID
13048             * @param status the status
13049             * @return the matching journal articles
13050             * @throws SystemException if a system exception occurred
13051             */
13052            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
13053                    int status) throws SystemException {
13054                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
13055                            QueryUtil.ALL_POS, null);
13056            }
13057    
13058            /**
13059             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
13060             *
13061             * <p>
13062             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13063             * </p>
13064             *
13065             * @param groupId the group ID
13066             * @param articleId the article ID
13067             * @param status the status
13068             * @param start the lower bound of the range of journal articles
13069             * @param end the upper bound of the range of journal articles (not inclusive)
13070             * @return the range of matching journal articles
13071             * @throws SystemException if a system exception occurred
13072             */
13073            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
13074                    int status, int start, int end) throws SystemException {
13075                    return findByG_A_ST(groupId, articleId, status, start, end, null);
13076            }
13077    
13078            /**
13079             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
13080             *
13081             * <p>
13082             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13083             * </p>
13084             *
13085             * @param groupId the group ID
13086             * @param articleId the article ID
13087             * @param status the status
13088             * @param start the lower bound of the range of journal articles
13089             * @param end the upper bound of the range of journal articles (not inclusive)
13090             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13091             * @return the ordered range of matching journal articles
13092             * @throws SystemException if a system exception occurred
13093             */
13094            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
13095                    int status, int start, int end, OrderByComparator orderByComparator)
13096                    throws SystemException {
13097                    FinderPath finderPath = null;
13098                    Object[] finderArgs = null;
13099    
13100                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13101                                    (orderByComparator == null)) {
13102                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
13103                            finderArgs = new Object[] { groupId, articleId, status };
13104                    }
13105                    else {
13106                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
13107                            finderArgs = new Object[] {
13108                                            groupId, articleId, status,
13109                                            
13110                                            start, end, orderByComparator
13111                                    };
13112                    }
13113    
13114                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13115                                    finderArgs, this);
13116    
13117                    if ((list != null) && !list.isEmpty()) {
13118                            for (JournalArticle journalArticle : list) {
13119                                    if ((groupId != journalArticle.getGroupId()) ||
13120                                                    !Validator.equals(articleId,
13121                                                            journalArticle.getArticleId()) ||
13122                                                    (status != journalArticle.getStatus())) {
13123                                            list = null;
13124    
13125                                            break;
13126                                    }
13127                            }
13128                    }
13129    
13130                    if (list == null) {
13131                            StringBundler query = null;
13132    
13133                            if (orderByComparator != null) {
13134                                    query = new StringBundler(5 +
13135                                                    (orderByComparator.getOrderByFields().length * 3));
13136                            }
13137                            else {
13138                                    query = new StringBundler(5);
13139                            }
13140    
13141                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13142    
13143                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
13144    
13145                            if (articleId == null) {
13146                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
13147                            }
13148                            else {
13149                                    if (articleId.equals(StringPool.BLANK)) {
13150                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
13151                                    }
13152                                    else {
13153                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
13154                                    }
13155                            }
13156    
13157                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
13158    
13159                            if (orderByComparator != null) {
13160                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13161                                            orderByComparator);
13162                            }
13163    
13164                            else {
13165                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13166                            }
13167    
13168                            String sql = query.toString();
13169    
13170                            Session session = null;
13171    
13172                            try {
13173                                    session = openSession();
13174    
13175                                    Query q = session.createQuery(sql);
13176    
13177                                    QueryPos qPos = QueryPos.getInstance(q);
13178    
13179                                    qPos.add(groupId);
13180    
13181                                    if (articleId != null) {
13182                                            qPos.add(articleId);
13183                                    }
13184    
13185                                    qPos.add(status);
13186    
13187                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
13188                                                    start, end);
13189                            }
13190                            catch (Exception e) {
13191                                    throw processException(e);
13192                            }
13193                            finally {
13194                                    if (list == null) {
13195                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
13196                                    }
13197                                    else {
13198                                            cacheResult(list);
13199    
13200                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
13201                                    }
13202    
13203                                    closeSession(session);
13204                            }
13205                    }
13206    
13207                    return list;
13208            }
13209    
13210            /**
13211             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
13212             *
13213             * <p>
13214             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13215             * </p>
13216             *
13217             * @param groupId the group ID
13218             * @param articleId the article ID
13219             * @param status the status
13220             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13221             * @return the first matching journal article
13222             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13223             * @throws SystemException if a system exception occurred
13224             */
13225            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
13226                    int status, OrderByComparator orderByComparator)
13227                    throws NoSuchArticleException, SystemException {
13228                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
13229                                    1, orderByComparator);
13230    
13231                    if (list.isEmpty()) {
13232                            StringBundler msg = new StringBundler(8);
13233    
13234                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13235    
13236                            msg.append("groupId=");
13237                            msg.append(groupId);
13238    
13239                            msg.append(", articleId=");
13240                            msg.append(articleId);
13241    
13242                            msg.append(", status=");
13243                            msg.append(status);
13244    
13245                            msg.append(StringPool.CLOSE_CURLY_BRACE);
13246    
13247                            throw new NoSuchArticleException(msg.toString());
13248                    }
13249                    else {
13250                            return list.get(0);
13251                    }
13252            }
13253    
13254            /**
13255             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
13256             *
13257             * <p>
13258             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13259             * </p>
13260             *
13261             * @param groupId the group ID
13262             * @param articleId the article ID
13263             * @param status the status
13264             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13265             * @return the last matching journal article
13266             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13267             * @throws SystemException if a system exception occurred
13268             */
13269            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
13270                    int status, OrderByComparator orderByComparator)
13271                    throws NoSuchArticleException, SystemException {
13272                    int count = countByG_A_ST(groupId, articleId, status);
13273    
13274                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
13275                                    count - 1, count, orderByComparator);
13276    
13277                    if (list.isEmpty()) {
13278                            StringBundler msg = new StringBundler(8);
13279    
13280                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13281    
13282                            msg.append("groupId=");
13283                            msg.append(groupId);
13284    
13285                            msg.append(", articleId=");
13286                            msg.append(articleId);
13287    
13288                            msg.append(", status=");
13289                            msg.append(status);
13290    
13291                            msg.append(StringPool.CLOSE_CURLY_BRACE);
13292    
13293                            throw new NoSuchArticleException(msg.toString());
13294                    }
13295                    else {
13296                            return list.get(0);
13297                    }
13298            }
13299    
13300            /**
13301             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
13302             *
13303             * <p>
13304             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13305             * </p>
13306             *
13307             * @param id the primary key of the current journal article
13308             * @param groupId the group ID
13309             * @param articleId the article ID
13310             * @param status the status
13311             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13312             * @return the previous, current, and next journal article
13313             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13314             * @throws SystemException if a system exception occurred
13315             */
13316            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
13317                    String articleId, int status, OrderByComparator orderByComparator)
13318                    throws NoSuchArticleException, SystemException {
13319                    JournalArticle journalArticle = findByPrimaryKey(id);
13320    
13321                    Session session = null;
13322    
13323                    try {
13324                            session = openSession();
13325    
13326                            JournalArticle[] array = new JournalArticleImpl[3];
13327    
13328                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
13329                                            groupId, articleId, status, orderByComparator, true);
13330    
13331                            array[1] = journalArticle;
13332    
13333                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
13334                                            groupId, articleId, status, orderByComparator, false);
13335    
13336                            return array;
13337                    }
13338                    catch (Exception e) {
13339                            throw processException(e);
13340                    }
13341                    finally {
13342                            closeSession(session);
13343                    }
13344            }
13345    
13346            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
13347                    JournalArticle journalArticle, long groupId, String articleId,
13348                    int status, OrderByComparator orderByComparator, boolean previous) {
13349                    StringBundler query = null;
13350    
13351                    if (orderByComparator != null) {
13352                            query = new StringBundler(6 +
13353                                            (orderByComparator.getOrderByFields().length * 6));
13354                    }
13355                    else {
13356                            query = new StringBundler(3);
13357                    }
13358    
13359                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13360    
13361                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
13362    
13363                    if (articleId == null) {
13364                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
13365                    }
13366                    else {
13367                            if (articleId.equals(StringPool.BLANK)) {
13368                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
13369                            }
13370                            else {
13371                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
13372                            }
13373                    }
13374    
13375                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
13376    
13377                    if (orderByComparator != null) {
13378                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13379    
13380                            if (orderByConditionFields.length > 0) {
13381                                    query.append(WHERE_AND);
13382                            }
13383    
13384                            for (int i = 0; i < orderByConditionFields.length; i++) {
13385                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13386                                    query.append(orderByConditionFields[i]);
13387    
13388                                    if ((i + 1) < orderByConditionFields.length) {
13389                                            if (orderByComparator.isAscending() ^ previous) {
13390                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13391                                            }
13392                                            else {
13393                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13394                                            }
13395                                    }
13396                                    else {
13397                                            if (orderByComparator.isAscending() ^ previous) {
13398                                                    query.append(WHERE_GREATER_THAN);
13399                                            }
13400                                            else {
13401                                                    query.append(WHERE_LESSER_THAN);
13402                                            }
13403                                    }
13404                            }
13405    
13406                            query.append(ORDER_BY_CLAUSE);
13407    
13408                            String[] orderByFields = orderByComparator.getOrderByFields();
13409    
13410                            for (int i = 0; i < orderByFields.length; i++) {
13411                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13412                                    query.append(orderByFields[i]);
13413    
13414                                    if ((i + 1) < orderByFields.length) {
13415                                            if (orderByComparator.isAscending() ^ previous) {
13416                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13417                                            }
13418                                            else {
13419                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13420                                            }
13421                                    }
13422                                    else {
13423                                            if (orderByComparator.isAscending() ^ previous) {
13424                                                    query.append(ORDER_BY_ASC);
13425                                            }
13426                                            else {
13427                                                    query.append(ORDER_BY_DESC);
13428                                            }
13429                                    }
13430                            }
13431                    }
13432    
13433                    else {
13434                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13435                    }
13436    
13437                    String sql = query.toString();
13438    
13439                    Query q = session.createQuery(sql);
13440    
13441                    q.setFirstResult(0);
13442                    q.setMaxResults(2);
13443    
13444                    QueryPos qPos = QueryPos.getInstance(q);
13445    
13446                    qPos.add(groupId);
13447    
13448                    if (articleId != null) {
13449                            qPos.add(articleId);
13450                    }
13451    
13452                    qPos.add(status);
13453    
13454                    if (orderByComparator != null) {
13455                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13456    
13457                            for (Object value : values) {
13458                                    qPos.add(value);
13459                            }
13460                    }
13461    
13462                    List<JournalArticle> list = q.list();
13463    
13464                    if (list.size() == 2) {
13465                            return list.get(1);
13466                    }
13467                    else {
13468                            return null;
13469                    }
13470            }
13471    
13472            /**
13473             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
13474             *
13475             * <p>
13476             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13477             * </p>
13478             *
13479             * @param groupId the group ID
13480             * @param articleId the article ID
13481             * @param statuses the statuses
13482             * @return the matching journal articles
13483             * @throws SystemException if a system exception occurred
13484             */
13485            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
13486                    int[] statuses) throws SystemException {
13487                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
13488                            QueryUtil.ALL_POS, null);
13489            }
13490    
13491            /**
13492             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
13493             *
13494             * <p>
13495             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13496             * </p>
13497             *
13498             * @param groupId the group ID
13499             * @param articleId the article ID
13500             * @param statuses the statuses
13501             * @param start the lower bound of the range of journal articles
13502             * @param end the upper bound of the range of journal articles (not inclusive)
13503             * @return the range of matching journal articles
13504             * @throws SystemException if a system exception occurred
13505             */
13506            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
13507                    int[] statuses, int start, int end) throws SystemException {
13508                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
13509            }
13510    
13511            /**
13512             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
13513             *
13514             * <p>
13515             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13516             * </p>
13517             *
13518             * @param groupId the group ID
13519             * @param articleId the article ID
13520             * @param statuses the statuses
13521             * @param start the lower bound of the range of journal articles
13522             * @param end the upper bound of the range of journal articles (not inclusive)
13523             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13524             * @return the ordered range of matching journal articles
13525             * @throws SystemException if a system exception occurred
13526             */
13527            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
13528                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
13529                    throws SystemException {
13530                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
13531                    Object[] finderArgs = null;
13532    
13533                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13534                                    (orderByComparator == null)) {
13535                            finderArgs = new Object[] {
13536                                            groupId, articleId, StringUtil.merge(statuses)
13537                                    };
13538                    }
13539                    else {
13540                            finderArgs = new Object[] {
13541                                            groupId, articleId, StringUtil.merge(statuses),
13542                                            
13543                                            start, end, orderByComparator
13544                                    };
13545                    }
13546    
13547                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13548                                    finderArgs, this);
13549    
13550                    if ((list != null) && !list.isEmpty()) {
13551                            for (JournalArticle journalArticle : list) {
13552                                    if ((groupId != journalArticle.getGroupId()) ||
13553                                                    !Validator.equals(articleId,
13554                                                            journalArticle.getArticleId()) ||
13555                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
13556                                            list = null;
13557    
13558                                            break;
13559                                    }
13560                            }
13561                    }
13562    
13563                    if (list == null) {
13564                            StringBundler query = new StringBundler();
13565    
13566                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13567    
13568                            boolean conjunctionable = false;
13569    
13570                            if (conjunctionable) {
13571                                    query.append(WHERE_AND);
13572                            }
13573    
13574                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
13575    
13576                            conjunctionable = true;
13577    
13578                            if (conjunctionable) {
13579                                    query.append(WHERE_AND);
13580                            }
13581    
13582                            if (articleId == null) {
13583                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
13584                            }
13585                            else {
13586                                    if (articleId.equals(StringPool.BLANK)) {
13587                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
13588                                    }
13589                                    else {
13590                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
13591                                    }
13592                            }
13593    
13594                            conjunctionable = true;
13595    
13596                            if ((statuses == null) || (statuses.length > 0)) {
13597                                    if (conjunctionable) {
13598                                            query.append(WHERE_AND);
13599                                    }
13600    
13601                                    query.append(StringPool.OPEN_PARENTHESIS);
13602    
13603                                    for (int i = 0; i < statuses.length; i++) {
13604                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
13605    
13606                                            if ((i + 1) < statuses.length) {
13607                                                    query.append(WHERE_OR);
13608                                            }
13609                                    }
13610    
13611                                    query.append(StringPool.CLOSE_PARENTHESIS);
13612    
13613                                    conjunctionable = true;
13614                            }
13615    
13616                            if (orderByComparator != null) {
13617                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13618                                            orderByComparator);
13619                            }
13620    
13621                            else {
13622                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13623                            }
13624    
13625                            String sql = query.toString();
13626    
13627                            Session session = null;
13628    
13629                            try {
13630                                    session = openSession();
13631    
13632                                    Query q = session.createQuery(sql);
13633    
13634                                    QueryPos qPos = QueryPos.getInstance(q);
13635    
13636                                    qPos.add(groupId);
13637    
13638                                    if (articleId != null) {
13639                                            qPos.add(articleId);
13640                                    }
13641    
13642                                    if (statuses != null) {
13643                                            qPos.add(statuses);
13644                                    }
13645    
13646                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
13647                                                    start, end);
13648                            }
13649                            catch (Exception e) {
13650                                    throw processException(e);
13651                            }
13652                            finally {
13653                                    if (list == null) {
13654                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
13655                                    }
13656                                    else {
13657                                            cacheResult(list);
13658    
13659                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
13660                                    }
13661    
13662                                    closeSession(session);
13663                            }
13664                    }
13665    
13666                    return list;
13667            }
13668    
13669            /**
13670             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
13671             *
13672             * @param groupId the group ID
13673             * @param articleId the article ID
13674             * @param status the status
13675             * @return the matching journal articles that the user has permission to view
13676             * @throws SystemException if a system exception occurred
13677             */
13678            public List<JournalArticle> filterFindByG_A_ST(long groupId,
13679                    String articleId, int status) throws SystemException {
13680                    return filterFindByG_A_ST(groupId, articleId, status,
13681                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13682            }
13683    
13684            /**
13685             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
13686             *
13687             * <p>
13688             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13689             * </p>
13690             *
13691             * @param groupId the group ID
13692             * @param articleId the article ID
13693             * @param status the status
13694             * @param start the lower bound of the range of journal articles
13695             * @param end the upper bound of the range of journal articles (not inclusive)
13696             * @return the range of matching journal articles that the user has permission to view
13697             * @throws SystemException if a system exception occurred
13698             */
13699            public List<JournalArticle> filterFindByG_A_ST(long groupId,
13700                    String articleId, int status, int start, int end)
13701                    throws SystemException {
13702                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
13703            }
13704    
13705            /**
13706             * 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;.
13707             *
13708             * <p>
13709             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13710             * </p>
13711             *
13712             * @param groupId the group ID
13713             * @param articleId the article ID
13714             * @param status the status
13715             * @param start the lower bound of the range of journal articles
13716             * @param end the upper bound of the range of journal articles (not inclusive)
13717             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13718             * @return the ordered range of matching journal articles that the user has permission to view
13719             * @throws SystemException if a system exception occurred
13720             */
13721            public List<JournalArticle> filterFindByG_A_ST(long groupId,
13722                    String articleId, int status, int start, int end,
13723                    OrderByComparator orderByComparator) throws SystemException {
13724                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13725                            return findByG_A_ST(groupId, articleId, status, start, end,
13726                                    orderByComparator);
13727                    }
13728    
13729                    StringBundler query = null;
13730    
13731                    if (orderByComparator != null) {
13732                            query = new StringBundler(5 +
13733                                            (orderByComparator.getOrderByFields().length * 3));
13734                    }
13735                    else {
13736                            query = new StringBundler(5);
13737                    }
13738    
13739                    if (getDB().isSupportsInlineDistinct()) {
13740                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13741                    }
13742                    else {
13743                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13744                    }
13745    
13746                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
13747    
13748                    if (articleId == null) {
13749                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
13750                    }
13751                    else {
13752                            if (articleId.equals(StringPool.BLANK)) {
13753                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
13754                            }
13755                            else {
13756                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
13757                            }
13758                    }
13759    
13760                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
13761    
13762                    if (!getDB().isSupportsInlineDistinct()) {
13763                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13764                    }
13765    
13766                    if (orderByComparator != null) {
13767                            if (getDB().isSupportsInlineDistinct()) {
13768                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13769                                            orderByComparator);
13770                            }
13771                            else {
13772                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13773                                            orderByComparator);
13774                            }
13775                    }
13776    
13777                    else {
13778                            if (getDB().isSupportsInlineDistinct()) {
13779                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13780                            }
13781                            else {
13782                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13783                            }
13784                    }
13785    
13786                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13787                                    JournalArticle.class.getName(),
13788                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13789    
13790                    Session session = null;
13791    
13792                    try {
13793                            session = openSession();
13794    
13795                            SQLQuery q = session.createSQLQuery(sql);
13796    
13797                            if (getDB().isSupportsInlineDistinct()) {
13798                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13799                            }
13800                            else {
13801                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13802                            }
13803    
13804                            QueryPos qPos = QueryPos.getInstance(q);
13805    
13806                            qPos.add(groupId);
13807    
13808                            if (articleId != null) {
13809                                    qPos.add(articleId);
13810                            }
13811    
13812                            qPos.add(status);
13813    
13814                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13815                                    end);
13816                    }
13817                    catch (Exception e) {
13818                            throw processException(e);
13819                    }
13820                    finally {
13821                            closeSession(session);
13822                    }
13823            }
13824    
13825            /**
13826             * 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;.
13827             *
13828             * @param id the primary key of the current journal article
13829             * @param groupId the group ID
13830             * @param articleId the article ID
13831             * @param status the status
13832             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13833             * @return the previous, current, and next journal article
13834             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13835             * @throws SystemException if a system exception occurred
13836             */
13837            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
13838                    long groupId, String articleId, int status,
13839                    OrderByComparator orderByComparator)
13840                    throws NoSuchArticleException, SystemException {
13841                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13842                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
13843                                    orderByComparator);
13844                    }
13845    
13846                    JournalArticle journalArticle = findByPrimaryKey(id);
13847    
13848                    Session session = null;
13849    
13850                    try {
13851                            session = openSession();
13852    
13853                            JournalArticle[] array = new JournalArticleImpl[3];
13854    
13855                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
13856                                            groupId, articleId, status, orderByComparator, true);
13857    
13858                            array[1] = journalArticle;
13859    
13860                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
13861                                            groupId, articleId, status, orderByComparator, false);
13862    
13863                            return array;
13864                    }
13865                    catch (Exception e) {
13866                            throw processException(e);
13867                    }
13868                    finally {
13869                            closeSession(session);
13870                    }
13871            }
13872    
13873            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
13874                    JournalArticle journalArticle, long groupId, String articleId,
13875                    int status, OrderByComparator orderByComparator, boolean previous) {
13876                    StringBundler query = null;
13877    
13878                    if (orderByComparator != null) {
13879                            query = new StringBundler(6 +
13880                                            (orderByComparator.getOrderByFields().length * 6));
13881                    }
13882                    else {
13883                            query = new StringBundler(3);
13884                    }
13885    
13886                    if (getDB().isSupportsInlineDistinct()) {
13887                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13888                    }
13889                    else {
13890                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13891                    }
13892    
13893                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
13894    
13895                    if (articleId == null) {
13896                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
13897                    }
13898                    else {
13899                            if (articleId.equals(StringPool.BLANK)) {
13900                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
13901                            }
13902                            else {
13903                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
13904                            }
13905                    }
13906    
13907                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
13908    
13909                    if (!getDB().isSupportsInlineDistinct()) {
13910                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13911                    }
13912    
13913                    if (orderByComparator != null) {
13914                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13915    
13916                            if (orderByConditionFields.length > 0) {
13917                                    query.append(WHERE_AND);
13918                            }
13919    
13920                            for (int i = 0; i < orderByConditionFields.length; i++) {
13921                                    if (getDB().isSupportsInlineDistinct()) {
13922                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13923                                    }
13924                                    else {
13925                                            query.append(_ORDER_BY_ENTITY_TABLE);
13926                                    }
13927    
13928                                    query.append(orderByConditionFields[i]);
13929    
13930                                    if ((i + 1) < orderByConditionFields.length) {
13931                                            if (orderByComparator.isAscending() ^ previous) {
13932                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13933                                            }
13934                                            else {
13935                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13936                                            }
13937                                    }
13938                                    else {
13939                                            if (orderByComparator.isAscending() ^ previous) {
13940                                                    query.append(WHERE_GREATER_THAN);
13941                                            }
13942                                            else {
13943                                                    query.append(WHERE_LESSER_THAN);
13944                                            }
13945                                    }
13946                            }
13947    
13948                            query.append(ORDER_BY_CLAUSE);
13949    
13950                            String[] orderByFields = orderByComparator.getOrderByFields();
13951    
13952                            for (int i = 0; i < orderByFields.length; i++) {
13953                                    if (getDB().isSupportsInlineDistinct()) {
13954                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13955                                    }
13956                                    else {
13957                                            query.append(_ORDER_BY_ENTITY_TABLE);
13958                                    }
13959    
13960                                    query.append(orderByFields[i]);
13961    
13962                                    if ((i + 1) < orderByFields.length) {
13963                                            if (orderByComparator.isAscending() ^ previous) {
13964                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13965                                            }
13966                                            else {
13967                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13968                                            }
13969                                    }
13970                                    else {
13971                                            if (orderByComparator.isAscending() ^ previous) {
13972                                                    query.append(ORDER_BY_ASC);
13973                                            }
13974                                            else {
13975                                                    query.append(ORDER_BY_DESC);
13976                                            }
13977                                    }
13978                            }
13979                    }
13980    
13981                    else {
13982                            if (getDB().isSupportsInlineDistinct()) {
13983                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13984                            }
13985                            else {
13986                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13987                            }
13988                    }
13989    
13990                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13991                                    JournalArticle.class.getName(),
13992                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13993    
13994                    SQLQuery q = session.createSQLQuery(sql);
13995    
13996                    q.setFirstResult(0);
13997                    q.setMaxResults(2);
13998    
13999                    if (getDB().isSupportsInlineDistinct()) {
14000                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14001                    }
14002                    else {
14003                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14004                    }
14005    
14006                    QueryPos qPos = QueryPos.getInstance(q);
14007    
14008                    qPos.add(groupId);
14009    
14010                    if (articleId != null) {
14011                            qPos.add(articleId);
14012                    }
14013    
14014                    qPos.add(status);
14015    
14016                    if (orderByComparator != null) {
14017                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14018    
14019                            for (Object value : values) {
14020                                    qPos.add(value);
14021                            }
14022                    }
14023    
14024                    List<JournalArticle> list = q.list();
14025    
14026                    if (list.size() == 2) {
14027                            return list.get(1);
14028                    }
14029                    else {
14030                            return null;
14031                    }
14032            }
14033    
14034            /**
14035             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
14036             *
14037             * @param groupId the group ID
14038             * @param articleId the article ID
14039             * @param statuses the statuses
14040             * @return the matching journal articles that the user has permission to view
14041             * @throws SystemException if a system exception occurred
14042             */
14043            public List<JournalArticle> filterFindByG_A_ST(long groupId,
14044                    String articleId, int[] statuses) throws SystemException {
14045                    return filterFindByG_A_ST(groupId, articleId, statuses,
14046                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14047            }
14048    
14049            /**
14050             * 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;.
14051             *
14052             * <p>
14053             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14054             * </p>
14055             *
14056             * @param groupId the group ID
14057             * @param articleId the article ID
14058             * @param statuses the statuses
14059             * @param start the lower bound of the range of journal articles
14060             * @param end the upper bound of the range of journal articles (not inclusive)
14061             * @return the range of matching journal articles that the user has permission to view
14062             * @throws SystemException if a system exception occurred
14063             */
14064            public List<JournalArticle> filterFindByG_A_ST(long groupId,
14065                    String articleId, int[] statuses, int start, int end)
14066                    throws SystemException {
14067                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
14068            }
14069    
14070            /**
14071             * 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;.
14072             *
14073             * <p>
14074             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14075             * </p>
14076             *
14077             * @param groupId the group ID
14078             * @param articleId the article ID
14079             * @param statuses the statuses
14080             * @param start the lower bound of the range of journal articles
14081             * @param end the upper bound of the range of journal articles (not inclusive)
14082             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14083             * @return the ordered range of matching journal articles that the user has permission to view
14084             * @throws SystemException if a system exception occurred
14085             */
14086            public List<JournalArticle> filterFindByG_A_ST(long groupId,
14087                    String articleId, int[] statuses, int start, int end,
14088                    OrderByComparator orderByComparator) throws SystemException {
14089                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14090                            return findByG_A_ST(groupId, articleId, statuses, start, end,
14091                                    orderByComparator);
14092                    }
14093    
14094                    StringBundler query = new StringBundler();
14095    
14096                    if (getDB().isSupportsInlineDistinct()) {
14097                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14098                    }
14099                    else {
14100                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14101                    }
14102    
14103                    boolean conjunctionable = false;
14104    
14105                    if (conjunctionable) {
14106                            query.append(WHERE_AND);
14107                    }
14108    
14109                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
14110    
14111                    conjunctionable = true;
14112    
14113                    if (conjunctionable) {
14114                            query.append(WHERE_AND);
14115                    }
14116    
14117                    if (articleId == null) {
14118                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
14119                    }
14120                    else {
14121                            if (articleId.equals(StringPool.BLANK)) {
14122                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
14123                            }
14124                            else {
14125                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
14126                            }
14127                    }
14128    
14129                    conjunctionable = true;
14130    
14131                    if ((statuses == null) || (statuses.length > 0)) {
14132                            if (conjunctionable) {
14133                                    query.append(WHERE_AND);
14134                            }
14135    
14136                            query.append(StringPool.OPEN_PARENTHESIS);
14137    
14138                            for (int i = 0; i < statuses.length; i++) {
14139                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
14140    
14141                                    if ((i + 1) < statuses.length) {
14142                                            query.append(WHERE_OR);
14143                                    }
14144                            }
14145    
14146                            query.append(StringPool.CLOSE_PARENTHESIS);
14147    
14148                            conjunctionable = true;
14149                    }
14150    
14151                    if (!getDB().isSupportsInlineDistinct()) {
14152                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14153                    }
14154    
14155                    if (orderByComparator != null) {
14156                            if (getDB().isSupportsInlineDistinct()) {
14157                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14158                                            orderByComparator);
14159                            }
14160                            else {
14161                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14162                                            orderByComparator);
14163                            }
14164                    }
14165    
14166                    else {
14167                            if (getDB().isSupportsInlineDistinct()) {
14168                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14169                            }
14170                            else {
14171                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14172                            }
14173                    }
14174    
14175                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14176                                    JournalArticle.class.getName(),
14177                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14178    
14179                    Session session = null;
14180    
14181                    try {
14182                            session = openSession();
14183    
14184                            SQLQuery q = session.createSQLQuery(sql);
14185    
14186                            if (getDB().isSupportsInlineDistinct()) {
14187                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14188                            }
14189                            else {
14190                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14191                            }
14192    
14193                            QueryPos qPos = QueryPos.getInstance(q);
14194    
14195                            qPos.add(groupId);
14196    
14197                            if (articleId != null) {
14198                                    qPos.add(articleId);
14199                            }
14200    
14201                            if (statuses != null) {
14202                                    qPos.add(statuses);
14203                            }
14204    
14205                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14206                                    end);
14207                    }
14208                    catch (Exception e) {
14209                            throw processException(e);
14210                    }
14211                    finally {
14212                            closeSession(session);
14213                    }
14214            }
14215    
14216            /**
14217             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14218             *
14219             * @param groupId the group ID
14220             * @param urlTitle the url title
14221             * @param status the status
14222             * @return the matching journal articles
14223             * @throws SystemException if a system exception occurred
14224             */
14225            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
14226                    int status) throws SystemException {
14227                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
14228                            QueryUtil.ALL_POS, null);
14229            }
14230    
14231            /**
14232             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14233             *
14234             * <p>
14235             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14236             * </p>
14237             *
14238             * @param groupId the group ID
14239             * @param urlTitle the url title
14240             * @param status the status
14241             * @param start the lower bound of the range of journal articles
14242             * @param end the upper bound of the range of journal articles (not inclusive)
14243             * @return the range of matching journal articles
14244             * @throws SystemException if a system exception occurred
14245             */
14246            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
14247                    int status, int start, int end) throws SystemException {
14248                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
14249            }
14250    
14251            /**
14252             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14253             *
14254             * <p>
14255             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14256             * </p>
14257             *
14258             * @param groupId the group ID
14259             * @param urlTitle the url title
14260             * @param status the status
14261             * @param start the lower bound of the range of journal articles
14262             * @param end the upper bound of the range of journal articles (not inclusive)
14263             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14264             * @return the ordered range of matching journal articles
14265             * @throws SystemException if a system exception occurred
14266             */
14267            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
14268                    int status, int start, int end, OrderByComparator orderByComparator)
14269                    throws SystemException {
14270                    FinderPath finderPath = null;
14271                    Object[] finderArgs = null;
14272    
14273                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14274                                    (orderByComparator == null)) {
14275                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
14276                            finderArgs = new Object[] { groupId, urlTitle, status };
14277                    }
14278                    else {
14279                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
14280                            finderArgs = new Object[] {
14281                                            groupId, urlTitle, status,
14282                                            
14283                                            start, end, orderByComparator
14284                                    };
14285                    }
14286    
14287                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14288                                    finderArgs, this);
14289    
14290                    if ((list != null) && !list.isEmpty()) {
14291                            for (JournalArticle journalArticle : list) {
14292                                    if ((groupId != journalArticle.getGroupId()) ||
14293                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
14294                                                    (status != journalArticle.getStatus())) {
14295                                            list = null;
14296    
14297                                            break;
14298                                    }
14299                            }
14300                    }
14301    
14302                    if (list == null) {
14303                            StringBundler query = null;
14304    
14305                            if (orderByComparator != null) {
14306                                    query = new StringBundler(5 +
14307                                                    (orderByComparator.getOrderByFields().length * 3));
14308                            }
14309                            else {
14310                                    query = new StringBundler(5);
14311                            }
14312    
14313                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14314    
14315                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
14316    
14317                            if (urlTitle == null) {
14318                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
14319                            }
14320                            else {
14321                                    if (urlTitle.equals(StringPool.BLANK)) {
14322                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
14323                                    }
14324                                    else {
14325                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
14326                                    }
14327                            }
14328    
14329                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
14330    
14331                            if (orderByComparator != null) {
14332                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14333                                            orderByComparator);
14334                            }
14335    
14336                            else {
14337                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14338                            }
14339    
14340                            String sql = query.toString();
14341    
14342                            Session session = null;
14343    
14344                            try {
14345                                    session = openSession();
14346    
14347                                    Query q = session.createQuery(sql);
14348    
14349                                    QueryPos qPos = QueryPos.getInstance(q);
14350    
14351                                    qPos.add(groupId);
14352    
14353                                    if (urlTitle != null) {
14354                                            qPos.add(urlTitle);
14355                                    }
14356    
14357                                    qPos.add(status);
14358    
14359                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
14360                                                    start, end);
14361                            }
14362                            catch (Exception e) {
14363                                    throw processException(e);
14364                            }
14365                            finally {
14366                                    if (list == null) {
14367                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
14368                                    }
14369                                    else {
14370                                            cacheResult(list);
14371    
14372                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
14373                                    }
14374    
14375                                    closeSession(session);
14376                            }
14377                    }
14378    
14379                    return list;
14380            }
14381    
14382            /**
14383             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14384             *
14385             * <p>
14386             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14387             * </p>
14388             *
14389             * @param groupId the group ID
14390             * @param urlTitle the url title
14391             * @param status the status
14392             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14393             * @return the first matching journal article
14394             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14395             * @throws SystemException if a system exception occurred
14396             */
14397            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
14398                    int status, OrderByComparator orderByComparator)
14399                    throws NoSuchArticleException, SystemException {
14400                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
14401                                    1, orderByComparator);
14402    
14403                    if (list.isEmpty()) {
14404                            StringBundler msg = new StringBundler(8);
14405    
14406                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14407    
14408                            msg.append("groupId=");
14409                            msg.append(groupId);
14410    
14411                            msg.append(", urlTitle=");
14412                            msg.append(urlTitle);
14413    
14414                            msg.append(", status=");
14415                            msg.append(status);
14416    
14417                            msg.append(StringPool.CLOSE_CURLY_BRACE);
14418    
14419                            throw new NoSuchArticleException(msg.toString());
14420                    }
14421                    else {
14422                            return list.get(0);
14423                    }
14424            }
14425    
14426            /**
14427             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14428             *
14429             * <p>
14430             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14431             * </p>
14432             *
14433             * @param groupId the group ID
14434             * @param urlTitle the url title
14435             * @param status the status
14436             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14437             * @return the last matching journal article
14438             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14439             * @throws SystemException if a system exception occurred
14440             */
14441            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
14442                    int status, OrderByComparator orderByComparator)
14443                    throws NoSuchArticleException, SystemException {
14444                    int count = countByG_UT_ST(groupId, urlTitle, status);
14445    
14446                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
14447                                    count - 1, count, orderByComparator);
14448    
14449                    if (list.isEmpty()) {
14450                            StringBundler msg = new StringBundler(8);
14451    
14452                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14453    
14454                            msg.append("groupId=");
14455                            msg.append(groupId);
14456    
14457                            msg.append(", urlTitle=");
14458                            msg.append(urlTitle);
14459    
14460                            msg.append(", status=");
14461                            msg.append(status);
14462    
14463                            msg.append(StringPool.CLOSE_CURLY_BRACE);
14464    
14465                            throw new NoSuchArticleException(msg.toString());
14466                    }
14467                    else {
14468                            return list.get(0);
14469                    }
14470            }
14471    
14472            /**
14473             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14474             *
14475             * <p>
14476             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14477             * </p>
14478             *
14479             * @param id the primary key of the current journal article
14480             * @param groupId the group ID
14481             * @param urlTitle the url title
14482             * @param status the status
14483             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14484             * @return the previous, current, and next journal article
14485             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14486             * @throws SystemException if a system exception occurred
14487             */
14488            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
14489                    String urlTitle, int status, OrderByComparator orderByComparator)
14490                    throws NoSuchArticleException, SystemException {
14491                    JournalArticle journalArticle = findByPrimaryKey(id);
14492    
14493                    Session session = null;
14494    
14495                    try {
14496                            session = openSession();
14497    
14498                            JournalArticle[] array = new JournalArticleImpl[3];
14499    
14500                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
14501                                            groupId, urlTitle, status, orderByComparator, true);
14502    
14503                            array[1] = journalArticle;
14504    
14505                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
14506                                            groupId, urlTitle, status, orderByComparator, false);
14507    
14508                            return array;
14509                    }
14510                    catch (Exception e) {
14511                            throw processException(e);
14512                    }
14513                    finally {
14514                            closeSession(session);
14515                    }
14516            }
14517    
14518            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
14519                    JournalArticle journalArticle, long groupId, String urlTitle,
14520                    int status, OrderByComparator orderByComparator, boolean previous) {
14521                    StringBundler query = null;
14522    
14523                    if (orderByComparator != null) {
14524                            query = new StringBundler(6 +
14525                                            (orderByComparator.getOrderByFields().length * 6));
14526                    }
14527                    else {
14528                            query = new StringBundler(3);
14529                    }
14530    
14531                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14532    
14533                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
14534    
14535                    if (urlTitle == null) {
14536                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
14537                    }
14538                    else {
14539                            if (urlTitle.equals(StringPool.BLANK)) {
14540                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
14541                            }
14542                            else {
14543                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
14544                            }
14545                    }
14546    
14547                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
14548    
14549                    if (orderByComparator != null) {
14550                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14551    
14552                            if (orderByConditionFields.length > 0) {
14553                                    query.append(WHERE_AND);
14554                            }
14555    
14556                            for (int i = 0; i < orderByConditionFields.length; i++) {
14557                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14558                                    query.append(orderByConditionFields[i]);
14559    
14560                                    if ((i + 1) < orderByConditionFields.length) {
14561                                            if (orderByComparator.isAscending() ^ previous) {
14562                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14563                                            }
14564                                            else {
14565                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14566                                            }
14567                                    }
14568                                    else {
14569                                            if (orderByComparator.isAscending() ^ previous) {
14570                                                    query.append(WHERE_GREATER_THAN);
14571                                            }
14572                                            else {
14573                                                    query.append(WHERE_LESSER_THAN);
14574                                            }
14575                                    }
14576                            }
14577    
14578                            query.append(ORDER_BY_CLAUSE);
14579    
14580                            String[] orderByFields = orderByComparator.getOrderByFields();
14581    
14582                            for (int i = 0; i < orderByFields.length; i++) {
14583                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14584                                    query.append(orderByFields[i]);
14585    
14586                                    if ((i + 1) < orderByFields.length) {
14587                                            if (orderByComparator.isAscending() ^ previous) {
14588                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14589                                            }
14590                                            else {
14591                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14592                                            }
14593                                    }
14594                                    else {
14595                                            if (orderByComparator.isAscending() ^ previous) {
14596                                                    query.append(ORDER_BY_ASC);
14597                                            }
14598                                            else {
14599                                                    query.append(ORDER_BY_DESC);
14600                                            }
14601                                    }
14602                            }
14603                    }
14604    
14605                    else {
14606                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14607                    }
14608    
14609                    String sql = query.toString();
14610    
14611                    Query q = session.createQuery(sql);
14612    
14613                    q.setFirstResult(0);
14614                    q.setMaxResults(2);
14615    
14616                    QueryPos qPos = QueryPos.getInstance(q);
14617    
14618                    qPos.add(groupId);
14619    
14620                    if (urlTitle != null) {
14621                            qPos.add(urlTitle);
14622                    }
14623    
14624                    qPos.add(status);
14625    
14626                    if (orderByComparator != null) {
14627                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14628    
14629                            for (Object value : values) {
14630                                    qPos.add(value);
14631                            }
14632                    }
14633    
14634                    List<JournalArticle> list = q.list();
14635    
14636                    if (list.size() == 2) {
14637                            return list.get(1);
14638                    }
14639                    else {
14640                            return null;
14641                    }
14642            }
14643    
14644            /**
14645             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14646             *
14647             * @param groupId the group ID
14648             * @param urlTitle the url title
14649             * @param status the status
14650             * @return the matching journal articles that the user has permission to view
14651             * @throws SystemException if a system exception occurred
14652             */
14653            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
14654                    String urlTitle, int status) throws SystemException {
14655                    return filterFindByG_UT_ST(groupId, urlTitle, status,
14656                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14657            }
14658    
14659            /**
14660             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14661             *
14662             * <p>
14663             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14664             * </p>
14665             *
14666             * @param groupId the group ID
14667             * @param urlTitle the url title
14668             * @param status the status
14669             * @param start the lower bound of the range of journal articles
14670             * @param end the upper bound of the range of journal articles (not inclusive)
14671             * @return the range of matching journal articles that the user has permission to view
14672             * @throws SystemException if a system exception occurred
14673             */
14674            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
14675                    String urlTitle, int status, int start, int end)
14676                    throws SystemException {
14677                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
14678            }
14679    
14680            /**
14681             * 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;.
14682             *
14683             * <p>
14684             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14685             * </p>
14686             *
14687             * @param groupId the group ID
14688             * @param urlTitle the url title
14689             * @param status the status
14690             * @param start the lower bound of the range of journal articles
14691             * @param end the upper bound of the range of journal articles (not inclusive)
14692             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14693             * @return the ordered range of matching journal articles that the user has permission to view
14694             * @throws SystemException if a system exception occurred
14695             */
14696            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
14697                    String urlTitle, int status, int start, int end,
14698                    OrderByComparator orderByComparator) throws SystemException {
14699                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14700                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
14701                                    orderByComparator);
14702                    }
14703    
14704                    StringBundler query = null;
14705    
14706                    if (orderByComparator != null) {
14707                            query = new StringBundler(5 +
14708                                            (orderByComparator.getOrderByFields().length * 3));
14709                    }
14710                    else {
14711                            query = new StringBundler(5);
14712                    }
14713    
14714                    if (getDB().isSupportsInlineDistinct()) {
14715                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14716                    }
14717                    else {
14718                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14719                    }
14720    
14721                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
14722    
14723                    if (urlTitle == null) {
14724                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
14725                    }
14726                    else {
14727                            if (urlTitle.equals(StringPool.BLANK)) {
14728                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
14729                            }
14730                            else {
14731                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
14732                            }
14733                    }
14734    
14735                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
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                            if (urlTitle != null) {
14784                                    qPos.add(urlTitle);
14785                            }
14786    
14787                            qPos.add(status);
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 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;.
14802             *
14803             * @param id the primary key of the current journal article
14804             * @param groupId the group ID
14805             * @param urlTitle the url title
14806             * @param status the status
14807             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14808             * @return the previous, current, and next journal article
14809             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14810             * @throws SystemException if a system exception occurred
14811             */
14812            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
14813                    long groupId, String urlTitle, int status,
14814                    OrderByComparator orderByComparator)
14815                    throws NoSuchArticleException, SystemException {
14816                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14817                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
14818                                    orderByComparator);
14819                    }
14820    
14821                    JournalArticle journalArticle = findByPrimaryKey(id);
14822    
14823                    Session session = null;
14824    
14825                    try {
14826                            session = openSession();
14827    
14828                            JournalArticle[] array = new JournalArticleImpl[3];
14829    
14830                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
14831                                            groupId, urlTitle, status, orderByComparator, true);
14832    
14833                            array[1] = journalArticle;
14834    
14835                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
14836                                            groupId, urlTitle, status, orderByComparator, false);
14837    
14838                            return array;
14839                    }
14840                    catch (Exception e) {
14841                            throw processException(e);
14842                    }
14843                    finally {
14844                            closeSession(session);
14845                    }
14846            }
14847    
14848            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
14849                    JournalArticle journalArticle, long groupId, String urlTitle,
14850                    int status, OrderByComparator orderByComparator, boolean previous) {
14851                    StringBundler query = null;
14852    
14853                    if (orderByComparator != null) {
14854                            query = new StringBundler(6 +
14855                                            (orderByComparator.getOrderByFields().length * 6));
14856                    }
14857                    else {
14858                            query = new StringBundler(3);
14859                    }
14860    
14861                    if (getDB().isSupportsInlineDistinct()) {
14862                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14863                    }
14864                    else {
14865                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14866                    }
14867    
14868                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
14869    
14870                    if (urlTitle == null) {
14871                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
14872                    }
14873                    else {
14874                            if (urlTitle.equals(StringPool.BLANK)) {
14875                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
14876                            }
14877                            else {
14878                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
14879                            }
14880                    }
14881    
14882                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
14883    
14884                    if (!getDB().isSupportsInlineDistinct()) {
14885                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14886                    }
14887    
14888                    if (orderByComparator != null) {
14889                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14890    
14891                            if (orderByConditionFields.length > 0) {
14892                                    query.append(WHERE_AND);
14893                            }
14894    
14895                            for (int i = 0; i < orderByConditionFields.length; i++) {
14896                                    if (getDB().isSupportsInlineDistinct()) {
14897                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14898                                    }
14899                                    else {
14900                                            query.append(_ORDER_BY_ENTITY_TABLE);
14901                                    }
14902    
14903                                    query.append(orderByConditionFields[i]);
14904    
14905                                    if ((i + 1) < orderByConditionFields.length) {
14906                                            if (orderByComparator.isAscending() ^ previous) {
14907                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14908                                            }
14909                                            else {
14910                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14911                                            }
14912                                    }
14913                                    else {
14914                                            if (orderByComparator.isAscending() ^ previous) {
14915                                                    query.append(WHERE_GREATER_THAN);
14916                                            }
14917                                            else {
14918                                                    query.append(WHERE_LESSER_THAN);
14919                                            }
14920                                    }
14921                            }
14922    
14923                            query.append(ORDER_BY_CLAUSE);
14924    
14925                            String[] orderByFields = orderByComparator.getOrderByFields();
14926    
14927                            for (int i = 0; i < orderByFields.length; i++) {
14928                                    if (getDB().isSupportsInlineDistinct()) {
14929                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14930                                    }
14931                                    else {
14932                                            query.append(_ORDER_BY_ENTITY_TABLE);
14933                                    }
14934    
14935                                    query.append(orderByFields[i]);
14936    
14937                                    if ((i + 1) < orderByFields.length) {
14938                                            if (orderByComparator.isAscending() ^ previous) {
14939                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14940                                            }
14941                                            else {
14942                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14943                                            }
14944                                    }
14945                                    else {
14946                                            if (orderByComparator.isAscending() ^ previous) {
14947                                                    query.append(ORDER_BY_ASC);
14948                                            }
14949                                            else {
14950                                                    query.append(ORDER_BY_DESC);
14951                                            }
14952                                    }
14953                            }
14954                    }
14955    
14956                    else {
14957                            if (getDB().isSupportsInlineDistinct()) {
14958                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14959                            }
14960                            else {
14961                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14962                            }
14963                    }
14964    
14965                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14966                                    JournalArticle.class.getName(),
14967                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14968    
14969                    SQLQuery q = session.createSQLQuery(sql);
14970    
14971                    q.setFirstResult(0);
14972                    q.setMaxResults(2);
14973    
14974                    if (getDB().isSupportsInlineDistinct()) {
14975                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14976                    }
14977                    else {
14978                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14979                    }
14980    
14981                    QueryPos qPos = QueryPos.getInstance(q);
14982    
14983                    qPos.add(groupId);
14984    
14985                    if (urlTitle != null) {
14986                            qPos.add(urlTitle);
14987                    }
14988    
14989                    qPos.add(status);
14990    
14991                    if (orderByComparator != null) {
14992                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14993    
14994                            for (Object value : values) {
14995                                    qPos.add(value);
14996                            }
14997                    }
14998    
14999                    List<JournalArticle> list = q.list();
15000    
15001                    if (list.size() == 2) {
15002                            return list.get(1);
15003                    }
15004                    else {
15005                            return null;
15006                    }
15007            }
15008    
15009            /**
15010             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
15011             *
15012             * @param companyId the company ID
15013             * @param version the version
15014             * @param status the status
15015             * @return the matching journal articles
15016             * @throws SystemException if a system exception occurred
15017             */
15018            public List<JournalArticle> findByC_V_ST(long companyId, double version,
15019                    int status) throws SystemException {
15020                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
15021                            QueryUtil.ALL_POS, null);
15022            }
15023    
15024            /**
15025             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
15026             *
15027             * <p>
15028             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15029             * </p>
15030             *
15031             * @param companyId the company ID
15032             * @param version the version
15033             * @param status the status
15034             * @param start the lower bound of the range of journal articles
15035             * @param end the upper bound of the range of journal articles (not inclusive)
15036             * @return the range of matching journal articles
15037             * @throws SystemException if a system exception occurred
15038             */
15039            public List<JournalArticle> findByC_V_ST(long companyId, double version,
15040                    int status, int start, int end) throws SystemException {
15041                    return findByC_V_ST(companyId, version, status, start, end, null);
15042            }
15043    
15044            /**
15045             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
15046             *
15047             * <p>
15048             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15049             * </p>
15050             *
15051             * @param companyId the company ID
15052             * @param version the version
15053             * @param status the status
15054             * @param start the lower bound of the range of journal articles
15055             * @param end the upper bound of the range of journal articles (not inclusive)
15056             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15057             * @return the ordered range of matching journal articles
15058             * @throws SystemException if a system exception occurred
15059             */
15060            public List<JournalArticle> findByC_V_ST(long companyId, double version,
15061                    int status, int start, int end, OrderByComparator orderByComparator)
15062                    throws SystemException {
15063                    FinderPath finderPath = null;
15064                    Object[] finderArgs = null;
15065    
15066                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15067                                    (orderByComparator == null)) {
15068                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
15069                            finderArgs = new Object[] { companyId, version, status };
15070                    }
15071                    else {
15072                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
15073                            finderArgs = new Object[] {
15074                                            companyId, version, status,
15075                                            
15076                                            start, end, orderByComparator
15077                                    };
15078                    }
15079    
15080                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15081                                    finderArgs, this);
15082    
15083                    if ((list != null) && !list.isEmpty()) {
15084                            for (JournalArticle journalArticle : list) {
15085                                    if ((companyId != journalArticle.getCompanyId()) ||
15086                                                    (version != journalArticle.getVersion()) ||
15087                                                    (status != journalArticle.getStatus())) {
15088                                            list = null;
15089    
15090                                            break;
15091                                    }
15092                            }
15093                    }
15094    
15095                    if (list == null) {
15096                            StringBundler query = null;
15097    
15098                            if (orderByComparator != null) {
15099                                    query = new StringBundler(5 +
15100                                                    (orderByComparator.getOrderByFields().length * 3));
15101                            }
15102                            else {
15103                                    query = new StringBundler(5);
15104                            }
15105    
15106                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15107    
15108                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
15109    
15110                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
15111    
15112                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
15113    
15114                            if (orderByComparator != null) {
15115                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15116                                            orderByComparator);
15117                            }
15118    
15119                            else {
15120                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15121                            }
15122    
15123                            String sql = query.toString();
15124    
15125                            Session session = null;
15126    
15127                            try {
15128                                    session = openSession();
15129    
15130                                    Query q = session.createQuery(sql);
15131    
15132                                    QueryPos qPos = QueryPos.getInstance(q);
15133    
15134                                    qPos.add(companyId);
15135    
15136                                    qPos.add(version);
15137    
15138                                    qPos.add(status);
15139    
15140                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
15141                                                    start, end);
15142                            }
15143                            catch (Exception e) {
15144                                    throw processException(e);
15145                            }
15146                            finally {
15147                                    if (list == null) {
15148                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
15149                                    }
15150                                    else {
15151                                            cacheResult(list);
15152    
15153                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
15154                                    }
15155    
15156                                    closeSession(session);
15157                            }
15158                    }
15159    
15160                    return list;
15161            }
15162    
15163            /**
15164             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
15165             *
15166             * <p>
15167             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15168             * </p>
15169             *
15170             * @param companyId the company ID
15171             * @param version the version
15172             * @param status the status
15173             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15174             * @return the first matching journal article
15175             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15176             * @throws SystemException if a system exception occurred
15177             */
15178            public JournalArticle findByC_V_ST_First(long companyId, double version,
15179                    int status, OrderByComparator orderByComparator)
15180                    throws NoSuchArticleException, SystemException {
15181                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
15182                                    1, orderByComparator);
15183    
15184                    if (list.isEmpty()) {
15185                            StringBundler msg = new StringBundler(8);
15186    
15187                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15188    
15189                            msg.append("companyId=");
15190                            msg.append(companyId);
15191    
15192                            msg.append(", version=");
15193                            msg.append(version);
15194    
15195                            msg.append(", status=");
15196                            msg.append(status);
15197    
15198                            msg.append(StringPool.CLOSE_CURLY_BRACE);
15199    
15200                            throw new NoSuchArticleException(msg.toString());
15201                    }
15202                    else {
15203                            return list.get(0);
15204                    }
15205            }
15206    
15207            /**
15208             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
15209             *
15210             * <p>
15211             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15212             * </p>
15213             *
15214             * @param companyId the company ID
15215             * @param version the version
15216             * @param status the status
15217             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15218             * @return the last matching journal article
15219             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15220             * @throws SystemException if a system exception occurred
15221             */
15222            public JournalArticle findByC_V_ST_Last(long companyId, double version,
15223                    int status, OrderByComparator orderByComparator)
15224                    throws NoSuchArticleException, SystemException {
15225                    int count = countByC_V_ST(companyId, version, status);
15226    
15227                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
15228                                    count - 1, count, orderByComparator);
15229    
15230                    if (list.isEmpty()) {
15231                            StringBundler msg = new StringBundler(8);
15232    
15233                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15234    
15235                            msg.append("companyId=");
15236                            msg.append(companyId);
15237    
15238                            msg.append(", version=");
15239                            msg.append(version);
15240    
15241                            msg.append(", status=");
15242                            msg.append(status);
15243    
15244                            msg.append(StringPool.CLOSE_CURLY_BRACE);
15245    
15246                            throw new NoSuchArticleException(msg.toString());
15247                    }
15248                    else {
15249                            return list.get(0);
15250                    }
15251            }
15252    
15253            /**
15254             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
15255             *
15256             * <p>
15257             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15258             * </p>
15259             *
15260             * @param id the primary key of the current journal article
15261             * @param companyId the company ID
15262             * @param version the version
15263             * @param status the status
15264             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15265             * @return the previous, current, and next journal article
15266             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15267             * @throws SystemException if a system exception occurred
15268             */
15269            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
15270                    double version, int status, OrderByComparator orderByComparator)
15271                    throws NoSuchArticleException, SystemException {
15272                    JournalArticle journalArticle = findByPrimaryKey(id);
15273    
15274                    Session session = null;
15275    
15276                    try {
15277                            session = openSession();
15278    
15279                            JournalArticle[] array = new JournalArticleImpl[3];
15280    
15281                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
15282                                            companyId, version, status, orderByComparator, true);
15283    
15284                            array[1] = journalArticle;
15285    
15286                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
15287                                            companyId, version, status, orderByComparator, false);
15288    
15289                            return array;
15290                    }
15291                    catch (Exception e) {
15292                            throw processException(e);
15293                    }
15294                    finally {
15295                            closeSession(session);
15296                    }
15297            }
15298    
15299            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
15300                    JournalArticle journalArticle, long companyId, double version,
15301                    int status, OrderByComparator orderByComparator, boolean previous) {
15302                    StringBundler query = null;
15303    
15304                    if (orderByComparator != null) {
15305                            query = new StringBundler(6 +
15306                                            (orderByComparator.getOrderByFields().length * 6));
15307                    }
15308                    else {
15309                            query = new StringBundler(3);
15310                    }
15311    
15312                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15313    
15314                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
15315    
15316                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
15317    
15318                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
15319    
15320                    if (orderByComparator != null) {
15321                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15322    
15323                            if (orderByConditionFields.length > 0) {
15324                                    query.append(WHERE_AND);
15325                            }
15326    
15327                            for (int i = 0; i < orderByConditionFields.length; i++) {
15328                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15329                                    query.append(orderByConditionFields[i]);
15330    
15331                                    if ((i + 1) < orderByConditionFields.length) {
15332                                            if (orderByComparator.isAscending() ^ previous) {
15333                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15334                                            }
15335                                            else {
15336                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15337                                            }
15338                                    }
15339                                    else {
15340                                            if (orderByComparator.isAscending() ^ previous) {
15341                                                    query.append(WHERE_GREATER_THAN);
15342                                            }
15343                                            else {
15344                                                    query.append(WHERE_LESSER_THAN);
15345                                            }
15346                                    }
15347                            }
15348    
15349                            query.append(ORDER_BY_CLAUSE);
15350    
15351                            String[] orderByFields = orderByComparator.getOrderByFields();
15352    
15353                            for (int i = 0; i < orderByFields.length; i++) {
15354                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15355                                    query.append(orderByFields[i]);
15356    
15357                                    if ((i + 1) < orderByFields.length) {
15358                                            if (orderByComparator.isAscending() ^ previous) {
15359                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15360                                            }
15361                                            else {
15362                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15363                                            }
15364                                    }
15365                                    else {
15366                                            if (orderByComparator.isAscending() ^ previous) {
15367                                                    query.append(ORDER_BY_ASC);
15368                                            }
15369                                            else {
15370                                                    query.append(ORDER_BY_DESC);
15371                                            }
15372                                    }
15373                            }
15374                    }
15375    
15376                    else {
15377                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15378                    }
15379    
15380                    String sql = query.toString();
15381    
15382                    Query q = session.createQuery(sql);
15383    
15384                    q.setFirstResult(0);
15385                    q.setMaxResults(2);
15386    
15387                    QueryPos qPos = QueryPos.getInstance(q);
15388    
15389                    qPos.add(companyId);
15390    
15391                    qPos.add(version);
15392    
15393                    qPos.add(status);
15394    
15395                    if (orderByComparator != null) {
15396                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15397    
15398                            for (Object value : values) {
15399                                    qPos.add(value);
15400                            }
15401                    }
15402    
15403                    List<JournalArticle> list = q.list();
15404    
15405                    if (list.size() == 2) {
15406                            return list.get(1);
15407                    }
15408                    else {
15409                            return null;
15410                    }
15411            }
15412    
15413            /**
15414             * Returns all the journal articles.
15415             *
15416             * @return the journal articles
15417             * @throws SystemException if a system exception occurred
15418             */
15419            public List<JournalArticle> findAll() throws SystemException {
15420                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15421            }
15422    
15423            /**
15424             * Returns a range of all the journal articles.
15425             *
15426             * <p>
15427             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15428             * </p>
15429             *
15430             * @param start the lower bound of the range of journal articles
15431             * @param end the upper bound of the range of journal articles (not inclusive)
15432             * @return the range of journal articles
15433             * @throws SystemException if a system exception occurred
15434             */
15435            public List<JournalArticle> findAll(int start, int end)
15436                    throws SystemException {
15437                    return findAll(start, end, null);
15438            }
15439    
15440            /**
15441             * Returns an ordered range of all the journal articles.
15442             *
15443             * <p>
15444             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15445             * </p>
15446             *
15447             * @param start the lower bound of the range of journal articles
15448             * @param end the upper bound of the range of journal articles (not inclusive)
15449             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15450             * @return the ordered range of journal articles
15451             * @throws SystemException if a system exception occurred
15452             */
15453            public List<JournalArticle> findAll(int start, int end,
15454                    OrderByComparator orderByComparator) throws SystemException {
15455                    FinderPath finderPath = null;
15456                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
15457    
15458                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15459                                    (orderByComparator == null)) {
15460                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
15461                            finderArgs = FINDER_ARGS_EMPTY;
15462                    }
15463                    else {
15464                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
15465                            finderArgs = new Object[] { start, end, orderByComparator };
15466                    }
15467    
15468                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15469                                    finderArgs, this);
15470    
15471                    if (list == null) {
15472                            StringBundler query = null;
15473                            String sql = null;
15474    
15475                            if (orderByComparator != null) {
15476                                    query = new StringBundler(2 +
15477                                                    (orderByComparator.getOrderByFields().length * 3));
15478    
15479                                    query.append(_SQL_SELECT_JOURNALARTICLE);
15480    
15481                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15482                                            orderByComparator);
15483    
15484                                    sql = query.toString();
15485                            }
15486                            else {
15487                                    sql = _SQL_SELECT_JOURNALARTICLE.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
15488                            }
15489    
15490                            Session session = null;
15491    
15492                            try {
15493                                    session = openSession();
15494    
15495                                    Query q = session.createQuery(sql);
15496    
15497                                    if (orderByComparator == null) {
15498                                            list = (List<JournalArticle>)QueryUtil.list(q,
15499                                                            getDialect(), start, end, false);
15500    
15501                                            Collections.sort(list);
15502                                    }
15503                                    else {
15504                                            list = (List<JournalArticle>)QueryUtil.list(q,
15505                                                            getDialect(), start, end);
15506                                    }
15507                            }
15508                            catch (Exception e) {
15509                                    throw processException(e);
15510                            }
15511                            finally {
15512                                    if (list == null) {
15513                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
15514                                    }
15515                                    else {
15516                                            cacheResult(list);
15517    
15518                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
15519                                    }
15520    
15521                                    closeSession(session);
15522                            }
15523                    }
15524    
15525                    return list;
15526            }
15527    
15528            /**
15529             * Removes all the journal articles where uuid = &#63; from the database.
15530             *
15531             * @param uuid the uuid
15532             * @throws SystemException if a system exception occurred
15533             */
15534            public void removeByUuid(String uuid) throws SystemException {
15535                    for (JournalArticle journalArticle : findByUuid(uuid)) {
15536                            remove(journalArticle);
15537                    }
15538            }
15539    
15540            /**
15541             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
15542             *
15543             * @param uuid the uuid
15544             * @param groupId the group ID
15545             * @throws SystemException if a system exception occurred
15546             */
15547            public void removeByUUID_G(String uuid, long groupId)
15548                    throws NoSuchArticleException, SystemException {
15549                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
15550    
15551                    remove(journalArticle);
15552            }
15553    
15554            /**
15555             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
15556             *
15557             * @param resourcePrimKey the resource prim key
15558             * @throws SystemException if a system exception occurred
15559             */
15560            public void removeByResourcePrimKey(long resourcePrimKey)
15561                    throws SystemException {
15562                    for (JournalArticle journalArticle : findByResourcePrimKey(
15563                                    resourcePrimKey)) {
15564                            remove(journalArticle);
15565                    }
15566            }
15567    
15568            /**
15569             * Removes all the journal articles where groupId = &#63; from the database.
15570             *
15571             * @param groupId the group ID
15572             * @throws SystemException if a system exception occurred
15573             */
15574            public void removeByGroupId(long groupId) throws SystemException {
15575                    for (JournalArticle journalArticle : findByGroupId(groupId)) {
15576                            remove(journalArticle);
15577                    }
15578            }
15579    
15580            /**
15581             * Removes all the journal articles where companyId = &#63; from the database.
15582             *
15583             * @param companyId the company ID
15584             * @throws SystemException if a system exception occurred
15585             */
15586            public void removeByCompanyId(long companyId) throws SystemException {
15587                    for (JournalArticle journalArticle : findByCompanyId(companyId)) {
15588                            remove(journalArticle);
15589                    }
15590            }
15591    
15592            /**
15593             * Removes all the journal articles where structureId = &#63; from the database.
15594             *
15595             * @param structureId the structure ID
15596             * @throws SystemException if a system exception occurred
15597             */
15598            public void removeByStructureId(String structureId)
15599                    throws SystemException {
15600                    for (JournalArticle journalArticle : findByStructureId(structureId)) {
15601                            remove(journalArticle);
15602                    }
15603            }
15604    
15605            /**
15606             * Removes all the journal articles where templateId = &#63; from the database.
15607             *
15608             * @param templateId the template ID
15609             * @throws SystemException if a system exception occurred
15610             */
15611            public void removeByTemplateId(String templateId) throws SystemException {
15612                    for (JournalArticle journalArticle : findByTemplateId(templateId)) {
15613                            remove(journalArticle);
15614                    }
15615            }
15616    
15617            /**
15618             * Removes all the journal articles where smallImageId = &#63; from the database.
15619             *
15620             * @param smallImageId the small image ID
15621             * @throws SystemException if a system exception occurred
15622             */
15623            public void removeBySmallImageId(long smallImageId)
15624                    throws SystemException {
15625                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId)) {
15626                            remove(journalArticle);
15627                    }
15628            }
15629    
15630            /**
15631             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
15632             *
15633             * @param resourcePrimKey the resource prim key
15634             * @param status the status
15635             * @throws SystemException if a system exception occurred
15636             */
15637            public void removeByR_ST(long resourcePrimKey, int status)
15638                    throws SystemException {
15639                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey, status)) {
15640                            remove(journalArticle);
15641                    }
15642            }
15643    
15644            /**
15645             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
15646             *
15647             * @param groupId the group ID
15648             * @param articleId the article ID
15649             * @throws SystemException if a system exception occurred
15650             */
15651            public void removeByG_A(long groupId, String articleId)
15652                    throws SystemException {
15653                    for (JournalArticle journalArticle : findByG_A(groupId, articleId)) {
15654                            remove(journalArticle);
15655                    }
15656            }
15657    
15658            /**
15659             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
15660             *
15661             * @param groupId the group ID
15662             * @param urlTitle the url title
15663             * @throws SystemException if a system exception occurred
15664             */
15665            public void removeByG_UT(long groupId, String urlTitle)
15666                    throws SystemException {
15667                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle)) {
15668                            remove(journalArticle);
15669                    }
15670            }
15671    
15672            /**
15673             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
15674             *
15675             * @param groupId the group ID
15676             * @param structureId the structure ID
15677             * @throws SystemException if a system exception occurred
15678             */
15679            public void removeByG_S(long groupId, String structureId)
15680                    throws SystemException {
15681                    for (JournalArticle journalArticle : findByG_S(groupId, structureId)) {
15682                            remove(journalArticle);
15683                    }
15684            }
15685    
15686            /**
15687             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
15688             *
15689             * @param groupId the group ID
15690             * @param templateId the template ID
15691             * @throws SystemException if a system exception occurred
15692             */
15693            public void removeByG_T(long groupId, String templateId)
15694                    throws SystemException {
15695                    for (JournalArticle journalArticle : findByG_T(groupId, templateId)) {
15696                            remove(journalArticle);
15697                    }
15698            }
15699    
15700            /**
15701             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
15702             *
15703             * @param groupId the group ID
15704             * @param layoutUuid the layout uuid
15705             * @throws SystemException if a system exception occurred
15706             */
15707            public void removeByG_L(long groupId, String layoutUuid)
15708                    throws SystemException {
15709                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid)) {
15710                            remove(journalArticle);
15711                    }
15712            }
15713    
15714            /**
15715             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
15716             *
15717             * @param groupId the group ID
15718             * @param status the status
15719             * @throws SystemException if a system exception occurred
15720             */
15721            public void removeByG_ST(long groupId, int status)
15722                    throws SystemException {
15723                    for (JournalArticle journalArticle : findByG_ST(groupId, status)) {
15724                            remove(journalArticle);
15725                    }
15726            }
15727    
15728            /**
15729             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
15730             *
15731             * @param companyId the company ID
15732             * @param version the version
15733             * @throws SystemException if a system exception occurred
15734             */
15735            public void removeByC_V(long companyId, double version)
15736                    throws SystemException {
15737                    for (JournalArticle journalArticle : findByC_V(companyId, version)) {
15738                            remove(journalArticle);
15739                    }
15740            }
15741    
15742            /**
15743             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
15744             *
15745             * @param companyId the company ID
15746             * @param status the status
15747             * @throws SystemException if a system exception occurred
15748             */
15749            public void removeByC_ST(long companyId, int status)
15750                    throws SystemException {
15751                    for (JournalArticle journalArticle : findByC_ST(companyId, status)) {
15752                            remove(journalArticle);
15753                    }
15754            }
15755    
15756            /**
15757             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
15758             *
15759             * @param groupId the group ID
15760             * @param classNameId the class name ID
15761             * @param classPK the class p k
15762             * @throws SystemException if a system exception occurred
15763             */
15764            public void removeByG_C_C(long groupId, long classNameId, long classPK)
15765                    throws SystemException {
15766                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
15767                                    classPK)) {
15768                            remove(journalArticle);
15769                    }
15770            }
15771    
15772            /**
15773             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
15774             *
15775             * @param groupId the group ID
15776             * @param classNameId the class name ID
15777             * @param structureId the structure ID
15778             * @throws SystemException if a system exception occurred
15779             */
15780            public void removeByG_C_S(long groupId, long classNameId, String structureId)
15781                    throws NoSuchArticleException, SystemException {
15782                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
15783                                    structureId);
15784    
15785                    remove(journalArticle);
15786            }
15787    
15788            /**
15789             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
15790             *
15791             * @param groupId the group ID
15792             * @param classNameId the class name ID
15793             * @param templateId the template ID
15794             * @throws SystemException if a system exception occurred
15795             */
15796            public void removeByG_C_T(long groupId, long classNameId, String templateId)
15797                    throws SystemException {
15798                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
15799                                    templateId)) {
15800                            remove(journalArticle);
15801                    }
15802            }
15803    
15804            /**
15805             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
15806             *
15807             * @param groupId the group ID
15808             * @param classNameId the class name ID
15809             * @param layoutUuid the layout uuid
15810             * @throws SystemException if a system exception occurred
15811             */
15812            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
15813                    throws SystemException {
15814                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
15815                                    layoutUuid)) {
15816                            remove(journalArticle);
15817                    }
15818            }
15819    
15820            /**
15821             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
15822             *
15823             * @param groupId the group ID
15824             * @param articleId the article ID
15825             * @param version the version
15826             * @throws SystemException if a system exception occurred
15827             */
15828            public void removeByG_A_V(long groupId, String articleId, double version)
15829                    throws NoSuchArticleException, SystemException {
15830                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
15831    
15832                    remove(journalArticle);
15833            }
15834    
15835            /**
15836             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
15837             *
15838             * @param groupId the group ID
15839             * @param articleId the article ID
15840             * @param status the status
15841             * @throws SystemException if a system exception occurred
15842             */
15843            public void removeByG_A_ST(long groupId, String articleId, int status)
15844                    throws SystemException {
15845                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
15846                                    status)) {
15847                            remove(journalArticle);
15848                    }
15849            }
15850    
15851            /**
15852             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
15853             *
15854             * @param groupId the group ID
15855             * @param urlTitle the url title
15856             * @param status the status
15857             * @throws SystemException if a system exception occurred
15858             */
15859            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
15860                    throws SystemException {
15861                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
15862                                    status)) {
15863                            remove(journalArticle);
15864                    }
15865            }
15866    
15867            /**
15868             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
15869             *
15870             * @param companyId the company ID
15871             * @param version the version
15872             * @param status the status
15873             * @throws SystemException if a system exception occurred
15874             */
15875            public void removeByC_V_ST(long companyId, double version, int status)
15876                    throws SystemException {
15877                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
15878                                    status)) {
15879                            remove(journalArticle);
15880                    }
15881            }
15882    
15883            /**
15884             * Removes all the journal articles from the database.
15885             *
15886             * @throws SystemException if a system exception occurred
15887             */
15888            public void removeAll() throws SystemException {
15889                    for (JournalArticle journalArticle : findAll()) {
15890                            remove(journalArticle);
15891                    }
15892            }
15893    
15894            /**
15895             * Returns the number of journal articles where uuid = &#63;.
15896             *
15897             * @param uuid the uuid
15898             * @return the number of matching journal articles
15899             * @throws SystemException if a system exception occurred
15900             */
15901            public int countByUuid(String uuid) throws SystemException {
15902                    Object[] finderArgs = new Object[] { uuid };
15903    
15904                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
15905                                    finderArgs, this);
15906    
15907                    if (count == null) {
15908                            StringBundler query = new StringBundler(2);
15909    
15910                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15911    
15912                            if (uuid == null) {
15913                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
15914                            }
15915                            else {
15916                                    if (uuid.equals(StringPool.BLANK)) {
15917                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
15918                                    }
15919                                    else {
15920                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
15921                                    }
15922                            }
15923    
15924                            String sql = query.toString();
15925    
15926                            Session session = null;
15927    
15928                            try {
15929                                    session = openSession();
15930    
15931                                    Query q = session.createQuery(sql);
15932    
15933                                    QueryPos qPos = QueryPos.getInstance(q);
15934    
15935                                    if (uuid != null) {
15936                                            qPos.add(uuid);
15937                                    }
15938    
15939                                    count = (Long)q.uniqueResult();
15940                            }
15941                            catch (Exception e) {
15942                                    throw processException(e);
15943                            }
15944                            finally {
15945                                    if (count == null) {
15946                                            count = Long.valueOf(0);
15947                                    }
15948    
15949                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
15950                                            finderArgs, count);
15951    
15952                                    closeSession(session);
15953                            }
15954                    }
15955    
15956                    return count.intValue();
15957            }
15958    
15959            /**
15960             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
15961             *
15962             * @param uuid the uuid
15963             * @param groupId the group ID
15964             * @return the number of matching journal articles
15965             * @throws SystemException if a system exception occurred
15966             */
15967            public int countByUUID_G(String uuid, long groupId)
15968                    throws SystemException {
15969                    Object[] finderArgs = new Object[] { uuid, groupId };
15970    
15971                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
15972                                    finderArgs, this);
15973    
15974                    if (count == null) {
15975                            StringBundler query = new StringBundler(3);
15976    
15977                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15978    
15979                            if (uuid == null) {
15980                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
15981                            }
15982                            else {
15983                                    if (uuid.equals(StringPool.BLANK)) {
15984                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
15985                                    }
15986                                    else {
15987                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
15988                                    }
15989                            }
15990    
15991                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
15992    
15993                            String sql = query.toString();
15994    
15995                            Session session = null;
15996    
15997                            try {
15998                                    session = openSession();
15999    
16000                                    Query q = session.createQuery(sql);
16001    
16002                                    QueryPos qPos = QueryPos.getInstance(q);
16003    
16004                                    if (uuid != null) {
16005                                            qPos.add(uuid);
16006                                    }
16007    
16008                                    qPos.add(groupId);
16009    
16010                                    count = (Long)q.uniqueResult();
16011                            }
16012                            catch (Exception e) {
16013                                    throw processException(e);
16014                            }
16015                            finally {
16016                                    if (count == null) {
16017                                            count = Long.valueOf(0);
16018                                    }
16019    
16020                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
16021                                            finderArgs, count);
16022    
16023                                    closeSession(session);
16024                            }
16025                    }
16026    
16027                    return count.intValue();
16028            }
16029    
16030            /**
16031             * Returns the number of journal articles where resourcePrimKey = &#63;.
16032             *
16033             * @param resourcePrimKey the resource prim key
16034             * @return the number of matching journal articles
16035             * @throws SystemException if a system exception occurred
16036             */
16037            public int countByResourcePrimKey(long resourcePrimKey)
16038                    throws SystemException {
16039                    Object[] finderArgs = new Object[] { resourcePrimKey };
16040    
16041                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
16042                                    finderArgs, this);
16043    
16044                    if (count == null) {
16045                            StringBundler query = new StringBundler(2);
16046    
16047                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16048    
16049                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
16050    
16051                            String sql = query.toString();
16052    
16053                            Session session = null;
16054    
16055                            try {
16056                                    session = openSession();
16057    
16058                                    Query q = session.createQuery(sql);
16059    
16060                                    QueryPos qPos = QueryPos.getInstance(q);
16061    
16062                                    qPos.add(resourcePrimKey);
16063    
16064                                    count = (Long)q.uniqueResult();
16065                            }
16066                            catch (Exception e) {
16067                                    throw processException(e);
16068                            }
16069                            finally {
16070                                    if (count == null) {
16071                                            count = Long.valueOf(0);
16072                                    }
16073    
16074                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
16075                                            finderArgs, count);
16076    
16077                                    closeSession(session);
16078                            }
16079                    }
16080    
16081                    return count.intValue();
16082            }
16083    
16084            /**
16085             * Returns the number of journal articles where groupId = &#63;.
16086             *
16087             * @param groupId the group ID
16088             * @return the number of matching journal articles
16089             * @throws SystemException if a system exception occurred
16090             */
16091            public int countByGroupId(long groupId) throws SystemException {
16092                    Object[] finderArgs = new Object[] { groupId };
16093    
16094                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
16095                                    finderArgs, this);
16096    
16097                    if (count == null) {
16098                            StringBundler query = new StringBundler(2);
16099    
16100                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16101    
16102                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
16103    
16104                            String sql = query.toString();
16105    
16106                            Session session = null;
16107    
16108                            try {
16109                                    session = openSession();
16110    
16111                                    Query q = session.createQuery(sql);
16112    
16113                                    QueryPos qPos = QueryPos.getInstance(q);
16114    
16115                                    qPos.add(groupId);
16116    
16117                                    count = (Long)q.uniqueResult();
16118                            }
16119                            catch (Exception e) {
16120                                    throw processException(e);
16121                            }
16122                            finally {
16123                                    if (count == null) {
16124                                            count = Long.valueOf(0);
16125                                    }
16126    
16127                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
16128                                            finderArgs, count);
16129    
16130                                    closeSession(session);
16131                            }
16132                    }
16133    
16134                    return count.intValue();
16135            }
16136    
16137            /**
16138             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
16139             *
16140             * @param groupId the group ID
16141             * @return the number of matching journal articles that the user has permission to view
16142             * @throws SystemException if a system exception occurred
16143             */
16144            public int filterCountByGroupId(long groupId) throws SystemException {
16145                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16146                            return countByGroupId(groupId);
16147                    }
16148    
16149                    StringBundler query = new StringBundler(2);
16150    
16151                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16152    
16153                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
16154    
16155                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16156                                    JournalArticle.class.getName(),
16157                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16158    
16159                    Session session = null;
16160    
16161                    try {
16162                            session = openSession();
16163    
16164                            SQLQuery q = session.createSQLQuery(sql);
16165    
16166                            q.addScalar(COUNT_COLUMN_NAME,
16167                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16168    
16169                            QueryPos qPos = QueryPos.getInstance(q);
16170    
16171                            qPos.add(groupId);
16172    
16173                            Long count = (Long)q.uniqueResult();
16174    
16175                            return count.intValue();
16176                    }
16177                    catch (Exception e) {
16178                            throw processException(e);
16179                    }
16180                    finally {
16181                            closeSession(session);
16182                    }
16183            }
16184    
16185            /**
16186             * Returns the number of journal articles where companyId = &#63;.
16187             *
16188             * @param companyId the company ID
16189             * @return the number of matching journal articles
16190             * @throws SystemException if a system exception occurred
16191             */
16192            public int countByCompanyId(long companyId) throws SystemException {
16193                    Object[] finderArgs = new Object[] { companyId };
16194    
16195                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
16196                                    finderArgs, this);
16197    
16198                    if (count == null) {
16199                            StringBundler query = new StringBundler(2);
16200    
16201                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16202    
16203                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
16204    
16205                            String sql = query.toString();
16206    
16207                            Session session = null;
16208    
16209                            try {
16210                                    session = openSession();
16211    
16212                                    Query q = session.createQuery(sql);
16213    
16214                                    QueryPos qPos = QueryPos.getInstance(q);
16215    
16216                                    qPos.add(companyId);
16217    
16218                                    count = (Long)q.uniqueResult();
16219                            }
16220                            catch (Exception e) {
16221                                    throw processException(e);
16222                            }
16223                            finally {
16224                                    if (count == null) {
16225                                            count = Long.valueOf(0);
16226                                    }
16227    
16228                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
16229                                            finderArgs, count);
16230    
16231                                    closeSession(session);
16232                            }
16233                    }
16234    
16235                    return count.intValue();
16236            }
16237    
16238            /**
16239             * Returns the number of journal articles where structureId = &#63;.
16240             *
16241             * @param structureId the structure ID
16242             * @return the number of matching journal articles
16243             * @throws SystemException if a system exception occurred
16244             */
16245            public int countByStructureId(String structureId) throws SystemException {
16246                    Object[] finderArgs = new Object[] { structureId };
16247    
16248                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
16249                                    finderArgs, this);
16250    
16251                    if (count == null) {
16252                            StringBundler query = new StringBundler(2);
16253    
16254                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16255    
16256                            if (structureId == null) {
16257                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
16258                            }
16259                            else {
16260                                    if (structureId.equals(StringPool.BLANK)) {
16261                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
16262                                    }
16263                                    else {
16264                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
16265                                    }
16266                            }
16267    
16268                            String sql = query.toString();
16269    
16270                            Session session = null;
16271    
16272                            try {
16273                                    session = openSession();
16274    
16275                                    Query q = session.createQuery(sql);
16276    
16277                                    QueryPos qPos = QueryPos.getInstance(q);
16278    
16279                                    if (structureId != null) {
16280                                            qPos.add(structureId);
16281                                    }
16282    
16283                                    count = (Long)q.uniqueResult();
16284                            }
16285                            catch (Exception e) {
16286                                    throw processException(e);
16287                            }
16288                            finally {
16289                                    if (count == null) {
16290                                            count = Long.valueOf(0);
16291                                    }
16292    
16293                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
16294                                            finderArgs, count);
16295    
16296                                    closeSession(session);
16297                            }
16298                    }
16299    
16300                    return count.intValue();
16301            }
16302    
16303            /**
16304             * Returns the number of journal articles where templateId = &#63;.
16305             *
16306             * @param templateId the template ID
16307             * @return the number of matching journal articles
16308             * @throws SystemException if a system exception occurred
16309             */
16310            public int countByTemplateId(String templateId) throws SystemException {
16311                    Object[] finderArgs = new Object[] { templateId };
16312    
16313                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
16314                                    finderArgs, this);
16315    
16316                    if (count == null) {
16317                            StringBundler query = new StringBundler(2);
16318    
16319                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16320    
16321                            if (templateId == null) {
16322                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
16323                            }
16324                            else {
16325                                    if (templateId.equals(StringPool.BLANK)) {
16326                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
16327                                    }
16328                                    else {
16329                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
16330                                    }
16331                            }
16332    
16333                            String sql = query.toString();
16334    
16335                            Session session = null;
16336    
16337                            try {
16338                                    session = openSession();
16339    
16340                                    Query q = session.createQuery(sql);
16341    
16342                                    QueryPos qPos = QueryPos.getInstance(q);
16343    
16344                                    if (templateId != null) {
16345                                            qPos.add(templateId);
16346                                    }
16347    
16348                                    count = (Long)q.uniqueResult();
16349                            }
16350                            catch (Exception e) {
16351                                    throw processException(e);
16352                            }
16353                            finally {
16354                                    if (count == null) {
16355                                            count = Long.valueOf(0);
16356                                    }
16357    
16358                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
16359                                            finderArgs, count);
16360    
16361                                    closeSession(session);
16362                            }
16363                    }
16364    
16365                    return count.intValue();
16366            }
16367    
16368            /**
16369             * Returns the number of journal articles where smallImageId = &#63;.
16370             *
16371             * @param smallImageId the small image ID
16372             * @return the number of matching journal articles
16373             * @throws SystemException if a system exception occurred
16374             */
16375            public int countBySmallImageId(long smallImageId) throws SystemException {
16376                    Object[] finderArgs = new Object[] { smallImageId };
16377    
16378                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
16379                                    finderArgs, this);
16380    
16381                    if (count == null) {
16382                            StringBundler query = new StringBundler(2);
16383    
16384                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16385    
16386                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
16387    
16388                            String sql = query.toString();
16389    
16390                            Session session = null;
16391    
16392                            try {
16393                                    session = openSession();
16394    
16395                                    Query q = session.createQuery(sql);
16396    
16397                                    QueryPos qPos = QueryPos.getInstance(q);
16398    
16399                                    qPos.add(smallImageId);
16400    
16401                                    count = (Long)q.uniqueResult();
16402                            }
16403                            catch (Exception e) {
16404                                    throw processException(e);
16405                            }
16406                            finally {
16407                                    if (count == null) {
16408                                            count = Long.valueOf(0);
16409                                    }
16410    
16411                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
16412                                            finderArgs, count);
16413    
16414                                    closeSession(session);
16415                            }
16416                    }
16417    
16418                    return count.intValue();
16419            }
16420    
16421            /**
16422             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
16423             *
16424             * @param resourcePrimKey the resource prim key
16425             * @param status the status
16426             * @return the number of matching journal articles
16427             * @throws SystemException if a system exception occurred
16428             */
16429            public int countByR_ST(long resourcePrimKey, int status)
16430                    throws SystemException {
16431                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
16432    
16433                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_ST,
16434                                    finderArgs, this);
16435    
16436                    if (count == null) {
16437                            StringBundler query = new StringBundler(3);
16438    
16439                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16440    
16441                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
16442    
16443                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
16444    
16445                            String sql = query.toString();
16446    
16447                            Session session = null;
16448    
16449                            try {
16450                                    session = openSession();
16451    
16452                                    Query q = session.createQuery(sql);
16453    
16454                                    QueryPos qPos = QueryPos.getInstance(q);
16455    
16456                                    qPos.add(resourcePrimKey);
16457    
16458                                    qPos.add(status);
16459    
16460                                    count = (Long)q.uniqueResult();
16461                            }
16462                            catch (Exception e) {
16463                                    throw processException(e);
16464                            }
16465                            finally {
16466                                    if (count == null) {
16467                                            count = Long.valueOf(0);
16468                                    }
16469    
16470                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_ST,
16471                                            finderArgs, count);
16472    
16473                                    closeSession(session);
16474                            }
16475                    }
16476    
16477                    return count.intValue();
16478            }
16479    
16480            /**
16481             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
16482             *
16483             * @param groupId the group ID
16484             * @param articleId the article ID
16485             * @return the number of matching journal articles
16486             * @throws SystemException if a system exception occurred
16487             */
16488            public int countByG_A(long groupId, String articleId)
16489                    throws SystemException {
16490                    Object[] finderArgs = new Object[] { groupId, articleId };
16491    
16492                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
16493                                    finderArgs, this);
16494    
16495                    if (count == null) {
16496                            StringBundler query = new StringBundler(3);
16497    
16498                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16499    
16500                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
16501    
16502                            if (articleId == null) {
16503                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
16504                            }
16505                            else {
16506                                    if (articleId.equals(StringPool.BLANK)) {
16507                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
16508                                    }
16509                                    else {
16510                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
16511                                    }
16512                            }
16513    
16514                            String sql = query.toString();
16515    
16516                            Session session = null;
16517    
16518                            try {
16519                                    session = openSession();
16520    
16521                                    Query q = session.createQuery(sql);
16522    
16523                                    QueryPos qPos = QueryPos.getInstance(q);
16524    
16525                                    qPos.add(groupId);
16526    
16527                                    if (articleId != null) {
16528                                            qPos.add(articleId);
16529                                    }
16530    
16531                                    count = (Long)q.uniqueResult();
16532                            }
16533                            catch (Exception e) {
16534                                    throw processException(e);
16535                            }
16536                            finally {
16537                                    if (count == null) {
16538                                            count = Long.valueOf(0);
16539                                    }
16540    
16541                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
16542                                            count);
16543    
16544                                    closeSession(session);
16545                            }
16546                    }
16547    
16548                    return count.intValue();
16549            }
16550    
16551            /**
16552             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
16553             *
16554             * @param groupId the group ID
16555             * @param articleId the article ID
16556             * @return the number of matching journal articles that the user has permission to view
16557             * @throws SystemException if a system exception occurred
16558             */
16559            public int filterCountByG_A(long groupId, String articleId)
16560                    throws SystemException {
16561                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16562                            return countByG_A(groupId, articleId);
16563                    }
16564    
16565                    StringBundler query = new StringBundler(3);
16566    
16567                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16568    
16569                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
16570    
16571                    if (articleId == null) {
16572                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
16573                    }
16574                    else {
16575                            if (articleId.equals(StringPool.BLANK)) {
16576                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
16577                            }
16578                            else {
16579                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
16580                            }
16581                    }
16582    
16583                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16584                                    JournalArticle.class.getName(),
16585                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16586    
16587                    Session session = null;
16588    
16589                    try {
16590                            session = openSession();
16591    
16592                            SQLQuery q = session.createSQLQuery(sql);
16593    
16594                            q.addScalar(COUNT_COLUMN_NAME,
16595                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16596    
16597                            QueryPos qPos = QueryPos.getInstance(q);
16598    
16599                            qPos.add(groupId);
16600    
16601                            if (articleId != null) {
16602                                    qPos.add(articleId);
16603                            }
16604    
16605                            Long count = (Long)q.uniqueResult();
16606    
16607                            return count.intValue();
16608                    }
16609                    catch (Exception e) {
16610                            throw processException(e);
16611                    }
16612                    finally {
16613                            closeSession(session);
16614                    }
16615            }
16616    
16617            /**
16618             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
16619             *
16620             * @param groupId the group ID
16621             * @param urlTitle the url title
16622             * @return the number of matching journal articles
16623             * @throws SystemException if a system exception occurred
16624             */
16625            public int countByG_UT(long groupId, String urlTitle)
16626                    throws SystemException {
16627                    Object[] finderArgs = new Object[] { groupId, urlTitle };
16628    
16629                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT,
16630                                    finderArgs, this);
16631    
16632                    if (count == null) {
16633                            StringBundler query = new StringBundler(3);
16634    
16635                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16636    
16637                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
16638    
16639                            if (urlTitle == null) {
16640                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
16641                            }
16642                            else {
16643                                    if (urlTitle.equals(StringPool.BLANK)) {
16644                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
16645                                    }
16646                                    else {
16647                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
16648                                    }
16649                            }
16650    
16651                            String sql = query.toString();
16652    
16653                            Session session = null;
16654    
16655                            try {
16656                                    session = openSession();
16657    
16658                                    Query q = session.createQuery(sql);
16659    
16660                                    QueryPos qPos = QueryPos.getInstance(q);
16661    
16662                                    qPos.add(groupId);
16663    
16664                                    if (urlTitle != null) {
16665                                            qPos.add(urlTitle);
16666                                    }
16667    
16668                                    count = (Long)q.uniqueResult();
16669                            }
16670                            catch (Exception e) {
16671                                    throw processException(e);
16672                            }
16673                            finally {
16674                                    if (count == null) {
16675                                            count = Long.valueOf(0);
16676                                    }
16677    
16678                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT,
16679                                            finderArgs, count);
16680    
16681                                    closeSession(session);
16682                            }
16683                    }
16684    
16685                    return count.intValue();
16686            }
16687    
16688            /**
16689             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
16690             *
16691             * @param groupId the group ID
16692             * @param urlTitle the url title
16693             * @return the number of matching journal articles that the user has permission to view
16694             * @throws SystemException if a system exception occurred
16695             */
16696            public int filterCountByG_UT(long groupId, String urlTitle)
16697                    throws SystemException {
16698                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16699                            return countByG_UT(groupId, urlTitle);
16700                    }
16701    
16702                    StringBundler query = new StringBundler(3);
16703    
16704                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16705    
16706                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
16707    
16708                    if (urlTitle == null) {
16709                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
16710                    }
16711                    else {
16712                            if (urlTitle.equals(StringPool.BLANK)) {
16713                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
16714                            }
16715                            else {
16716                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
16717                            }
16718                    }
16719    
16720                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16721                                    JournalArticle.class.getName(),
16722                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16723    
16724                    Session session = null;
16725    
16726                    try {
16727                            session = openSession();
16728    
16729                            SQLQuery q = session.createSQLQuery(sql);
16730    
16731                            q.addScalar(COUNT_COLUMN_NAME,
16732                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16733    
16734                            QueryPos qPos = QueryPos.getInstance(q);
16735    
16736                            qPos.add(groupId);
16737    
16738                            if (urlTitle != null) {
16739                                    qPos.add(urlTitle);
16740                            }
16741    
16742                            Long count = (Long)q.uniqueResult();
16743    
16744                            return count.intValue();
16745                    }
16746                    catch (Exception e) {
16747                            throw processException(e);
16748                    }
16749                    finally {
16750                            closeSession(session);
16751                    }
16752            }
16753    
16754            /**
16755             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
16756             *
16757             * @param groupId the group ID
16758             * @param structureId the structure ID
16759             * @return the number of matching journal articles
16760             * @throws SystemException if a system exception occurred
16761             */
16762            public int countByG_S(long groupId, String structureId)
16763                    throws SystemException {
16764                    Object[] finderArgs = new Object[] { groupId, structureId };
16765    
16766                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
16767                                    finderArgs, this);
16768    
16769                    if (count == null) {
16770                            StringBundler query = new StringBundler(3);
16771    
16772                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16773    
16774                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
16775    
16776                            if (structureId == null) {
16777                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
16778                            }
16779                            else {
16780                                    if (structureId.equals(StringPool.BLANK)) {
16781                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
16782                                    }
16783                                    else {
16784                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
16785                                    }
16786                            }
16787    
16788                            String sql = query.toString();
16789    
16790                            Session session = null;
16791    
16792                            try {
16793                                    session = openSession();
16794    
16795                                    Query q = session.createQuery(sql);
16796    
16797                                    QueryPos qPos = QueryPos.getInstance(q);
16798    
16799                                    qPos.add(groupId);
16800    
16801                                    if (structureId != null) {
16802                                            qPos.add(structureId);
16803                                    }
16804    
16805                                    count = (Long)q.uniqueResult();
16806                            }
16807                            catch (Exception e) {
16808                                    throw processException(e);
16809                            }
16810                            finally {
16811                                    if (count == null) {
16812                                            count = Long.valueOf(0);
16813                                    }
16814    
16815                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
16816                                            count);
16817    
16818                                    closeSession(session);
16819                            }
16820                    }
16821    
16822                    return count.intValue();
16823            }
16824    
16825            /**
16826             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
16827             *
16828             * @param groupId the group ID
16829             * @param structureId the structure ID
16830             * @return the number of matching journal articles that the user has permission to view
16831             * @throws SystemException if a system exception occurred
16832             */
16833            public int filterCountByG_S(long groupId, String structureId)
16834                    throws SystemException {
16835                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16836                            return countByG_S(groupId, structureId);
16837                    }
16838    
16839                    StringBundler query = new StringBundler(3);
16840    
16841                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16842    
16843                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
16844    
16845                    if (structureId == null) {
16846                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
16847                    }
16848                    else {
16849                            if (structureId.equals(StringPool.BLANK)) {
16850                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
16851                            }
16852                            else {
16853                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
16854                            }
16855                    }
16856    
16857                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16858                                    JournalArticle.class.getName(),
16859                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16860    
16861                    Session session = null;
16862    
16863                    try {
16864                            session = openSession();
16865    
16866                            SQLQuery q = session.createSQLQuery(sql);
16867    
16868                            q.addScalar(COUNT_COLUMN_NAME,
16869                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16870    
16871                            QueryPos qPos = QueryPos.getInstance(q);
16872    
16873                            qPos.add(groupId);
16874    
16875                            if (structureId != null) {
16876                                    qPos.add(structureId);
16877                            }
16878    
16879                            Long count = (Long)q.uniqueResult();
16880    
16881                            return count.intValue();
16882                    }
16883                    catch (Exception e) {
16884                            throw processException(e);
16885                    }
16886                    finally {
16887                            closeSession(session);
16888                    }
16889            }
16890    
16891            /**
16892             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
16893             *
16894             * @param groupId the group ID
16895             * @param templateId the template ID
16896             * @return the number of matching journal articles
16897             * @throws SystemException if a system exception occurred
16898             */
16899            public int countByG_T(long groupId, String templateId)
16900                    throws SystemException {
16901                    Object[] finderArgs = new Object[] { groupId, templateId };
16902    
16903                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T,
16904                                    finderArgs, this);
16905    
16906                    if (count == null) {
16907                            StringBundler query = new StringBundler(3);
16908    
16909                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16910    
16911                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
16912    
16913                            if (templateId == null) {
16914                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
16915                            }
16916                            else {
16917                                    if (templateId.equals(StringPool.BLANK)) {
16918                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
16919                                    }
16920                                    else {
16921                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
16922                                    }
16923                            }
16924    
16925                            String sql = query.toString();
16926    
16927                            Session session = null;
16928    
16929                            try {
16930                                    session = openSession();
16931    
16932                                    Query q = session.createQuery(sql);
16933    
16934                                    QueryPos qPos = QueryPos.getInstance(q);
16935    
16936                                    qPos.add(groupId);
16937    
16938                                    if (templateId != null) {
16939                                            qPos.add(templateId);
16940                                    }
16941    
16942                                    count = (Long)q.uniqueResult();
16943                            }
16944                            catch (Exception e) {
16945                                    throw processException(e);
16946                            }
16947                            finally {
16948                                    if (count == null) {
16949                                            count = Long.valueOf(0);
16950                                    }
16951    
16952                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_T, finderArgs,
16953                                            count);
16954    
16955                                    closeSession(session);
16956                            }
16957                    }
16958    
16959                    return count.intValue();
16960            }
16961    
16962            /**
16963             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
16964             *
16965             * @param groupId the group ID
16966             * @param templateId the template ID
16967             * @return the number of matching journal articles that the user has permission to view
16968             * @throws SystemException if a system exception occurred
16969             */
16970            public int filterCountByG_T(long groupId, String templateId)
16971                    throws SystemException {
16972                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16973                            return countByG_T(groupId, templateId);
16974                    }
16975    
16976                    StringBundler query = new StringBundler(3);
16977    
16978                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16979    
16980                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
16981    
16982                    if (templateId == null) {
16983                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
16984                    }
16985                    else {
16986                            if (templateId.equals(StringPool.BLANK)) {
16987                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
16988                            }
16989                            else {
16990                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
16991                            }
16992                    }
16993    
16994                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16995                                    JournalArticle.class.getName(),
16996                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16997    
16998                    Session session = null;
16999    
17000                    try {
17001                            session = openSession();
17002    
17003                            SQLQuery q = session.createSQLQuery(sql);
17004    
17005                            q.addScalar(COUNT_COLUMN_NAME,
17006                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17007    
17008                            QueryPos qPos = QueryPos.getInstance(q);
17009    
17010                            qPos.add(groupId);
17011    
17012                            if (templateId != null) {
17013                                    qPos.add(templateId);
17014                            }
17015    
17016                            Long count = (Long)q.uniqueResult();
17017    
17018                            return count.intValue();
17019                    }
17020                    catch (Exception e) {
17021                            throw processException(e);
17022                    }
17023                    finally {
17024                            closeSession(session);
17025                    }
17026            }
17027    
17028            /**
17029             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
17030             *
17031             * @param groupId the group ID
17032             * @param layoutUuid the layout uuid
17033             * @return the number of matching journal articles
17034             * @throws SystemException if a system exception occurred
17035             */
17036            public int countByG_L(long groupId, String layoutUuid)
17037                    throws SystemException {
17038                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
17039    
17040                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_L,
17041                                    finderArgs, this);
17042    
17043                    if (count == null) {
17044                            StringBundler query = new StringBundler(3);
17045    
17046                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17047    
17048                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
17049    
17050                            if (layoutUuid == null) {
17051                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
17052                            }
17053                            else {
17054                                    if (layoutUuid.equals(StringPool.BLANK)) {
17055                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
17056                                    }
17057                                    else {
17058                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
17059                                    }
17060                            }
17061    
17062                            String sql = query.toString();
17063    
17064                            Session session = null;
17065    
17066                            try {
17067                                    session = openSession();
17068    
17069                                    Query q = session.createQuery(sql);
17070    
17071                                    QueryPos qPos = QueryPos.getInstance(q);
17072    
17073                                    qPos.add(groupId);
17074    
17075                                    if (layoutUuid != null) {
17076                                            qPos.add(layoutUuid);
17077                                    }
17078    
17079                                    count = (Long)q.uniqueResult();
17080                            }
17081                            catch (Exception e) {
17082                                    throw processException(e);
17083                            }
17084                            finally {
17085                                    if (count == null) {
17086                                            count = Long.valueOf(0);
17087                                    }
17088    
17089                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_L, finderArgs,
17090                                            count);
17091    
17092                                    closeSession(session);
17093                            }
17094                    }
17095    
17096                    return count.intValue();
17097            }
17098    
17099            /**
17100             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
17101             *
17102             * @param groupId the group ID
17103             * @param layoutUuid the layout uuid
17104             * @return the number of matching journal articles that the user has permission to view
17105             * @throws SystemException if a system exception occurred
17106             */
17107            public int filterCountByG_L(long groupId, String layoutUuid)
17108                    throws SystemException {
17109                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17110                            return countByG_L(groupId, layoutUuid);
17111                    }
17112    
17113                    StringBundler query = new StringBundler(3);
17114    
17115                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17116    
17117                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
17118    
17119                    if (layoutUuid == null) {
17120                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
17121                    }
17122                    else {
17123                            if (layoutUuid.equals(StringPool.BLANK)) {
17124                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
17125                            }
17126                            else {
17127                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
17128                            }
17129                    }
17130    
17131                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17132                                    JournalArticle.class.getName(),
17133                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17134    
17135                    Session session = null;
17136    
17137                    try {
17138                            session = openSession();
17139    
17140                            SQLQuery q = session.createSQLQuery(sql);
17141    
17142                            q.addScalar(COUNT_COLUMN_NAME,
17143                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17144    
17145                            QueryPos qPos = QueryPos.getInstance(q);
17146    
17147                            qPos.add(groupId);
17148    
17149                            if (layoutUuid != null) {
17150                                    qPos.add(layoutUuid);
17151                            }
17152    
17153                            Long count = (Long)q.uniqueResult();
17154    
17155                            return count.intValue();
17156                    }
17157                    catch (Exception e) {
17158                            throw processException(e);
17159                    }
17160                    finally {
17161                            closeSession(session);
17162                    }
17163            }
17164    
17165            /**
17166             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
17167             *
17168             * @param groupId the group ID
17169             * @param status the status
17170             * @return the number of matching journal articles
17171             * @throws SystemException if a system exception occurred
17172             */
17173            public int countByG_ST(long groupId, int status) throws SystemException {
17174                    Object[] finderArgs = new Object[] { groupId, status };
17175    
17176                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_ST,
17177                                    finderArgs, this);
17178    
17179                    if (count == null) {
17180                            StringBundler query = new StringBundler(3);
17181    
17182                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17183    
17184                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
17185    
17186                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
17187    
17188                            String sql = query.toString();
17189    
17190                            Session session = null;
17191    
17192                            try {
17193                                    session = openSession();
17194    
17195                                    Query q = session.createQuery(sql);
17196    
17197                                    QueryPos qPos = QueryPos.getInstance(q);
17198    
17199                                    qPos.add(groupId);
17200    
17201                                    qPos.add(status);
17202    
17203                                    count = (Long)q.uniqueResult();
17204                            }
17205                            catch (Exception e) {
17206                                    throw processException(e);
17207                            }
17208                            finally {
17209                                    if (count == null) {
17210                                            count = Long.valueOf(0);
17211                                    }
17212    
17213                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_ST,
17214                                            finderArgs, count);
17215    
17216                                    closeSession(session);
17217                            }
17218                    }
17219    
17220                    return count.intValue();
17221            }
17222    
17223            /**
17224             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
17225             *
17226             * @param groupId the group ID
17227             * @param status the status
17228             * @return the number of matching journal articles that the user has permission to view
17229             * @throws SystemException if a system exception occurred
17230             */
17231            public int filterCountByG_ST(long groupId, int status)
17232                    throws SystemException {
17233                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17234                            return countByG_ST(groupId, status);
17235                    }
17236    
17237                    StringBundler query = new StringBundler(3);
17238    
17239                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17240    
17241                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
17242    
17243                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
17244    
17245                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17246                                    JournalArticle.class.getName(),
17247                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17248    
17249                    Session session = null;
17250    
17251                    try {
17252                            session = openSession();
17253    
17254                            SQLQuery q = session.createSQLQuery(sql);
17255    
17256                            q.addScalar(COUNT_COLUMN_NAME,
17257                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17258    
17259                            QueryPos qPos = QueryPos.getInstance(q);
17260    
17261                            qPos.add(groupId);
17262    
17263                            qPos.add(status);
17264    
17265                            Long count = (Long)q.uniqueResult();
17266    
17267                            return count.intValue();
17268                    }
17269                    catch (Exception e) {
17270                            throw processException(e);
17271                    }
17272                    finally {
17273                            closeSession(session);
17274                    }
17275            }
17276    
17277            /**
17278             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
17279             *
17280             * @param companyId the company ID
17281             * @param version the version
17282             * @return the number of matching journal articles
17283             * @throws SystemException if a system exception occurred
17284             */
17285            public int countByC_V(long companyId, double version)
17286                    throws SystemException {
17287                    Object[] finderArgs = new Object[] { companyId, version };
17288    
17289                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V,
17290                                    finderArgs, this);
17291    
17292                    if (count == null) {
17293                            StringBundler query = new StringBundler(3);
17294    
17295                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17296    
17297                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
17298    
17299                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
17300    
17301                            String sql = query.toString();
17302    
17303                            Session session = null;
17304    
17305                            try {
17306                                    session = openSession();
17307    
17308                                    Query q = session.createQuery(sql);
17309    
17310                                    QueryPos qPos = QueryPos.getInstance(q);
17311    
17312                                    qPos.add(companyId);
17313    
17314                                    qPos.add(version);
17315    
17316                                    count = (Long)q.uniqueResult();
17317                            }
17318                            catch (Exception e) {
17319                                    throw processException(e);
17320                            }
17321                            finally {
17322                                    if (count == null) {
17323                                            count = Long.valueOf(0);
17324                                    }
17325    
17326                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V, finderArgs,
17327                                            count);
17328    
17329                                    closeSession(session);
17330                            }
17331                    }
17332    
17333                    return count.intValue();
17334            }
17335    
17336            /**
17337             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
17338             *
17339             * @param companyId the company ID
17340             * @param status the status
17341             * @return the number of matching journal articles
17342             * @throws SystemException if a system exception occurred
17343             */
17344            public int countByC_ST(long companyId, int status)
17345                    throws SystemException {
17346                    Object[] finderArgs = new Object[] { companyId, status };
17347    
17348                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_ST,
17349                                    finderArgs, this);
17350    
17351                    if (count == null) {
17352                            StringBundler query = new StringBundler(3);
17353    
17354                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17355    
17356                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
17357    
17358                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
17359    
17360                            String sql = query.toString();
17361    
17362                            Session session = null;
17363    
17364                            try {
17365                                    session = openSession();
17366    
17367                                    Query q = session.createQuery(sql);
17368    
17369                                    QueryPos qPos = QueryPos.getInstance(q);
17370    
17371                                    qPos.add(companyId);
17372    
17373                                    qPos.add(status);
17374    
17375                                    count = (Long)q.uniqueResult();
17376                            }
17377                            catch (Exception e) {
17378                                    throw processException(e);
17379                            }
17380                            finally {
17381                                    if (count == null) {
17382                                            count = Long.valueOf(0);
17383                                    }
17384    
17385                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_ST,
17386                                            finderArgs, count);
17387    
17388                                    closeSession(session);
17389                            }
17390                    }
17391    
17392                    return count.intValue();
17393            }
17394    
17395            /**
17396             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17397             *
17398             * @param groupId the group ID
17399             * @param classNameId the class name ID
17400             * @param classPK the class p k
17401             * @return the number of matching journal articles
17402             * @throws SystemException if a system exception occurred
17403             */
17404            public int countByG_C_C(long groupId, long classNameId, long classPK)
17405                    throws SystemException {
17406                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
17407    
17408                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C,
17409                                    finderArgs, this);
17410    
17411                    if (count == null) {
17412                            StringBundler query = new StringBundler(4);
17413    
17414                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17415    
17416                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17417    
17418                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17419    
17420                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17421    
17422                            String sql = query.toString();
17423    
17424                            Session session = null;
17425    
17426                            try {
17427                                    session = openSession();
17428    
17429                                    Query q = session.createQuery(sql);
17430    
17431                                    QueryPos qPos = QueryPos.getInstance(q);
17432    
17433                                    qPos.add(groupId);
17434    
17435                                    qPos.add(classNameId);
17436    
17437                                    qPos.add(classPK);
17438    
17439                                    count = (Long)q.uniqueResult();
17440                            }
17441                            catch (Exception e) {
17442                                    throw processException(e);
17443                            }
17444                            finally {
17445                                    if (count == null) {
17446                                            count = Long.valueOf(0);
17447                                    }
17448    
17449                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C,
17450                                            finderArgs, count);
17451    
17452                                    closeSession(session);
17453                            }
17454                    }
17455    
17456                    return count.intValue();
17457            }
17458    
17459            /**
17460             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
17461             *
17462             * @param groupId the group ID
17463             * @param classNameId the class name ID
17464             * @param classPK the class p k
17465             * @return the number of matching journal articles that the user has permission to view
17466             * @throws SystemException if a system exception occurred
17467             */
17468            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
17469                    throws SystemException {
17470                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17471                            return countByG_C_C(groupId, classNameId, classPK);
17472                    }
17473    
17474                    StringBundler query = new StringBundler(4);
17475    
17476                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17477    
17478                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
17479    
17480                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
17481    
17482                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
17483    
17484                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17485                                    JournalArticle.class.getName(),
17486                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17487    
17488                    Session session = null;
17489    
17490                    try {
17491                            session = openSession();
17492    
17493                            SQLQuery q = session.createSQLQuery(sql);
17494    
17495                            q.addScalar(COUNT_COLUMN_NAME,
17496                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17497    
17498                            QueryPos qPos = QueryPos.getInstance(q);
17499    
17500                            qPos.add(groupId);
17501    
17502                            qPos.add(classNameId);
17503    
17504                            qPos.add(classPK);
17505    
17506                            Long count = (Long)q.uniqueResult();
17507    
17508                            return count.intValue();
17509                    }
17510                    catch (Exception e) {
17511                            throw processException(e);
17512                    }
17513                    finally {
17514                            closeSession(session);
17515                    }
17516            }
17517    
17518            /**
17519             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
17520             *
17521             * @param groupId the group ID
17522             * @param classNameId the class name ID
17523             * @param structureId the structure ID
17524             * @return the number of matching journal articles
17525             * @throws SystemException if a system exception occurred
17526             */
17527            public int countByG_C_S(long groupId, long classNameId, String structureId)
17528                    throws SystemException {
17529                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
17530    
17531                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
17532                                    finderArgs, this);
17533    
17534                    if (count == null) {
17535                            StringBundler query = new StringBundler(4);
17536    
17537                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17538    
17539                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
17540    
17541                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
17542    
17543                            if (structureId == null) {
17544                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
17545                            }
17546                            else {
17547                                    if (structureId.equals(StringPool.BLANK)) {
17548                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
17549                                    }
17550                                    else {
17551                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
17552                                    }
17553                            }
17554    
17555                            String sql = query.toString();
17556    
17557                            Session session = null;
17558    
17559                            try {
17560                                    session = openSession();
17561    
17562                                    Query q = session.createQuery(sql);
17563    
17564                                    QueryPos qPos = QueryPos.getInstance(q);
17565    
17566                                    qPos.add(groupId);
17567    
17568                                    qPos.add(classNameId);
17569    
17570                                    if (structureId != null) {
17571                                            qPos.add(structureId);
17572                                    }
17573    
17574                                    count = (Long)q.uniqueResult();
17575                            }
17576                            catch (Exception e) {
17577                                    throw processException(e);
17578                            }
17579                            finally {
17580                                    if (count == null) {
17581                                            count = Long.valueOf(0);
17582                                    }
17583    
17584                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
17585                                            finderArgs, count);
17586    
17587                                    closeSession(session);
17588                            }
17589                    }
17590    
17591                    return count.intValue();
17592            }
17593    
17594            /**
17595             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
17596             *
17597             * @param groupId the group ID
17598             * @param classNameId the class name ID
17599             * @param templateId the template ID
17600             * @return the number of matching journal articles
17601             * @throws SystemException if a system exception occurred
17602             */
17603            public int countByG_C_T(long groupId, long classNameId, String templateId)
17604                    throws SystemException {
17605                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
17606    
17607                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_T,
17608                                    finderArgs, this);
17609    
17610                    if (count == null) {
17611                            StringBundler query = new StringBundler(4);
17612    
17613                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17614    
17615                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
17616    
17617                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
17618    
17619                            if (templateId == null) {
17620                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
17621                            }
17622                            else {
17623                                    if (templateId.equals(StringPool.BLANK)) {
17624                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
17625                                    }
17626                                    else {
17627                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
17628                                    }
17629                            }
17630    
17631                            String sql = query.toString();
17632    
17633                            Session session = null;
17634    
17635                            try {
17636                                    session = openSession();
17637    
17638                                    Query q = session.createQuery(sql);
17639    
17640                                    QueryPos qPos = QueryPos.getInstance(q);
17641    
17642                                    qPos.add(groupId);
17643    
17644                                    qPos.add(classNameId);
17645    
17646                                    if (templateId != null) {
17647                                            qPos.add(templateId);
17648                                    }
17649    
17650                                    count = (Long)q.uniqueResult();
17651                            }
17652                            catch (Exception e) {
17653                                    throw processException(e);
17654                            }
17655                            finally {
17656                                    if (count == null) {
17657                                            count = Long.valueOf(0);
17658                                    }
17659    
17660                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_T,
17661                                            finderArgs, count);
17662    
17663                                    closeSession(session);
17664                            }
17665                    }
17666    
17667                    return count.intValue();
17668            }
17669    
17670            /**
17671             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
17672             *
17673             * @param groupId the group ID
17674             * @param classNameId the class name ID
17675             * @param templateId the template ID
17676             * @return the number of matching journal articles that the user has permission to view
17677             * @throws SystemException if a system exception occurred
17678             */
17679            public int filterCountByG_C_T(long groupId, long classNameId,
17680                    String templateId) throws SystemException {
17681                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17682                            return countByG_C_T(groupId, classNameId, templateId);
17683                    }
17684    
17685                    StringBundler query = new StringBundler(4);
17686    
17687                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17688    
17689                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
17690    
17691                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
17692    
17693                    if (templateId == null) {
17694                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
17695                    }
17696                    else {
17697                            if (templateId.equals(StringPool.BLANK)) {
17698                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
17699                            }
17700                            else {
17701                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
17702                            }
17703                    }
17704    
17705                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17706                                    JournalArticle.class.getName(),
17707                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17708    
17709                    Session session = null;
17710    
17711                    try {
17712                            session = openSession();
17713    
17714                            SQLQuery q = session.createSQLQuery(sql);
17715    
17716                            q.addScalar(COUNT_COLUMN_NAME,
17717                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17718    
17719                            QueryPos qPos = QueryPos.getInstance(q);
17720    
17721                            qPos.add(groupId);
17722    
17723                            qPos.add(classNameId);
17724    
17725                            if (templateId != null) {
17726                                    qPos.add(templateId);
17727                            }
17728    
17729                            Long count = (Long)q.uniqueResult();
17730    
17731                            return count.intValue();
17732                    }
17733                    catch (Exception e) {
17734                            throw processException(e);
17735                    }
17736                    finally {
17737                            closeSession(session);
17738                    }
17739            }
17740    
17741            /**
17742             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
17743             *
17744             * @param groupId the group ID
17745             * @param classNameId the class name ID
17746             * @param layoutUuid the layout uuid
17747             * @return the number of matching journal articles
17748             * @throws SystemException if a system exception occurred
17749             */
17750            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
17751                    throws SystemException {
17752                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
17753    
17754                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_L,
17755                                    finderArgs, this);
17756    
17757                    if (count == null) {
17758                            StringBundler query = new StringBundler(4);
17759    
17760                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17761    
17762                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
17763    
17764                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
17765    
17766                            if (layoutUuid == null) {
17767                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
17768                            }
17769                            else {
17770                                    if (layoutUuid.equals(StringPool.BLANK)) {
17771                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
17772                                    }
17773                                    else {
17774                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
17775                                    }
17776                            }
17777    
17778                            String sql = query.toString();
17779    
17780                            Session session = null;
17781    
17782                            try {
17783                                    session = openSession();
17784    
17785                                    Query q = session.createQuery(sql);
17786    
17787                                    QueryPos qPos = QueryPos.getInstance(q);
17788    
17789                                    qPos.add(groupId);
17790    
17791                                    qPos.add(classNameId);
17792    
17793                                    if (layoutUuid != null) {
17794                                            qPos.add(layoutUuid);
17795                                    }
17796    
17797                                    count = (Long)q.uniqueResult();
17798                            }
17799                            catch (Exception e) {
17800                                    throw processException(e);
17801                            }
17802                            finally {
17803                                    if (count == null) {
17804                                            count = Long.valueOf(0);
17805                                    }
17806    
17807                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_L,
17808                                            finderArgs, count);
17809    
17810                                    closeSession(session);
17811                            }
17812                    }
17813    
17814                    return count.intValue();
17815            }
17816    
17817            /**
17818             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
17819             *
17820             * @param groupId the group ID
17821             * @param classNameId the class name ID
17822             * @param layoutUuid the layout uuid
17823             * @return the number of matching journal articles that the user has permission to view
17824             * @throws SystemException if a system exception occurred
17825             */
17826            public int filterCountByG_C_L(long groupId, long classNameId,
17827                    String layoutUuid) throws SystemException {
17828                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17829                            return countByG_C_L(groupId, classNameId, layoutUuid);
17830                    }
17831    
17832                    StringBundler query = new StringBundler(4);
17833    
17834                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17835    
17836                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
17837    
17838                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
17839    
17840                    if (layoutUuid == null) {
17841                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
17842                    }
17843                    else {
17844                            if (layoutUuid.equals(StringPool.BLANK)) {
17845                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
17846                            }
17847                            else {
17848                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
17849                            }
17850                    }
17851    
17852                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17853                                    JournalArticle.class.getName(),
17854                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17855    
17856                    Session session = null;
17857    
17858                    try {
17859                            session = openSession();
17860    
17861                            SQLQuery q = session.createSQLQuery(sql);
17862    
17863                            q.addScalar(COUNT_COLUMN_NAME,
17864                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17865    
17866                            QueryPos qPos = QueryPos.getInstance(q);
17867    
17868                            qPos.add(groupId);
17869    
17870                            qPos.add(classNameId);
17871    
17872                            if (layoutUuid != null) {
17873                                    qPos.add(layoutUuid);
17874                            }
17875    
17876                            Long count = (Long)q.uniqueResult();
17877    
17878                            return count.intValue();
17879                    }
17880                    catch (Exception e) {
17881                            throw processException(e);
17882                    }
17883                    finally {
17884                            closeSession(session);
17885                    }
17886            }
17887    
17888            /**
17889             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
17890             *
17891             * @param groupId the group ID
17892             * @param articleId the article ID
17893             * @param version the version
17894             * @return the number of matching journal articles
17895             * @throws SystemException if a system exception occurred
17896             */
17897            public int countByG_A_V(long groupId, String articleId, double version)
17898                    throws SystemException {
17899                    Object[] finderArgs = new Object[] { groupId, articleId, version };
17900    
17901                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_V,
17902                                    finderArgs, this);
17903    
17904                    if (count == null) {
17905                            StringBundler query = new StringBundler(4);
17906    
17907                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17908    
17909                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
17910    
17911                            if (articleId == null) {
17912                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
17913                            }
17914                            else {
17915                                    if (articleId.equals(StringPool.BLANK)) {
17916                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
17917                                    }
17918                                    else {
17919                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
17920                                    }
17921                            }
17922    
17923                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
17924    
17925                            String sql = query.toString();
17926    
17927                            Session session = null;
17928    
17929                            try {
17930                                    session = openSession();
17931    
17932                                    Query q = session.createQuery(sql);
17933    
17934                                    QueryPos qPos = QueryPos.getInstance(q);
17935    
17936                                    qPos.add(groupId);
17937    
17938                                    if (articleId != null) {
17939                                            qPos.add(articleId);
17940                                    }
17941    
17942                                    qPos.add(version);
17943    
17944                                    count = (Long)q.uniqueResult();
17945                            }
17946                            catch (Exception e) {
17947                                    throw processException(e);
17948                            }
17949                            finally {
17950                                    if (count == null) {
17951                                            count = Long.valueOf(0);
17952                                    }
17953    
17954                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V,
17955                                            finderArgs, count);
17956    
17957                                    closeSession(session);
17958                            }
17959                    }
17960    
17961                    return count.intValue();
17962            }
17963    
17964            /**
17965             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
17966             *
17967             * @param groupId the group ID
17968             * @param articleId the article ID
17969             * @param status the status
17970             * @return the number of matching journal articles
17971             * @throws SystemException if a system exception occurred
17972             */
17973            public int countByG_A_ST(long groupId, String articleId, int status)
17974                    throws SystemException {
17975                    Object[] finderArgs = new Object[] { groupId, articleId, status };
17976    
17977                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_ST,
17978                                    finderArgs, this);
17979    
17980                    if (count == null) {
17981                            StringBundler query = new StringBundler(4);
17982    
17983                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17984    
17985                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
17986    
17987                            if (articleId == null) {
17988                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
17989                            }
17990                            else {
17991                                    if (articleId.equals(StringPool.BLANK)) {
17992                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
17993                                    }
17994                                    else {
17995                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
17996                                    }
17997                            }
17998    
17999                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
18000    
18001                            String sql = query.toString();
18002    
18003                            Session session = null;
18004    
18005                            try {
18006                                    session = openSession();
18007    
18008                                    Query q = session.createQuery(sql);
18009    
18010                                    QueryPos qPos = QueryPos.getInstance(q);
18011    
18012                                    qPos.add(groupId);
18013    
18014                                    if (articleId != null) {
18015                                            qPos.add(articleId);
18016                                    }
18017    
18018                                    qPos.add(status);
18019    
18020                                    count = (Long)q.uniqueResult();
18021                            }
18022                            catch (Exception e) {
18023                                    throw processException(e);
18024                            }
18025                            finally {
18026                                    if (count == null) {
18027                                            count = Long.valueOf(0);
18028                                    }
18029    
18030                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_ST,
18031                                            finderArgs, count);
18032    
18033                                    closeSession(session);
18034                            }
18035                    }
18036    
18037                    return count.intValue();
18038            }
18039    
18040            /**
18041             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
18042             *
18043             * @param groupId the group ID
18044             * @param articleId the article ID
18045             * @param statuses the statuses
18046             * @return the number of matching journal articles
18047             * @throws SystemException if a system exception occurred
18048             */
18049            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
18050                    throws SystemException {
18051                    Object[] finderArgs = new Object[] {
18052                                    groupId, articleId, StringUtil.merge(statuses)
18053                            };
18054    
18055                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
18056                                    finderArgs, this);
18057    
18058                    if (count == null) {
18059                            StringBundler query = new StringBundler();
18060    
18061                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18062    
18063                            boolean conjunctionable = false;
18064    
18065                            if (conjunctionable) {
18066                                    query.append(WHERE_AND);
18067                            }
18068    
18069                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
18070    
18071                            conjunctionable = true;
18072    
18073                            if (conjunctionable) {
18074                                    query.append(WHERE_AND);
18075                            }
18076    
18077                            if (articleId == null) {
18078                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
18079                            }
18080                            else {
18081                                    if (articleId.equals(StringPool.BLANK)) {
18082                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
18083                                    }
18084                                    else {
18085                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
18086                                    }
18087                            }
18088    
18089                            conjunctionable = true;
18090    
18091                            if ((statuses == null) || (statuses.length > 0)) {
18092                                    if (conjunctionable) {
18093                                            query.append(WHERE_AND);
18094                                    }
18095    
18096                                    query.append(StringPool.OPEN_PARENTHESIS);
18097    
18098                                    for (int i = 0; i < statuses.length; i++) {
18099                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
18100    
18101                                            if ((i + 1) < statuses.length) {
18102                                                    query.append(WHERE_OR);
18103                                            }
18104                                    }
18105    
18106                                    query.append(StringPool.CLOSE_PARENTHESIS);
18107    
18108                                    conjunctionable = true;
18109                            }
18110    
18111                            String sql = query.toString();
18112    
18113                            Session session = null;
18114    
18115                            try {
18116                                    session = openSession();
18117    
18118                                    Query q = session.createQuery(sql);
18119    
18120                                    QueryPos qPos = QueryPos.getInstance(q);
18121    
18122                                    qPos.add(groupId);
18123    
18124                                    if (articleId != null) {
18125                                            qPos.add(articleId);
18126                                    }
18127    
18128                                    if (statuses != null) {
18129                                            qPos.add(statuses);
18130                                    }
18131    
18132                                    count = (Long)q.uniqueResult();
18133                            }
18134                            catch (Exception e) {
18135                                    throw processException(e);
18136                            }
18137                            finally {
18138                                    if (count == null) {
18139                                            count = Long.valueOf(0);
18140                                    }
18141    
18142                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
18143                                            finderArgs, count);
18144    
18145                                    closeSession(session);
18146                            }
18147                    }
18148    
18149                    return count.intValue();
18150            }
18151    
18152            /**
18153             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
18154             *
18155             * @param groupId the group ID
18156             * @param articleId the article ID
18157             * @param status the status
18158             * @return the number of matching journal articles that the user has permission to view
18159             * @throws SystemException if a system exception occurred
18160             */
18161            public int filterCountByG_A_ST(long groupId, String articleId, int status)
18162                    throws SystemException {
18163                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18164                            return countByG_A_ST(groupId, articleId, status);
18165                    }
18166    
18167                    StringBundler query = new StringBundler(4);
18168    
18169                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18170    
18171                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
18172    
18173                    if (articleId == null) {
18174                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
18175                    }
18176                    else {
18177                            if (articleId.equals(StringPool.BLANK)) {
18178                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
18179                            }
18180                            else {
18181                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
18182                            }
18183                    }
18184    
18185                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
18186    
18187                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18188                                    JournalArticle.class.getName(),
18189                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18190    
18191                    Session session = null;
18192    
18193                    try {
18194                            session = openSession();
18195    
18196                            SQLQuery q = session.createSQLQuery(sql);
18197    
18198                            q.addScalar(COUNT_COLUMN_NAME,
18199                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18200    
18201                            QueryPos qPos = QueryPos.getInstance(q);
18202    
18203                            qPos.add(groupId);
18204    
18205                            if (articleId != null) {
18206                                    qPos.add(articleId);
18207                            }
18208    
18209                            qPos.add(status);
18210    
18211                            Long count = (Long)q.uniqueResult();
18212    
18213                            return count.intValue();
18214                    }
18215                    catch (Exception e) {
18216                            throw processException(e);
18217                    }
18218                    finally {
18219                            closeSession(session);
18220                    }
18221            }
18222    
18223            /**
18224             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
18225             *
18226             * @param groupId the group ID
18227             * @param articleId the article ID
18228             * @param statuses the statuses
18229             * @return the number of matching journal articles that the user has permission to view
18230             * @throws SystemException if a system exception occurred
18231             */
18232            public int filterCountByG_A_ST(long groupId, String articleId,
18233                    int[] statuses) throws SystemException {
18234                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18235                            return countByG_A_ST(groupId, articleId, statuses);
18236                    }
18237    
18238                    StringBundler query = new StringBundler();
18239    
18240                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18241    
18242                    boolean conjunctionable = false;
18243    
18244                    if (conjunctionable) {
18245                            query.append(WHERE_AND);
18246                    }
18247    
18248                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
18249    
18250                    conjunctionable = true;
18251    
18252                    if (conjunctionable) {
18253                            query.append(WHERE_AND);
18254                    }
18255    
18256                    if (articleId == null) {
18257                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
18258                    }
18259                    else {
18260                            if (articleId.equals(StringPool.BLANK)) {
18261                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
18262                            }
18263                            else {
18264                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
18265                            }
18266                    }
18267    
18268                    conjunctionable = true;
18269    
18270                    if ((statuses == null) || (statuses.length > 0)) {
18271                            if (conjunctionable) {
18272                                    query.append(WHERE_AND);
18273                            }
18274    
18275                            query.append(StringPool.OPEN_PARENTHESIS);
18276    
18277                            for (int i = 0; i < statuses.length; i++) {
18278                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
18279    
18280                                    if ((i + 1) < statuses.length) {
18281                                            query.append(WHERE_OR);
18282                                    }
18283                            }
18284    
18285                            query.append(StringPool.CLOSE_PARENTHESIS);
18286    
18287                            conjunctionable = true;
18288                    }
18289    
18290                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18291                                    JournalArticle.class.getName(),
18292                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18293    
18294                    Session session = null;
18295    
18296                    try {
18297                            session = openSession();
18298    
18299                            SQLQuery q = session.createSQLQuery(sql);
18300    
18301                            q.addScalar(COUNT_COLUMN_NAME,
18302                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18303    
18304                            QueryPos qPos = QueryPos.getInstance(q);
18305    
18306                            qPos.add(groupId);
18307    
18308                            if (articleId != null) {
18309                                    qPos.add(articleId);
18310                            }
18311    
18312                            if (statuses != null) {
18313                                    qPos.add(statuses);
18314                            }
18315    
18316                            Long count = (Long)q.uniqueResult();
18317    
18318                            return count.intValue();
18319                    }
18320                    catch (Exception e) {
18321                            throw processException(e);
18322                    }
18323                    finally {
18324                            closeSession(session);
18325                    }
18326            }
18327    
18328            /**
18329             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
18330             *
18331             * @param groupId the group ID
18332             * @param urlTitle the url title
18333             * @param status the status
18334             * @return the number of matching journal articles
18335             * @throws SystemException if a system exception occurred
18336             */
18337            public int countByG_UT_ST(long groupId, String urlTitle, int status)
18338                    throws SystemException {
18339                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
18340    
18341                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT_ST,
18342                                    finderArgs, this);
18343    
18344                    if (count == null) {
18345                            StringBundler query = new StringBundler(4);
18346    
18347                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18348    
18349                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
18350    
18351                            if (urlTitle == null) {
18352                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
18353                            }
18354                            else {
18355                                    if (urlTitle.equals(StringPool.BLANK)) {
18356                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
18357                                    }
18358                                    else {
18359                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
18360                                    }
18361                            }
18362    
18363                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
18364    
18365                            String sql = query.toString();
18366    
18367                            Session session = null;
18368    
18369                            try {
18370                                    session = openSession();
18371    
18372                                    Query q = session.createQuery(sql);
18373    
18374                                    QueryPos qPos = QueryPos.getInstance(q);
18375    
18376                                    qPos.add(groupId);
18377    
18378                                    if (urlTitle != null) {
18379                                            qPos.add(urlTitle);
18380                                    }
18381    
18382                                    qPos.add(status);
18383    
18384                                    count = (Long)q.uniqueResult();
18385                            }
18386                            catch (Exception e) {
18387                                    throw processException(e);
18388                            }
18389                            finally {
18390                                    if (count == null) {
18391                                            count = Long.valueOf(0);
18392                                    }
18393    
18394                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT_ST,
18395                                            finderArgs, count);
18396    
18397                                    closeSession(session);
18398                            }
18399                    }
18400    
18401                    return count.intValue();
18402            }
18403    
18404            /**
18405             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
18406             *
18407             * @param groupId the group ID
18408             * @param urlTitle the url title
18409             * @param status the status
18410             * @return the number of matching journal articles that the user has permission to view
18411             * @throws SystemException if a system exception occurred
18412             */
18413            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
18414                    throws SystemException {
18415                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18416                            return countByG_UT_ST(groupId, urlTitle, status);
18417                    }
18418    
18419                    StringBundler query = new StringBundler(4);
18420    
18421                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18422    
18423                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
18424    
18425                    if (urlTitle == null) {
18426                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
18427                    }
18428                    else {
18429                            if (urlTitle.equals(StringPool.BLANK)) {
18430                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
18431                            }
18432                            else {
18433                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
18434                            }
18435                    }
18436    
18437                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
18438    
18439                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18440                                    JournalArticle.class.getName(),
18441                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18442    
18443                    Session session = null;
18444    
18445                    try {
18446                            session = openSession();
18447    
18448                            SQLQuery q = session.createSQLQuery(sql);
18449    
18450                            q.addScalar(COUNT_COLUMN_NAME,
18451                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18452    
18453                            QueryPos qPos = QueryPos.getInstance(q);
18454    
18455                            qPos.add(groupId);
18456    
18457                            if (urlTitle != null) {
18458                                    qPos.add(urlTitle);
18459                            }
18460    
18461                            qPos.add(status);
18462    
18463                            Long count = (Long)q.uniqueResult();
18464    
18465                            return count.intValue();
18466                    }
18467                    catch (Exception e) {
18468                            throw processException(e);
18469                    }
18470                    finally {
18471                            closeSession(session);
18472                    }
18473            }
18474    
18475            /**
18476             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
18477             *
18478             * @param companyId the company ID
18479             * @param version the version
18480             * @param status the status
18481             * @return the number of matching journal articles
18482             * @throws SystemException if a system exception occurred
18483             */
18484            public int countByC_V_ST(long companyId, double version, int status)
18485                    throws SystemException {
18486                    Object[] finderArgs = new Object[] { companyId, version, status };
18487    
18488                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V_ST,
18489                                    finderArgs, this);
18490    
18491                    if (count == null) {
18492                            StringBundler query = new StringBundler(4);
18493    
18494                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18495    
18496                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
18497    
18498                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
18499    
18500                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
18501    
18502                            String sql = query.toString();
18503    
18504                            Session session = null;
18505    
18506                            try {
18507                                    session = openSession();
18508    
18509                                    Query q = session.createQuery(sql);
18510    
18511                                    QueryPos qPos = QueryPos.getInstance(q);
18512    
18513                                    qPos.add(companyId);
18514    
18515                                    qPos.add(version);
18516    
18517                                    qPos.add(status);
18518    
18519                                    count = (Long)q.uniqueResult();
18520                            }
18521                            catch (Exception e) {
18522                                    throw processException(e);
18523                            }
18524                            finally {
18525                                    if (count == null) {
18526                                            count = Long.valueOf(0);
18527                                    }
18528    
18529                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V_ST,
18530                                            finderArgs, count);
18531    
18532                                    closeSession(session);
18533                            }
18534                    }
18535    
18536                    return count.intValue();
18537            }
18538    
18539            /**
18540             * Returns the number of journal articles.
18541             *
18542             * @return the number of journal articles
18543             * @throws SystemException if a system exception occurred
18544             */
18545            public int countAll() throws SystemException {
18546                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
18547                                    FINDER_ARGS_EMPTY, this);
18548    
18549                    if (count == null) {
18550                            Session session = null;
18551    
18552                            try {
18553                                    session = openSession();
18554    
18555                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
18556    
18557                                    count = (Long)q.uniqueResult();
18558                            }
18559                            catch (Exception e) {
18560                                    throw processException(e);
18561                            }
18562                            finally {
18563                                    if (count == null) {
18564                                            count = Long.valueOf(0);
18565                                    }
18566    
18567                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
18568                                            FINDER_ARGS_EMPTY, count);
18569    
18570                                    closeSession(session);
18571                            }
18572                    }
18573    
18574                    return count.intValue();
18575            }
18576    
18577            /**
18578             * Initializes the journal article persistence.
18579             */
18580            public void afterPropertiesSet() {
18581                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
18582                                            com.liferay.portal.util.PropsUtil.get(
18583                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
18584    
18585                    if (listenerClassNames.length > 0) {
18586                            try {
18587                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
18588    
18589                                    for (String listenerClassName : listenerClassNames) {
18590                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
18591                                                            listenerClassName));
18592                                    }
18593    
18594                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
18595                            }
18596                            catch (Exception e) {
18597                                    _log.error(e);
18598                            }
18599                    }
18600            }
18601    
18602            public void destroy() {
18603                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
18604                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
18605                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18606            }
18607    
18608            @BeanReference(type = JournalArticlePersistence.class)
18609            protected JournalArticlePersistence journalArticlePersistence;
18610            @BeanReference(type = JournalArticleImagePersistence.class)
18611            protected JournalArticleImagePersistence journalArticleImagePersistence;
18612            @BeanReference(type = JournalArticleResourcePersistence.class)
18613            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
18614            @BeanReference(type = JournalContentSearchPersistence.class)
18615            protected JournalContentSearchPersistence journalContentSearchPersistence;
18616            @BeanReference(type = JournalFeedPersistence.class)
18617            protected JournalFeedPersistence journalFeedPersistence;
18618            @BeanReference(type = JournalStructurePersistence.class)
18619            protected JournalStructurePersistence journalStructurePersistence;
18620            @BeanReference(type = JournalTemplatePersistence.class)
18621            protected JournalTemplatePersistence journalTemplatePersistence;
18622            @BeanReference(type = CompanyPersistence.class)
18623            protected CompanyPersistence companyPersistence;
18624            @BeanReference(type = GroupPersistence.class)
18625            protected GroupPersistence groupPersistence;
18626            @BeanReference(type = ImagePersistence.class)
18627            protected ImagePersistence imagePersistence;
18628            @BeanReference(type = PortletPreferencesPersistence.class)
18629            protected PortletPreferencesPersistence portletPreferencesPersistence;
18630            @BeanReference(type = ResourcePersistence.class)
18631            protected ResourcePersistence resourcePersistence;
18632            @BeanReference(type = SubscriptionPersistence.class)
18633            protected SubscriptionPersistence subscriptionPersistence;
18634            @BeanReference(type = UserPersistence.class)
18635            protected UserPersistence userPersistence;
18636            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
18637            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
18638            @BeanReference(type = AssetCategoryPersistence.class)
18639            protected AssetCategoryPersistence assetCategoryPersistence;
18640            @BeanReference(type = AssetEntryPersistence.class)
18641            protected AssetEntryPersistence assetEntryPersistence;
18642            @BeanReference(type = AssetLinkPersistence.class)
18643            protected AssetLinkPersistence assetLinkPersistence;
18644            @BeanReference(type = AssetTagPersistence.class)
18645            protected AssetTagPersistence assetTagPersistence;
18646            @BeanReference(type = ExpandoValuePersistence.class)
18647            protected ExpandoValuePersistence expandoValuePersistence;
18648            @BeanReference(type = MBMessagePersistence.class)
18649            protected MBMessagePersistence mbMessagePersistence;
18650            @BeanReference(type = RatingsStatsPersistence.class)
18651            protected RatingsStatsPersistence ratingsStatsPersistence;
18652            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
18653            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
18654            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
18655            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
18656            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
18657            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
18658            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?)";
18659            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
18660            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
18661            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?) AND ";
18662            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
18663            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
18664                    "journalArticle.resourcePrimKey = ?";
18665            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
18666            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
18667            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
18668            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalArticle.structureId = ?";
18669            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
18670            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
18671            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2 = "journalArticle.templateId = ?";
18672            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
18673            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
18674            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
18675            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
18676            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
18677            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
18678            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
18679            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?)";
18680            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
18681            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
18682            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
18683            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?)";
18684            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
18685            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
18686            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
18687            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
18688            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
18689            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
18690            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
18691            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
18692            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
18693            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
18694            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
18695            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
18696            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
18697            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
18698            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
18699            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
18700            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
18701            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
18702            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
18703            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
18704            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
18705            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
18706            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
18707            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
18708            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
18709            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
18710            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
18711            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
18712            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
18713            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
18714            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
18715            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
18716            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
18717            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
18718            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
18719            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
18720            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
18721            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
18722            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
18723            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
18724            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
18725            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
18726            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
18727                    _removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
18728            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
18729            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
18730            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
18731            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
18732                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
18733            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
18734                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
18735            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
18736                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
18737            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
18738            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
18739                    _removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
18740            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
18741            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
18742            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
18743            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?) AND ";
18744            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
18745            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
18746            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
18747            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
18748    
18749            private static String _removeConjunction(String sql) {
18750                    int pos = sql.indexOf(" AND ");
18751    
18752                    if (pos != -1) {
18753                            sql = sql.substring(0, pos);
18754                    }
18755    
18756                    return sql;
18757            }
18758    
18759            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
18760            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
18761            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
18762                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
18763            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
18764                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
18765            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
18766            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
18767            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
18768            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
18769            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
18770            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
18771            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
18772            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
18773            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
18774            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
18775                            @Override
18776                            public Object clone() {
18777                                    return this;
18778                            }
18779    
18780                            @Override
18781                            public CacheModel<JournalArticle> toCacheModel() {
18782                                    return _nullJournalArticleCacheModel;
18783                            }
18784                    };
18785    
18786            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
18787                            public JournalArticle toEntityModel() {
18788                                    return _nullJournalArticle;
18789                            }
18790                    };
18791    }