001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.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    
937                    else {
938                            if ((journalArticleModelImpl.getColumnBitmask() &
939                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
940                                    Object[] args = new Object[] {
941                                                    journalArticleModelImpl.getOriginalUuid()
942                                            };
943    
944                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
945                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
946                                            args);
947    
948                                    args = new Object[] { journalArticleModelImpl.getUuid() };
949    
950                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
951                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
952                                            args);
953                            }
954    
955                            if ((journalArticleModelImpl.getColumnBitmask() &
956                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
957                                    Object[] args = new Object[] {
958                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey())
959                                            };
960    
961                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
962                                            args);
963                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
964                                            args);
965    
966                                    args = new Object[] {
967                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey())
968                                            };
969    
970                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
971                                            args);
972                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
973                                            args);
974                            }
975    
976                            if ((journalArticleModelImpl.getColumnBitmask() &
977                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
978                                    Object[] args = new Object[] {
979                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
980                                            };
981    
982                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
983                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
984                                            args);
985    
986                                    args = new Object[] {
987                                                    Long.valueOf(journalArticleModelImpl.getGroupId())
988                                            };
989    
990                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
991                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
992                                            args);
993                            }
994    
995                            if ((journalArticleModelImpl.getColumnBitmask() &
996                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
997                                    Object[] args = new Object[] {
998                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId())
999                                            };
1000    
1001                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
1002                                            args);
1003                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
1004                                            args);
1005    
1006                                    args = new Object[] {
1007                                                    Long.valueOf(journalArticleModelImpl.getCompanyId())
1008                                            };
1009    
1010                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
1011                                            args);
1012                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
1013                                            args);
1014                            }
1015    
1016                            if ((journalArticleModelImpl.getColumnBitmask() &
1017                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID.getColumnBitmask()) != 0) {
1018                                    Object[] args = new Object[] {
1019                                                    journalArticleModelImpl.getOriginalStructureId()
1020                                            };
1021    
1022                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1023                                            args);
1024                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
1025                                            args);
1026    
1027                                    args = new Object[] { journalArticleModelImpl.getStructureId() };
1028    
1029                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
1030                                            args);
1031                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID,
1032                                            args);
1033                            }
1034    
1035                            if ((journalArticleModelImpl.getColumnBitmask() &
1036                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID.getColumnBitmask()) != 0) {
1037                                    Object[] args = new Object[] {
1038                                                    journalArticleModelImpl.getOriginalTemplateId()
1039                                            };
1040    
1041                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
1042                                            args);
1043                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
1044                                            args);
1045    
1046                                    args = new Object[] { journalArticleModelImpl.getTemplateId() };
1047    
1048                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
1049                                            args);
1050                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID,
1051                                            args);
1052                            }
1053    
1054                            if ((journalArticleModelImpl.getColumnBitmask() &
1055                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
1056                                    Object[] args = new Object[] {
1057                                                    Long.valueOf(journalArticleModelImpl.getOriginalSmallImageId())
1058                                            };
1059    
1060                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
1061                                            args);
1062                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
1063                                            args);
1064    
1065                                    args = new Object[] {
1066                                                    Long.valueOf(journalArticleModelImpl.getSmallImageId())
1067                                            };
1068    
1069                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
1070                                            args);
1071                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
1072                                            args);
1073                            }
1074    
1075                            if ((journalArticleModelImpl.getColumnBitmask() &
1076                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
1077                                    Object[] args = new Object[] {
1078                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey()),
1079                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1080                                            };
1081    
1082                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
1083                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
1084                                            args);
1085    
1086                                    args = new Object[] {
1087                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey()),
1088                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1089                                            };
1090    
1091                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
1092                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
1093                                            args);
1094                            }
1095    
1096                            if ((journalArticleModelImpl.getColumnBitmask() &
1097                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
1098                                    Object[] args = new Object[] {
1099                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1100                                                    
1101                                                    journalArticleModelImpl.getOriginalArticleId()
1102                                            };
1103    
1104                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1105                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
1106                                            args);
1107    
1108                                    args = new Object[] {
1109                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1110                                                    
1111                                                    journalArticleModelImpl.getArticleId()
1112                                            };
1113    
1114                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1115                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
1116                                            args);
1117                            }
1118    
1119                            if ((journalArticleModelImpl.getColumnBitmask() &
1120                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
1121                                    Object[] args = new Object[] {
1122                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1123                                                    
1124                                                    journalArticleModelImpl.getOriginalUrlTitle()
1125                                            };
1126    
1127                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
1128                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
1129                                            args);
1130    
1131                                    args = new Object[] {
1132                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1133                                                    
1134                                                    journalArticleModelImpl.getUrlTitle()
1135                                            };
1136    
1137                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
1138                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
1139                                            args);
1140                            }
1141    
1142                            if ((journalArticleModelImpl.getColumnBitmask() &
1143                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
1144                                    Object[] args = new Object[] {
1145                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1146                                                    
1147                                                    journalArticleModelImpl.getOriginalStructureId()
1148                                            };
1149    
1150                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1151                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1152                                            args);
1153    
1154                                    args = new Object[] {
1155                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1156                                                    
1157                                                    journalArticleModelImpl.getStructureId()
1158                                            };
1159    
1160                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1161                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1162                                            args);
1163                            }
1164    
1165                            if ((journalArticleModelImpl.getColumnBitmask() &
1166                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
1167                                    Object[] args = new Object[] {
1168                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1169                                                    
1170                                                    journalArticleModelImpl.getOriginalTemplateId()
1171                                            };
1172    
1173                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
1174                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
1175                                            args);
1176    
1177                                    args = new Object[] {
1178                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1179                                                    
1180                                                    journalArticleModelImpl.getTemplateId()
1181                                            };
1182    
1183                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
1184                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
1185                                            args);
1186                            }
1187    
1188                            if ((journalArticleModelImpl.getColumnBitmask() &
1189                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
1190                                    Object[] args = new Object[] {
1191                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1192                                                    
1193                                                    journalArticleModelImpl.getOriginalLayoutUuid()
1194                                            };
1195    
1196                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
1197                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
1198                                            args);
1199    
1200                                    args = new Object[] {
1201                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1202                                                    
1203                                                    journalArticleModelImpl.getLayoutUuid()
1204                                            };
1205    
1206                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
1207                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
1208                                            args);
1209                            }
1210    
1211                            if ((journalArticleModelImpl.getColumnBitmask() &
1212                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
1213                                    Object[] args = new Object[] {
1214                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1215                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1216                                            };
1217    
1218                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
1219                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
1220                                            args);
1221    
1222                                    args = new Object[] {
1223                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1224                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1225                                            };
1226    
1227                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
1228                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
1229                                            args);
1230                            }
1231    
1232                            if ((journalArticleModelImpl.getColumnBitmask() &
1233                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
1234                                    Object[] args = new Object[] {
1235                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1236                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion())
1237                                            };
1238    
1239                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
1240                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
1241                                            args);
1242    
1243                                    args = new Object[] {
1244                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1245                                                    Double.valueOf(journalArticleModelImpl.getVersion())
1246                                            };
1247    
1248                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
1249                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
1250                                            args);
1251                            }
1252    
1253                            if ((journalArticleModelImpl.getColumnBitmask() &
1254                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
1255                                    Object[] args = new Object[] {
1256                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1257                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1258                                            };
1259    
1260                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
1261                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
1262                                            args);
1263    
1264                                    args = new Object[] {
1265                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1266                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1267                                            };
1268    
1269                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
1270                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
1271                                            args);
1272                            }
1273    
1274                            if ((journalArticleModelImpl.getColumnBitmask() &
1275                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
1276                                    Object[] args = new Object[] {
1277                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1278                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1279                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassPK())
1280                                            };
1281    
1282                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
1283                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
1284                                            args);
1285    
1286                                    args = new Object[] {
1287                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1288                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1289                                                    Long.valueOf(journalArticleModelImpl.getClassPK())
1290                                            };
1291    
1292                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
1293                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
1294                                            args);
1295                            }
1296    
1297                            if ((journalArticleModelImpl.getColumnBitmask() &
1298                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
1299                                    Object[] args = new Object[] {
1300                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1301                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1302                                                    
1303                                                    journalArticleModelImpl.getOriginalTemplateId()
1304                                            };
1305    
1306                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1307                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1308                                            args);
1309    
1310                                    args = new Object[] {
1311                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1312                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1313                                                    
1314                                                    journalArticleModelImpl.getTemplateId()
1315                                            };
1316    
1317                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1318                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1319                                            args);
1320                            }
1321    
1322                            if ((journalArticleModelImpl.getColumnBitmask() &
1323                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
1324                                    Object[] args = new Object[] {
1325                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1326                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1327                                                    
1328                                                    journalArticleModelImpl.getOriginalLayoutUuid()
1329                                            };
1330    
1331                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
1332                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
1333                                            args);
1334    
1335                                    args = new Object[] {
1336                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1337                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1338                                                    
1339                                                    journalArticleModelImpl.getLayoutUuid()
1340                                            };
1341    
1342                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
1343                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
1344                                            args);
1345                            }
1346    
1347                            if ((journalArticleModelImpl.getColumnBitmask() &
1348                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
1349                                    Object[] args = new Object[] {
1350                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1351                                                    
1352                                                    journalArticleModelImpl.getOriginalArticleId(),
1353                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1354                                            };
1355    
1356                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
1357                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
1358                                            args);
1359    
1360                                    args = new Object[] {
1361                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1362                                                    
1363                                                    journalArticleModelImpl.getArticleId(),
1364                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1365                                            };
1366    
1367                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
1368                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
1369                                            args);
1370                            }
1371    
1372                            if ((journalArticleModelImpl.getColumnBitmask() &
1373                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
1374                                    Object[] args = new Object[] {
1375                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1376                                                    
1377                                                    journalArticleModelImpl.getOriginalUrlTitle(),
1378                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1379                                            };
1380    
1381                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
1382                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
1383                                            args);
1384    
1385                                    args = new Object[] {
1386                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1387                                                    
1388                                                    journalArticleModelImpl.getUrlTitle(),
1389                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1390                                            };
1391    
1392                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
1393                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
1394                                            args);
1395                            }
1396    
1397                            if ((journalArticleModelImpl.getColumnBitmask() &
1398                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
1399                                    Object[] args = new Object[] {
1400                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1401                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion()),
1402                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1403                                            };
1404    
1405                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
1406                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
1407                                            args);
1408    
1409                                    args = new Object[] {
1410                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1411                                                    Double.valueOf(journalArticleModelImpl.getVersion()),
1412                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1413                                            };
1414    
1415                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
1416                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
1417                                            args);
1418                            }
1419                    }
1420    
1421                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1422                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
1423                            journalArticle);
1424    
1425                    if (isNew) {
1426                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1427                                    new Object[] {
1428                                            journalArticle.getUuid(),
1429                                            Long.valueOf(journalArticle.getGroupId())
1430                                    }, journalArticle);
1431    
1432                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
1433                                    new Object[] {
1434                                            Long.valueOf(journalArticle.getGroupId()),
1435                                            Long.valueOf(journalArticle.getClassNameId()),
1436                                            
1437                                    journalArticle.getStructureId()
1438                                    }, journalArticle);
1439    
1440                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
1441                                    new Object[] {
1442                                            Long.valueOf(journalArticle.getGroupId()),
1443                                            
1444                                    journalArticle.getArticleId(),
1445                                            Double.valueOf(journalArticle.getVersion())
1446                                    }, journalArticle);
1447                    }
1448                    else {
1449                            if ((journalArticleModelImpl.getColumnBitmask() &
1450                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
1451                                    Object[] args = new Object[] {
1452                                                    journalArticleModelImpl.getOriginalUuid(),
1453                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
1454                                            };
1455    
1456                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
1457    
1458                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
1459    
1460                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1461                                            new Object[] {
1462                                                    journalArticle.getUuid(),
1463                                                    Long.valueOf(journalArticle.getGroupId())
1464                                            }, journalArticle);
1465                            }
1466    
1467                            if ((journalArticleModelImpl.getColumnBitmask() &
1468                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
1469                                    Object[] args = new Object[] {
1470                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1471                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1472                                                    
1473                                                    journalArticleModelImpl.getOriginalStructureId()
1474                                            };
1475    
1476                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
1477    
1478                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
1479    
1480                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
1481                                            new Object[] {
1482                                                    Long.valueOf(journalArticle.getGroupId()),
1483                                                    Long.valueOf(journalArticle.getClassNameId()),
1484                                                    
1485                                            journalArticle.getStructureId()
1486                                            }, journalArticle);
1487                            }
1488    
1489                            if ((journalArticleModelImpl.getColumnBitmask() &
1490                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
1491                                    Object[] args = new Object[] {
1492                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1493                                                    
1494                                                    journalArticleModelImpl.getOriginalArticleId(),
1495                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion())
1496                                            };
1497    
1498                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
1499    
1500                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
1501    
1502                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
1503                                            new Object[] {
1504                                                    Long.valueOf(journalArticle.getGroupId()),
1505                                                    
1506                                            journalArticle.getArticleId(),
1507                                                    Double.valueOf(journalArticle.getVersion())
1508                                            }, journalArticle);
1509                            }
1510                    }
1511    
1512                    return journalArticle;
1513            }
1514    
1515            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
1516                    if (journalArticle instanceof JournalArticleImpl) {
1517                            return journalArticle;
1518                    }
1519    
1520                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
1521    
1522                    journalArticleImpl.setNew(journalArticle.isNew());
1523                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
1524    
1525                    journalArticleImpl.setUuid(journalArticle.getUuid());
1526                    journalArticleImpl.setId(journalArticle.getId());
1527                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
1528                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
1529                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
1530                    journalArticleImpl.setUserId(journalArticle.getUserId());
1531                    journalArticleImpl.setUserName(journalArticle.getUserName());
1532                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
1533                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
1534                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
1535                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
1536                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
1537                    journalArticleImpl.setVersion(journalArticle.getVersion());
1538                    journalArticleImpl.setTitle(journalArticle.getTitle());
1539                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
1540                    journalArticleImpl.setDescription(journalArticle.getDescription());
1541                    journalArticleImpl.setContent(journalArticle.getContent());
1542                    journalArticleImpl.setType(journalArticle.getType());
1543                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
1544                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
1545                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
1546                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
1547                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
1548                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
1549                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
1550                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
1551                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
1552                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
1553                    journalArticleImpl.setStatus(journalArticle.getStatus());
1554                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
1555                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
1556                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
1557    
1558                    return journalArticleImpl;
1559            }
1560    
1561            /**
1562             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
1563             *
1564             * @param primaryKey the primary key of the journal article
1565             * @return the journal article
1566             * @throws com.liferay.portal.NoSuchModelException if a journal article with the primary key could not be found
1567             * @throws SystemException if a system exception occurred
1568             */
1569            @Override
1570            public JournalArticle findByPrimaryKey(Serializable primaryKey)
1571                    throws NoSuchModelException, SystemException {
1572                    return findByPrimaryKey(((Long)primaryKey).longValue());
1573            }
1574    
1575            /**
1576             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
1577             *
1578             * @param id the primary key of the journal article
1579             * @return the journal article
1580             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1581             * @throws SystemException if a system exception occurred
1582             */
1583            public JournalArticle findByPrimaryKey(long id)
1584                    throws NoSuchArticleException, SystemException {
1585                    JournalArticle journalArticle = fetchByPrimaryKey(id);
1586    
1587                    if (journalArticle == null) {
1588                            if (_log.isWarnEnabled()) {
1589                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
1590                            }
1591    
1592                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1593                                    id);
1594                    }
1595    
1596                    return journalArticle;
1597            }
1598    
1599            /**
1600             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
1601             *
1602             * @param primaryKey the primary key of the journal article
1603             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
1604             * @throws SystemException if a system exception occurred
1605             */
1606            @Override
1607            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
1608                    throws SystemException {
1609                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
1610            }
1611    
1612            /**
1613             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
1614             *
1615             * @param id the primary key of the journal article
1616             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
1617             * @throws SystemException if a system exception occurred
1618             */
1619            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
1620                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1621                                    JournalArticleImpl.class, id);
1622    
1623                    if (journalArticle == _nullJournalArticle) {
1624                            return null;
1625                    }
1626    
1627                    if (journalArticle == null) {
1628                            Session session = null;
1629    
1630                            boolean hasException = false;
1631    
1632                            try {
1633                                    session = openSession();
1634    
1635                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
1636                                                    Long.valueOf(id));
1637                            }
1638                            catch (Exception e) {
1639                                    hasException = true;
1640    
1641                                    throw processException(e);
1642                            }
1643                            finally {
1644                                    if (journalArticle != null) {
1645                                            cacheResult(journalArticle);
1646                                    }
1647                                    else if (!hasException) {
1648                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1649                                                    JournalArticleImpl.class, id, _nullJournalArticle);
1650                                    }
1651    
1652                                    closeSession(session);
1653                            }
1654                    }
1655    
1656                    return journalArticle;
1657            }
1658    
1659            /**
1660             * Returns all the journal articles where uuid = &#63;.
1661             *
1662             * @param uuid the uuid
1663             * @return the matching journal articles
1664             * @throws SystemException if a system exception occurred
1665             */
1666            public List<JournalArticle> findByUuid(String uuid)
1667                    throws SystemException {
1668                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1669            }
1670    
1671            /**
1672             * Returns a range of all the journal articles where uuid = &#63;.
1673             *
1674             * <p>
1675             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1676             * </p>
1677             *
1678             * @param uuid the uuid
1679             * @param start the lower bound of the range of journal articles
1680             * @param end the upper bound of the range of journal articles (not inclusive)
1681             * @return the range of matching journal articles
1682             * @throws SystemException if a system exception occurred
1683             */
1684            public List<JournalArticle> findByUuid(String uuid, int start, int end)
1685                    throws SystemException {
1686                    return findByUuid(uuid, start, end, null);
1687            }
1688    
1689            /**
1690             * Returns an ordered range of all the journal articles where uuid = &#63;.
1691             *
1692             * <p>
1693             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1694             * </p>
1695             *
1696             * @param uuid the uuid
1697             * @param start the lower bound of the range of journal articles
1698             * @param end the upper bound of the range of journal articles (not inclusive)
1699             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1700             * @return the ordered range of matching journal articles
1701             * @throws SystemException if a system exception occurred
1702             */
1703            public List<JournalArticle> findByUuid(String uuid, int start, int end,
1704                    OrderByComparator orderByComparator) throws SystemException {
1705                    FinderPath finderPath = null;
1706                    Object[] finderArgs = null;
1707    
1708                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1709                                    (orderByComparator == null)) {
1710                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1711                            finderArgs = new Object[] { uuid };
1712                    }
1713                    else {
1714                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1715                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1716                    }
1717    
1718                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1719                                    finderArgs, this);
1720    
1721                    if ((list != null) && !list.isEmpty()) {
1722                            for (JournalArticle journalArticle : list) {
1723                                    if (!Validator.equals(uuid, journalArticle.getUuid())) {
1724                                            list = null;
1725    
1726                                            break;
1727                                    }
1728                            }
1729                    }
1730    
1731                    if (list == null) {
1732                            StringBundler query = null;
1733    
1734                            if (orderByComparator != null) {
1735                                    query = new StringBundler(3 +
1736                                                    (orderByComparator.getOrderByFields().length * 3));
1737                            }
1738                            else {
1739                                    query = new StringBundler(3);
1740                            }
1741    
1742                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1743    
1744                            if (uuid == null) {
1745                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1746                            }
1747                            else {
1748                                    if (uuid.equals(StringPool.BLANK)) {
1749                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1750                                    }
1751                                    else {
1752                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1753                                    }
1754                            }
1755    
1756                            if (orderByComparator != null) {
1757                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1758                                            orderByComparator);
1759                            }
1760    
1761                            else {
1762                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1763                            }
1764    
1765                            String sql = query.toString();
1766    
1767                            Session session = null;
1768    
1769                            try {
1770                                    session = openSession();
1771    
1772                                    Query q = session.createQuery(sql);
1773    
1774                                    QueryPos qPos = QueryPos.getInstance(q);
1775    
1776                                    if (uuid != null) {
1777                                            qPos.add(uuid);
1778                                    }
1779    
1780                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
1781                                                    start, end);
1782                            }
1783                            catch (Exception e) {
1784                                    throw processException(e);
1785                            }
1786                            finally {
1787                                    if (list == null) {
1788                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1789                                    }
1790                                    else {
1791                                            cacheResult(list);
1792    
1793                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1794                                    }
1795    
1796                                    closeSession(session);
1797                            }
1798                    }
1799    
1800                    return list;
1801            }
1802    
1803            /**
1804             * Returns the first journal article in the ordered set where uuid = &#63;.
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                    JournalArticle journalArticle = fetchByUuid_First(uuid,
1816                                    orderByComparator);
1817    
1818                    if (journalArticle != null) {
1819                            return journalArticle;
1820                    }
1821    
1822                    StringBundler msg = new StringBundler(4);
1823    
1824                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1825    
1826                    msg.append("uuid=");
1827                    msg.append(uuid);
1828    
1829                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1830    
1831                    throw new NoSuchArticleException(msg.toString());
1832            }
1833    
1834            /**
1835             * Returns the first journal article in the ordered set where uuid = &#63;.
1836             *
1837             * @param uuid the uuid
1838             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1839             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
1840             * @throws SystemException if a system exception occurred
1841             */
1842            public JournalArticle fetchByUuid_First(String uuid,
1843                    OrderByComparator orderByComparator) throws SystemException {
1844                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
1845    
1846                    if (!list.isEmpty()) {
1847                            return list.get(0);
1848                    }
1849    
1850                    return null;
1851            }
1852    
1853            /**
1854             * Returns the last journal article in the ordered set where uuid = &#63;.
1855             *
1856             * @param uuid the uuid
1857             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1858             * @return the last matching journal article
1859             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1860             * @throws SystemException if a system exception occurred
1861             */
1862            public JournalArticle findByUuid_Last(String uuid,
1863                    OrderByComparator orderByComparator)
1864                    throws NoSuchArticleException, SystemException {
1865                    JournalArticle journalArticle = fetchByUuid_Last(uuid, orderByComparator);
1866    
1867                    if (journalArticle != null) {
1868                            return journalArticle;
1869                    }
1870    
1871                    StringBundler msg = new StringBundler(4);
1872    
1873                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1874    
1875                    msg.append("uuid=");
1876                    msg.append(uuid);
1877    
1878                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1879    
1880                    throw new NoSuchArticleException(msg.toString());
1881            }
1882    
1883            /**
1884             * Returns the last journal article in the ordered set where uuid = &#63;.
1885             *
1886             * @param uuid the uuid
1887             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1888             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
1889             * @throws SystemException if a system exception occurred
1890             */
1891            public JournalArticle fetchByUuid_Last(String uuid,
1892                    OrderByComparator orderByComparator) throws SystemException {
1893                    int count = countByUuid(uuid);
1894    
1895                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
1896                                    orderByComparator);
1897    
1898                    if (!list.isEmpty()) {
1899                            return list.get(0);
1900                    }
1901    
1902                    return null;
1903            }
1904    
1905            /**
1906             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
1907             *
1908             * @param id the primary key of the current journal article
1909             * @param uuid the uuid
1910             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1911             * @return the previous, current, and next journal article
1912             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1913             * @throws SystemException if a system exception occurred
1914             */
1915            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
1916                    OrderByComparator orderByComparator)
1917                    throws NoSuchArticleException, SystemException {
1918                    JournalArticle journalArticle = findByPrimaryKey(id);
1919    
1920                    Session session = null;
1921    
1922                    try {
1923                            session = openSession();
1924    
1925                            JournalArticle[] array = new JournalArticleImpl[3];
1926    
1927                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
1928                                            orderByComparator, true);
1929    
1930                            array[1] = journalArticle;
1931    
1932                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
1933                                            orderByComparator, false);
1934    
1935                            return array;
1936                    }
1937                    catch (Exception e) {
1938                            throw processException(e);
1939                    }
1940                    finally {
1941                            closeSession(session);
1942                    }
1943            }
1944    
1945            protected JournalArticle getByUuid_PrevAndNext(Session session,
1946                    JournalArticle journalArticle, String uuid,
1947                    OrderByComparator orderByComparator, boolean previous) {
1948                    StringBundler query = null;
1949    
1950                    if (orderByComparator != null) {
1951                            query = new StringBundler(6 +
1952                                            (orderByComparator.getOrderByFields().length * 6));
1953                    }
1954                    else {
1955                            query = new StringBundler(3);
1956                    }
1957    
1958                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1959    
1960                    if (uuid == null) {
1961                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1962                    }
1963                    else {
1964                            if (uuid.equals(StringPool.BLANK)) {
1965                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1966                            }
1967                            else {
1968                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1969                            }
1970                    }
1971    
1972                    if (orderByComparator != null) {
1973                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1974    
1975                            if (orderByConditionFields.length > 0) {
1976                                    query.append(WHERE_AND);
1977                            }
1978    
1979                            for (int i = 0; i < orderByConditionFields.length; i++) {
1980                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1981                                    query.append(orderByConditionFields[i]);
1982    
1983                                    if ((i + 1) < orderByConditionFields.length) {
1984                                            if (orderByComparator.isAscending() ^ previous) {
1985                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1986                                            }
1987                                            else {
1988                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1989                                            }
1990                                    }
1991                                    else {
1992                                            if (orderByComparator.isAscending() ^ previous) {
1993                                                    query.append(WHERE_GREATER_THAN);
1994                                            }
1995                                            else {
1996                                                    query.append(WHERE_LESSER_THAN);
1997                                            }
1998                                    }
1999                            }
2000    
2001                            query.append(ORDER_BY_CLAUSE);
2002    
2003                            String[] orderByFields = orderByComparator.getOrderByFields();
2004    
2005                            for (int i = 0; i < orderByFields.length; i++) {
2006                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2007                                    query.append(orderByFields[i]);
2008    
2009                                    if ((i + 1) < orderByFields.length) {
2010                                            if (orderByComparator.isAscending() ^ previous) {
2011                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2012                                            }
2013                                            else {
2014                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2015                                            }
2016                                    }
2017                                    else {
2018                                            if (orderByComparator.isAscending() ^ previous) {
2019                                                    query.append(ORDER_BY_ASC);
2020                                            }
2021                                            else {
2022                                                    query.append(ORDER_BY_DESC);
2023                                            }
2024                                    }
2025                            }
2026                    }
2027    
2028                    else {
2029                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2030                    }
2031    
2032                    String sql = query.toString();
2033    
2034                    Query q = session.createQuery(sql);
2035    
2036                    q.setFirstResult(0);
2037                    q.setMaxResults(2);
2038    
2039                    QueryPos qPos = QueryPos.getInstance(q);
2040    
2041                    if (uuid != null) {
2042                            qPos.add(uuid);
2043                    }
2044    
2045                    if (orderByComparator != null) {
2046                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2047    
2048                            for (Object value : values) {
2049                                    qPos.add(value);
2050                            }
2051                    }
2052    
2053                    List<JournalArticle> list = q.list();
2054    
2055                    if (list.size() == 2) {
2056                            return list.get(1);
2057                    }
2058                    else {
2059                            return null;
2060                    }
2061            }
2062    
2063            /**
2064             * 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.
2065             *
2066             * @param uuid the uuid
2067             * @param groupId the group ID
2068             * @return the matching journal article
2069             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2070             * @throws SystemException if a system exception occurred
2071             */
2072            public JournalArticle findByUUID_G(String uuid, long groupId)
2073                    throws NoSuchArticleException, SystemException {
2074                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
2075    
2076                    if (journalArticle == null) {
2077                            StringBundler msg = new StringBundler(6);
2078    
2079                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2080    
2081                            msg.append("uuid=");
2082                            msg.append(uuid);
2083    
2084                            msg.append(", groupId=");
2085                            msg.append(groupId);
2086    
2087                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2088    
2089                            if (_log.isWarnEnabled()) {
2090                                    _log.warn(msg.toString());
2091                            }
2092    
2093                            throw new NoSuchArticleException(msg.toString());
2094                    }
2095    
2096                    return journalArticle;
2097            }
2098    
2099            /**
2100             * 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.
2101             *
2102             * @param uuid the uuid
2103             * @param groupId the group ID
2104             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
2105             * @throws SystemException if a system exception occurred
2106             */
2107            public JournalArticle fetchByUUID_G(String uuid, long groupId)
2108                    throws SystemException {
2109                    return fetchByUUID_G(uuid, groupId, true);
2110            }
2111    
2112            /**
2113             * 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.
2114             *
2115             * @param uuid the uuid
2116             * @param groupId the group ID
2117             * @param retrieveFromCache whether to use the finder cache
2118             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
2119             * @throws SystemException if a system exception occurred
2120             */
2121            public JournalArticle fetchByUUID_G(String uuid, long groupId,
2122                    boolean retrieveFromCache) throws SystemException {
2123                    Object[] finderArgs = new Object[] { uuid, groupId };
2124    
2125                    Object result = null;
2126    
2127                    if (retrieveFromCache) {
2128                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
2129                                            finderArgs, this);
2130                    }
2131    
2132                    if (result instanceof JournalArticle) {
2133                            JournalArticle journalArticle = (JournalArticle)result;
2134    
2135                            if (!Validator.equals(uuid, journalArticle.getUuid()) ||
2136                                            (groupId != journalArticle.getGroupId())) {
2137                                    result = null;
2138                            }
2139                    }
2140    
2141                    if (result == null) {
2142                            StringBundler query = new StringBundler(4);
2143    
2144                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2145    
2146                            if (uuid == null) {
2147                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2148                            }
2149                            else {
2150                                    if (uuid.equals(StringPool.BLANK)) {
2151                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2152                                    }
2153                                    else {
2154                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2155                                    }
2156                            }
2157    
2158                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2159    
2160                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2161    
2162                            String sql = query.toString();
2163    
2164                            Session session = null;
2165    
2166                            try {
2167                                    session = openSession();
2168    
2169                                    Query q = session.createQuery(sql);
2170    
2171                                    QueryPos qPos = QueryPos.getInstance(q);
2172    
2173                                    if (uuid != null) {
2174                                            qPos.add(uuid);
2175                                    }
2176    
2177                                    qPos.add(groupId);
2178    
2179                                    List<JournalArticle> list = q.list();
2180    
2181                                    result = list;
2182    
2183                                    JournalArticle journalArticle = null;
2184    
2185                                    if (list.isEmpty()) {
2186                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2187                                                    finderArgs, list);
2188                                    }
2189                                    else {
2190                                            journalArticle = list.get(0);
2191    
2192                                            cacheResult(journalArticle);
2193    
2194                                            if ((journalArticle.getUuid() == null) ||
2195                                                            !journalArticle.getUuid().equals(uuid) ||
2196                                                            (journalArticle.getGroupId() != groupId)) {
2197                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2198                                                            finderArgs, journalArticle);
2199                                            }
2200                                    }
2201    
2202                                    return journalArticle;
2203                            }
2204                            catch (Exception e) {
2205                                    throw processException(e);
2206                            }
2207                            finally {
2208                                    if (result == null) {
2209                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
2210                                                    finderArgs);
2211                                    }
2212    
2213                                    closeSession(session);
2214                            }
2215                    }
2216                    else {
2217                            if (result instanceof List<?>) {
2218                                    return null;
2219                            }
2220                            else {
2221                                    return (JournalArticle)result;
2222                            }
2223                    }
2224            }
2225    
2226            /**
2227             * Returns all the journal articles where resourcePrimKey = &#63;.
2228             *
2229             * @param resourcePrimKey the resource prim key
2230             * @return the matching journal articles
2231             * @throws SystemException if a system exception occurred
2232             */
2233            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
2234                    throws SystemException {
2235                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
2236                            QueryUtil.ALL_POS, null);
2237            }
2238    
2239            /**
2240             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
2241             *
2242             * <p>
2243             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2244             * </p>
2245             *
2246             * @param resourcePrimKey the resource prim key
2247             * @param start the lower bound of the range of journal articles
2248             * @param end the upper bound of the range of journal articles (not inclusive)
2249             * @return the range of matching journal articles
2250             * @throws SystemException if a system exception occurred
2251             */
2252            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
2253                    int start, int end) throws SystemException {
2254                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
2255            }
2256    
2257            /**
2258             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
2259             *
2260             * <p>
2261             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2262             * </p>
2263             *
2264             * @param resourcePrimKey the resource prim key
2265             * @param start the lower bound of the range of journal articles
2266             * @param end the upper bound of the range of journal articles (not inclusive)
2267             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2268             * @return the ordered range of matching journal articles
2269             * @throws SystemException if a system exception occurred
2270             */
2271            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
2272                    int start, int end, OrderByComparator orderByComparator)
2273                    throws SystemException {
2274                    FinderPath finderPath = null;
2275                    Object[] finderArgs = null;
2276    
2277                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2278                                    (orderByComparator == null)) {
2279                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
2280                            finderArgs = new Object[] { resourcePrimKey };
2281                    }
2282                    else {
2283                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
2284                            finderArgs = new Object[] {
2285                                            resourcePrimKey,
2286                                            
2287                                            start, end, orderByComparator
2288                                    };
2289                    }
2290    
2291                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2292                                    finderArgs, this);
2293    
2294                    if ((list != null) && !list.isEmpty()) {
2295                            for (JournalArticle journalArticle : list) {
2296                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey())) {
2297                                            list = null;
2298    
2299                                            break;
2300                                    }
2301                            }
2302                    }
2303    
2304                    if (list == null) {
2305                            StringBundler query = null;
2306    
2307                            if (orderByComparator != null) {
2308                                    query = new StringBundler(3 +
2309                                                    (orderByComparator.getOrderByFields().length * 3));
2310                            }
2311                            else {
2312                                    query = new StringBundler(3);
2313                            }
2314    
2315                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2316    
2317                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
2318    
2319                            if (orderByComparator != null) {
2320                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2321                                            orderByComparator);
2322                            }
2323    
2324                            else {
2325                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2326                            }
2327    
2328                            String sql = query.toString();
2329    
2330                            Session session = null;
2331    
2332                            try {
2333                                    session = openSession();
2334    
2335                                    Query q = session.createQuery(sql);
2336    
2337                                    QueryPos qPos = QueryPos.getInstance(q);
2338    
2339                                    qPos.add(resourcePrimKey);
2340    
2341                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2342                                                    start, end);
2343                            }
2344                            catch (Exception e) {
2345                                    throw processException(e);
2346                            }
2347                            finally {
2348                                    if (list == null) {
2349                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2350                                    }
2351                                    else {
2352                                            cacheResult(list);
2353    
2354                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2355                                    }
2356    
2357                                    closeSession(session);
2358                            }
2359                    }
2360    
2361                    return list;
2362            }
2363    
2364            /**
2365             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
2366             *
2367             * @param resourcePrimKey the resource prim key
2368             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2369             * @return the first matching journal article
2370             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2371             * @throws SystemException if a system exception occurred
2372             */
2373            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
2374                    OrderByComparator orderByComparator)
2375                    throws NoSuchArticleException, SystemException {
2376                    JournalArticle journalArticle = fetchByResourcePrimKey_First(resourcePrimKey,
2377                                    orderByComparator);
2378    
2379                    if (journalArticle != null) {
2380                            return journalArticle;
2381                    }
2382    
2383                    StringBundler msg = new StringBundler(4);
2384    
2385                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2386    
2387                    msg.append("resourcePrimKey=");
2388                    msg.append(resourcePrimKey);
2389    
2390                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2391    
2392                    throw new NoSuchArticleException(msg.toString());
2393            }
2394    
2395            /**
2396             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
2397             *
2398             * @param resourcePrimKey the resource prim key
2399             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2400             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2401             * @throws SystemException if a system exception occurred
2402             */
2403            public JournalArticle fetchByResourcePrimKey_First(long resourcePrimKey,
2404                    OrderByComparator orderByComparator) throws SystemException {
2405                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
2406                                    1, orderByComparator);
2407    
2408                    if (!list.isEmpty()) {
2409                            return list.get(0);
2410                    }
2411    
2412                    return null;
2413            }
2414    
2415            /**
2416             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
2417             *
2418             * @param resourcePrimKey the resource prim key
2419             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2420             * @return the last matching journal article
2421             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2422             * @throws SystemException if a system exception occurred
2423             */
2424            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
2425                    OrderByComparator orderByComparator)
2426                    throws NoSuchArticleException, SystemException {
2427                    JournalArticle journalArticle = fetchByResourcePrimKey_Last(resourcePrimKey,
2428                                    orderByComparator);
2429    
2430                    if (journalArticle != null) {
2431                            return journalArticle;
2432                    }
2433    
2434                    StringBundler msg = new StringBundler(4);
2435    
2436                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2437    
2438                    msg.append("resourcePrimKey=");
2439                    msg.append(resourcePrimKey);
2440    
2441                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2442    
2443                    throw new NoSuchArticleException(msg.toString());
2444            }
2445    
2446            /**
2447             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
2448             *
2449             * @param resourcePrimKey the resource prim key
2450             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2451             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2452             * @throws SystemException if a system exception occurred
2453             */
2454            public JournalArticle fetchByResourcePrimKey_Last(long resourcePrimKey,
2455                    OrderByComparator orderByComparator) throws SystemException {
2456                    int count = countByResourcePrimKey(resourcePrimKey);
2457    
2458                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
2459                                    count - 1, count, orderByComparator);
2460    
2461                    if (!list.isEmpty()) {
2462                            return list.get(0);
2463                    }
2464    
2465                    return null;
2466            }
2467    
2468            /**
2469             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
2470             *
2471             * @param id the primary key of the current journal article
2472             * @param resourcePrimKey the resource prim key
2473             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2474             * @return the previous, current, and next journal article
2475             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2476             * @throws SystemException if a system exception occurred
2477             */
2478            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
2479                    long resourcePrimKey, OrderByComparator orderByComparator)
2480                    throws NoSuchArticleException, SystemException {
2481                    JournalArticle journalArticle = findByPrimaryKey(id);
2482    
2483                    Session session = null;
2484    
2485                    try {
2486                            session = openSession();
2487    
2488                            JournalArticle[] array = new JournalArticleImpl[3];
2489    
2490                            array[0] = getByResourcePrimKey_PrevAndNext(session,
2491                                            journalArticle, resourcePrimKey, orderByComparator, true);
2492    
2493                            array[1] = journalArticle;
2494    
2495                            array[2] = getByResourcePrimKey_PrevAndNext(session,
2496                                            journalArticle, resourcePrimKey, orderByComparator, false);
2497    
2498                            return array;
2499                    }
2500                    catch (Exception e) {
2501                            throw processException(e);
2502                    }
2503                    finally {
2504                            closeSession(session);
2505                    }
2506            }
2507    
2508            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
2509                    JournalArticle journalArticle, long resourcePrimKey,
2510                    OrderByComparator orderByComparator, boolean previous) {
2511                    StringBundler query = null;
2512    
2513                    if (orderByComparator != null) {
2514                            query = new StringBundler(6 +
2515                                            (orderByComparator.getOrderByFields().length * 6));
2516                    }
2517                    else {
2518                            query = new StringBundler(3);
2519                    }
2520    
2521                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2522    
2523                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
2524    
2525                    if (orderByComparator != null) {
2526                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2527    
2528                            if (orderByConditionFields.length > 0) {
2529                                    query.append(WHERE_AND);
2530                            }
2531    
2532                            for (int i = 0; i < orderByConditionFields.length; i++) {
2533                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2534                                    query.append(orderByConditionFields[i]);
2535    
2536                                    if ((i + 1) < orderByConditionFields.length) {
2537                                            if (orderByComparator.isAscending() ^ previous) {
2538                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2539                                            }
2540                                            else {
2541                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2542                                            }
2543                                    }
2544                                    else {
2545                                            if (orderByComparator.isAscending() ^ previous) {
2546                                                    query.append(WHERE_GREATER_THAN);
2547                                            }
2548                                            else {
2549                                                    query.append(WHERE_LESSER_THAN);
2550                                            }
2551                                    }
2552                            }
2553    
2554                            query.append(ORDER_BY_CLAUSE);
2555    
2556                            String[] orderByFields = orderByComparator.getOrderByFields();
2557    
2558                            for (int i = 0; i < orderByFields.length; i++) {
2559                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2560                                    query.append(orderByFields[i]);
2561    
2562                                    if ((i + 1) < orderByFields.length) {
2563                                            if (orderByComparator.isAscending() ^ previous) {
2564                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2565                                            }
2566                                            else {
2567                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2568                                            }
2569                                    }
2570                                    else {
2571                                            if (orderByComparator.isAscending() ^ previous) {
2572                                                    query.append(ORDER_BY_ASC);
2573                                            }
2574                                            else {
2575                                                    query.append(ORDER_BY_DESC);
2576                                            }
2577                                    }
2578                            }
2579                    }
2580    
2581                    else {
2582                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2583                    }
2584    
2585                    String sql = query.toString();
2586    
2587                    Query q = session.createQuery(sql);
2588    
2589                    q.setFirstResult(0);
2590                    q.setMaxResults(2);
2591    
2592                    QueryPos qPos = QueryPos.getInstance(q);
2593    
2594                    qPos.add(resourcePrimKey);
2595    
2596                    if (orderByComparator != null) {
2597                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2598    
2599                            for (Object value : values) {
2600                                    qPos.add(value);
2601                            }
2602                    }
2603    
2604                    List<JournalArticle> list = q.list();
2605    
2606                    if (list.size() == 2) {
2607                            return list.get(1);
2608                    }
2609                    else {
2610                            return null;
2611                    }
2612            }
2613    
2614            /**
2615             * Returns all the journal articles where groupId = &#63;.
2616             *
2617             * @param groupId the group ID
2618             * @return the matching journal articles
2619             * @throws SystemException if a system exception occurred
2620             */
2621            public List<JournalArticle> findByGroupId(long groupId)
2622                    throws SystemException {
2623                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2624            }
2625    
2626            /**
2627             * Returns a range of all the journal articles where groupId = &#63;.
2628             *
2629             * <p>
2630             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2631             * </p>
2632             *
2633             * @param groupId the group ID
2634             * @param start the lower bound of the range of journal articles
2635             * @param end the upper bound of the range of journal articles (not inclusive)
2636             * @return the range of matching journal articles
2637             * @throws SystemException if a system exception occurred
2638             */
2639            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
2640                    throws SystemException {
2641                    return findByGroupId(groupId, start, end, null);
2642            }
2643    
2644            /**
2645             * Returns an ordered range of all the journal articles where groupId = &#63;.
2646             *
2647             * <p>
2648             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2649             * </p>
2650             *
2651             * @param groupId the group ID
2652             * @param start the lower bound of the range of journal articles
2653             * @param end the upper bound of the range of journal articles (not inclusive)
2654             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2655             * @return the ordered range of matching journal articles
2656             * @throws SystemException if a system exception occurred
2657             */
2658            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
2659                    OrderByComparator orderByComparator) throws SystemException {
2660                    FinderPath finderPath = null;
2661                    Object[] finderArgs = null;
2662    
2663                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2664                                    (orderByComparator == null)) {
2665                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2666                            finderArgs = new Object[] { groupId };
2667                    }
2668                    else {
2669                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2670                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2671                    }
2672    
2673                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2674                                    finderArgs, this);
2675    
2676                    if ((list != null) && !list.isEmpty()) {
2677                            for (JournalArticle journalArticle : list) {
2678                                    if ((groupId != journalArticle.getGroupId())) {
2679                                            list = null;
2680    
2681                                            break;
2682                                    }
2683                            }
2684                    }
2685    
2686                    if (list == null) {
2687                            StringBundler query = null;
2688    
2689                            if (orderByComparator != null) {
2690                                    query = new StringBundler(3 +
2691                                                    (orderByComparator.getOrderByFields().length * 3));
2692                            }
2693                            else {
2694                                    query = new StringBundler(3);
2695                            }
2696    
2697                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2698    
2699                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2700    
2701                            if (orderByComparator != null) {
2702                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2703                                            orderByComparator);
2704                            }
2705    
2706                            else {
2707                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2708                            }
2709    
2710                            String sql = query.toString();
2711    
2712                            Session session = null;
2713    
2714                            try {
2715                                    session = openSession();
2716    
2717                                    Query q = session.createQuery(sql);
2718    
2719                                    QueryPos qPos = QueryPos.getInstance(q);
2720    
2721                                    qPos.add(groupId);
2722    
2723                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2724                                                    start, end);
2725                            }
2726                            catch (Exception e) {
2727                                    throw processException(e);
2728                            }
2729                            finally {
2730                                    if (list == null) {
2731                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2732                                    }
2733                                    else {
2734                                            cacheResult(list);
2735    
2736                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2737                                    }
2738    
2739                                    closeSession(session);
2740                            }
2741                    }
2742    
2743                    return list;
2744            }
2745    
2746            /**
2747             * Returns the first journal article in the ordered set where groupId = &#63;.
2748             *
2749             * @param groupId the group ID
2750             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2751             * @return the first matching journal article
2752             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2753             * @throws SystemException if a system exception occurred
2754             */
2755            public JournalArticle findByGroupId_First(long groupId,
2756                    OrderByComparator orderByComparator)
2757                    throws NoSuchArticleException, SystemException {
2758                    JournalArticle journalArticle = fetchByGroupId_First(groupId,
2759                                    orderByComparator);
2760    
2761                    if (journalArticle != null) {
2762                            return journalArticle;
2763                    }
2764    
2765                    StringBundler msg = new StringBundler(4);
2766    
2767                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2768    
2769                    msg.append("groupId=");
2770                    msg.append(groupId);
2771    
2772                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2773    
2774                    throw new NoSuchArticleException(msg.toString());
2775            }
2776    
2777            /**
2778             * Returns the first journal article in the ordered set where groupId = &#63;.
2779             *
2780             * @param groupId the group ID
2781             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2782             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
2783             * @throws SystemException if a system exception occurred
2784             */
2785            public JournalArticle fetchByGroupId_First(long groupId,
2786                    OrderByComparator orderByComparator) throws SystemException {
2787                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2788                                    orderByComparator);
2789    
2790                    if (!list.isEmpty()) {
2791                            return list.get(0);
2792                    }
2793    
2794                    return null;
2795            }
2796    
2797            /**
2798             * Returns the last journal article in the ordered set where groupId = &#63;.
2799             *
2800             * @param groupId the group ID
2801             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2802             * @return the last matching journal article
2803             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2804             * @throws SystemException if a system exception occurred
2805             */
2806            public JournalArticle findByGroupId_Last(long groupId,
2807                    OrderByComparator orderByComparator)
2808                    throws NoSuchArticleException, SystemException {
2809                    JournalArticle journalArticle = fetchByGroupId_Last(groupId,
2810                                    orderByComparator);
2811    
2812                    if (journalArticle != null) {
2813                            return journalArticle;
2814                    }
2815    
2816                    StringBundler msg = new StringBundler(4);
2817    
2818                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2819    
2820                    msg.append("groupId=");
2821                    msg.append(groupId);
2822    
2823                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2824    
2825                    throw new NoSuchArticleException(msg.toString());
2826            }
2827    
2828            /**
2829             * Returns the last journal article in the ordered set where groupId = &#63;.
2830             *
2831             * @param groupId the group ID
2832             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2833             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
2834             * @throws SystemException if a system exception occurred
2835             */
2836            public JournalArticle fetchByGroupId_Last(long groupId,
2837                    OrderByComparator orderByComparator) throws SystemException {
2838                    int count = countByGroupId(groupId);
2839    
2840                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2841                                    orderByComparator);
2842    
2843                    if (!list.isEmpty()) {
2844                            return list.get(0);
2845                    }
2846    
2847                    return null;
2848            }
2849    
2850            /**
2851             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2852             *
2853             * @param id the primary key of the current journal article
2854             * @param groupId the group ID
2855             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2856             * @return the previous, current, and next journal article
2857             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2858             * @throws SystemException if a system exception occurred
2859             */
2860            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2861                    OrderByComparator orderByComparator)
2862                    throws NoSuchArticleException, SystemException {
2863                    JournalArticle journalArticle = findByPrimaryKey(id);
2864    
2865                    Session session = null;
2866    
2867                    try {
2868                            session = openSession();
2869    
2870                            JournalArticle[] array = new JournalArticleImpl[3];
2871    
2872                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2873                                            groupId, orderByComparator, true);
2874    
2875                            array[1] = journalArticle;
2876    
2877                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2878                                            groupId, orderByComparator, false);
2879    
2880                            return array;
2881                    }
2882                    catch (Exception e) {
2883                            throw processException(e);
2884                    }
2885                    finally {
2886                            closeSession(session);
2887                    }
2888            }
2889    
2890            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2891                    JournalArticle journalArticle, long groupId,
2892                    OrderByComparator orderByComparator, boolean previous) {
2893                    StringBundler query = null;
2894    
2895                    if (orderByComparator != null) {
2896                            query = new StringBundler(6 +
2897                                            (orderByComparator.getOrderByFields().length * 6));
2898                    }
2899                    else {
2900                            query = new StringBundler(3);
2901                    }
2902    
2903                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2904    
2905                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2906    
2907                    if (orderByComparator != null) {
2908                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2909    
2910                            if (orderByConditionFields.length > 0) {
2911                                    query.append(WHERE_AND);
2912                            }
2913    
2914                            for (int i = 0; i < orderByConditionFields.length; i++) {
2915                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2916                                    query.append(orderByConditionFields[i]);
2917    
2918                                    if ((i + 1) < orderByConditionFields.length) {
2919                                            if (orderByComparator.isAscending() ^ previous) {
2920                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2921                                            }
2922                                            else {
2923                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2924                                            }
2925                                    }
2926                                    else {
2927                                            if (orderByComparator.isAscending() ^ previous) {
2928                                                    query.append(WHERE_GREATER_THAN);
2929                                            }
2930                                            else {
2931                                                    query.append(WHERE_LESSER_THAN);
2932                                            }
2933                                    }
2934                            }
2935    
2936                            query.append(ORDER_BY_CLAUSE);
2937    
2938                            String[] orderByFields = orderByComparator.getOrderByFields();
2939    
2940                            for (int i = 0; i < orderByFields.length; i++) {
2941                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2942                                    query.append(orderByFields[i]);
2943    
2944                                    if ((i + 1) < orderByFields.length) {
2945                                            if (orderByComparator.isAscending() ^ previous) {
2946                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2947                                            }
2948                                            else {
2949                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2950                                            }
2951                                    }
2952                                    else {
2953                                            if (orderByComparator.isAscending() ^ previous) {
2954                                                    query.append(ORDER_BY_ASC);
2955                                            }
2956                                            else {
2957                                                    query.append(ORDER_BY_DESC);
2958                                            }
2959                                    }
2960                            }
2961                    }
2962    
2963                    else {
2964                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2965                    }
2966    
2967                    String sql = query.toString();
2968    
2969                    Query q = session.createQuery(sql);
2970    
2971                    q.setFirstResult(0);
2972                    q.setMaxResults(2);
2973    
2974                    QueryPos qPos = QueryPos.getInstance(q);
2975    
2976                    qPos.add(groupId);
2977    
2978                    if (orderByComparator != null) {
2979                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2980    
2981                            for (Object value : values) {
2982                                    qPos.add(value);
2983                            }
2984                    }
2985    
2986                    List<JournalArticle> list = q.list();
2987    
2988                    if (list.size() == 2) {
2989                            return list.get(1);
2990                    }
2991                    else {
2992                            return null;
2993                    }
2994            }
2995    
2996            /**
2997             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2998             *
2999             * @param groupId the group ID
3000             * @return the matching journal articles that the user has permission to view
3001             * @throws SystemException if a system exception occurred
3002             */
3003            public List<JournalArticle> filterFindByGroupId(long groupId)
3004                    throws SystemException {
3005                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
3006                            QueryUtil.ALL_POS, null);
3007            }
3008    
3009            /**
3010             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
3011             *
3012             * <p>
3013             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3014             * </p>
3015             *
3016             * @param groupId the group ID
3017             * @param start the lower bound of the range of journal articles
3018             * @param end the upper bound of the range of journal articles (not inclusive)
3019             * @return the range of matching journal articles that the user has permission to view
3020             * @throws SystemException if a system exception occurred
3021             */
3022            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
3023                    int end) throws SystemException {
3024                    return filterFindByGroupId(groupId, start, end, null);
3025            }
3026    
3027            /**
3028             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
3029             *
3030             * <p>
3031             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3032             * </p>
3033             *
3034             * @param groupId the group ID
3035             * @param start the lower bound of the range of journal articles
3036             * @param end the upper bound of the range of journal articles (not inclusive)
3037             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3038             * @return the ordered range of matching journal articles that the user has permission to view
3039             * @throws SystemException if a system exception occurred
3040             */
3041            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
3042                    int end, OrderByComparator orderByComparator) throws SystemException {
3043                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3044                            return findByGroupId(groupId, start, end, orderByComparator);
3045                    }
3046    
3047                    StringBundler query = null;
3048    
3049                    if (orderByComparator != null) {
3050                            query = new StringBundler(3 +
3051                                            (orderByComparator.getOrderByFields().length * 3));
3052                    }
3053                    else {
3054                            query = new StringBundler(3);
3055                    }
3056    
3057                    if (getDB().isSupportsInlineDistinct()) {
3058                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
3059                    }
3060                    else {
3061                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
3062                    }
3063    
3064                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3065    
3066                    if (!getDB().isSupportsInlineDistinct()) {
3067                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
3068                    }
3069    
3070                    if (orderByComparator != null) {
3071                            if (getDB().isSupportsInlineDistinct()) {
3072                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3073                                            orderByComparator);
3074                            }
3075                            else {
3076                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3077                                            orderByComparator);
3078                            }
3079                    }
3080    
3081                    else {
3082                            if (getDB().isSupportsInlineDistinct()) {
3083                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3084                            }
3085                            else {
3086                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
3087                            }
3088                    }
3089    
3090                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3091                                    JournalArticle.class.getName(),
3092                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3093    
3094                    Session session = null;
3095    
3096                    try {
3097                            session = openSession();
3098    
3099                            SQLQuery q = session.createSQLQuery(sql);
3100    
3101                            if (getDB().isSupportsInlineDistinct()) {
3102                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
3103                            }
3104                            else {
3105                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
3106                            }
3107    
3108                            QueryPos qPos = QueryPos.getInstance(q);
3109    
3110                            qPos.add(groupId);
3111    
3112                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
3113                                    end);
3114                    }
3115                    catch (Exception e) {
3116                            throw processException(e);
3117                    }
3118                    finally {
3119                            closeSession(session);
3120                    }
3121            }
3122    
3123            /**
3124             * 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;.
3125             *
3126             * @param id the primary key of the current journal article
3127             * @param groupId the group ID
3128             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3129             * @return the previous, current, and next journal article
3130             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3131             * @throws SystemException if a system exception occurred
3132             */
3133            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
3134                    long groupId, OrderByComparator orderByComparator)
3135                    throws NoSuchArticleException, SystemException {
3136                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3137                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
3138                    }
3139    
3140                    JournalArticle journalArticle = findByPrimaryKey(id);
3141    
3142                    Session session = null;
3143    
3144                    try {
3145                            session = openSession();
3146    
3147                            JournalArticle[] array = new JournalArticleImpl[3];
3148    
3149                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
3150                                            groupId, orderByComparator, true);
3151    
3152                            array[1] = journalArticle;
3153    
3154                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
3155                                            groupId, orderByComparator, false);
3156    
3157                            return array;
3158                    }
3159                    catch (Exception e) {
3160                            throw processException(e);
3161                    }
3162                    finally {
3163                            closeSession(session);
3164                    }
3165            }
3166    
3167            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
3168                    JournalArticle journalArticle, long groupId,
3169                    OrderByComparator orderByComparator, boolean previous) {
3170                    StringBundler query = null;
3171    
3172                    if (orderByComparator != null) {
3173                            query = new StringBundler(6 +
3174                                            (orderByComparator.getOrderByFields().length * 6));
3175                    }
3176                    else {
3177                            query = new StringBundler(3);
3178                    }
3179    
3180                    if (getDB().isSupportsInlineDistinct()) {
3181                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
3182                    }
3183                    else {
3184                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
3185                    }
3186    
3187                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3188    
3189                    if (!getDB().isSupportsInlineDistinct()) {
3190                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
3191                    }
3192    
3193                    if (orderByComparator != null) {
3194                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3195    
3196                            if (orderByConditionFields.length > 0) {
3197                                    query.append(WHERE_AND);
3198                            }
3199    
3200                            for (int i = 0; i < orderByConditionFields.length; i++) {
3201                                    if (getDB().isSupportsInlineDistinct()) {
3202                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3203                                    }
3204                                    else {
3205                                            query.append(_ORDER_BY_ENTITY_TABLE);
3206                                    }
3207    
3208                                    query.append(orderByConditionFields[i]);
3209    
3210                                    if ((i + 1) < orderByConditionFields.length) {
3211                                            if (orderByComparator.isAscending() ^ previous) {
3212                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3213                                            }
3214                                            else {
3215                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3216                                            }
3217                                    }
3218                                    else {
3219                                            if (orderByComparator.isAscending() ^ previous) {
3220                                                    query.append(WHERE_GREATER_THAN);
3221                                            }
3222                                            else {
3223                                                    query.append(WHERE_LESSER_THAN);
3224                                            }
3225                                    }
3226                            }
3227    
3228                            query.append(ORDER_BY_CLAUSE);
3229    
3230                            String[] orderByFields = orderByComparator.getOrderByFields();
3231    
3232                            for (int i = 0; i < orderByFields.length; i++) {
3233                                    if (getDB().isSupportsInlineDistinct()) {
3234                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3235                                    }
3236                                    else {
3237                                            query.append(_ORDER_BY_ENTITY_TABLE);
3238                                    }
3239    
3240                                    query.append(orderByFields[i]);
3241    
3242                                    if ((i + 1) < orderByFields.length) {
3243                                            if (orderByComparator.isAscending() ^ previous) {
3244                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3245                                            }
3246                                            else {
3247                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3248                                            }
3249                                    }
3250                                    else {
3251                                            if (orderByComparator.isAscending() ^ previous) {
3252                                                    query.append(ORDER_BY_ASC);
3253                                            }
3254                                            else {
3255                                                    query.append(ORDER_BY_DESC);
3256                                            }
3257                                    }
3258                            }
3259                    }
3260    
3261                    else {
3262                            if (getDB().isSupportsInlineDistinct()) {
3263                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3264                            }
3265                            else {
3266                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
3267                            }
3268                    }
3269    
3270                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3271                                    JournalArticle.class.getName(),
3272                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3273    
3274                    SQLQuery q = session.createSQLQuery(sql);
3275    
3276                    q.setFirstResult(0);
3277                    q.setMaxResults(2);
3278    
3279                    if (getDB().isSupportsInlineDistinct()) {
3280                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
3281                    }
3282                    else {
3283                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
3284                    }
3285    
3286                    QueryPos qPos = QueryPos.getInstance(q);
3287    
3288                    qPos.add(groupId);
3289    
3290                    if (orderByComparator != null) {
3291                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3292    
3293                            for (Object value : values) {
3294                                    qPos.add(value);
3295                            }
3296                    }
3297    
3298                    List<JournalArticle> list = q.list();
3299    
3300                    if (list.size() == 2) {
3301                            return list.get(1);
3302                    }
3303                    else {
3304                            return null;
3305                    }
3306            }
3307    
3308            /**
3309             * Returns all the journal articles where companyId = &#63;.
3310             *
3311             * @param companyId the company ID
3312             * @return the matching journal articles
3313             * @throws SystemException if a system exception occurred
3314             */
3315            public List<JournalArticle> findByCompanyId(long companyId)
3316                    throws SystemException {
3317                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3318                            null);
3319            }
3320    
3321            /**
3322             * Returns a range of all the journal articles where companyId = &#63;.
3323             *
3324             * <p>
3325             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3326             * </p>
3327             *
3328             * @param companyId the company ID
3329             * @param start the lower bound of the range of journal articles
3330             * @param end the upper bound of the range of journal articles (not inclusive)
3331             * @return the range of matching journal articles
3332             * @throws SystemException if a system exception occurred
3333             */
3334            public List<JournalArticle> findByCompanyId(long companyId, int start,
3335                    int end) throws SystemException {
3336                    return findByCompanyId(companyId, start, end, null);
3337            }
3338    
3339            /**
3340             * Returns an ordered range of all the journal articles where companyId = &#63;.
3341             *
3342             * <p>
3343             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3344             * </p>
3345             *
3346             * @param companyId the company ID
3347             * @param start the lower bound of the range of journal articles
3348             * @param end the upper bound of the range of journal articles (not inclusive)
3349             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3350             * @return the ordered range of matching journal articles
3351             * @throws SystemException if a system exception occurred
3352             */
3353            public List<JournalArticle> findByCompanyId(long companyId, int start,
3354                    int end, OrderByComparator orderByComparator) throws SystemException {
3355                    FinderPath finderPath = null;
3356                    Object[] finderArgs = null;
3357    
3358                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3359                                    (orderByComparator == null)) {
3360                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
3361                            finderArgs = new Object[] { companyId };
3362                    }
3363                    else {
3364                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
3365                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
3366                    }
3367    
3368                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3369                                    finderArgs, this);
3370    
3371                    if ((list != null) && !list.isEmpty()) {
3372                            for (JournalArticle journalArticle : list) {
3373                                    if ((companyId != journalArticle.getCompanyId())) {
3374                                            list = null;
3375    
3376                                            break;
3377                                    }
3378                            }
3379                    }
3380    
3381                    if (list == null) {
3382                            StringBundler query = null;
3383    
3384                            if (orderByComparator != null) {
3385                                    query = new StringBundler(3 +
3386                                                    (orderByComparator.getOrderByFields().length * 3));
3387                            }
3388                            else {
3389                                    query = new StringBundler(3);
3390                            }
3391    
3392                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3393    
3394                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3395    
3396                            if (orderByComparator != null) {
3397                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3398                                            orderByComparator);
3399                            }
3400    
3401                            else {
3402                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3403                            }
3404    
3405                            String sql = query.toString();
3406    
3407                            Session session = null;
3408    
3409                            try {
3410                                    session = openSession();
3411    
3412                                    Query q = session.createQuery(sql);
3413    
3414                                    QueryPos qPos = QueryPos.getInstance(q);
3415    
3416                                    qPos.add(companyId);
3417    
3418                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3419                                                    start, end);
3420                            }
3421                            catch (Exception e) {
3422                                    throw processException(e);
3423                            }
3424                            finally {
3425                                    if (list == null) {
3426                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3427                                    }
3428                                    else {
3429                                            cacheResult(list);
3430    
3431                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3432                                    }
3433    
3434                                    closeSession(session);
3435                            }
3436                    }
3437    
3438                    return list;
3439            }
3440    
3441            /**
3442             * Returns the first journal article in the ordered set where companyId = &#63;.
3443             *
3444             * @param companyId the company ID
3445             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3446             * @return the first matching journal article
3447             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3448             * @throws SystemException if a system exception occurred
3449             */
3450            public JournalArticle findByCompanyId_First(long companyId,
3451                    OrderByComparator orderByComparator)
3452                    throws NoSuchArticleException, SystemException {
3453                    JournalArticle journalArticle = fetchByCompanyId_First(companyId,
3454                                    orderByComparator);
3455    
3456                    if (journalArticle != null) {
3457                            return journalArticle;
3458                    }
3459    
3460                    StringBundler msg = new StringBundler(4);
3461    
3462                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3463    
3464                    msg.append("companyId=");
3465                    msg.append(companyId);
3466    
3467                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3468    
3469                    throw new NoSuchArticleException(msg.toString());
3470            }
3471    
3472            /**
3473             * Returns the first journal article in the ordered set where companyId = &#63;.
3474             *
3475             * @param companyId the company ID
3476             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3477             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3478             * @throws SystemException if a system exception occurred
3479             */
3480            public JournalArticle fetchByCompanyId_First(long companyId,
3481                    OrderByComparator orderByComparator) throws SystemException {
3482                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
3483                                    orderByComparator);
3484    
3485                    if (!list.isEmpty()) {
3486                            return list.get(0);
3487                    }
3488    
3489                    return null;
3490            }
3491    
3492            /**
3493             * Returns the last journal article in the ordered set where companyId = &#63;.
3494             *
3495             * @param companyId the company ID
3496             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3497             * @return the last matching journal article
3498             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3499             * @throws SystemException if a system exception occurred
3500             */
3501            public JournalArticle findByCompanyId_Last(long companyId,
3502                    OrderByComparator orderByComparator)
3503                    throws NoSuchArticleException, SystemException {
3504                    JournalArticle journalArticle = fetchByCompanyId_Last(companyId,
3505                                    orderByComparator);
3506    
3507                    if (journalArticle != null) {
3508                            return journalArticle;
3509                    }
3510    
3511                    StringBundler msg = new StringBundler(4);
3512    
3513                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3514    
3515                    msg.append("companyId=");
3516                    msg.append(companyId);
3517    
3518                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3519    
3520                    throw new NoSuchArticleException(msg.toString());
3521            }
3522    
3523            /**
3524             * Returns the last journal article in the ordered set where companyId = &#63;.
3525             *
3526             * @param companyId the company ID
3527             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3528             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3529             * @throws SystemException if a system exception occurred
3530             */
3531            public JournalArticle fetchByCompanyId_Last(long companyId,
3532                    OrderByComparator orderByComparator) throws SystemException {
3533                    int count = countByCompanyId(companyId);
3534    
3535                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3536                                    count, orderByComparator);
3537    
3538                    if (!list.isEmpty()) {
3539                            return list.get(0);
3540                    }
3541    
3542                    return null;
3543            }
3544    
3545            /**
3546             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3547             *
3548             * @param id the primary key of the current journal article
3549             * @param companyId the company ID
3550             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3551             * @return the previous, current, and next journal article
3552             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3553             * @throws SystemException if a system exception occurred
3554             */
3555            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3556                    long companyId, OrderByComparator orderByComparator)
3557                    throws NoSuchArticleException, SystemException {
3558                    JournalArticle journalArticle = findByPrimaryKey(id);
3559    
3560                    Session session = null;
3561    
3562                    try {
3563                            session = openSession();
3564    
3565                            JournalArticle[] array = new JournalArticleImpl[3];
3566    
3567                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3568                                            companyId, orderByComparator, true);
3569    
3570                            array[1] = journalArticle;
3571    
3572                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3573                                            companyId, orderByComparator, false);
3574    
3575                            return array;
3576                    }
3577                    catch (Exception e) {
3578                            throw processException(e);
3579                    }
3580                    finally {
3581                            closeSession(session);
3582                    }
3583            }
3584    
3585            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3586                    JournalArticle journalArticle, long companyId,
3587                    OrderByComparator orderByComparator, boolean previous) {
3588                    StringBundler query = null;
3589    
3590                    if (orderByComparator != null) {
3591                            query = new StringBundler(6 +
3592                                            (orderByComparator.getOrderByFields().length * 6));
3593                    }
3594                    else {
3595                            query = new StringBundler(3);
3596                    }
3597    
3598                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3599    
3600                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3601    
3602                    if (orderByComparator != null) {
3603                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3604    
3605                            if (orderByConditionFields.length > 0) {
3606                                    query.append(WHERE_AND);
3607                            }
3608    
3609                            for (int i = 0; i < orderByConditionFields.length; i++) {
3610                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3611                                    query.append(orderByConditionFields[i]);
3612    
3613                                    if ((i + 1) < orderByConditionFields.length) {
3614                                            if (orderByComparator.isAscending() ^ previous) {
3615                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3616                                            }
3617                                            else {
3618                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3619                                            }
3620                                    }
3621                                    else {
3622                                            if (orderByComparator.isAscending() ^ previous) {
3623                                                    query.append(WHERE_GREATER_THAN);
3624                                            }
3625                                            else {
3626                                                    query.append(WHERE_LESSER_THAN);
3627                                            }
3628                                    }
3629                            }
3630    
3631                            query.append(ORDER_BY_CLAUSE);
3632    
3633                            String[] orderByFields = orderByComparator.getOrderByFields();
3634    
3635                            for (int i = 0; i < orderByFields.length; i++) {
3636                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3637                                    query.append(orderByFields[i]);
3638    
3639                                    if ((i + 1) < orderByFields.length) {
3640                                            if (orderByComparator.isAscending() ^ previous) {
3641                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3642                                            }
3643                                            else {
3644                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3645                                            }
3646                                    }
3647                                    else {
3648                                            if (orderByComparator.isAscending() ^ previous) {
3649                                                    query.append(ORDER_BY_ASC);
3650                                            }
3651                                            else {
3652                                                    query.append(ORDER_BY_DESC);
3653                                            }
3654                                    }
3655                            }
3656                    }
3657    
3658                    else {
3659                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3660                    }
3661    
3662                    String sql = query.toString();
3663    
3664                    Query q = session.createQuery(sql);
3665    
3666                    q.setFirstResult(0);
3667                    q.setMaxResults(2);
3668    
3669                    QueryPos qPos = QueryPos.getInstance(q);
3670    
3671                    qPos.add(companyId);
3672    
3673                    if (orderByComparator != null) {
3674                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3675    
3676                            for (Object value : values) {
3677                                    qPos.add(value);
3678                            }
3679                    }
3680    
3681                    List<JournalArticle> list = q.list();
3682    
3683                    if (list.size() == 2) {
3684                            return list.get(1);
3685                    }
3686                    else {
3687                            return null;
3688                    }
3689            }
3690    
3691            /**
3692             * Returns all the journal articles where structureId = &#63;.
3693             *
3694             * @param structureId the structure ID
3695             * @return the matching journal articles
3696             * @throws SystemException if a system exception occurred
3697             */
3698            public List<JournalArticle> findByStructureId(String structureId)
3699                    throws SystemException {
3700                    return findByStructureId(structureId, QueryUtil.ALL_POS,
3701                            QueryUtil.ALL_POS, null);
3702            }
3703    
3704            /**
3705             * Returns a range of all the journal articles where structureId = &#63;.
3706             *
3707             * <p>
3708             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3709             * </p>
3710             *
3711             * @param structureId the structure ID
3712             * @param start the lower bound of the range of journal articles
3713             * @param end the upper bound of the range of journal articles (not inclusive)
3714             * @return the range of matching journal articles
3715             * @throws SystemException if a system exception occurred
3716             */
3717            public List<JournalArticle> findByStructureId(String structureId,
3718                    int start, int end) throws SystemException {
3719                    return findByStructureId(structureId, start, end, null);
3720            }
3721    
3722            /**
3723             * Returns an ordered range of all the journal articles where structureId = &#63;.
3724             *
3725             * <p>
3726             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3727             * </p>
3728             *
3729             * @param structureId the structure ID
3730             * @param start the lower bound of the range of journal articles
3731             * @param end the upper bound of the range of journal articles (not inclusive)
3732             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3733             * @return the ordered range of matching journal articles
3734             * @throws SystemException if a system exception occurred
3735             */
3736            public List<JournalArticle> findByStructureId(String structureId,
3737                    int start, int end, OrderByComparator orderByComparator)
3738                    throws SystemException {
3739                    FinderPath finderPath = null;
3740                    Object[] finderArgs = null;
3741    
3742                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3743                                    (orderByComparator == null)) {
3744                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STRUCTUREID;
3745                            finderArgs = new Object[] { structureId };
3746                    }
3747                    else {
3748                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STRUCTUREID;
3749                            finderArgs = new Object[] { structureId, start, end, orderByComparator };
3750                    }
3751    
3752                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3753                                    finderArgs, this);
3754    
3755                    if ((list != null) && !list.isEmpty()) {
3756                            for (JournalArticle journalArticle : list) {
3757                                    if (!Validator.equals(structureId,
3758                                                            journalArticle.getStructureId())) {
3759                                            list = null;
3760    
3761                                            break;
3762                                    }
3763                            }
3764                    }
3765    
3766                    if (list == null) {
3767                            StringBundler query = null;
3768    
3769                            if (orderByComparator != null) {
3770                                    query = new StringBundler(3 +
3771                                                    (orderByComparator.getOrderByFields().length * 3));
3772                            }
3773                            else {
3774                                    query = new StringBundler(3);
3775                            }
3776    
3777                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3778    
3779                            if (structureId == null) {
3780                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3781                            }
3782                            else {
3783                                    if (structureId.equals(StringPool.BLANK)) {
3784                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3785                                    }
3786                                    else {
3787                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3788                                    }
3789                            }
3790    
3791                            if (orderByComparator != null) {
3792                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3793                                            orderByComparator);
3794                            }
3795    
3796                            else {
3797                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3798                            }
3799    
3800                            String sql = query.toString();
3801    
3802                            Session session = null;
3803    
3804                            try {
3805                                    session = openSession();
3806    
3807                                    Query q = session.createQuery(sql);
3808    
3809                                    QueryPos qPos = QueryPos.getInstance(q);
3810    
3811                                    if (structureId != null) {
3812                                            qPos.add(structureId);
3813                                    }
3814    
3815                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3816                                                    start, end);
3817                            }
3818                            catch (Exception e) {
3819                                    throw processException(e);
3820                            }
3821                            finally {
3822                                    if (list == null) {
3823                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3824                                    }
3825                                    else {
3826                                            cacheResult(list);
3827    
3828                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3829                                    }
3830    
3831                                    closeSession(session);
3832                            }
3833                    }
3834    
3835                    return list;
3836            }
3837    
3838            /**
3839             * Returns the first journal article in the ordered set where structureId = &#63;.
3840             *
3841             * @param structureId the structure ID
3842             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3843             * @return the first matching journal article
3844             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3845             * @throws SystemException if a system exception occurred
3846             */
3847            public JournalArticle findByStructureId_First(String structureId,
3848                    OrderByComparator orderByComparator)
3849                    throws NoSuchArticleException, SystemException {
3850                    JournalArticle journalArticle = fetchByStructureId_First(structureId,
3851                                    orderByComparator);
3852    
3853                    if (journalArticle != null) {
3854                            return journalArticle;
3855                    }
3856    
3857                    StringBundler msg = new StringBundler(4);
3858    
3859                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3860    
3861                    msg.append("structureId=");
3862                    msg.append(structureId);
3863    
3864                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3865    
3866                    throw new NoSuchArticleException(msg.toString());
3867            }
3868    
3869            /**
3870             * Returns the first journal article in the ordered set where structureId = &#63;.
3871             *
3872             * @param structureId the structure ID
3873             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3874             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
3875             * @throws SystemException if a system exception occurred
3876             */
3877            public JournalArticle fetchByStructureId_First(String structureId,
3878                    OrderByComparator orderByComparator) throws SystemException {
3879                    List<JournalArticle> list = findByStructureId(structureId, 0, 1,
3880                                    orderByComparator);
3881    
3882                    if (!list.isEmpty()) {
3883                            return list.get(0);
3884                    }
3885    
3886                    return null;
3887            }
3888    
3889            /**
3890             * Returns the last journal article in the ordered set where structureId = &#63;.
3891             *
3892             * @param structureId the structure ID
3893             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3894             * @return the last matching journal article
3895             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3896             * @throws SystemException if a system exception occurred
3897             */
3898            public JournalArticle findByStructureId_Last(String structureId,
3899                    OrderByComparator orderByComparator)
3900                    throws NoSuchArticleException, SystemException {
3901                    JournalArticle journalArticle = fetchByStructureId_Last(structureId,
3902                                    orderByComparator);
3903    
3904                    if (journalArticle != null) {
3905                            return journalArticle;
3906                    }
3907    
3908                    StringBundler msg = new StringBundler(4);
3909    
3910                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3911    
3912                    msg.append("structureId=");
3913                    msg.append(structureId);
3914    
3915                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3916    
3917                    throw new NoSuchArticleException(msg.toString());
3918            }
3919    
3920            /**
3921             * Returns the last journal article in the ordered set where structureId = &#63;.
3922             *
3923             * @param structureId the structure ID
3924             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3925             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
3926             * @throws SystemException if a system exception occurred
3927             */
3928            public JournalArticle fetchByStructureId_Last(String structureId,
3929                    OrderByComparator orderByComparator) throws SystemException {
3930                    int count = countByStructureId(structureId);
3931    
3932                    List<JournalArticle> list = findByStructureId(structureId, count - 1,
3933                                    count, orderByComparator);
3934    
3935                    if (!list.isEmpty()) {
3936                            return list.get(0);
3937                    }
3938    
3939                    return null;
3940            }
3941    
3942            /**
3943             * Returns the journal articles before and after the current journal article in the ordered set where structureId = &#63;.
3944             *
3945             * @param id the primary key of the current journal article
3946             * @param structureId the structure ID
3947             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3948             * @return the previous, current, and next journal article
3949             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3950             * @throws SystemException if a system exception occurred
3951             */
3952            public JournalArticle[] findByStructureId_PrevAndNext(long id,
3953                    String structureId, OrderByComparator orderByComparator)
3954                    throws NoSuchArticleException, SystemException {
3955                    JournalArticle journalArticle = findByPrimaryKey(id);
3956    
3957                    Session session = null;
3958    
3959                    try {
3960                            session = openSession();
3961    
3962                            JournalArticle[] array = new JournalArticleImpl[3];
3963    
3964                            array[0] = getByStructureId_PrevAndNext(session, journalArticle,
3965                                            structureId, orderByComparator, true);
3966    
3967                            array[1] = journalArticle;
3968    
3969                            array[2] = getByStructureId_PrevAndNext(session, journalArticle,
3970                                            structureId, orderByComparator, false);
3971    
3972                            return array;
3973                    }
3974                    catch (Exception e) {
3975                            throw processException(e);
3976                    }
3977                    finally {
3978                            closeSession(session);
3979                    }
3980            }
3981    
3982            protected JournalArticle getByStructureId_PrevAndNext(Session session,
3983                    JournalArticle journalArticle, String structureId,
3984                    OrderByComparator orderByComparator, boolean previous) {
3985                    StringBundler query = null;
3986    
3987                    if (orderByComparator != null) {
3988                            query = new StringBundler(6 +
3989                                            (orderByComparator.getOrderByFields().length * 6));
3990                    }
3991                    else {
3992                            query = new StringBundler(3);
3993                    }
3994    
3995                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3996    
3997                    if (structureId == null) {
3998                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
3999                    }
4000                    else {
4001                            if (structureId.equals(StringPool.BLANK)) {
4002                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
4003                            }
4004                            else {
4005                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
4006                            }
4007                    }
4008    
4009                    if (orderByComparator != null) {
4010                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4011    
4012                            if (orderByConditionFields.length > 0) {
4013                                    query.append(WHERE_AND);
4014                            }
4015    
4016                            for (int i = 0; i < orderByConditionFields.length; i++) {
4017                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4018                                    query.append(orderByConditionFields[i]);
4019    
4020                                    if ((i + 1) < orderByConditionFields.length) {
4021                                            if (orderByComparator.isAscending() ^ previous) {
4022                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4023                                            }
4024                                            else {
4025                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4026                                            }
4027                                    }
4028                                    else {
4029                                            if (orderByComparator.isAscending() ^ previous) {
4030                                                    query.append(WHERE_GREATER_THAN);
4031                                            }
4032                                            else {
4033                                                    query.append(WHERE_LESSER_THAN);
4034                                            }
4035                                    }
4036                            }
4037    
4038                            query.append(ORDER_BY_CLAUSE);
4039    
4040                            String[] orderByFields = orderByComparator.getOrderByFields();
4041    
4042                            for (int i = 0; i < orderByFields.length; i++) {
4043                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4044                                    query.append(orderByFields[i]);
4045    
4046                                    if ((i + 1) < orderByFields.length) {
4047                                            if (orderByComparator.isAscending() ^ previous) {
4048                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4049                                            }
4050                                            else {
4051                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4052                                            }
4053                                    }
4054                                    else {
4055                                            if (orderByComparator.isAscending() ^ previous) {
4056                                                    query.append(ORDER_BY_ASC);
4057                                            }
4058                                            else {
4059                                                    query.append(ORDER_BY_DESC);
4060                                            }
4061                                    }
4062                            }
4063                    }
4064    
4065                    else {
4066                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4067                    }
4068    
4069                    String sql = query.toString();
4070    
4071                    Query q = session.createQuery(sql);
4072    
4073                    q.setFirstResult(0);
4074                    q.setMaxResults(2);
4075    
4076                    QueryPos qPos = QueryPos.getInstance(q);
4077    
4078                    if (structureId != null) {
4079                            qPos.add(structureId);
4080                    }
4081    
4082                    if (orderByComparator != null) {
4083                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4084    
4085                            for (Object value : values) {
4086                                    qPos.add(value);
4087                            }
4088                    }
4089    
4090                    List<JournalArticle> list = q.list();
4091    
4092                    if (list.size() == 2) {
4093                            return list.get(1);
4094                    }
4095                    else {
4096                            return null;
4097                    }
4098            }
4099    
4100            /**
4101             * Returns all the journal articles where templateId = &#63;.
4102             *
4103             * @param templateId the template ID
4104             * @return the matching journal articles
4105             * @throws SystemException if a system exception occurred
4106             */
4107            public List<JournalArticle> findByTemplateId(String templateId)
4108                    throws SystemException {
4109                    return findByTemplateId(templateId, QueryUtil.ALL_POS,
4110                            QueryUtil.ALL_POS, null);
4111            }
4112    
4113            /**
4114             * Returns a range of all the journal articles where templateId = &#63;.
4115             *
4116             * <p>
4117             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4118             * </p>
4119             *
4120             * @param templateId the template ID
4121             * @param start the lower bound of the range of journal articles
4122             * @param end the upper bound of the range of journal articles (not inclusive)
4123             * @return the range of matching journal articles
4124             * @throws SystemException if a system exception occurred
4125             */
4126            public List<JournalArticle> findByTemplateId(String templateId, int start,
4127                    int end) throws SystemException {
4128                    return findByTemplateId(templateId, start, end, null);
4129            }
4130    
4131            /**
4132             * Returns an ordered range of all the journal articles where templateId = &#63;.
4133             *
4134             * <p>
4135             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4136             * </p>
4137             *
4138             * @param templateId the template ID
4139             * @param start the lower bound of the range of journal articles
4140             * @param end the upper bound of the range of journal articles (not inclusive)
4141             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4142             * @return the ordered range of matching journal articles
4143             * @throws SystemException if a system exception occurred
4144             */
4145            public List<JournalArticle> findByTemplateId(String templateId, int start,
4146                    int end, OrderByComparator orderByComparator) throws SystemException {
4147                    FinderPath finderPath = null;
4148                    Object[] finderArgs = null;
4149    
4150                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4151                                    (orderByComparator == null)) {
4152                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEMPLATEID;
4153                            finderArgs = new Object[] { templateId };
4154                    }
4155                    else {
4156                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEMPLATEID;
4157                            finderArgs = new Object[] { templateId, start, end, orderByComparator };
4158                    }
4159    
4160                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4161                                    finderArgs, this);
4162    
4163                    if ((list != null) && !list.isEmpty()) {
4164                            for (JournalArticle journalArticle : list) {
4165                                    if (!Validator.equals(templateId, journalArticle.getTemplateId())) {
4166                                            list = null;
4167    
4168                                            break;
4169                                    }
4170                            }
4171                    }
4172    
4173                    if (list == null) {
4174                            StringBundler query = null;
4175    
4176                            if (orderByComparator != null) {
4177                                    query = new StringBundler(3 +
4178                                                    (orderByComparator.getOrderByFields().length * 3));
4179                            }
4180                            else {
4181                                    query = new StringBundler(3);
4182                            }
4183    
4184                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4185    
4186                            if (templateId == null) {
4187                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4188                            }
4189                            else {
4190                                    if (templateId.equals(StringPool.BLANK)) {
4191                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4192                                    }
4193                                    else {
4194                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4195                                    }
4196                            }
4197    
4198                            if (orderByComparator != null) {
4199                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4200                                            orderByComparator);
4201                            }
4202    
4203                            else {
4204                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4205                            }
4206    
4207                            String sql = query.toString();
4208    
4209                            Session session = null;
4210    
4211                            try {
4212                                    session = openSession();
4213    
4214                                    Query q = session.createQuery(sql);
4215    
4216                                    QueryPos qPos = QueryPos.getInstance(q);
4217    
4218                                    if (templateId != null) {
4219                                            qPos.add(templateId);
4220                                    }
4221    
4222                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4223                                                    start, end);
4224                            }
4225                            catch (Exception e) {
4226                                    throw processException(e);
4227                            }
4228                            finally {
4229                                    if (list == null) {
4230                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4231                                    }
4232                                    else {
4233                                            cacheResult(list);
4234    
4235                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4236                                    }
4237    
4238                                    closeSession(session);
4239                            }
4240                    }
4241    
4242                    return list;
4243            }
4244    
4245            /**
4246             * Returns the first journal article in the ordered set where templateId = &#63;.
4247             *
4248             * @param templateId the template ID
4249             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4250             * @return the first matching journal article
4251             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4252             * @throws SystemException if a system exception occurred
4253             */
4254            public JournalArticle findByTemplateId_First(String templateId,
4255                    OrderByComparator orderByComparator)
4256                    throws NoSuchArticleException, SystemException {
4257                    JournalArticle journalArticle = fetchByTemplateId_First(templateId,
4258                                    orderByComparator);
4259    
4260                    if (journalArticle != null) {
4261                            return journalArticle;
4262                    }
4263    
4264                    StringBundler msg = new StringBundler(4);
4265    
4266                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4267    
4268                    msg.append("templateId=");
4269                    msg.append(templateId);
4270    
4271                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4272    
4273                    throw new NoSuchArticleException(msg.toString());
4274            }
4275    
4276            /**
4277             * Returns the first journal article in the ordered set where templateId = &#63;.
4278             *
4279             * @param templateId the template ID
4280             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4281             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4282             * @throws SystemException if a system exception occurred
4283             */
4284            public JournalArticle fetchByTemplateId_First(String templateId,
4285                    OrderByComparator orderByComparator) throws SystemException {
4286                    List<JournalArticle> list = findByTemplateId(templateId, 0, 1,
4287                                    orderByComparator);
4288    
4289                    if (!list.isEmpty()) {
4290                            return list.get(0);
4291                    }
4292    
4293                    return null;
4294            }
4295    
4296            /**
4297             * Returns the last journal article in the ordered set where templateId = &#63;.
4298             *
4299             * @param templateId the template ID
4300             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4301             * @return the last matching journal article
4302             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4303             * @throws SystemException if a system exception occurred
4304             */
4305            public JournalArticle findByTemplateId_Last(String templateId,
4306                    OrderByComparator orderByComparator)
4307                    throws NoSuchArticleException, SystemException {
4308                    JournalArticle journalArticle = fetchByTemplateId_Last(templateId,
4309                                    orderByComparator);
4310    
4311                    if (journalArticle != null) {
4312                            return journalArticle;
4313                    }
4314    
4315                    StringBundler msg = new StringBundler(4);
4316    
4317                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4318    
4319                    msg.append("templateId=");
4320                    msg.append(templateId);
4321    
4322                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4323    
4324                    throw new NoSuchArticleException(msg.toString());
4325            }
4326    
4327            /**
4328             * Returns the last journal article in the ordered set where templateId = &#63;.
4329             *
4330             * @param templateId the template ID
4331             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4332             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4333             * @throws SystemException if a system exception occurred
4334             */
4335            public JournalArticle fetchByTemplateId_Last(String templateId,
4336                    OrderByComparator orderByComparator) throws SystemException {
4337                    int count = countByTemplateId(templateId);
4338    
4339                    List<JournalArticle> list = findByTemplateId(templateId, count - 1,
4340                                    count, orderByComparator);
4341    
4342                    if (!list.isEmpty()) {
4343                            return list.get(0);
4344                    }
4345    
4346                    return null;
4347            }
4348    
4349            /**
4350             * Returns the journal articles before and after the current journal article in the ordered set where templateId = &#63;.
4351             *
4352             * @param id the primary key of the current journal article
4353             * @param templateId the template ID
4354             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4355             * @return the previous, current, and next journal article
4356             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4357             * @throws SystemException if a system exception occurred
4358             */
4359            public JournalArticle[] findByTemplateId_PrevAndNext(long id,
4360                    String templateId, OrderByComparator orderByComparator)
4361                    throws NoSuchArticleException, SystemException {
4362                    JournalArticle journalArticle = findByPrimaryKey(id);
4363    
4364                    Session session = null;
4365    
4366                    try {
4367                            session = openSession();
4368    
4369                            JournalArticle[] array = new JournalArticleImpl[3];
4370    
4371                            array[0] = getByTemplateId_PrevAndNext(session, journalArticle,
4372                                            templateId, orderByComparator, true);
4373    
4374                            array[1] = journalArticle;
4375    
4376                            array[2] = getByTemplateId_PrevAndNext(session, journalArticle,
4377                                            templateId, orderByComparator, false);
4378    
4379                            return array;
4380                    }
4381                    catch (Exception e) {
4382                            throw processException(e);
4383                    }
4384                    finally {
4385                            closeSession(session);
4386                    }
4387            }
4388    
4389            protected JournalArticle getByTemplateId_PrevAndNext(Session session,
4390                    JournalArticle journalArticle, String templateId,
4391                    OrderByComparator orderByComparator, boolean previous) {
4392                    StringBundler query = null;
4393    
4394                    if (orderByComparator != null) {
4395                            query = new StringBundler(6 +
4396                                            (orderByComparator.getOrderByFields().length * 6));
4397                    }
4398                    else {
4399                            query = new StringBundler(3);
4400                    }
4401    
4402                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4403    
4404                    if (templateId == null) {
4405                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
4406                    }
4407                    else {
4408                            if (templateId.equals(StringPool.BLANK)) {
4409                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
4410                            }
4411                            else {
4412                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
4413                            }
4414                    }
4415    
4416                    if (orderByComparator != null) {
4417                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4418    
4419                            if (orderByConditionFields.length > 0) {
4420                                    query.append(WHERE_AND);
4421                            }
4422    
4423                            for (int i = 0; i < orderByConditionFields.length; i++) {
4424                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4425                                    query.append(orderByConditionFields[i]);
4426    
4427                                    if ((i + 1) < orderByConditionFields.length) {
4428                                            if (orderByComparator.isAscending() ^ previous) {
4429                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4430                                            }
4431                                            else {
4432                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4433                                            }
4434                                    }
4435                                    else {
4436                                            if (orderByComparator.isAscending() ^ previous) {
4437                                                    query.append(WHERE_GREATER_THAN);
4438                                            }
4439                                            else {
4440                                                    query.append(WHERE_LESSER_THAN);
4441                                            }
4442                                    }
4443                            }
4444    
4445                            query.append(ORDER_BY_CLAUSE);
4446    
4447                            String[] orderByFields = orderByComparator.getOrderByFields();
4448    
4449                            for (int i = 0; i < orderByFields.length; i++) {
4450                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4451                                    query.append(orderByFields[i]);
4452    
4453                                    if ((i + 1) < orderByFields.length) {
4454                                            if (orderByComparator.isAscending() ^ previous) {
4455                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4456                                            }
4457                                            else {
4458                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4459                                            }
4460                                    }
4461                                    else {
4462                                            if (orderByComparator.isAscending() ^ previous) {
4463                                                    query.append(ORDER_BY_ASC);
4464                                            }
4465                                            else {
4466                                                    query.append(ORDER_BY_DESC);
4467                                            }
4468                                    }
4469                            }
4470                    }
4471    
4472                    else {
4473                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4474                    }
4475    
4476                    String sql = query.toString();
4477    
4478                    Query q = session.createQuery(sql);
4479    
4480                    q.setFirstResult(0);
4481                    q.setMaxResults(2);
4482    
4483                    QueryPos qPos = QueryPos.getInstance(q);
4484    
4485                    if (templateId != null) {
4486                            qPos.add(templateId);
4487                    }
4488    
4489                    if (orderByComparator != null) {
4490                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4491    
4492                            for (Object value : values) {
4493                                    qPos.add(value);
4494                            }
4495                    }
4496    
4497                    List<JournalArticle> list = q.list();
4498    
4499                    if (list.size() == 2) {
4500                            return list.get(1);
4501                    }
4502                    else {
4503                            return null;
4504                    }
4505            }
4506    
4507            /**
4508             * Returns all the journal articles where smallImageId = &#63;.
4509             *
4510             * @param smallImageId the small image ID
4511             * @return the matching journal articles
4512             * @throws SystemException if a system exception occurred
4513             */
4514            public List<JournalArticle> findBySmallImageId(long smallImageId)
4515                    throws SystemException {
4516                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
4517                            QueryUtil.ALL_POS, null);
4518            }
4519    
4520            /**
4521             * Returns a range of all the journal articles where smallImageId = &#63;.
4522             *
4523             * <p>
4524             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4525             * </p>
4526             *
4527             * @param smallImageId the small image ID
4528             * @param start the lower bound of the range of journal articles
4529             * @param end the upper bound of the range of journal articles (not inclusive)
4530             * @return the range of matching journal articles
4531             * @throws SystemException if a system exception occurred
4532             */
4533            public List<JournalArticle> findBySmallImageId(long smallImageId,
4534                    int start, int end) throws SystemException {
4535                    return findBySmallImageId(smallImageId, start, end, null);
4536            }
4537    
4538            /**
4539             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
4540             *
4541             * <p>
4542             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4543             * </p>
4544             *
4545             * @param smallImageId the small image ID
4546             * @param start the lower bound of the range of journal articles
4547             * @param end the upper bound of the range of journal articles (not inclusive)
4548             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4549             * @return the ordered range of matching journal articles
4550             * @throws SystemException if a system exception occurred
4551             */
4552            public List<JournalArticle> findBySmallImageId(long smallImageId,
4553                    int start, int end, OrderByComparator orderByComparator)
4554                    throws SystemException {
4555                    FinderPath finderPath = null;
4556                    Object[] finderArgs = null;
4557    
4558                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4559                                    (orderByComparator == null)) {
4560                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
4561                            finderArgs = new Object[] { smallImageId };
4562                    }
4563                    else {
4564                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
4565                            finderArgs = new Object[] {
4566                                            smallImageId,
4567                                            
4568                                            start, end, orderByComparator
4569                                    };
4570                    }
4571    
4572                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4573                                    finderArgs, this);
4574    
4575                    if ((list != null) && !list.isEmpty()) {
4576                            for (JournalArticle journalArticle : list) {
4577                                    if ((smallImageId != journalArticle.getSmallImageId())) {
4578                                            list = null;
4579    
4580                                            break;
4581                                    }
4582                            }
4583                    }
4584    
4585                    if (list == null) {
4586                            StringBundler query = null;
4587    
4588                            if (orderByComparator != null) {
4589                                    query = new StringBundler(3 +
4590                                                    (orderByComparator.getOrderByFields().length * 3));
4591                            }
4592                            else {
4593                                    query = new StringBundler(3);
4594                            }
4595    
4596                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4597    
4598                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
4599    
4600                            if (orderByComparator != null) {
4601                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4602                                            orderByComparator);
4603                            }
4604    
4605                            else {
4606                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4607                            }
4608    
4609                            String sql = query.toString();
4610    
4611                            Session session = null;
4612    
4613                            try {
4614                                    session = openSession();
4615    
4616                                    Query q = session.createQuery(sql);
4617    
4618                                    QueryPos qPos = QueryPos.getInstance(q);
4619    
4620                                    qPos.add(smallImageId);
4621    
4622                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4623                                                    start, end);
4624                            }
4625                            catch (Exception e) {
4626                                    throw processException(e);
4627                            }
4628                            finally {
4629                                    if (list == null) {
4630                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4631                                    }
4632                                    else {
4633                                            cacheResult(list);
4634    
4635                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4636                                    }
4637    
4638                                    closeSession(session);
4639                            }
4640                    }
4641    
4642                    return list;
4643            }
4644    
4645            /**
4646             * Returns the first journal article in the ordered set where smallImageId = &#63;.
4647             *
4648             * @param smallImageId the small image ID
4649             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4650             * @return the first matching journal article
4651             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4652             * @throws SystemException if a system exception occurred
4653             */
4654            public JournalArticle findBySmallImageId_First(long smallImageId,
4655                    OrderByComparator orderByComparator)
4656                    throws NoSuchArticleException, SystemException {
4657                    JournalArticle journalArticle = fetchBySmallImageId_First(smallImageId,
4658                                    orderByComparator);
4659    
4660                    if (journalArticle != null) {
4661                            return journalArticle;
4662                    }
4663    
4664                    StringBundler msg = new StringBundler(4);
4665    
4666                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4667    
4668                    msg.append("smallImageId=");
4669                    msg.append(smallImageId);
4670    
4671                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4672    
4673                    throw new NoSuchArticleException(msg.toString());
4674            }
4675    
4676            /**
4677             * Returns the first journal article in the ordered set where smallImageId = &#63;.
4678             *
4679             * @param smallImageId the small image ID
4680             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4681             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
4682             * @throws SystemException if a system exception occurred
4683             */
4684            public JournalArticle fetchBySmallImageId_First(long smallImageId,
4685                    OrderByComparator orderByComparator) throws SystemException {
4686                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
4687                                    orderByComparator);
4688    
4689                    if (!list.isEmpty()) {
4690                            return list.get(0);
4691                    }
4692    
4693                    return null;
4694            }
4695    
4696            /**
4697             * Returns the last journal article in the ordered set where smallImageId = &#63;.
4698             *
4699             * @param smallImageId the small image ID
4700             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4701             * @return the last matching journal article
4702             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4703             * @throws SystemException if a system exception occurred
4704             */
4705            public JournalArticle findBySmallImageId_Last(long smallImageId,
4706                    OrderByComparator orderByComparator)
4707                    throws NoSuchArticleException, SystemException {
4708                    JournalArticle journalArticle = fetchBySmallImageId_Last(smallImageId,
4709                                    orderByComparator);
4710    
4711                    if (journalArticle != null) {
4712                            return journalArticle;
4713                    }
4714    
4715                    StringBundler msg = new StringBundler(4);
4716    
4717                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4718    
4719                    msg.append("smallImageId=");
4720                    msg.append(smallImageId);
4721    
4722                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4723    
4724                    throw new NoSuchArticleException(msg.toString());
4725            }
4726    
4727            /**
4728             * Returns the last journal article in the ordered set where smallImageId = &#63;.
4729             *
4730             * @param smallImageId the small image ID
4731             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4732             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
4733             * @throws SystemException if a system exception occurred
4734             */
4735            public JournalArticle fetchBySmallImageId_Last(long smallImageId,
4736                    OrderByComparator orderByComparator) throws SystemException {
4737                    int count = countBySmallImageId(smallImageId);
4738    
4739                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
4740                                    count, orderByComparator);
4741    
4742                    if (!list.isEmpty()) {
4743                            return list.get(0);
4744                    }
4745    
4746                    return null;
4747            }
4748    
4749            /**
4750             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
4751             *
4752             * @param id the primary key of the current journal article
4753             * @param smallImageId the small image ID
4754             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4755             * @return the previous, current, and next journal article
4756             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4757             * @throws SystemException if a system exception occurred
4758             */
4759            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
4760                    long smallImageId, OrderByComparator orderByComparator)
4761                    throws NoSuchArticleException, SystemException {
4762                    JournalArticle journalArticle = findByPrimaryKey(id);
4763    
4764                    Session session = null;
4765    
4766                    try {
4767                            session = openSession();
4768    
4769                            JournalArticle[] array = new JournalArticleImpl[3];
4770    
4771                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
4772                                            smallImageId, orderByComparator, true);
4773    
4774                            array[1] = journalArticle;
4775    
4776                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
4777                                            smallImageId, orderByComparator, false);
4778    
4779                            return array;
4780                    }
4781                    catch (Exception e) {
4782                            throw processException(e);
4783                    }
4784                    finally {
4785                            closeSession(session);
4786                    }
4787            }
4788    
4789            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
4790                    JournalArticle journalArticle, long smallImageId,
4791                    OrderByComparator orderByComparator, boolean previous) {
4792                    StringBundler query = null;
4793    
4794                    if (orderByComparator != null) {
4795                            query = new StringBundler(6 +
4796                                            (orderByComparator.getOrderByFields().length * 6));
4797                    }
4798                    else {
4799                            query = new StringBundler(3);
4800                    }
4801    
4802                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4803    
4804                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
4805    
4806                    if (orderByComparator != null) {
4807                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4808    
4809                            if (orderByConditionFields.length > 0) {
4810                                    query.append(WHERE_AND);
4811                            }
4812    
4813                            for (int i = 0; i < orderByConditionFields.length; i++) {
4814                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4815                                    query.append(orderByConditionFields[i]);
4816    
4817                                    if ((i + 1) < orderByConditionFields.length) {
4818                                            if (orderByComparator.isAscending() ^ previous) {
4819                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4820                                            }
4821                                            else {
4822                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4823                                            }
4824                                    }
4825                                    else {
4826                                            if (orderByComparator.isAscending() ^ previous) {
4827                                                    query.append(WHERE_GREATER_THAN);
4828                                            }
4829                                            else {
4830                                                    query.append(WHERE_LESSER_THAN);
4831                                            }
4832                                    }
4833                            }
4834    
4835                            query.append(ORDER_BY_CLAUSE);
4836    
4837                            String[] orderByFields = orderByComparator.getOrderByFields();
4838    
4839                            for (int i = 0; i < orderByFields.length; i++) {
4840                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4841                                    query.append(orderByFields[i]);
4842    
4843                                    if ((i + 1) < orderByFields.length) {
4844                                            if (orderByComparator.isAscending() ^ previous) {
4845                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4846                                            }
4847                                            else {
4848                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4849                                            }
4850                                    }
4851                                    else {
4852                                            if (orderByComparator.isAscending() ^ previous) {
4853                                                    query.append(ORDER_BY_ASC);
4854                                            }
4855                                            else {
4856                                                    query.append(ORDER_BY_DESC);
4857                                            }
4858                                    }
4859                            }
4860                    }
4861    
4862                    else {
4863                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4864                    }
4865    
4866                    String sql = query.toString();
4867    
4868                    Query q = session.createQuery(sql);
4869    
4870                    q.setFirstResult(0);
4871                    q.setMaxResults(2);
4872    
4873                    QueryPos qPos = QueryPos.getInstance(q);
4874    
4875                    qPos.add(smallImageId);
4876    
4877                    if (orderByComparator != null) {
4878                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4879    
4880                            for (Object value : values) {
4881                                    qPos.add(value);
4882                            }
4883                    }
4884    
4885                    List<JournalArticle> list = q.list();
4886    
4887                    if (list.size() == 2) {
4888                            return list.get(1);
4889                    }
4890                    else {
4891                            return null;
4892                    }
4893            }
4894    
4895            /**
4896             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
4897             *
4898             * @param resourcePrimKey the resource prim key
4899             * @param status the status
4900             * @return the matching journal articles
4901             * @throws SystemException if a system exception occurred
4902             */
4903            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
4904                    throws SystemException {
4905                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
4906                            QueryUtil.ALL_POS, null);
4907            }
4908    
4909            /**
4910             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
4911             *
4912             * <p>
4913             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4914             * </p>
4915             *
4916             * @param resourcePrimKey the resource prim key
4917             * @param status the status
4918             * @param start the lower bound of the range of journal articles
4919             * @param end the upper bound of the range of journal articles (not inclusive)
4920             * @return the range of matching journal articles
4921             * @throws SystemException if a system exception occurred
4922             */
4923            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
4924                    int start, int end) throws SystemException {
4925                    return findByR_ST(resourcePrimKey, status, start, end, null);
4926            }
4927    
4928            /**
4929             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
4930             *
4931             * <p>
4932             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4933             * </p>
4934             *
4935             * @param resourcePrimKey the resource prim key
4936             * @param status the status
4937             * @param start the lower bound of the range of journal articles
4938             * @param end the upper bound of the range of journal articles (not inclusive)
4939             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4940             * @return the ordered range of matching journal articles
4941             * @throws SystemException if a system exception occurred
4942             */
4943            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
4944                    int start, int end, OrderByComparator orderByComparator)
4945                    throws SystemException {
4946                    FinderPath finderPath = null;
4947                    Object[] finderArgs = null;
4948    
4949                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4950                                    (orderByComparator == null)) {
4951                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
4952                            finderArgs = new Object[] { resourcePrimKey, status };
4953                    }
4954                    else {
4955                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
4956                            finderArgs = new Object[] {
4957                                            resourcePrimKey, status,
4958                                            
4959                                            start, end, orderByComparator
4960                                    };
4961                    }
4962    
4963                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4964                                    finderArgs, this);
4965    
4966                    if ((list != null) && !list.isEmpty()) {
4967                            for (JournalArticle journalArticle : list) {
4968                                    if ((resourcePrimKey != journalArticle.getResourcePrimKey()) ||
4969                                                    (status != journalArticle.getStatus())) {
4970                                            list = null;
4971    
4972                                            break;
4973                                    }
4974                            }
4975                    }
4976    
4977                    if (list == null) {
4978                            StringBundler query = null;
4979    
4980                            if (orderByComparator != null) {
4981                                    query = new StringBundler(4 +
4982                                                    (orderByComparator.getOrderByFields().length * 3));
4983                            }
4984                            else {
4985                                    query = new StringBundler(4);
4986                            }
4987    
4988                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4989    
4990                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
4991    
4992                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
4993    
4994                            if (orderByComparator != null) {
4995                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4996                                            orderByComparator);
4997                            }
4998    
4999                            else {
5000                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5001                            }
5002    
5003                            String sql = query.toString();
5004    
5005                            Session session = null;
5006    
5007                            try {
5008                                    session = openSession();
5009    
5010                                    Query q = session.createQuery(sql);
5011    
5012                                    QueryPos qPos = QueryPos.getInstance(q);
5013    
5014                                    qPos.add(resourcePrimKey);
5015    
5016                                    qPos.add(status);
5017    
5018                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5019                                                    start, end);
5020                            }
5021                            catch (Exception e) {
5022                                    throw processException(e);
5023                            }
5024                            finally {
5025                                    if (list == null) {
5026                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5027                                    }
5028                                    else {
5029                                            cacheResult(list);
5030    
5031                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5032                                    }
5033    
5034                                    closeSession(session);
5035                            }
5036                    }
5037    
5038                    return list;
5039            }
5040    
5041            /**
5042             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5043             *
5044             * @param resourcePrimKey the resource prim key
5045             * @param status the status
5046             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5047             * @return the first matching journal article
5048             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5049             * @throws SystemException if a system exception occurred
5050             */
5051            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
5052                    OrderByComparator orderByComparator)
5053                    throws NoSuchArticleException, SystemException {
5054                    JournalArticle journalArticle = fetchByR_ST_First(resourcePrimKey,
5055                                    status, orderByComparator);
5056    
5057                    if (journalArticle != null) {
5058                            return journalArticle;
5059                    }
5060    
5061                    StringBundler msg = new StringBundler(6);
5062    
5063                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5064    
5065                    msg.append("resourcePrimKey=");
5066                    msg.append(resourcePrimKey);
5067    
5068                    msg.append(", status=");
5069                    msg.append(status);
5070    
5071                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5072    
5073                    throw new NoSuchArticleException(msg.toString());
5074            }
5075    
5076            /**
5077             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5078             *
5079             * @param resourcePrimKey the resource prim key
5080             * @param status the status
5081             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5082             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5083             * @throws SystemException if a system exception occurred
5084             */
5085            public JournalArticle fetchByR_ST_First(long resourcePrimKey, int status,
5086                    OrderByComparator orderByComparator) throws SystemException {
5087                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
5088                                    orderByComparator);
5089    
5090                    if (!list.isEmpty()) {
5091                            return list.get(0);
5092                    }
5093    
5094                    return null;
5095            }
5096    
5097            /**
5098             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5099             *
5100             * @param resourcePrimKey the resource prim key
5101             * @param status the status
5102             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5103             * @return the last matching journal article
5104             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5105             * @throws SystemException if a system exception occurred
5106             */
5107            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
5108                    OrderByComparator orderByComparator)
5109                    throws NoSuchArticleException, SystemException {
5110                    JournalArticle journalArticle = fetchByR_ST_Last(resourcePrimKey,
5111                                    status, orderByComparator);
5112    
5113                    if (journalArticle != null) {
5114                            return journalArticle;
5115                    }
5116    
5117                    StringBundler msg = new StringBundler(6);
5118    
5119                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5120    
5121                    msg.append("resourcePrimKey=");
5122                    msg.append(resourcePrimKey);
5123    
5124                    msg.append(", status=");
5125                    msg.append(status);
5126    
5127                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5128    
5129                    throw new NoSuchArticleException(msg.toString());
5130            }
5131    
5132            /**
5133             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5134             *
5135             * @param resourcePrimKey the resource prim key
5136             * @param status the status
5137             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5138             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5139             * @throws SystemException if a system exception occurred
5140             */
5141            public JournalArticle fetchByR_ST_Last(long resourcePrimKey, int status,
5142                    OrderByComparator orderByComparator) throws SystemException {
5143                    int count = countByR_ST(resourcePrimKey, status);
5144    
5145                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
5146                                    count - 1, count, orderByComparator);
5147    
5148                    if (!list.isEmpty()) {
5149                            return list.get(0);
5150                    }
5151    
5152                    return null;
5153            }
5154    
5155            /**
5156             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
5157             *
5158             * @param id the primary key of the current journal article
5159             * @param resourcePrimKey the resource prim key
5160             * @param status the status
5161             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5162             * @return the previous, current, and next journal article
5163             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5164             * @throws SystemException if a system exception occurred
5165             */
5166            public JournalArticle[] findByR_ST_PrevAndNext(long id,
5167                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
5168                    throws NoSuchArticleException, SystemException {
5169                    JournalArticle journalArticle = findByPrimaryKey(id);
5170    
5171                    Session session = null;
5172    
5173                    try {
5174                            session = openSession();
5175    
5176                            JournalArticle[] array = new JournalArticleImpl[3];
5177    
5178                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
5179                                            resourcePrimKey, status, orderByComparator, true);
5180    
5181                            array[1] = journalArticle;
5182    
5183                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
5184                                            resourcePrimKey, status, orderByComparator, false);
5185    
5186                            return array;
5187                    }
5188                    catch (Exception e) {
5189                            throw processException(e);
5190                    }
5191                    finally {
5192                            closeSession(session);
5193                    }
5194            }
5195    
5196            protected JournalArticle getByR_ST_PrevAndNext(Session session,
5197                    JournalArticle journalArticle, long resourcePrimKey, int status,
5198                    OrderByComparator orderByComparator, boolean previous) {
5199                    StringBundler query = null;
5200    
5201                    if (orderByComparator != null) {
5202                            query = new StringBundler(6 +
5203                                            (orderByComparator.getOrderByFields().length * 6));
5204                    }
5205                    else {
5206                            query = new StringBundler(3);
5207                    }
5208    
5209                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5210    
5211                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
5212    
5213                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
5214    
5215                    if (orderByComparator != null) {
5216                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5217    
5218                            if (orderByConditionFields.length > 0) {
5219                                    query.append(WHERE_AND);
5220                            }
5221    
5222                            for (int i = 0; i < orderByConditionFields.length; i++) {
5223                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5224                                    query.append(orderByConditionFields[i]);
5225    
5226                                    if ((i + 1) < orderByConditionFields.length) {
5227                                            if (orderByComparator.isAscending() ^ previous) {
5228                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5229                                            }
5230                                            else {
5231                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5232                                            }
5233                                    }
5234                                    else {
5235                                            if (orderByComparator.isAscending() ^ previous) {
5236                                                    query.append(WHERE_GREATER_THAN);
5237                                            }
5238                                            else {
5239                                                    query.append(WHERE_LESSER_THAN);
5240                                            }
5241                                    }
5242                            }
5243    
5244                            query.append(ORDER_BY_CLAUSE);
5245    
5246                            String[] orderByFields = orderByComparator.getOrderByFields();
5247    
5248                            for (int i = 0; i < orderByFields.length; i++) {
5249                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5250                                    query.append(orderByFields[i]);
5251    
5252                                    if ((i + 1) < orderByFields.length) {
5253                                            if (orderByComparator.isAscending() ^ previous) {
5254                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5255                                            }
5256                                            else {
5257                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5258                                            }
5259                                    }
5260                                    else {
5261                                            if (orderByComparator.isAscending() ^ previous) {
5262                                                    query.append(ORDER_BY_ASC);
5263                                            }
5264                                            else {
5265                                                    query.append(ORDER_BY_DESC);
5266                                            }
5267                                    }
5268                            }
5269                    }
5270    
5271                    else {
5272                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5273                    }
5274    
5275                    String sql = query.toString();
5276    
5277                    Query q = session.createQuery(sql);
5278    
5279                    q.setFirstResult(0);
5280                    q.setMaxResults(2);
5281    
5282                    QueryPos qPos = QueryPos.getInstance(q);
5283    
5284                    qPos.add(resourcePrimKey);
5285    
5286                    qPos.add(status);
5287    
5288                    if (orderByComparator != null) {
5289                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5290    
5291                            for (Object value : values) {
5292                                    qPos.add(value);
5293                            }
5294                    }
5295    
5296                    List<JournalArticle> list = q.list();
5297    
5298                    if (list.size() == 2) {
5299                            return list.get(1);
5300                    }
5301                    else {
5302                            return null;
5303                    }
5304            }
5305    
5306            /**
5307             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
5308             *
5309             * @param groupId the group ID
5310             * @param articleId the article ID
5311             * @return the matching journal articles
5312             * @throws SystemException if a system exception occurred
5313             */
5314            public List<JournalArticle> findByG_A(long groupId, String articleId)
5315                    throws SystemException {
5316                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
5317                            QueryUtil.ALL_POS, null);
5318            }
5319    
5320            /**
5321             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
5322             *
5323             * <p>
5324             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5325             * </p>
5326             *
5327             * @param groupId the group ID
5328             * @param articleId the article ID
5329             * @param start the lower bound of the range of journal articles
5330             * @param end the upper bound of the range of journal articles (not inclusive)
5331             * @return the range of matching journal articles
5332             * @throws SystemException if a system exception occurred
5333             */
5334            public List<JournalArticle> findByG_A(long groupId, String articleId,
5335                    int start, int end) throws SystemException {
5336                    return findByG_A(groupId, articleId, start, end, null);
5337            }
5338    
5339            /**
5340             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
5341             *
5342             * <p>
5343             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5344             * </p>
5345             *
5346             * @param groupId the group ID
5347             * @param articleId the article ID
5348             * @param start the lower bound of the range of journal articles
5349             * @param end the upper bound of the range of journal articles (not inclusive)
5350             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5351             * @return the ordered range of matching journal articles
5352             * @throws SystemException if a system exception occurred
5353             */
5354            public List<JournalArticle> findByG_A(long groupId, String articleId,
5355                    int start, int end, OrderByComparator orderByComparator)
5356                    throws SystemException {
5357                    FinderPath finderPath = null;
5358                    Object[] finderArgs = null;
5359    
5360                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5361                                    (orderByComparator == null)) {
5362                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
5363                            finderArgs = new Object[] { groupId, articleId };
5364                    }
5365                    else {
5366                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
5367                            finderArgs = new Object[] {
5368                                            groupId, articleId,
5369                                            
5370                                            start, end, orderByComparator
5371                                    };
5372                    }
5373    
5374                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5375                                    finderArgs, this);
5376    
5377                    if ((list != null) && !list.isEmpty()) {
5378                            for (JournalArticle journalArticle : list) {
5379                                    if ((groupId != journalArticle.getGroupId()) ||
5380                                                    !Validator.equals(articleId,
5381                                                            journalArticle.getArticleId())) {
5382                                            list = null;
5383    
5384                                            break;
5385                                    }
5386                            }
5387                    }
5388    
5389                    if (list == null) {
5390                            StringBundler query = null;
5391    
5392                            if (orderByComparator != null) {
5393                                    query = new StringBundler(4 +
5394                                                    (orderByComparator.getOrderByFields().length * 3));
5395                            }
5396                            else {
5397                                    query = new StringBundler(4);
5398                            }
5399    
5400                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5401    
5402                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
5403    
5404                            if (articleId == null) {
5405                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
5406                            }
5407                            else {
5408                                    if (articleId.equals(StringPool.BLANK)) {
5409                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
5410                                    }
5411                                    else {
5412                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
5413                                    }
5414                            }
5415    
5416                            if (orderByComparator != null) {
5417                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5418                                            orderByComparator);
5419                            }
5420    
5421                            else {
5422                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5423                            }
5424    
5425                            String sql = query.toString();
5426    
5427                            Session session = null;
5428    
5429                            try {
5430                                    session = openSession();
5431    
5432                                    Query q = session.createQuery(sql);
5433    
5434                                    QueryPos qPos = QueryPos.getInstance(q);
5435    
5436                                    qPos.add(groupId);
5437    
5438                                    if (articleId != null) {
5439                                            qPos.add(articleId);
5440                                    }
5441    
5442                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5443                                                    start, end);
5444                            }
5445                            catch (Exception e) {
5446                                    throw processException(e);
5447                            }
5448                            finally {
5449                                    if (list == null) {
5450                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5451                                    }
5452                                    else {
5453                                            cacheResult(list);
5454    
5455                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5456                                    }
5457    
5458                                    closeSession(session);
5459                            }
5460                    }
5461    
5462                    return list;
5463            }
5464    
5465            /**
5466             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
5467             *
5468             * @param groupId the group ID
5469             * @param articleId the article ID
5470             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5471             * @return the first matching journal article
5472             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5473             * @throws SystemException if a system exception occurred
5474             */
5475            public JournalArticle findByG_A_First(long groupId, String articleId,
5476                    OrderByComparator orderByComparator)
5477                    throws NoSuchArticleException, SystemException {
5478                    JournalArticle journalArticle = fetchByG_A_First(groupId, articleId,
5479                                    orderByComparator);
5480    
5481                    if (journalArticle != null) {
5482                            return journalArticle;
5483                    }
5484    
5485                    StringBundler msg = new StringBundler(6);
5486    
5487                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5488    
5489                    msg.append("groupId=");
5490                    msg.append(groupId);
5491    
5492                    msg.append(", articleId=");
5493                    msg.append(articleId);
5494    
5495                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5496    
5497                    throw new NoSuchArticleException(msg.toString());
5498            }
5499    
5500            /**
5501             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
5502             *
5503             * @param groupId the group ID
5504             * @param articleId the article ID
5505             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5506             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
5507             * @throws SystemException if a system exception occurred
5508             */
5509            public JournalArticle fetchByG_A_First(long groupId, String articleId,
5510                    OrderByComparator orderByComparator) throws SystemException {
5511                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
5512                                    orderByComparator);
5513    
5514                    if (!list.isEmpty()) {
5515                            return list.get(0);
5516                    }
5517    
5518                    return null;
5519            }
5520    
5521            /**
5522             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
5523             *
5524             * @param groupId the group ID
5525             * @param articleId the article ID
5526             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5527             * @return the last matching journal article
5528             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5529             * @throws SystemException if a system exception occurred
5530             */
5531            public JournalArticle findByG_A_Last(long groupId, String articleId,
5532                    OrderByComparator orderByComparator)
5533                    throws NoSuchArticleException, SystemException {
5534                    JournalArticle journalArticle = fetchByG_A_Last(groupId, articleId,
5535                                    orderByComparator);
5536    
5537                    if (journalArticle != null) {
5538                            return journalArticle;
5539                    }
5540    
5541                    StringBundler msg = new StringBundler(6);
5542    
5543                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5544    
5545                    msg.append("groupId=");
5546                    msg.append(groupId);
5547    
5548                    msg.append(", articleId=");
5549                    msg.append(articleId);
5550    
5551                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5552    
5553                    throw new NoSuchArticleException(msg.toString());
5554            }
5555    
5556            /**
5557             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
5558             *
5559             * @param groupId the group ID
5560             * @param articleId the article ID
5561             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5562             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
5563             * @throws SystemException if a system exception occurred
5564             */
5565            public JournalArticle fetchByG_A_Last(long groupId, String articleId,
5566                    OrderByComparator orderByComparator) throws SystemException {
5567                    int count = countByG_A(groupId, articleId);
5568    
5569                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
5570                                    count, orderByComparator);
5571    
5572                    if (!list.isEmpty()) {
5573                            return list.get(0);
5574                    }
5575    
5576                    return null;
5577            }
5578    
5579            /**
5580             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
5581             *
5582             * @param id the primary key of the current journal article
5583             * @param groupId the group ID
5584             * @param articleId the article ID
5585             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5586             * @return the previous, current, and next journal article
5587             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5588             * @throws SystemException if a system exception occurred
5589             */
5590            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
5591                    String articleId, OrderByComparator orderByComparator)
5592                    throws NoSuchArticleException, SystemException {
5593                    JournalArticle journalArticle = findByPrimaryKey(id);
5594    
5595                    Session session = null;
5596    
5597                    try {
5598                            session = openSession();
5599    
5600                            JournalArticle[] array = new JournalArticleImpl[3];
5601    
5602                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
5603                                            articleId, orderByComparator, true);
5604    
5605                            array[1] = journalArticle;
5606    
5607                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
5608                                            articleId, orderByComparator, false);
5609    
5610                            return array;
5611                    }
5612                    catch (Exception e) {
5613                            throw processException(e);
5614                    }
5615                    finally {
5616                            closeSession(session);
5617                    }
5618            }
5619    
5620            protected JournalArticle getByG_A_PrevAndNext(Session session,
5621                    JournalArticle journalArticle, long groupId, String articleId,
5622                    OrderByComparator orderByComparator, boolean previous) {
5623                    StringBundler query = null;
5624    
5625                    if (orderByComparator != null) {
5626                            query = new StringBundler(6 +
5627                                            (orderByComparator.getOrderByFields().length * 6));
5628                    }
5629                    else {
5630                            query = new StringBundler(3);
5631                    }
5632    
5633                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5634    
5635                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
5636    
5637                    if (articleId == null) {
5638                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
5639                    }
5640                    else {
5641                            if (articleId.equals(StringPool.BLANK)) {
5642                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
5643                            }
5644                            else {
5645                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
5646                            }
5647                    }
5648    
5649                    if (orderByComparator != null) {
5650                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5651    
5652                            if (orderByConditionFields.length > 0) {
5653                                    query.append(WHERE_AND);
5654                            }
5655    
5656                            for (int i = 0; i < orderByConditionFields.length; i++) {
5657                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5658                                    query.append(orderByConditionFields[i]);
5659    
5660                                    if ((i + 1) < orderByConditionFields.length) {
5661                                            if (orderByComparator.isAscending() ^ previous) {
5662                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5663                                            }
5664                                            else {
5665                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5666                                            }
5667                                    }
5668                                    else {
5669                                            if (orderByComparator.isAscending() ^ previous) {
5670                                                    query.append(WHERE_GREATER_THAN);
5671                                            }
5672                                            else {
5673                                                    query.append(WHERE_LESSER_THAN);
5674                                            }
5675                                    }
5676                            }
5677    
5678                            query.append(ORDER_BY_CLAUSE);
5679    
5680                            String[] orderByFields = orderByComparator.getOrderByFields();
5681    
5682                            for (int i = 0; i < orderByFields.length; i++) {
5683                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5684                                    query.append(orderByFields[i]);
5685    
5686                                    if ((i + 1) < orderByFields.length) {
5687                                            if (orderByComparator.isAscending() ^ previous) {
5688                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5689                                            }
5690                                            else {
5691                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5692                                            }
5693                                    }
5694                                    else {
5695                                            if (orderByComparator.isAscending() ^ previous) {
5696                                                    query.append(ORDER_BY_ASC);
5697                                            }
5698                                            else {
5699                                                    query.append(ORDER_BY_DESC);
5700                                            }
5701                                    }
5702                            }
5703                    }
5704    
5705                    else {
5706                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5707                    }
5708    
5709                    String sql = query.toString();
5710    
5711                    Query q = session.createQuery(sql);
5712    
5713                    q.setFirstResult(0);
5714                    q.setMaxResults(2);
5715    
5716                    QueryPos qPos = QueryPos.getInstance(q);
5717    
5718                    qPos.add(groupId);
5719    
5720                    if (articleId != null) {
5721                            qPos.add(articleId);
5722                    }
5723    
5724                    if (orderByComparator != null) {
5725                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5726    
5727                            for (Object value : values) {
5728                                    qPos.add(value);
5729                            }
5730                    }
5731    
5732                    List<JournalArticle> list = q.list();
5733    
5734                    if (list.size() == 2) {
5735                            return list.get(1);
5736                    }
5737                    else {
5738                            return null;
5739                    }
5740            }
5741    
5742            /**
5743             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
5744             *
5745             * @param groupId the group ID
5746             * @param articleId the article ID
5747             * @return the matching journal articles that the user has permission to view
5748             * @throws SystemException if a system exception occurred
5749             */
5750            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
5751                    throws SystemException {
5752                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
5753                            QueryUtil.ALL_POS, null);
5754            }
5755    
5756            /**
5757             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
5758             *
5759             * <p>
5760             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5761             * </p>
5762             *
5763             * @param groupId the group ID
5764             * @param articleId the article ID
5765             * @param start the lower bound of the range of journal articles
5766             * @param end the upper bound of the range of journal articles (not inclusive)
5767             * @return the range of matching journal articles that the user has permission to view
5768             * @throws SystemException if a system exception occurred
5769             */
5770            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
5771                    int start, int end) throws SystemException {
5772                    return filterFindByG_A(groupId, articleId, start, end, null);
5773            }
5774    
5775            /**
5776             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
5777             *
5778             * <p>
5779             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5780             * </p>
5781             *
5782             * @param groupId the group ID
5783             * @param articleId the article ID
5784             * @param start the lower bound of the range of journal articles
5785             * @param end the upper bound of the range of journal articles (not inclusive)
5786             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5787             * @return the ordered range of matching journal articles that the user has permission to view
5788             * @throws SystemException if a system exception occurred
5789             */
5790            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
5791                    int start, int end, OrderByComparator orderByComparator)
5792                    throws SystemException {
5793                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5794                            return findByG_A(groupId, articleId, start, end, orderByComparator);
5795                    }
5796    
5797                    StringBundler query = null;
5798    
5799                    if (orderByComparator != null) {
5800                            query = new StringBundler(4 +
5801                                            (orderByComparator.getOrderByFields().length * 3));
5802                    }
5803                    else {
5804                            query = new StringBundler(4);
5805                    }
5806    
5807                    if (getDB().isSupportsInlineDistinct()) {
5808                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
5809                    }
5810                    else {
5811                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
5812                    }
5813    
5814                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
5815    
5816                    if (articleId == null) {
5817                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
5818                    }
5819                    else {
5820                            if (articleId.equals(StringPool.BLANK)) {
5821                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
5822                            }
5823                            else {
5824                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
5825                            }
5826                    }
5827    
5828                    if (!getDB().isSupportsInlineDistinct()) {
5829                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
5830                    }
5831    
5832                    if (orderByComparator != null) {
5833                            if (getDB().isSupportsInlineDistinct()) {
5834                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5835                                            orderByComparator);
5836                            }
5837                            else {
5838                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5839                                            orderByComparator);
5840                            }
5841                    }
5842    
5843                    else {
5844                            if (getDB().isSupportsInlineDistinct()) {
5845                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5846                            }
5847                            else {
5848                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
5849                            }
5850                    }
5851    
5852                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5853                                    JournalArticle.class.getName(),
5854                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5855    
5856                    Session session = null;
5857    
5858                    try {
5859                            session = openSession();
5860    
5861                            SQLQuery q = session.createSQLQuery(sql);
5862    
5863                            if (getDB().isSupportsInlineDistinct()) {
5864                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
5865                            }
5866                            else {
5867                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
5868                            }
5869    
5870                            QueryPos qPos = QueryPos.getInstance(q);
5871    
5872                            qPos.add(groupId);
5873    
5874                            if (articleId != null) {
5875                                    qPos.add(articleId);
5876                            }
5877    
5878                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
5879                                    end);
5880                    }
5881                    catch (Exception e) {
5882                            throw processException(e);
5883                    }
5884                    finally {
5885                            closeSession(session);
5886                    }
5887            }
5888    
5889            /**
5890             * 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;.
5891             *
5892             * @param id the primary key of the current journal article
5893             * @param groupId the group ID
5894             * @param articleId the article ID
5895             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5896             * @return the previous, current, and next journal article
5897             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5898             * @throws SystemException if a system exception occurred
5899             */
5900            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
5901                    String articleId, OrderByComparator orderByComparator)
5902                    throws NoSuchArticleException, SystemException {
5903                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5904                            return findByG_A_PrevAndNext(id, groupId, articleId,
5905                                    orderByComparator);
5906                    }
5907    
5908                    JournalArticle journalArticle = findByPrimaryKey(id);
5909    
5910                    Session session = null;
5911    
5912                    try {
5913                            session = openSession();
5914    
5915                            JournalArticle[] array = new JournalArticleImpl[3];
5916    
5917                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
5918                                            groupId, articleId, orderByComparator, true);
5919    
5920                            array[1] = journalArticle;
5921    
5922                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
5923                                            groupId, articleId, orderByComparator, false);
5924    
5925                            return array;
5926                    }
5927                    catch (Exception e) {
5928                            throw processException(e);
5929                    }
5930                    finally {
5931                            closeSession(session);
5932                    }
5933            }
5934    
5935            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
5936                    JournalArticle journalArticle, long groupId, String articleId,
5937                    OrderByComparator orderByComparator, boolean previous) {
5938                    StringBundler query = null;
5939    
5940                    if (orderByComparator != null) {
5941                            query = new StringBundler(6 +
5942                                            (orderByComparator.getOrderByFields().length * 6));
5943                    }
5944                    else {
5945                            query = new StringBundler(3);
5946                    }
5947    
5948                    if (getDB().isSupportsInlineDistinct()) {
5949                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
5950                    }
5951                    else {
5952                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
5953                    }
5954    
5955                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
5956    
5957                    if (articleId == null) {
5958                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
5959                    }
5960                    else {
5961                            if (articleId.equals(StringPool.BLANK)) {
5962                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
5963                            }
5964                            else {
5965                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
5966                            }
5967                    }
5968    
5969                    if (!getDB().isSupportsInlineDistinct()) {
5970                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
5971                    }
5972    
5973                    if (orderByComparator != null) {
5974                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5975    
5976                            if (orderByConditionFields.length > 0) {
5977                                    query.append(WHERE_AND);
5978                            }
5979    
5980                            for (int i = 0; i < orderByConditionFields.length; i++) {
5981                                    if (getDB().isSupportsInlineDistinct()) {
5982                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5983                                    }
5984                                    else {
5985                                            query.append(_ORDER_BY_ENTITY_TABLE);
5986                                    }
5987    
5988                                    query.append(orderByConditionFields[i]);
5989    
5990                                    if ((i + 1) < orderByConditionFields.length) {
5991                                            if (orderByComparator.isAscending() ^ previous) {
5992                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5993                                            }
5994                                            else {
5995                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5996                                            }
5997                                    }
5998                                    else {
5999                                            if (orderByComparator.isAscending() ^ previous) {
6000                                                    query.append(WHERE_GREATER_THAN);
6001                                            }
6002                                            else {
6003                                                    query.append(WHERE_LESSER_THAN);
6004                                            }
6005                                    }
6006                            }
6007    
6008                            query.append(ORDER_BY_CLAUSE);
6009    
6010                            String[] orderByFields = orderByComparator.getOrderByFields();
6011    
6012                            for (int i = 0; i < orderByFields.length; i++) {
6013                                    if (getDB().isSupportsInlineDistinct()) {
6014                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6015                                    }
6016                                    else {
6017                                            query.append(_ORDER_BY_ENTITY_TABLE);
6018                                    }
6019    
6020                                    query.append(orderByFields[i]);
6021    
6022                                    if ((i + 1) < orderByFields.length) {
6023                                            if (orderByComparator.isAscending() ^ previous) {
6024                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6025                                            }
6026                                            else {
6027                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6028                                            }
6029                                    }
6030                                    else {
6031                                            if (orderByComparator.isAscending() ^ previous) {
6032                                                    query.append(ORDER_BY_ASC);
6033                                            }
6034                                            else {
6035                                                    query.append(ORDER_BY_DESC);
6036                                            }
6037                                    }
6038                            }
6039                    }
6040    
6041                    else {
6042                            if (getDB().isSupportsInlineDistinct()) {
6043                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6044                            }
6045                            else {
6046                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6047                            }
6048                    }
6049    
6050                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6051                                    JournalArticle.class.getName(),
6052                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6053    
6054                    SQLQuery q = session.createSQLQuery(sql);
6055    
6056                    q.setFirstResult(0);
6057                    q.setMaxResults(2);
6058    
6059                    if (getDB().isSupportsInlineDistinct()) {
6060                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6061                    }
6062                    else {
6063                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6064                    }
6065    
6066                    QueryPos qPos = QueryPos.getInstance(q);
6067    
6068                    qPos.add(groupId);
6069    
6070                    if (articleId != null) {
6071                            qPos.add(articleId);
6072                    }
6073    
6074                    if (orderByComparator != null) {
6075                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6076    
6077                            for (Object value : values) {
6078                                    qPos.add(value);
6079                            }
6080                    }
6081    
6082                    List<JournalArticle> list = q.list();
6083    
6084                    if (list.size() == 2) {
6085                            return list.get(1);
6086                    }
6087                    else {
6088                            return null;
6089                    }
6090            }
6091    
6092            /**
6093             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
6094             *
6095             * @param groupId the group ID
6096             * @param urlTitle the url title
6097             * @return the matching journal articles
6098             * @throws SystemException if a system exception occurred
6099             */
6100            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
6101                    throws SystemException {
6102                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
6103                            QueryUtil.ALL_POS, null);
6104            }
6105    
6106            /**
6107             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
6108             *
6109             * <p>
6110             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6111             * </p>
6112             *
6113             * @param groupId the group ID
6114             * @param urlTitle the url title
6115             * @param start the lower bound of the range of journal articles
6116             * @param end the upper bound of the range of journal articles (not inclusive)
6117             * @return the range of matching journal articles
6118             * @throws SystemException if a system exception occurred
6119             */
6120            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
6121                    int start, int end) throws SystemException {
6122                    return findByG_UT(groupId, urlTitle, start, end, null);
6123            }
6124    
6125            /**
6126             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
6127             *
6128             * <p>
6129             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6130             * </p>
6131             *
6132             * @param groupId the group ID
6133             * @param urlTitle the url title
6134             * @param start the lower bound of the range of journal articles
6135             * @param end the upper bound of the range of journal articles (not inclusive)
6136             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6137             * @return the ordered range of matching journal articles
6138             * @throws SystemException if a system exception occurred
6139             */
6140            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
6141                    int start, int end, OrderByComparator orderByComparator)
6142                    throws SystemException {
6143                    FinderPath finderPath = null;
6144                    Object[] finderArgs = null;
6145    
6146                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6147                                    (orderByComparator == null)) {
6148                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
6149                            finderArgs = new Object[] { groupId, urlTitle };
6150                    }
6151                    else {
6152                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
6153                            finderArgs = new Object[] {
6154                                            groupId, urlTitle,
6155                                            
6156                                            start, end, orderByComparator
6157                                    };
6158                    }
6159    
6160                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6161                                    finderArgs, this);
6162    
6163                    if ((list != null) && !list.isEmpty()) {
6164                            for (JournalArticle journalArticle : list) {
6165                                    if ((groupId != journalArticle.getGroupId()) ||
6166                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle())) {
6167                                            list = null;
6168    
6169                                            break;
6170                                    }
6171                            }
6172                    }
6173    
6174                    if (list == null) {
6175                            StringBundler query = null;
6176    
6177                            if (orderByComparator != null) {
6178                                    query = new StringBundler(4 +
6179                                                    (orderByComparator.getOrderByFields().length * 3));
6180                            }
6181                            else {
6182                                    query = new StringBundler(4);
6183                            }
6184    
6185                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6186    
6187                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
6188    
6189                            if (urlTitle == null) {
6190                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
6191                            }
6192                            else {
6193                                    if (urlTitle.equals(StringPool.BLANK)) {
6194                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
6195                                    }
6196                                    else {
6197                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
6198                                    }
6199                            }
6200    
6201                            if (orderByComparator != null) {
6202                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6203                                            orderByComparator);
6204                            }
6205    
6206                            else {
6207                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6208                            }
6209    
6210                            String sql = query.toString();
6211    
6212                            Session session = null;
6213    
6214                            try {
6215                                    session = openSession();
6216    
6217                                    Query q = session.createQuery(sql);
6218    
6219                                    QueryPos qPos = QueryPos.getInstance(q);
6220    
6221                                    qPos.add(groupId);
6222    
6223                                    if (urlTitle != null) {
6224                                            qPos.add(urlTitle);
6225                                    }
6226    
6227                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
6228                                                    start, end);
6229                            }
6230                            catch (Exception e) {
6231                                    throw processException(e);
6232                            }
6233                            finally {
6234                                    if (list == null) {
6235                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6236                                    }
6237                                    else {
6238                                            cacheResult(list);
6239    
6240                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6241                                    }
6242    
6243                                    closeSession(session);
6244                            }
6245                    }
6246    
6247                    return list;
6248            }
6249    
6250            /**
6251             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
6252             *
6253             * @param groupId the group ID
6254             * @param urlTitle the url title
6255             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6256             * @return the first matching journal article
6257             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6258             * @throws SystemException if a system exception occurred
6259             */
6260            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
6261                    OrderByComparator orderByComparator)
6262                    throws NoSuchArticleException, SystemException {
6263                    JournalArticle journalArticle = fetchByG_UT_First(groupId, urlTitle,
6264                                    orderByComparator);
6265    
6266                    if (journalArticle != null) {
6267                            return journalArticle;
6268                    }
6269    
6270                    StringBundler msg = new StringBundler(6);
6271    
6272                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6273    
6274                    msg.append("groupId=");
6275                    msg.append(groupId);
6276    
6277                    msg.append(", urlTitle=");
6278                    msg.append(urlTitle);
6279    
6280                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6281    
6282                    throw new NoSuchArticleException(msg.toString());
6283            }
6284    
6285            /**
6286             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
6287             *
6288             * @param groupId the group ID
6289             * @param urlTitle the url title
6290             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6291             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
6292             * @throws SystemException if a system exception occurred
6293             */
6294            public JournalArticle fetchByG_UT_First(long groupId, String urlTitle,
6295                    OrderByComparator orderByComparator) throws SystemException {
6296                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
6297                                    orderByComparator);
6298    
6299                    if (!list.isEmpty()) {
6300                            return list.get(0);
6301                    }
6302    
6303                    return null;
6304            }
6305    
6306            /**
6307             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
6308             *
6309             * @param groupId the group ID
6310             * @param urlTitle the url title
6311             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6312             * @return the last matching journal article
6313             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6314             * @throws SystemException if a system exception occurred
6315             */
6316            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
6317                    OrderByComparator orderByComparator)
6318                    throws NoSuchArticleException, SystemException {
6319                    JournalArticle journalArticle = fetchByG_UT_Last(groupId, urlTitle,
6320                                    orderByComparator);
6321    
6322                    if (journalArticle != null) {
6323                            return journalArticle;
6324                    }
6325    
6326                    StringBundler msg = new StringBundler(6);
6327    
6328                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6329    
6330                    msg.append("groupId=");
6331                    msg.append(groupId);
6332    
6333                    msg.append(", urlTitle=");
6334                    msg.append(urlTitle);
6335    
6336                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6337    
6338                    throw new NoSuchArticleException(msg.toString());
6339            }
6340    
6341            /**
6342             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
6343             *
6344             * @param groupId the group ID
6345             * @param urlTitle the url title
6346             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6347             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
6348             * @throws SystemException if a system exception occurred
6349             */
6350            public JournalArticle fetchByG_UT_Last(long groupId, String urlTitle,
6351                    OrderByComparator orderByComparator) throws SystemException {
6352                    int count = countByG_UT(groupId, urlTitle);
6353    
6354                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
6355                                    count, orderByComparator);
6356    
6357                    if (!list.isEmpty()) {
6358                            return list.get(0);
6359                    }
6360    
6361                    return null;
6362            }
6363    
6364            /**
6365             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
6366             *
6367             * @param id the primary key of the current journal article
6368             * @param groupId the group ID
6369             * @param urlTitle the url title
6370             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6371             * @return the previous, current, and next journal article
6372             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6373             * @throws SystemException if a system exception occurred
6374             */
6375            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
6376                    String urlTitle, OrderByComparator orderByComparator)
6377                    throws NoSuchArticleException, SystemException {
6378                    JournalArticle journalArticle = findByPrimaryKey(id);
6379    
6380                    Session session = null;
6381    
6382                    try {
6383                            session = openSession();
6384    
6385                            JournalArticle[] array = new JournalArticleImpl[3];
6386    
6387                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
6388                                            urlTitle, orderByComparator, true);
6389    
6390                            array[1] = journalArticle;
6391    
6392                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
6393                                            urlTitle, orderByComparator, false);
6394    
6395                            return array;
6396                    }
6397                    catch (Exception e) {
6398                            throw processException(e);
6399                    }
6400                    finally {
6401                            closeSession(session);
6402                    }
6403            }
6404    
6405            protected JournalArticle getByG_UT_PrevAndNext(Session session,
6406                    JournalArticle journalArticle, long groupId, String urlTitle,
6407                    OrderByComparator orderByComparator, boolean previous) {
6408                    StringBundler query = null;
6409    
6410                    if (orderByComparator != null) {
6411                            query = new StringBundler(6 +
6412                                            (orderByComparator.getOrderByFields().length * 6));
6413                    }
6414                    else {
6415                            query = new StringBundler(3);
6416                    }
6417    
6418                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6419    
6420                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
6421    
6422                    if (urlTitle == null) {
6423                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
6424                    }
6425                    else {
6426                            if (urlTitle.equals(StringPool.BLANK)) {
6427                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
6428                            }
6429                            else {
6430                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
6431                            }
6432                    }
6433    
6434                    if (orderByComparator != null) {
6435                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6436    
6437                            if (orderByConditionFields.length > 0) {
6438                                    query.append(WHERE_AND);
6439                            }
6440    
6441                            for (int i = 0; i < orderByConditionFields.length; i++) {
6442                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6443                                    query.append(orderByConditionFields[i]);
6444    
6445                                    if ((i + 1) < orderByConditionFields.length) {
6446                                            if (orderByComparator.isAscending() ^ previous) {
6447                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6448                                            }
6449                                            else {
6450                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6451                                            }
6452                                    }
6453                                    else {
6454                                            if (orderByComparator.isAscending() ^ previous) {
6455                                                    query.append(WHERE_GREATER_THAN);
6456                                            }
6457                                            else {
6458                                                    query.append(WHERE_LESSER_THAN);
6459                                            }
6460                                    }
6461                            }
6462    
6463                            query.append(ORDER_BY_CLAUSE);
6464    
6465                            String[] orderByFields = orderByComparator.getOrderByFields();
6466    
6467                            for (int i = 0; i < orderByFields.length; i++) {
6468                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6469                                    query.append(orderByFields[i]);
6470    
6471                                    if ((i + 1) < orderByFields.length) {
6472                                            if (orderByComparator.isAscending() ^ previous) {
6473                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6474                                            }
6475                                            else {
6476                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6477                                            }
6478                                    }
6479                                    else {
6480                                            if (orderByComparator.isAscending() ^ previous) {
6481                                                    query.append(ORDER_BY_ASC);
6482                                            }
6483                                            else {
6484                                                    query.append(ORDER_BY_DESC);
6485                                            }
6486                                    }
6487                            }
6488                    }
6489    
6490                    else {
6491                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6492                    }
6493    
6494                    String sql = query.toString();
6495    
6496                    Query q = session.createQuery(sql);
6497    
6498                    q.setFirstResult(0);
6499                    q.setMaxResults(2);
6500    
6501                    QueryPos qPos = QueryPos.getInstance(q);
6502    
6503                    qPos.add(groupId);
6504    
6505                    if (urlTitle != null) {
6506                            qPos.add(urlTitle);
6507                    }
6508    
6509                    if (orderByComparator != null) {
6510                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6511    
6512                            for (Object value : values) {
6513                                    qPos.add(value);
6514                            }
6515                    }
6516    
6517                    List<JournalArticle> list = q.list();
6518    
6519                    if (list.size() == 2) {
6520                            return list.get(1);
6521                    }
6522                    else {
6523                            return null;
6524                    }
6525            }
6526    
6527            /**
6528             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
6529             *
6530             * @param groupId the group ID
6531             * @param urlTitle the url title
6532             * @return the matching journal articles that the user has permission to view
6533             * @throws SystemException if a system exception occurred
6534             */
6535            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
6536                    throws SystemException {
6537                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
6538                            QueryUtil.ALL_POS, null);
6539            }
6540    
6541            /**
6542             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
6543             *
6544             * <p>
6545             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6546             * </p>
6547             *
6548             * @param groupId the group ID
6549             * @param urlTitle the url title
6550             * @param start the lower bound of the range of journal articles
6551             * @param end the upper bound of the range of journal articles (not inclusive)
6552             * @return the range of matching journal articles that the user has permission to view
6553             * @throws SystemException if a system exception occurred
6554             */
6555            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
6556                    int start, int end) throws SystemException {
6557                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
6558            }
6559    
6560            /**
6561             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
6562             *
6563             * <p>
6564             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6565             * </p>
6566             *
6567             * @param groupId the group ID
6568             * @param urlTitle the url title
6569             * @param start the lower bound of the range of journal articles
6570             * @param end the upper bound of the range of journal articles (not inclusive)
6571             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6572             * @return the ordered range of matching journal articles that the user has permission to view
6573             * @throws SystemException if a system exception occurred
6574             */
6575            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
6576                    int start, int end, OrderByComparator orderByComparator)
6577                    throws SystemException {
6578                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6579                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
6580                    }
6581    
6582                    StringBundler query = null;
6583    
6584                    if (orderByComparator != null) {
6585                            query = new StringBundler(4 +
6586                                            (orderByComparator.getOrderByFields().length * 3));
6587                    }
6588                    else {
6589                            query = new StringBundler(4);
6590                    }
6591    
6592                    if (getDB().isSupportsInlineDistinct()) {
6593                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6594                    }
6595                    else {
6596                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6597                    }
6598    
6599                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
6600    
6601                    if (urlTitle == null) {
6602                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
6603                    }
6604                    else {
6605                            if (urlTitle.equals(StringPool.BLANK)) {
6606                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
6607                            }
6608                            else {
6609                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
6610                            }
6611                    }
6612    
6613                    if (!getDB().isSupportsInlineDistinct()) {
6614                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6615                    }
6616    
6617                    if (orderByComparator != null) {
6618                            if (getDB().isSupportsInlineDistinct()) {
6619                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6620                                            orderByComparator);
6621                            }
6622                            else {
6623                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6624                                            orderByComparator);
6625                            }
6626                    }
6627    
6628                    else {
6629                            if (getDB().isSupportsInlineDistinct()) {
6630                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6631                            }
6632                            else {
6633                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6634                            }
6635                    }
6636    
6637                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6638                                    JournalArticle.class.getName(),
6639                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6640    
6641                    Session session = null;
6642    
6643                    try {
6644                            session = openSession();
6645    
6646                            SQLQuery q = session.createSQLQuery(sql);
6647    
6648                            if (getDB().isSupportsInlineDistinct()) {
6649                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6650                            }
6651                            else {
6652                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6653                            }
6654    
6655                            QueryPos qPos = QueryPos.getInstance(q);
6656    
6657                            qPos.add(groupId);
6658    
6659                            if (urlTitle != null) {
6660                                    qPos.add(urlTitle);
6661                            }
6662    
6663                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6664                                    end);
6665                    }
6666                    catch (Exception e) {
6667                            throw processException(e);
6668                    }
6669                    finally {
6670                            closeSession(session);
6671                    }
6672            }
6673    
6674            /**
6675             * 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;.
6676             *
6677             * @param id the primary key of the current journal article
6678             * @param groupId the group ID
6679             * @param urlTitle the url title
6680             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6681             * @return the previous, current, and next journal article
6682             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6683             * @throws SystemException if a system exception occurred
6684             */
6685            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
6686                    String urlTitle, OrderByComparator orderByComparator)
6687                    throws NoSuchArticleException, SystemException {
6688                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6689                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
6690                                    orderByComparator);
6691                    }
6692    
6693                    JournalArticle journalArticle = findByPrimaryKey(id);
6694    
6695                    Session session = null;
6696    
6697                    try {
6698                            session = openSession();
6699    
6700                            JournalArticle[] array = new JournalArticleImpl[3];
6701    
6702                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
6703                                            groupId, urlTitle, orderByComparator, true);
6704    
6705                            array[1] = journalArticle;
6706    
6707                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
6708                                            groupId, urlTitle, orderByComparator, false);
6709    
6710                            return array;
6711                    }
6712                    catch (Exception e) {
6713                            throw processException(e);
6714                    }
6715                    finally {
6716                            closeSession(session);
6717                    }
6718            }
6719    
6720            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
6721                    JournalArticle journalArticle, long groupId, String urlTitle,
6722                    OrderByComparator orderByComparator, boolean previous) {
6723                    StringBundler query = null;
6724    
6725                    if (orderByComparator != null) {
6726                            query = new StringBundler(6 +
6727                                            (orderByComparator.getOrderByFields().length * 6));
6728                    }
6729                    else {
6730                            query = new StringBundler(3);
6731                    }
6732    
6733                    if (getDB().isSupportsInlineDistinct()) {
6734                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6735                    }
6736                    else {
6737                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6738                    }
6739    
6740                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
6741    
6742                    if (urlTitle == null) {
6743                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
6744                    }
6745                    else {
6746                            if (urlTitle.equals(StringPool.BLANK)) {
6747                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
6748                            }
6749                            else {
6750                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
6751                            }
6752                    }
6753    
6754                    if (!getDB().isSupportsInlineDistinct()) {
6755                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6756                    }
6757    
6758                    if (orderByComparator != null) {
6759                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6760    
6761                            if (orderByConditionFields.length > 0) {
6762                                    query.append(WHERE_AND);
6763                            }
6764    
6765                            for (int i = 0; i < orderByConditionFields.length; i++) {
6766                                    if (getDB().isSupportsInlineDistinct()) {
6767                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6768                                    }
6769                                    else {
6770                                            query.append(_ORDER_BY_ENTITY_TABLE);
6771                                    }
6772    
6773                                    query.append(orderByConditionFields[i]);
6774    
6775                                    if ((i + 1) < orderByConditionFields.length) {
6776                                            if (orderByComparator.isAscending() ^ previous) {
6777                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6778                                            }
6779                                            else {
6780                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6781                                            }
6782                                    }
6783                                    else {
6784                                            if (orderByComparator.isAscending() ^ previous) {
6785                                                    query.append(WHERE_GREATER_THAN);
6786                                            }
6787                                            else {
6788                                                    query.append(WHERE_LESSER_THAN);
6789                                            }
6790                                    }
6791                            }
6792    
6793                            query.append(ORDER_BY_CLAUSE);
6794    
6795                            String[] orderByFields = orderByComparator.getOrderByFields();
6796    
6797                            for (int i = 0; i < orderByFields.length; i++) {
6798                                    if (getDB().isSupportsInlineDistinct()) {
6799                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6800                                    }
6801                                    else {
6802                                            query.append(_ORDER_BY_ENTITY_TABLE);
6803                                    }
6804    
6805                                    query.append(orderByFields[i]);
6806    
6807                                    if ((i + 1) < orderByFields.length) {
6808                                            if (orderByComparator.isAscending() ^ previous) {
6809                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6810                                            }
6811                                            else {
6812                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6813                                            }
6814                                    }
6815                                    else {
6816                                            if (orderByComparator.isAscending() ^ previous) {
6817                                                    query.append(ORDER_BY_ASC);
6818                                            }
6819                                            else {
6820                                                    query.append(ORDER_BY_DESC);
6821                                            }
6822                                    }
6823                            }
6824                    }
6825    
6826                    else {
6827                            if (getDB().isSupportsInlineDistinct()) {
6828                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6829                            }
6830                            else {
6831                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6832                            }
6833                    }
6834    
6835                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6836                                    JournalArticle.class.getName(),
6837                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6838    
6839                    SQLQuery q = session.createSQLQuery(sql);
6840    
6841                    q.setFirstResult(0);
6842                    q.setMaxResults(2);
6843    
6844                    if (getDB().isSupportsInlineDistinct()) {
6845                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6846                    }
6847                    else {
6848                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6849                    }
6850    
6851                    QueryPos qPos = QueryPos.getInstance(q);
6852    
6853                    qPos.add(groupId);
6854    
6855                    if (urlTitle != null) {
6856                            qPos.add(urlTitle);
6857                    }
6858    
6859                    if (orderByComparator != null) {
6860                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6861    
6862                            for (Object value : values) {
6863                                    qPos.add(value);
6864                            }
6865                    }
6866    
6867                    List<JournalArticle> list = q.list();
6868    
6869                    if (list.size() == 2) {
6870                            return list.get(1);
6871                    }
6872                    else {
6873                            return null;
6874                    }
6875            }
6876    
6877            /**
6878             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
6879             *
6880             * @param groupId the group ID
6881             * @param structureId the structure ID
6882             * @return the matching journal articles
6883             * @throws SystemException if a system exception occurred
6884             */
6885            public List<JournalArticle> findByG_S(long groupId, String structureId)
6886                    throws SystemException {
6887                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
6888                            QueryUtil.ALL_POS, null);
6889            }
6890    
6891            /**
6892             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
6893             *
6894             * <p>
6895             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6896             * </p>
6897             *
6898             * @param groupId the group ID
6899             * @param structureId the structure ID
6900             * @param start the lower bound of the range of journal articles
6901             * @param end the upper bound of the range of journal articles (not inclusive)
6902             * @return the range of matching journal articles
6903             * @throws SystemException if a system exception occurred
6904             */
6905            public List<JournalArticle> findByG_S(long groupId, String structureId,
6906                    int start, int end) throws SystemException {
6907                    return findByG_S(groupId, structureId, start, end, null);
6908            }
6909    
6910            /**
6911             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
6912             *
6913             * <p>
6914             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6915             * </p>
6916             *
6917             * @param groupId the group ID
6918             * @param structureId the structure ID
6919             * @param start the lower bound of the range of journal articles
6920             * @param end the upper bound of the range of journal articles (not inclusive)
6921             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6922             * @return the ordered range of matching journal articles
6923             * @throws SystemException if a system exception occurred
6924             */
6925            public List<JournalArticle> findByG_S(long groupId, String structureId,
6926                    int start, int end, OrderByComparator orderByComparator)
6927                    throws SystemException {
6928                    FinderPath finderPath = null;
6929                    Object[] finderArgs = null;
6930    
6931                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6932                                    (orderByComparator == null)) {
6933                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
6934                            finderArgs = new Object[] { groupId, structureId };
6935                    }
6936                    else {
6937                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
6938                            finderArgs = new Object[] {
6939                                            groupId, structureId,
6940                                            
6941                                            start, end, orderByComparator
6942                                    };
6943                    }
6944    
6945                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6946                                    finderArgs, this);
6947    
6948                    if ((list != null) && !list.isEmpty()) {
6949                            for (JournalArticle journalArticle : list) {
6950                                    if ((groupId != journalArticle.getGroupId()) ||
6951                                                    !Validator.equals(structureId,
6952                                                            journalArticle.getStructureId())) {
6953                                            list = null;
6954    
6955                                            break;
6956                                    }
6957                            }
6958                    }
6959    
6960                    if (list == null) {
6961                            StringBundler query = null;
6962    
6963                            if (orderByComparator != null) {
6964                                    query = new StringBundler(4 +
6965                                                    (orderByComparator.getOrderByFields().length * 3));
6966                            }
6967                            else {
6968                                    query = new StringBundler(4);
6969                            }
6970    
6971                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6972    
6973                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6974    
6975                            if (structureId == null) {
6976                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
6977                            }
6978                            else {
6979                                    if (structureId.equals(StringPool.BLANK)) {
6980                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
6981                                    }
6982                                    else {
6983                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
6984                                    }
6985                            }
6986    
6987                            if (orderByComparator != null) {
6988                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6989                                            orderByComparator);
6990                            }
6991    
6992                            else {
6993                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6994                            }
6995    
6996                            String sql = query.toString();
6997    
6998                            Session session = null;
6999    
7000                            try {
7001                                    session = openSession();
7002    
7003                                    Query q = session.createQuery(sql);
7004    
7005                                    QueryPos qPos = QueryPos.getInstance(q);
7006    
7007                                    qPos.add(groupId);
7008    
7009                                    if (structureId != null) {
7010                                            qPos.add(structureId);
7011                                    }
7012    
7013                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
7014                                                    start, end);
7015                            }
7016                            catch (Exception e) {
7017                                    throw processException(e);
7018                            }
7019                            finally {
7020                                    if (list == null) {
7021                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7022                                    }
7023                                    else {
7024                                            cacheResult(list);
7025    
7026                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7027                                    }
7028    
7029                                    closeSession(session);
7030                            }
7031                    }
7032    
7033                    return list;
7034            }
7035    
7036            /**
7037             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
7038             *
7039             * @param groupId the group ID
7040             * @param structureId the structure ID
7041             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7042             * @return the first matching journal article
7043             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7044             * @throws SystemException if a system exception occurred
7045             */
7046            public JournalArticle findByG_S_First(long groupId, String structureId,
7047                    OrderByComparator orderByComparator)
7048                    throws NoSuchArticleException, SystemException {
7049                    JournalArticle journalArticle = fetchByG_S_First(groupId, structureId,
7050                                    orderByComparator);
7051    
7052                    if (journalArticle != null) {
7053                            return journalArticle;
7054                    }
7055    
7056                    StringBundler msg = new StringBundler(6);
7057    
7058                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7059    
7060                    msg.append("groupId=");
7061                    msg.append(groupId);
7062    
7063                    msg.append(", structureId=");
7064                    msg.append(structureId);
7065    
7066                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7067    
7068                    throw new NoSuchArticleException(msg.toString());
7069            }
7070    
7071            /**
7072             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
7073             *
7074             * @param groupId the group ID
7075             * @param structureId the structure ID
7076             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7077             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7078             * @throws SystemException if a system exception occurred
7079             */
7080            public JournalArticle fetchByG_S_First(long groupId, String structureId,
7081                    OrderByComparator orderByComparator) throws SystemException {
7082                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
7083                                    orderByComparator);
7084    
7085                    if (!list.isEmpty()) {
7086                            return list.get(0);
7087                    }
7088    
7089                    return null;
7090            }
7091    
7092            /**
7093             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
7094             *
7095             * @param groupId the group ID
7096             * @param structureId the structure ID
7097             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7098             * @return the last matching journal article
7099             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7100             * @throws SystemException if a system exception occurred
7101             */
7102            public JournalArticle findByG_S_Last(long groupId, String structureId,
7103                    OrderByComparator orderByComparator)
7104                    throws NoSuchArticleException, SystemException {
7105                    JournalArticle journalArticle = fetchByG_S_Last(groupId, structureId,
7106                                    orderByComparator);
7107    
7108                    if (journalArticle != null) {
7109                            return journalArticle;
7110                    }
7111    
7112                    StringBundler msg = new StringBundler(6);
7113    
7114                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7115    
7116                    msg.append("groupId=");
7117                    msg.append(groupId);
7118    
7119                    msg.append(", structureId=");
7120                    msg.append(structureId);
7121    
7122                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7123    
7124                    throw new NoSuchArticleException(msg.toString());
7125            }
7126    
7127            /**
7128             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
7129             *
7130             * @param groupId the group ID
7131             * @param structureId the structure ID
7132             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7133             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7134             * @throws SystemException if a system exception occurred
7135             */
7136            public JournalArticle fetchByG_S_Last(long groupId, String structureId,
7137                    OrderByComparator orderByComparator) throws SystemException {
7138                    int count = countByG_S(groupId, structureId);
7139    
7140                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
7141                                    count, orderByComparator);
7142    
7143                    if (!list.isEmpty()) {
7144                            return list.get(0);
7145                    }
7146    
7147                    return null;
7148            }
7149    
7150            /**
7151             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
7152             *
7153             * @param id the primary key of the current journal article
7154             * @param groupId the group ID
7155             * @param structureId the structure ID
7156             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7157             * @return the previous, current, and next journal article
7158             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7159             * @throws SystemException if a system exception occurred
7160             */
7161            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
7162                    String structureId, OrderByComparator orderByComparator)
7163                    throws NoSuchArticleException, SystemException {
7164                    JournalArticle journalArticle = findByPrimaryKey(id);
7165    
7166                    Session session = null;
7167    
7168                    try {
7169                            session = openSession();
7170    
7171                            JournalArticle[] array = new JournalArticleImpl[3];
7172    
7173                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
7174                                            structureId, orderByComparator, true);
7175    
7176                            array[1] = journalArticle;
7177    
7178                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
7179                                            structureId, orderByComparator, false);
7180    
7181                            return array;
7182                    }
7183                    catch (Exception e) {
7184                            throw processException(e);
7185                    }
7186                    finally {
7187                            closeSession(session);
7188                    }
7189            }
7190    
7191            protected JournalArticle getByG_S_PrevAndNext(Session session,
7192                    JournalArticle journalArticle, long groupId, String structureId,
7193                    OrderByComparator orderByComparator, boolean previous) {
7194                    StringBundler query = null;
7195    
7196                    if (orderByComparator != null) {
7197                            query = new StringBundler(6 +
7198                                            (orderByComparator.getOrderByFields().length * 6));
7199                    }
7200                    else {
7201                            query = new StringBundler(3);
7202                    }
7203    
7204                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7205    
7206                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7207    
7208                    if (structureId == null) {
7209                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
7210                    }
7211                    else {
7212                            if (structureId.equals(StringPool.BLANK)) {
7213                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
7214                            }
7215                            else {
7216                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
7217                            }
7218                    }
7219    
7220                    if (orderByComparator != null) {
7221                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7222    
7223                            if (orderByConditionFields.length > 0) {
7224                                    query.append(WHERE_AND);
7225                            }
7226    
7227                            for (int i = 0; i < orderByConditionFields.length; i++) {
7228                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7229                                    query.append(orderByConditionFields[i]);
7230    
7231                                    if ((i + 1) < orderByConditionFields.length) {
7232                                            if (orderByComparator.isAscending() ^ previous) {
7233                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7234                                            }
7235                                            else {
7236                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7237                                            }
7238                                    }
7239                                    else {
7240                                            if (orderByComparator.isAscending() ^ previous) {
7241                                                    query.append(WHERE_GREATER_THAN);
7242                                            }
7243                                            else {
7244                                                    query.append(WHERE_LESSER_THAN);
7245                                            }
7246                                    }
7247                            }
7248    
7249                            query.append(ORDER_BY_CLAUSE);
7250    
7251                            String[] orderByFields = orderByComparator.getOrderByFields();
7252    
7253                            for (int i = 0; i < orderByFields.length; i++) {
7254                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7255                                    query.append(orderByFields[i]);
7256    
7257                                    if ((i + 1) < orderByFields.length) {
7258                                            if (orderByComparator.isAscending() ^ previous) {
7259                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7260                                            }
7261                                            else {
7262                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7263                                            }
7264                                    }
7265                                    else {
7266                                            if (orderByComparator.isAscending() ^ previous) {
7267                                                    query.append(ORDER_BY_ASC);
7268                                            }
7269                                            else {
7270                                                    query.append(ORDER_BY_DESC);
7271                                            }
7272                                    }
7273                            }
7274                    }
7275    
7276                    else {
7277                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7278                    }
7279    
7280                    String sql = query.toString();
7281    
7282                    Query q = session.createQuery(sql);
7283    
7284                    q.setFirstResult(0);
7285                    q.setMaxResults(2);
7286    
7287                    QueryPos qPos = QueryPos.getInstance(q);
7288    
7289                    qPos.add(groupId);
7290    
7291                    if (structureId != null) {
7292                            qPos.add(structureId);
7293                    }
7294    
7295                    if (orderByComparator != null) {
7296                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7297    
7298                            for (Object value : values) {
7299                                    qPos.add(value);
7300                            }
7301                    }
7302    
7303                    List<JournalArticle> list = q.list();
7304    
7305                    if (list.size() == 2) {
7306                            return list.get(1);
7307                    }
7308                    else {
7309                            return null;
7310                    }
7311            }
7312    
7313            /**
7314             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
7315             *
7316             * @param groupId the group ID
7317             * @param structureId the structure ID
7318             * @return the matching journal articles that the user has permission to view
7319             * @throws SystemException if a system exception occurred
7320             */
7321            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
7322                    throws SystemException {
7323                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
7324                            QueryUtil.ALL_POS, null);
7325            }
7326    
7327            /**
7328             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
7329             *
7330             * <p>
7331             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7332             * </p>
7333             *
7334             * @param groupId the group ID
7335             * @param structureId the structure ID
7336             * @param start the lower bound of the range of journal articles
7337             * @param end the upper bound of the range of journal articles (not inclusive)
7338             * @return the range of matching journal articles that the user has permission to view
7339             * @throws SystemException if a system exception occurred
7340             */
7341            public List<JournalArticle> filterFindByG_S(long groupId,
7342                    String structureId, int start, int end) throws SystemException {
7343                    return filterFindByG_S(groupId, structureId, start, end, null);
7344            }
7345    
7346            /**
7347             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
7348             *
7349             * <p>
7350             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7351             * </p>
7352             *
7353             * @param groupId the group ID
7354             * @param structureId the structure ID
7355             * @param start the lower bound of the range of journal articles
7356             * @param end the upper bound of the range of journal articles (not inclusive)
7357             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7358             * @return the ordered range of matching journal articles that the user has permission to view
7359             * @throws SystemException if a system exception occurred
7360             */
7361            public List<JournalArticle> filterFindByG_S(long groupId,
7362                    String structureId, int start, int end,
7363                    OrderByComparator orderByComparator) throws SystemException {
7364                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7365                            return findByG_S(groupId, structureId, start, end, orderByComparator);
7366                    }
7367    
7368                    StringBundler query = null;
7369    
7370                    if (orderByComparator != null) {
7371                            query = new StringBundler(4 +
7372                                            (orderByComparator.getOrderByFields().length * 3));
7373                    }
7374                    else {
7375                            query = new StringBundler(4);
7376                    }
7377    
7378                    if (getDB().isSupportsInlineDistinct()) {
7379                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7380                    }
7381                    else {
7382                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7383                    }
7384    
7385                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7386    
7387                    if (structureId == null) {
7388                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
7389                    }
7390                    else {
7391                            if (structureId.equals(StringPool.BLANK)) {
7392                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
7393                            }
7394                            else {
7395                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
7396                            }
7397                    }
7398    
7399                    if (!getDB().isSupportsInlineDistinct()) {
7400                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7401                    }
7402    
7403                    if (orderByComparator != null) {
7404                            if (getDB().isSupportsInlineDistinct()) {
7405                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7406                                            orderByComparator);
7407                            }
7408                            else {
7409                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7410                                            orderByComparator);
7411                            }
7412                    }
7413    
7414                    else {
7415                            if (getDB().isSupportsInlineDistinct()) {
7416                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7417                            }
7418                            else {
7419                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7420                            }
7421                    }
7422    
7423                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7424                                    JournalArticle.class.getName(),
7425                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7426    
7427                    Session session = null;
7428    
7429                    try {
7430                            session = openSession();
7431    
7432                            SQLQuery q = session.createSQLQuery(sql);
7433    
7434                            if (getDB().isSupportsInlineDistinct()) {
7435                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7436                            }
7437                            else {
7438                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7439                            }
7440    
7441                            QueryPos qPos = QueryPos.getInstance(q);
7442    
7443                            qPos.add(groupId);
7444    
7445                            if (structureId != null) {
7446                                    qPos.add(structureId);
7447                            }
7448    
7449                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7450                                    end);
7451                    }
7452                    catch (Exception e) {
7453                            throw processException(e);
7454                    }
7455                    finally {
7456                            closeSession(session);
7457                    }
7458            }
7459    
7460            /**
7461             * 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;.
7462             *
7463             * @param id the primary key of the current journal article
7464             * @param groupId the group ID
7465             * @param structureId the structure ID
7466             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7467             * @return the previous, current, and next journal article
7468             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7469             * @throws SystemException if a system exception occurred
7470             */
7471            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
7472                    String structureId, OrderByComparator orderByComparator)
7473                    throws NoSuchArticleException, SystemException {
7474                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7475                            return findByG_S_PrevAndNext(id, groupId, structureId,
7476                                    orderByComparator);
7477                    }
7478    
7479                    JournalArticle journalArticle = findByPrimaryKey(id);
7480    
7481                    Session session = null;
7482    
7483                    try {
7484                            session = openSession();
7485    
7486                            JournalArticle[] array = new JournalArticleImpl[3];
7487    
7488                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
7489                                            groupId, structureId, orderByComparator, true);
7490    
7491                            array[1] = journalArticle;
7492    
7493                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
7494                                            groupId, structureId, orderByComparator, false);
7495    
7496                            return array;
7497                    }
7498                    catch (Exception e) {
7499                            throw processException(e);
7500                    }
7501                    finally {
7502                            closeSession(session);
7503                    }
7504            }
7505    
7506            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
7507                    JournalArticle journalArticle, long groupId, String structureId,
7508                    OrderByComparator orderByComparator, boolean previous) {
7509                    StringBundler query = null;
7510    
7511                    if (orderByComparator != null) {
7512                            query = new StringBundler(6 +
7513                                            (orderByComparator.getOrderByFields().length * 6));
7514                    }
7515                    else {
7516                            query = new StringBundler(3);
7517                    }
7518    
7519                    if (getDB().isSupportsInlineDistinct()) {
7520                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7521                    }
7522                    else {
7523                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7524                    }
7525    
7526                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7527    
7528                    if (structureId == null) {
7529                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
7530                    }
7531                    else {
7532                            if (structureId.equals(StringPool.BLANK)) {
7533                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
7534                            }
7535                            else {
7536                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
7537                            }
7538                    }
7539    
7540                    if (!getDB().isSupportsInlineDistinct()) {
7541                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7542                    }
7543    
7544                    if (orderByComparator != null) {
7545                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7546    
7547                            if (orderByConditionFields.length > 0) {
7548                                    query.append(WHERE_AND);
7549                            }
7550    
7551                            for (int i = 0; i < orderByConditionFields.length; i++) {
7552                                    if (getDB().isSupportsInlineDistinct()) {
7553                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7554                                    }
7555                                    else {
7556                                            query.append(_ORDER_BY_ENTITY_TABLE);
7557                                    }
7558    
7559                                    query.append(orderByConditionFields[i]);
7560    
7561                                    if ((i + 1) < orderByConditionFields.length) {
7562                                            if (orderByComparator.isAscending() ^ previous) {
7563                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7564                                            }
7565                                            else {
7566                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7567                                            }
7568                                    }
7569                                    else {
7570                                            if (orderByComparator.isAscending() ^ previous) {
7571                                                    query.append(WHERE_GREATER_THAN);
7572                                            }
7573                                            else {
7574                                                    query.append(WHERE_LESSER_THAN);
7575                                            }
7576                                    }
7577                            }
7578    
7579                            query.append(ORDER_BY_CLAUSE);
7580    
7581                            String[] orderByFields = orderByComparator.getOrderByFields();
7582    
7583                            for (int i = 0; i < orderByFields.length; i++) {
7584                                    if (getDB().isSupportsInlineDistinct()) {
7585                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7586                                    }
7587                                    else {
7588                                            query.append(_ORDER_BY_ENTITY_TABLE);
7589                                    }
7590    
7591                                    query.append(orderByFields[i]);
7592    
7593                                    if ((i + 1) < orderByFields.length) {
7594                                            if (orderByComparator.isAscending() ^ previous) {
7595                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7596                                            }
7597                                            else {
7598                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7599                                            }
7600                                    }
7601                                    else {
7602                                            if (orderByComparator.isAscending() ^ previous) {
7603                                                    query.append(ORDER_BY_ASC);
7604                                            }
7605                                            else {
7606                                                    query.append(ORDER_BY_DESC);
7607                                            }
7608                                    }
7609                            }
7610                    }
7611    
7612                    else {
7613                            if (getDB().isSupportsInlineDistinct()) {
7614                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7615                            }
7616                            else {
7617                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7618                            }
7619                    }
7620    
7621                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7622                                    JournalArticle.class.getName(),
7623                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7624    
7625                    SQLQuery q = session.createSQLQuery(sql);
7626    
7627                    q.setFirstResult(0);
7628                    q.setMaxResults(2);
7629    
7630                    if (getDB().isSupportsInlineDistinct()) {
7631                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7632                    }
7633                    else {
7634                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7635                    }
7636    
7637                    QueryPos qPos = QueryPos.getInstance(q);
7638    
7639                    qPos.add(groupId);
7640    
7641                    if (structureId != null) {
7642                            qPos.add(structureId);
7643                    }
7644    
7645                    if (orderByComparator != null) {
7646                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7647    
7648                            for (Object value : values) {
7649                                    qPos.add(value);
7650                            }
7651                    }
7652    
7653                    List<JournalArticle> list = q.list();
7654    
7655                    if (list.size() == 2) {
7656                            return list.get(1);
7657                    }
7658                    else {
7659                            return null;
7660                    }
7661            }
7662    
7663            /**
7664             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
7665             *
7666             * @param groupId the group ID
7667             * @param templateId the template ID
7668             * @return the matching journal articles
7669             * @throws SystemException if a system exception occurred
7670             */
7671            public List<JournalArticle> findByG_T(long groupId, String templateId)
7672                    throws SystemException {
7673                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
7674                            QueryUtil.ALL_POS, null);
7675            }
7676    
7677            /**
7678             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
7679             *
7680             * <p>
7681             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7682             * </p>
7683             *
7684             * @param groupId the group ID
7685             * @param templateId the template ID
7686             * @param start the lower bound of the range of journal articles
7687             * @param end the upper bound of the range of journal articles (not inclusive)
7688             * @return the range of matching journal articles
7689             * @throws SystemException if a system exception occurred
7690             */
7691            public List<JournalArticle> findByG_T(long groupId, String templateId,
7692                    int start, int end) throws SystemException {
7693                    return findByG_T(groupId, templateId, start, end, null);
7694            }
7695    
7696            /**
7697             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
7698             *
7699             * <p>
7700             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7701             * </p>
7702             *
7703             * @param groupId the group ID
7704             * @param templateId the template ID
7705             * @param start the lower bound of the range of journal articles
7706             * @param end the upper bound of the range of journal articles (not inclusive)
7707             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7708             * @return the ordered range of matching journal articles
7709             * @throws SystemException if a system exception occurred
7710             */
7711            public List<JournalArticle> findByG_T(long groupId, String templateId,
7712                    int start, int end, OrderByComparator orderByComparator)
7713                    throws SystemException {
7714                    FinderPath finderPath = null;
7715                    Object[] finderArgs = null;
7716    
7717                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7718                                    (orderByComparator == null)) {
7719                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
7720                            finderArgs = new Object[] { groupId, templateId };
7721                    }
7722                    else {
7723                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
7724                            finderArgs = new Object[] {
7725                                            groupId, templateId,
7726                                            
7727                                            start, end, orderByComparator
7728                                    };
7729                    }
7730    
7731                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7732                                    finderArgs, this);
7733    
7734                    if ((list != null) && !list.isEmpty()) {
7735                            for (JournalArticle journalArticle : list) {
7736                                    if ((groupId != journalArticle.getGroupId()) ||
7737                                                    !Validator.equals(templateId,
7738                                                            journalArticle.getTemplateId())) {
7739                                            list = null;
7740    
7741                                            break;
7742                                    }
7743                            }
7744                    }
7745    
7746                    if (list == null) {
7747                            StringBundler query = null;
7748    
7749                            if (orderByComparator != null) {
7750                                    query = new StringBundler(4 +
7751                                                    (orderByComparator.getOrderByFields().length * 3));
7752                            }
7753                            else {
7754                                    query = new StringBundler(4);
7755                            }
7756    
7757                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7758    
7759                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
7760    
7761                            if (templateId == null) {
7762                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
7763                            }
7764                            else {
7765                                    if (templateId.equals(StringPool.BLANK)) {
7766                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
7767                                    }
7768                                    else {
7769                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
7770                                    }
7771                            }
7772    
7773                            if (orderByComparator != null) {
7774                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7775                                            orderByComparator);
7776                            }
7777    
7778                            else {
7779                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7780                            }
7781    
7782                            String sql = query.toString();
7783    
7784                            Session session = null;
7785    
7786                            try {
7787                                    session = openSession();
7788    
7789                                    Query q = session.createQuery(sql);
7790    
7791                                    QueryPos qPos = QueryPos.getInstance(q);
7792    
7793                                    qPos.add(groupId);
7794    
7795                                    if (templateId != null) {
7796                                            qPos.add(templateId);
7797                                    }
7798    
7799                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
7800                                                    start, end);
7801                            }
7802                            catch (Exception e) {
7803                                    throw processException(e);
7804                            }
7805                            finally {
7806                                    if (list == null) {
7807                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7808                                    }
7809                                    else {
7810                                            cacheResult(list);
7811    
7812                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7813                                    }
7814    
7815                                    closeSession(session);
7816                            }
7817                    }
7818    
7819                    return list;
7820            }
7821    
7822            /**
7823             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
7824             *
7825             * @param groupId the group ID
7826             * @param templateId the template ID
7827             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7828             * @return the first matching journal article
7829             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7830             * @throws SystemException if a system exception occurred
7831             */
7832            public JournalArticle findByG_T_First(long groupId, String templateId,
7833                    OrderByComparator orderByComparator)
7834                    throws NoSuchArticleException, SystemException {
7835                    JournalArticle journalArticle = fetchByG_T_First(groupId, templateId,
7836                                    orderByComparator);
7837    
7838                    if (journalArticle != null) {
7839                            return journalArticle;
7840                    }
7841    
7842                    StringBundler msg = new StringBundler(6);
7843    
7844                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7845    
7846                    msg.append("groupId=");
7847                    msg.append(groupId);
7848    
7849                    msg.append(", templateId=");
7850                    msg.append(templateId);
7851    
7852                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7853    
7854                    throw new NoSuchArticleException(msg.toString());
7855            }
7856    
7857            /**
7858             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
7859             *
7860             * @param groupId the group ID
7861             * @param templateId the template ID
7862             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7863             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
7864             * @throws SystemException if a system exception occurred
7865             */
7866            public JournalArticle fetchByG_T_First(long groupId, String templateId,
7867                    OrderByComparator orderByComparator) throws SystemException {
7868                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
7869                                    orderByComparator);
7870    
7871                    if (!list.isEmpty()) {
7872                            return list.get(0);
7873                    }
7874    
7875                    return null;
7876            }
7877    
7878            /**
7879             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
7880             *
7881             * @param groupId the group ID
7882             * @param templateId the template ID
7883             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7884             * @return the last matching journal article
7885             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7886             * @throws SystemException if a system exception occurred
7887             */
7888            public JournalArticle findByG_T_Last(long groupId, String templateId,
7889                    OrderByComparator orderByComparator)
7890                    throws NoSuchArticleException, SystemException {
7891                    JournalArticle journalArticle = fetchByG_T_Last(groupId, templateId,
7892                                    orderByComparator);
7893    
7894                    if (journalArticle != null) {
7895                            return journalArticle;
7896                    }
7897    
7898                    StringBundler msg = new StringBundler(6);
7899    
7900                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7901    
7902                    msg.append("groupId=");
7903                    msg.append(groupId);
7904    
7905                    msg.append(", templateId=");
7906                    msg.append(templateId);
7907    
7908                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7909    
7910                    throw new NoSuchArticleException(msg.toString());
7911            }
7912    
7913            /**
7914             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
7915             *
7916             * @param groupId the group ID
7917             * @param templateId the template ID
7918             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7919             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
7920             * @throws SystemException if a system exception occurred
7921             */
7922            public JournalArticle fetchByG_T_Last(long groupId, String templateId,
7923                    OrderByComparator orderByComparator) throws SystemException {
7924                    int count = countByG_T(groupId, templateId);
7925    
7926                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
7927                                    count, orderByComparator);
7928    
7929                    if (!list.isEmpty()) {
7930                            return list.get(0);
7931                    }
7932    
7933                    return null;
7934            }
7935    
7936            /**
7937             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
7938             *
7939             * @param id the primary key of the current journal article
7940             * @param groupId the group ID
7941             * @param templateId the template ID
7942             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7943             * @return the previous, current, and next journal article
7944             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7945             * @throws SystemException if a system exception occurred
7946             */
7947            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
7948                    String templateId, OrderByComparator orderByComparator)
7949                    throws NoSuchArticleException, SystemException {
7950                    JournalArticle journalArticle = findByPrimaryKey(id);
7951    
7952                    Session session = null;
7953    
7954                    try {
7955                            session = openSession();
7956    
7957                            JournalArticle[] array = new JournalArticleImpl[3];
7958    
7959                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
7960                                            templateId, orderByComparator, true);
7961    
7962                            array[1] = journalArticle;
7963    
7964                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
7965                                            templateId, orderByComparator, false);
7966    
7967                            return array;
7968                    }
7969                    catch (Exception e) {
7970                            throw processException(e);
7971                    }
7972                    finally {
7973                            closeSession(session);
7974                    }
7975            }
7976    
7977            protected JournalArticle getByG_T_PrevAndNext(Session session,
7978                    JournalArticle journalArticle, long groupId, String templateId,
7979                    OrderByComparator orderByComparator, boolean previous) {
7980                    StringBundler query = null;
7981    
7982                    if (orderByComparator != null) {
7983                            query = new StringBundler(6 +
7984                                            (orderByComparator.getOrderByFields().length * 6));
7985                    }
7986                    else {
7987                            query = new StringBundler(3);
7988                    }
7989    
7990                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7991    
7992                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
7993    
7994                    if (templateId == null) {
7995                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
7996                    }
7997                    else {
7998                            if (templateId.equals(StringPool.BLANK)) {
7999                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
8000                            }
8001                            else {
8002                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
8003                            }
8004                    }
8005    
8006                    if (orderByComparator != null) {
8007                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8008    
8009                            if (orderByConditionFields.length > 0) {
8010                                    query.append(WHERE_AND);
8011                            }
8012    
8013                            for (int i = 0; i < orderByConditionFields.length; i++) {
8014                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8015                                    query.append(orderByConditionFields[i]);
8016    
8017                                    if ((i + 1) < orderByConditionFields.length) {
8018                                            if (orderByComparator.isAscending() ^ previous) {
8019                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8020                                            }
8021                                            else {
8022                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8023                                            }
8024                                    }
8025                                    else {
8026                                            if (orderByComparator.isAscending() ^ previous) {
8027                                                    query.append(WHERE_GREATER_THAN);
8028                                            }
8029                                            else {
8030                                                    query.append(WHERE_LESSER_THAN);
8031                                            }
8032                                    }
8033                            }
8034    
8035                            query.append(ORDER_BY_CLAUSE);
8036    
8037                            String[] orderByFields = orderByComparator.getOrderByFields();
8038    
8039                            for (int i = 0; i < orderByFields.length; i++) {
8040                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8041                                    query.append(orderByFields[i]);
8042    
8043                                    if ((i + 1) < orderByFields.length) {
8044                                            if (orderByComparator.isAscending() ^ previous) {
8045                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8046                                            }
8047                                            else {
8048                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8049                                            }
8050                                    }
8051                                    else {
8052                                            if (orderByComparator.isAscending() ^ previous) {
8053                                                    query.append(ORDER_BY_ASC);
8054                                            }
8055                                            else {
8056                                                    query.append(ORDER_BY_DESC);
8057                                            }
8058                                    }
8059                            }
8060                    }
8061    
8062                    else {
8063                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8064                    }
8065    
8066                    String sql = query.toString();
8067    
8068                    Query q = session.createQuery(sql);
8069    
8070                    q.setFirstResult(0);
8071                    q.setMaxResults(2);
8072    
8073                    QueryPos qPos = QueryPos.getInstance(q);
8074    
8075                    qPos.add(groupId);
8076    
8077                    if (templateId != null) {
8078                            qPos.add(templateId);
8079                    }
8080    
8081                    if (orderByComparator != null) {
8082                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8083    
8084                            for (Object value : values) {
8085                                    qPos.add(value);
8086                            }
8087                    }
8088    
8089                    List<JournalArticle> list = q.list();
8090    
8091                    if (list.size() == 2) {
8092                            return list.get(1);
8093                    }
8094                    else {
8095                            return null;
8096                    }
8097            }
8098    
8099            /**
8100             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
8101             *
8102             * @param groupId the group ID
8103             * @param templateId the template ID
8104             * @return the matching journal articles that the user has permission to view
8105             * @throws SystemException if a system exception occurred
8106             */
8107            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
8108                    throws SystemException {
8109                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
8110                            QueryUtil.ALL_POS, null);
8111            }
8112    
8113            /**
8114             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
8115             *
8116             * <p>
8117             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8118             * </p>
8119             *
8120             * @param groupId the group ID
8121             * @param templateId the template ID
8122             * @param start the lower bound of the range of journal articles
8123             * @param end the upper bound of the range of journal articles (not inclusive)
8124             * @return the range of matching journal articles that the user has permission to view
8125             * @throws SystemException if a system exception occurred
8126             */
8127            public List<JournalArticle> filterFindByG_T(long groupId,
8128                    String templateId, int start, int end) throws SystemException {
8129                    return filterFindByG_T(groupId, templateId, start, end, null);
8130            }
8131    
8132            /**
8133             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
8134             *
8135             * <p>
8136             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8137             * </p>
8138             *
8139             * @param groupId the group ID
8140             * @param templateId the template ID
8141             * @param start the lower bound of the range of journal articles
8142             * @param end the upper bound of the range of journal articles (not inclusive)
8143             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8144             * @return the ordered range of matching journal articles that the user has permission to view
8145             * @throws SystemException if a system exception occurred
8146             */
8147            public List<JournalArticle> filterFindByG_T(long groupId,
8148                    String templateId, int start, int end,
8149                    OrderByComparator orderByComparator) throws SystemException {
8150                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8151                            return findByG_T(groupId, templateId, start, end, orderByComparator);
8152                    }
8153    
8154                    StringBundler query = null;
8155    
8156                    if (orderByComparator != null) {
8157                            query = new StringBundler(4 +
8158                                            (orderByComparator.getOrderByFields().length * 3));
8159                    }
8160                    else {
8161                            query = new StringBundler(4);
8162                    }
8163    
8164                    if (getDB().isSupportsInlineDistinct()) {
8165                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8166                    }
8167                    else {
8168                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8169                    }
8170    
8171                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
8172    
8173                    if (templateId == null) {
8174                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
8175                    }
8176                    else {
8177                            if (templateId.equals(StringPool.BLANK)) {
8178                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
8179                            }
8180                            else {
8181                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
8182                            }
8183                    }
8184    
8185                    if (!getDB().isSupportsInlineDistinct()) {
8186                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8187                    }
8188    
8189                    if (orderByComparator != null) {
8190                            if (getDB().isSupportsInlineDistinct()) {
8191                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8192                                            orderByComparator);
8193                            }
8194                            else {
8195                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8196                                            orderByComparator);
8197                            }
8198                    }
8199    
8200                    else {
8201                            if (getDB().isSupportsInlineDistinct()) {
8202                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8203                            }
8204                            else {
8205                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8206                            }
8207                    }
8208    
8209                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8210                                    JournalArticle.class.getName(),
8211                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8212    
8213                    Session session = null;
8214    
8215                    try {
8216                            session = openSession();
8217    
8218                            SQLQuery q = session.createSQLQuery(sql);
8219    
8220                            if (getDB().isSupportsInlineDistinct()) {
8221                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8222                            }
8223                            else {
8224                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8225                            }
8226    
8227                            QueryPos qPos = QueryPos.getInstance(q);
8228    
8229                            qPos.add(groupId);
8230    
8231                            if (templateId != null) {
8232                                    qPos.add(templateId);
8233                            }
8234    
8235                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8236                                    end);
8237                    }
8238                    catch (Exception e) {
8239                            throw processException(e);
8240                    }
8241                    finally {
8242                            closeSession(session);
8243                    }
8244            }
8245    
8246            /**
8247             * 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;.
8248             *
8249             * @param id the primary key of the current journal article
8250             * @param groupId the group ID
8251             * @param templateId the template ID
8252             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8253             * @return the previous, current, and next journal article
8254             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8255             * @throws SystemException if a system exception occurred
8256             */
8257            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
8258                    String templateId, OrderByComparator orderByComparator)
8259                    throws NoSuchArticleException, SystemException {
8260                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8261                            return findByG_T_PrevAndNext(id, groupId, templateId,
8262                                    orderByComparator);
8263                    }
8264    
8265                    JournalArticle journalArticle = findByPrimaryKey(id);
8266    
8267                    Session session = null;
8268    
8269                    try {
8270                            session = openSession();
8271    
8272                            JournalArticle[] array = new JournalArticleImpl[3];
8273    
8274                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
8275                                            groupId, templateId, orderByComparator, true);
8276    
8277                            array[1] = journalArticle;
8278    
8279                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
8280                                            groupId, templateId, orderByComparator, false);
8281    
8282                            return array;
8283                    }
8284                    catch (Exception e) {
8285                            throw processException(e);
8286                    }
8287                    finally {
8288                            closeSession(session);
8289                    }
8290            }
8291    
8292            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
8293                    JournalArticle journalArticle, long groupId, String templateId,
8294                    OrderByComparator orderByComparator, boolean previous) {
8295                    StringBundler query = null;
8296    
8297                    if (orderByComparator != null) {
8298                            query = new StringBundler(6 +
8299                                            (orderByComparator.getOrderByFields().length * 6));
8300                    }
8301                    else {
8302                            query = new StringBundler(3);
8303                    }
8304    
8305                    if (getDB().isSupportsInlineDistinct()) {
8306                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8307                    }
8308                    else {
8309                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8310                    }
8311    
8312                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
8313    
8314                    if (templateId == null) {
8315                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
8316                    }
8317                    else {
8318                            if (templateId.equals(StringPool.BLANK)) {
8319                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
8320                            }
8321                            else {
8322                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
8323                            }
8324                    }
8325    
8326                    if (!getDB().isSupportsInlineDistinct()) {
8327                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8328                    }
8329    
8330                    if (orderByComparator != null) {
8331                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8332    
8333                            if (orderByConditionFields.length > 0) {
8334                                    query.append(WHERE_AND);
8335                            }
8336    
8337                            for (int i = 0; i < orderByConditionFields.length; i++) {
8338                                    if (getDB().isSupportsInlineDistinct()) {
8339                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8340                                    }
8341                                    else {
8342                                            query.append(_ORDER_BY_ENTITY_TABLE);
8343                                    }
8344    
8345                                    query.append(orderByConditionFields[i]);
8346    
8347                                    if ((i + 1) < orderByConditionFields.length) {
8348                                            if (orderByComparator.isAscending() ^ previous) {
8349                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8350                                            }
8351                                            else {
8352                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8353                                            }
8354                                    }
8355                                    else {
8356                                            if (orderByComparator.isAscending() ^ previous) {
8357                                                    query.append(WHERE_GREATER_THAN);
8358                                            }
8359                                            else {
8360                                                    query.append(WHERE_LESSER_THAN);
8361                                            }
8362                                    }
8363                            }
8364    
8365                            query.append(ORDER_BY_CLAUSE);
8366    
8367                            String[] orderByFields = orderByComparator.getOrderByFields();
8368    
8369                            for (int i = 0; i < orderByFields.length; i++) {
8370                                    if (getDB().isSupportsInlineDistinct()) {
8371                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8372                                    }
8373                                    else {
8374                                            query.append(_ORDER_BY_ENTITY_TABLE);
8375                                    }
8376    
8377                                    query.append(orderByFields[i]);
8378    
8379                                    if ((i + 1) < orderByFields.length) {
8380                                            if (orderByComparator.isAscending() ^ previous) {
8381                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8382                                            }
8383                                            else {
8384                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8385                                            }
8386                                    }
8387                                    else {
8388                                            if (orderByComparator.isAscending() ^ previous) {
8389                                                    query.append(ORDER_BY_ASC);
8390                                            }
8391                                            else {
8392                                                    query.append(ORDER_BY_DESC);
8393                                            }
8394                                    }
8395                            }
8396                    }
8397    
8398                    else {
8399                            if (getDB().isSupportsInlineDistinct()) {
8400                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8401                            }
8402                            else {
8403                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8404                            }
8405                    }
8406    
8407                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8408                                    JournalArticle.class.getName(),
8409                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8410    
8411                    SQLQuery q = session.createSQLQuery(sql);
8412    
8413                    q.setFirstResult(0);
8414                    q.setMaxResults(2);
8415    
8416                    if (getDB().isSupportsInlineDistinct()) {
8417                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8418                    }
8419                    else {
8420                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8421                    }
8422    
8423                    QueryPos qPos = QueryPos.getInstance(q);
8424    
8425                    qPos.add(groupId);
8426    
8427                    if (templateId != null) {
8428                            qPos.add(templateId);
8429                    }
8430    
8431                    if (orderByComparator != null) {
8432                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8433    
8434                            for (Object value : values) {
8435                                    qPos.add(value);
8436                            }
8437                    }
8438    
8439                    List<JournalArticle> list = q.list();
8440    
8441                    if (list.size() == 2) {
8442                            return list.get(1);
8443                    }
8444                    else {
8445                            return null;
8446                    }
8447            }
8448    
8449            /**
8450             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
8451             *
8452             * @param groupId the group ID
8453             * @param layoutUuid the layout uuid
8454             * @return the matching journal articles
8455             * @throws SystemException if a system exception occurred
8456             */
8457            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
8458                    throws SystemException {
8459                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
8460                            QueryUtil.ALL_POS, null);
8461            }
8462    
8463            /**
8464             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
8465             *
8466             * <p>
8467             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8468             * </p>
8469             *
8470             * @param groupId the group ID
8471             * @param layoutUuid the layout uuid
8472             * @param start the lower bound of the range of journal articles
8473             * @param end the upper bound of the range of journal articles (not inclusive)
8474             * @return the range of matching journal articles
8475             * @throws SystemException if a system exception occurred
8476             */
8477            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
8478                    int start, int end) throws SystemException {
8479                    return findByG_L(groupId, layoutUuid, start, end, null);
8480            }
8481    
8482            /**
8483             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
8484             *
8485             * <p>
8486             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8487             * </p>
8488             *
8489             * @param groupId the group ID
8490             * @param layoutUuid the layout uuid
8491             * @param start the lower bound of the range of journal articles
8492             * @param end the upper bound of the range of journal articles (not inclusive)
8493             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8494             * @return the ordered range of matching journal articles
8495             * @throws SystemException if a system exception occurred
8496             */
8497            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
8498                    int start, int end, OrderByComparator orderByComparator)
8499                    throws SystemException {
8500                    FinderPath finderPath = null;
8501                    Object[] finderArgs = null;
8502    
8503                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8504                                    (orderByComparator == null)) {
8505                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
8506                            finderArgs = new Object[] { groupId, layoutUuid };
8507                    }
8508                    else {
8509                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
8510                            finderArgs = new Object[] {
8511                                            groupId, layoutUuid,
8512                                            
8513                                            start, end, orderByComparator
8514                                    };
8515                    }
8516    
8517                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8518                                    finderArgs, this);
8519    
8520                    if ((list != null) && !list.isEmpty()) {
8521                            for (JournalArticle journalArticle : list) {
8522                                    if ((groupId != journalArticle.getGroupId()) ||
8523                                                    !Validator.equals(layoutUuid,
8524                                                            journalArticle.getLayoutUuid())) {
8525                                            list = null;
8526    
8527                                            break;
8528                                    }
8529                            }
8530                    }
8531    
8532                    if (list == null) {
8533                            StringBundler query = null;
8534    
8535                            if (orderByComparator != null) {
8536                                    query = new StringBundler(4 +
8537                                                    (orderByComparator.getOrderByFields().length * 3));
8538                            }
8539                            else {
8540                                    query = new StringBundler(4);
8541                            }
8542    
8543                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8544    
8545                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
8546    
8547                            if (layoutUuid == null) {
8548                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
8549                            }
8550                            else {
8551                                    if (layoutUuid.equals(StringPool.BLANK)) {
8552                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
8553                                    }
8554                                    else {
8555                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
8556                                    }
8557                            }
8558    
8559                            if (orderByComparator != null) {
8560                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8561                                            orderByComparator);
8562                            }
8563    
8564                            else {
8565                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8566                            }
8567    
8568                            String sql = query.toString();
8569    
8570                            Session session = null;
8571    
8572                            try {
8573                                    session = openSession();
8574    
8575                                    Query q = session.createQuery(sql);
8576    
8577                                    QueryPos qPos = QueryPos.getInstance(q);
8578    
8579                                    qPos.add(groupId);
8580    
8581                                    if (layoutUuid != null) {
8582                                            qPos.add(layoutUuid);
8583                                    }
8584    
8585                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
8586                                                    start, end);
8587                            }
8588                            catch (Exception e) {
8589                                    throw processException(e);
8590                            }
8591                            finally {
8592                                    if (list == null) {
8593                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8594                                    }
8595                                    else {
8596                                            cacheResult(list);
8597    
8598                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8599                                    }
8600    
8601                                    closeSession(session);
8602                            }
8603                    }
8604    
8605                    return list;
8606            }
8607    
8608            /**
8609             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
8610             *
8611             * @param groupId the group ID
8612             * @param layoutUuid the layout uuid
8613             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8614             * @return the first matching journal article
8615             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8616             * @throws SystemException if a system exception occurred
8617             */
8618            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
8619                    OrderByComparator orderByComparator)
8620                    throws NoSuchArticleException, SystemException {
8621                    JournalArticle journalArticle = fetchByG_L_First(groupId, layoutUuid,
8622                                    orderByComparator);
8623    
8624                    if (journalArticle != null) {
8625                            return journalArticle;
8626                    }
8627    
8628                    StringBundler msg = new StringBundler(6);
8629    
8630                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8631    
8632                    msg.append("groupId=");
8633                    msg.append(groupId);
8634    
8635                    msg.append(", layoutUuid=");
8636                    msg.append(layoutUuid);
8637    
8638                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8639    
8640                    throw new NoSuchArticleException(msg.toString());
8641            }
8642    
8643            /**
8644             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
8645             *
8646             * @param groupId the group ID
8647             * @param layoutUuid the layout uuid
8648             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8649             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
8650             * @throws SystemException if a system exception occurred
8651             */
8652            public JournalArticle fetchByG_L_First(long groupId, String layoutUuid,
8653                    OrderByComparator orderByComparator) throws SystemException {
8654                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
8655                                    orderByComparator);
8656    
8657                    if (!list.isEmpty()) {
8658                            return list.get(0);
8659                    }
8660    
8661                    return null;
8662            }
8663    
8664            /**
8665             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
8666             *
8667             * @param groupId the group ID
8668             * @param layoutUuid the layout uuid
8669             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8670             * @return the last matching journal article
8671             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8672             * @throws SystemException if a system exception occurred
8673             */
8674            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
8675                    OrderByComparator orderByComparator)
8676                    throws NoSuchArticleException, SystemException {
8677                    JournalArticle journalArticle = fetchByG_L_Last(groupId, layoutUuid,
8678                                    orderByComparator);
8679    
8680                    if (journalArticle != null) {
8681                            return journalArticle;
8682                    }
8683    
8684                    StringBundler msg = new StringBundler(6);
8685    
8686                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8687    
8688                    msg.append("groupId=");
8689                    msg.append(groupId);
8690    
8691                    msg.append(", layoutUuid=");
8692                    msg.append(layoutUuid);
8693    
8694                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8695    
8696                    throw new NoSuchArticleException(msg.toString());
8697            }
8698    
8699            /**
8700             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
8701             *
8702             * @param groupId the group ID
8703             * @param layoutUuid the layout uuid
8704             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8705             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
8706             * @throws SystemException if a system exception occurred
8707             */
8708            public JournalArticle fetchByG_L_Last(long groupId, String layoutUuid,
8709                    OrderByComparator orderByComparator) throws SystemException {
8710                    int count = countByG_L(groupId, layoutUuid);
8711    
8712                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
8713                                    count, orderByComparator);
8714    
8715                    if (!list.isEmpty()) {
8716                            return list.get(0);
8717                    }
8718    
8719                    return null;
8720            }
8721    
8722            /**
8723             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
8724             *
8725             * @param id the primary key of the current journal article
8726             * @param groupId the group ID
8727             * @param layoutUuid the layout uuid
8728             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8729             * @return the previous, current, and next journal article
8730             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8731             * @throws SystemException if a system exception occurred
8732             */
8733            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
8734                    String layoutUuid, OrderByComparator orderByComparator)
8735                    throws NoSuchArticleException, SystemException {
8736                    JournalArticle journalArticle = findByPrimaryKey(id);
8737    
8738                    Session session = null;
8739    
8740                    try {
8741                            session = openSession();
8742    
8743                            JournalArticle[] array = new JournalArticleImpl[3];
8744    
8745                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
8746                                            layoutUuid, orderByComparator, true);
8747    
8748                            array[1] = journalArticle;
8749    
8750                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
8751                                            layoutUuid, orderByComparator, false);
8752    
8753                            return array;
8754                    }
8755                    catch (Exception e) {
8756                            throw processException(e);
8757                    }
8758                    finally {
8759                            closeSession(session);
8760                    }
8761            }
8762    
8763            protected JournalArticle getByG_L_PrevAndNext(Session session,
8764                    JournalArticle journalArticle, long groupId, String layoutUuid,
8765                    OrderByComparator orderByComparator, boolean previous) {
8766                    StringBundler query = null;
8767    
8768                    if (orderByComparator != null) {
8769                            query = new StringBundler(6 +
8770                                            (orderByComparator.getOrderByFields().length * 6));
8771                    }
8772                    else {
8773                            query = new StringBundler(3);
8774                    }
8775    
8776                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8777    
8778                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
8779    
8780                    if (layoutUuid == null) {
8781                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
8782                    }
8783                    else {
8784                            if (layoutUuid.equals(StringPool.BLANK)) {
8785                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
8786                            }
8787                            else {
8788                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
8789                            }
8790                    }
8791    
8792                    if (orderByComparator != null) {
8793                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8794    
8795                            if (orderByConditionFields.length > 0) {
8796                                    query.append(WHERE_AND);
8797                            }
8798    
8799                            for (int i = 0; i < orderByConditionFields.length; i++) {
8800                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8801                                    query.append(orderByConditionFields[i]);
8802    
8803                                    if ((i + 1) < orderByConditionFields.length) {
8804                                            if (orderByComparator.isAscending() ^ previous) {
8805                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8806                                            }
8807                                            else {
8808                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8809                                            }
8810                                    }
8811                                    else {
8812                                            if (orderByComparator.isAscending() ^ previous) {
8813                                                    query.append(WHERE_GREATER_THAN);
8814                                            }
8815                                            else {
8816                                                    query.append(WHERE_LESSER_THAN);
8817                                            }
8818                                    }
8819                            }
8820    
8821                            query.append(ORDER_BY_CLAUSE);
8822    
8823                            String[] orderByFields = orderByComparator.getOrderByFields();
8824    
8825                            for (int i = 0; i < orderByFields.length; i++) {
8826                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8827                                    query.append(orderByFields[i]);
8828    
8829                                    if ((i + 1) < orderByFields.length) {
8830                                            if (orderByComparator.isAscending() ^ previous) {
8831                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8832                                            }
8833                                            else {
8834                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8835                                            }
8836                                    }
8837                                    else {
8838                                            if (orderByComparator.isAscending() ^ previous) {
8839                                                    query.append(ORDER_BY_ASC);
8840                                            }
8841                                            else {
8842                                                    query.append(ORDER_BY_DESC);
8843                                            }
8844                                    }
8845                            }
8846                    }
8847    
8848                    else {
8849                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8850                    }
8851    
8852                    String sql = query.toString();
8853    
8854                    Query q = session.createQuery(sql);
8855    
8856                    q.setFirstResult(0);
8857                    q.setMaxResults(2);
8858    
8859                    QueryPos qPos = QueryPos.getInstance(q);
8860    
8861                    qPos.add(groupId);
8862    
8863                    if (layoutUuid != null) {
8864                            qPos.add(layoutUuid);
8865                    }
8866    
8867                    if (orderByComparator != null) {
8868                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8869    
8870                            for (Object value : values) {
8871                                    qPos.add(value);
8872                            }
8873                    }
8874    
8875                    List<JournalArticle> list = q.list();
8876    
8877                    if (list.size() == 2) {
8878                            return list.get(1);
8879                    }
8880                    else {
8881                            return null;
8882                    }
8883            }
8884    
8885            /**
8886             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
8887             *
8888             * @param groupId the group ID
8889             * @param layoutUuid the layout uuid
8890             * @return the matching journal articles that the user has permission to view
8891             * @throws SystemException if a system exception occurred
8892             */
8893            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
8894                    throws SystemException {
8895                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
8896                            QueryUtil.ALL_POS, null);
8897            }
8898    
8899            /**
8900             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
8901             *
8902             * <p>
8903             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8904             * </p>
8905             *
8906             * @param groupId the group ID
8907             * @param layoutUuid the layout uuid
8908             * @param start the lower bound of the range of journal articles
8909             * @param end the upper bound of the range of journal articles (not inclusive)
8910             * @return the range of matching journal articles that the user has permission to view
8911             * @throws SystemException if a system exception occurred
8912             */
8913            public List<JournalArticle> filterFindByG_L(long groupId,
8914                    String layoutUuid, int start, int end) throws SystemException {
8915                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
8916            }
8917    
8918            /**
8919             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
8920             *
8921             * <p>
8922             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8923             * </p>
8924             *
8925             * @param groupId the group ID
8926             * @param layoutUuid the layout uuid
8927             * @param start the lower bound of the range of journal articles
8928             * @param end the upper bound of the range of journal articles (not inclusive)
8929             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8930             * @return the ordered range of matching journal articles that the user has permission to view
8931             * @throws SystemException if a system exception occurred
8932             */
8933            public List<JournalArticle> filterFindByG_L(long groupId,
8934                    String layoutUuid, int start, int end,
8935                    OrderByComparator orderByComparator) throws SystemException {
8936                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8937                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
8938                    }
8939    
8940                    StringBundler query = null;
8941    
8942                    if (orderByComparator != null) {
8943                            query = new StringBundler(4 +
8944                                            (orderByComparator.getOrderByFields().length * 3));
8945                    }
8946                    else {
8947                            query = new StringBundler(4);
8948                    }
8949    
8950                    if (getDB().isSupportsInlineDistinct()) {
8951                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8952                    }
8953                    else {
8954                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8955                    }
8956    
8957                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
8958    
8959                    if (layoutUuid == null) {
8960                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
8961                    }
8962                    else {
8963                            if (layoutUuid.equals(StringPool.BLANK)) {
8964                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
8965                            }
8966                            else {
8967                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
8968                            }
8969                    }
8970    
8971                    if (!getDB().isSupportsInlineDistinct()) {
8972                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8973                    }
8974    
8975                    if (orderByComparator != null) {
8976                            if (getDB().isSupportsInlineDistinct()) {
8977                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8978                                            orderByComparator);
8979                            }
8980                            else {
8981                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8982                                            orderByComparator);
8983                            }
8984                    }
8985    
8986                    else {
8987                            if (getDB().isSupportsInlineDistinct()) {
8988                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8989                            }
8990                            else {
8991                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8992                            }
8993                    }
8994    
8995                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8996                                    JournalArticle.class.getName(),
8997                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8998    
8999                    Session session = null;
9000    
9001                    try {
9002                            session = openSession();
9003    
9004                            SQLQuery q = session.createSQLQuery(sql);
9005    
9006                            if (getDB().isSupportsInlineDistinct()) {
9007                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9008                            }
9009                            else {
9010                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9011                            }
9012    
9013                            QueryPos qPos = QueryPos.getInstance(q);
9014    
9015                            qPos.add(groupId);
9016    
9017                            if (layoutUuid != null) {
9018                                    qPos.add(layoutUuid);
9019                            }
9020    
9021                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9022                                    end);
9023                    }
9024                    catch (Exception e) {
9025                            throw processException(e);
9026                    }
9027                    finally {
9028                            closeSession(session);
9029                    }
9030            }
9031    
9032            /**
9033             * 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;.
9034             *
9035             * @param id the primary key of the current journal article
9036             * @param groupId the group ID
9037             * @param layoutUuid the layout uuid
9038             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9039             * @return the previous, current, and next journal article
9040             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9041             * @throws SystemException if a system exception occurred
9042             */
9043            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
9044                    String layoutUuid, OrderByComparator orderByComparator)
9045                    throws NoSuchArticleException, SystemException {
9046                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9047                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
9048                                    orderByComparator);
9049                    }
9050    
9051                    JournalArticle journalArticle = findByPrimaryKey(id);
9052    
9053                    Session session = null;
9054    
9055                    try {
9056                            session = openSession();
9057    
9058                            JournalArticle[] array = new JournalArticleImpl[3];
9059    
9060                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
9061                                            groupId, layoutUuid, orderByComparator, true);
9062    
9063                            array[1] = journalArticle;
9064    
9065                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
9066                                            groupId, layoutUuid, orderByComparator, false);
9067    
9068                            return array;
9069                    }
9070                    catch (Exception e) {
9071                            throw processException(e);
9072                    }
9073                    finally {
9074                            closeSession(session);
9075                    }
9076            }
9077    
9078            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
9079                    JournalArticle journalArticle, long groupId, String layoutUuid,
9080                    OrderByComparator orderByComparator, boolean previous) {
9081                    StringBundler query = null;
9082    
9083                    if (orderByComparator != null) {
9084                            query = new StringBundler(6 +
9085                                            (orderByComparator.getOrderByFields().length * 6));
9086                    }
9087                    else {
9088                            query = new StringBundler(3);
9089                    }
9090    
9091                    if (getDB().isSupportsInlineDistinct()) {
9092                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9093                    }
9094                    else {
9095                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9096                    }
9097    
9098                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
9099    
9100                    if (layoutUuid == null) {
9101                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
9102                    }
9103                    else {
9104                            if (layoutUuid.equals(StringPool.BLANK)) {
9105                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
9106                            }
9107                            else {
9108                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
9109                            }
9110                    }
9111    
9112                    if (!getDB().isSupportsInlineDistinct()) {
9113                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9114                    }
9115    
9116                    if (orderByComparator != null) {
9117                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9118    
9119                            if (orderByConditionFields.length > 0) {
9120                                    query.append(WHERE_AND);
9121                            }
9122    
9123                            for (int i = 0; i < orderByConditionFields.length; i++) {
9124                                    if (getDB().isSupportsInlineDistinct()) {
9125                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9126                                    }
9127                                    else {
9128                                            query.append(_ORDER_BY_ENTITY_TABLE);
9129                                    }
9130    
9131                                    query.append(orderByConditionFields[i]);
9132    
9133                                    if ((i + 1) < orderByConditionFields.length) {
9134                                            if (orderByComparator.isAscending() ^ previous) {
9135                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9136                                            }
9137                                            else {
9138                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9139                                            }
9140                                    }
9141                                    else {
9142                                            if (orderByComparator.isAscending() ^ previous) {
9143                                                    query.append(WHERE_GREATER_THAN);
9144                                            }
9145                                            else {
9146                                                    query.append(WHERE_LESSER_THAN);
9147                                            }
9148                                    }
9149                            }
9150    
9151                            query.append(ORDER_BY_CLAUSE);
9152    
9153                            String[] orderByFields = orderByComparator.getOrderByFields();
9154    
9155                            for (int i = 0; i < orderByFields.length; i++) {
9156                                    if (getDB().isSupportsInlineDistinct()) {
9157                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9158                                    }
9159                                    else {
9160                                            query.append(_ORDER_BY_ENTITY_TABLE);
9161                                    }
9162    
9163                                    query.append(orderByFields[i]);
9164    
9165                                    if ((i + 1) < orderByFields.length) {
9166                                            if (orderByComparator.isAscending() ^ previous) {
9167                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9168                                            }
9169                                            else {
9170                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9171                                            }
9172                                    }
9173                                    else {
9174                                            if (orderByComparator.isAscending() ^ previous) {
9175                                                    query.append(ORDER_BY_ASC);
9176                                            }
9177                                            else {
9178                                                    query.append(ORDER_BY_DESC);
9179                                            }
9180                                    }
9181                            }
9182                    }
9183    
9184                    else {
9185                            if (getDB().isSupportsInlineDistinct()) {
9186                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9187                            }
9188                            else {
9189                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9190                            }
9191                    }
9192    
9193                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9194                                    JournalArticle.class.getName(),
9195                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9196    
9197                    SQLQuery q = session.createSQLQuery(sql);
9198    
9199                    q.setFirstResult(0);
9200                    q.setMaxResults(2);
9201    
9202                    if (getDB().isSupportsInlineDistinct()) {
9203                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9204                    }
9205                    else {
9206                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9207                    }
9208    
9209                    QueryPos qPos = QueryPos.getInstance(q);
9210    
9211                    qPos.add(groupId);
9212    
9213                    if (layoutUuid != null) {
9214                            qPos.add(layoutUuid);
9215                    }
9216    
9217                    if (orderByComparator != null) {
9218                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9219    
9220                            for (Object value : values) {
9221                                    qPos.add(value);
9222                            }
9223                    }
9224    
9225                    List<JournalArticle> list = q.list();
9226    
9227                    if (list.size() == 2) {
9228                            return list.get(1);
9229                    }
9230                    else {
9231                            return null;
9232                    }
9233            }
9234    
9235            /**
9236             * Returns all the journal articles where groupId = &#63; and status = &#63;.
9237             *
9238             * @param groupId the group ID
9239             * @param status the status
9240             * @return the matching journal articles
9241             * @throws SystemException if a system exception occurred
9242             */
9243            public List<JournalArticle> findByG_ST(long groupId, int status)
9244                    throws SystemException {
9245                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
9246                            QueryUtil.ALL_POS, null);
9247            }
9248    
9249            /**
9250             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
9251             *
9252             * <p>
9253             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9254             * </p>
9255             *
9256             * @param groupId the group ID
9257             * @param status the status
9258             * @param start the lower bound of the range of journal articles
9259             * @param end the upper bound of the range of journal articles (not inclusive)
9260             * @return the range of matching journal articles
9261             * @throws SystemException if a system exception occurred
9262             */
9263            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
9264                    int end) throws SystemException {
9265                    return findByG_ST(groupId, status, start, end, null);
9266            }
9267    
9268            /**
9269             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
9270             *
9271             * <p>
9272             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9273             * </p>
9274             *
9275             * @param groupId the group ID
9276             * @param status the status
9277             * @param start the lower bound of the range of journal articles
9278             * @param end the upper bound of the range of journal articles (not inclusive)
9279             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9280             * @return the ordered range of matching journal articles
9281             * @throws SystemException if a system exception occurred
9282             */
9283            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
9284                    int end, OrderByComparator orderByComparator) throws SystemException {
9285                    FinderPath finderPath = null;
9286                    Object[] finderArgs = null;
9287    
9288                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9289                                    (orderByComparator == null)) {
9290                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
9291                            finderArgs = new Object[] { groupId, status };
9292                    }
9293                    else {
9294                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
9295                            finderArgs = new Object[] {
9296                                            groupId, status,
9297                                            
9298                                            start, end, orderByComparator
9299                                    };
9300                    }
9301    
9302                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9303                                    finderArgs, this);
9304    
9305                    if ((list != null) && !list.isEmpty()) {
9306                            for (JournalArticle journalArticle : list) {
9307                                    if ((groupId != journalArticle.getGroupId()) ||
9308                                                    (status != journalArticle.getStatus())) {
9309                                            list = null;
9310    
9311                                            break;
9312                                    }
9313                            }
9314                    }
9315    
9316                    if (list == null) {
9317                            StringBundler query = null;
9318    
9319                            if (orderByComparator != null) {
9320                                    query = new StringBundler(4 +
9321                                                    (orderByComparator.getOrderByFields().length * 3));
9322                            }
9323                            else {
9324                                    query = new StringBundler(4);
9325                            }
9326    
9327                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9328    
9329                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
9330    
9331                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
9332    
9333                            if (orderByComparator != null) {
9334                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9335                                            orderByComparator);
9336                            }
9337    
9338                            else {
9339                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9340                            }
9341    
9342                            String sql = query.toString();
9343    
9344                            Session session = null;
9345    
9346                            try {
9347                                    session = openSession();
9348    
9349                                    Query q = session.createQuery(sql);
9350    
9351                                    QueryPos qPos = QueryPos.getInstance(q);
9352    
9353                                    qPos.add(groupId);
9354    
9355                                    qPos.add(status);
9356    
9357                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
9358                                                    start, end);
9359                            }
9360                            catch (Exception e) {
9361                                    throw processException(e);
9362                            }
9363                            finally {
9364                                    if (list == null) {
9365                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9366                                    }
9367                                    else {
9368                                            cacheResult(list);
9369    
9370                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9371                                    }
9372    
9373                                    closeSession(session);
9374                            }
9375                    }
9376    
9377                    return list;
9378            }
9379    
9380            /**
9381             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
9382             *
9383             * @param groupId the group ID
9384             * @param status the status
9385             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9386             * @return the first matching journal article
9387             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9388             * @throws SystemException if a system exception occurred
9389             */
9390            public JournalArticle findByG_ST_First(long groupId, int status,
9391                    OrderByComparator orderByComparator)
9392                    throws NoSuchArticleException, SystemException {
9393                    JournalArticle journalArticle = fetchByG_ST_First(groupId, status,
9394                                    orderByComparator);
9395    
9396                    if (journalArticle != null) {
9397                            return journalArticle;
9398                    }
9399    
9400                    StringBundler msg = new StringBundler(6);
9401    
9402                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9403    
9404                    msg.append("groupId=");
9405                    msg.append(groupId);
9406    
9407                    msg.append(", status=");
9408                    msg.append(status);
9409    
9410                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9411    
9412                    throw new NoSuchArticleException(msg.toString());
9413            }
9414    
9415            /**
9416             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
9417             *
9418             * @param groupId the group ID
9419             * @param status the status
9420             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9421             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
9422             * @throws SystemException if a system exception occurred
9423             */
9424            public JournalArticle fetchByG_ST_First(long groupId, int status,
9425                    OrderByComparator orderByComparator) throws SystemException {
9426                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
9427                                    orderByComparator);
9428    
9429                    if (!list.isEmpty()) {
9430                            return list.get(0);
9431                    }
9432    
9433                    return null;
9434            }
9435    
9436            /**
9437             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
9438             *
9439             * @param groupId the group ID
9440             * @param status the status
9441             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9442             * @return the last matching journal article
9443             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9444             * @throws SystemException if a system exception occurred
9445             */
9446            public JournalArticle findByG_ST_Last(long groupId, int status,
9447                    OrderByComparator orderByComparator)
9448                    throws NoSuchArticleException, SystemException {
9449                    JournalArticle journalArticle = fetchByG_ST_Last(groupId, status,
9450                                    orderByComparator);
9451    
9452                    if (journalArticle != null) {
9453                            return journalArticle;
9454                    }
9455    
9456                    StringBundler msg = new StringBundler(6);
9457    
9458                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9459    
9460                    msg.append("groupId=");
9461                    msg.append(groupId);
9462    
9463                    msg.append(", status=");
9464                    msg.append(status);
9465    
9466                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9467    
9468                    throw new NoSuchArticleException(msg.toString());
9469            }
9470    
9471            /**
9472             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
9473             *
9474             * @param groupId the group ID
9475             * @param status the status
9476             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9477             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
9478             * @throws SystemException if a system exception occurred
9479             */
9480            public JournalArticle fetchByG_ST_Last(long groupId, int status,
9481                    OrderByComparator orderByComparator) throws SystemException {
9482                    int count = countByG_ST(groupId, status);
9483    
9484                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
9485                                    count, orderByComparator);
9486    
9487                    if (!list.isEmpty()) {
9488                            return list.get(0);
9489                    }
9490    
9491                    return null;
9492            }
9493    
9494            /**
9495             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
9496             *
9497             * @param id the primary key of the current journal article
9498             * @param groupId the group ID
9499             * @param status the status
9500             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9501             * @return the previous, current, and next journal article
9502             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9503             * @throws SystemException if a system exception occurred
9504             */
9505            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
9506                    int status, OrderByComparator orderByComparator)
9507                    throws NoSuchArticleException, SystemException {
9508                    JournalArticle journalArticle = findByPrimaryKey(id);
9509    
9510                    Session session = null;
9511    
9512                    try {
9513                            session = openSession();
9514    
9515                            JournalArticle[] array = new JournalArticleImpl[3];
9516    
9517                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
9518                                            status, orderByComparator, true);
9519    
9520                            array[1] = journalArticle;
9521    
9522                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
9523                                            status, orderByComparator, false);
9524    
9525                            return array;
9526                    }
9527                    catch (Exception e) {
9528                            throw processException(e);
9529                    }
9530                    finally {
9531                            closeSession(session);
9532                    }
9533            }
9534    
9535            protected JournalArticle getByG_ST_PrevAndNext(Session session,
9536                    JournalArticle journalArticle, long groupId, int status,
9537                    OrderByComparator orderByComparator, boolean previous) {
9538                    StringBundler query = null;
9539    
9540                    if (orderByComparator != null) {
9541                            query = new StringBundler(6 +
9542                                            (orderByComparator.getOrderByFields().length * 6));
9543                    }
9544                    else {
9545                            query = new StringBundler(3);
9546                    }
9547    
9548                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9549    
9550                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
9551    
9552                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
9553    
9554                    if (orderByComparator != null) {
9555                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9556    
9557                            if (orderByConditionFields.length > 0) {
9558                                    query.append(WHERE_AND);
9559                            }
9560    
9561                            for (int i = 0; i < orderByConditionFields.length; i++) {
9562                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9563                                    query.append(orderByConditionFields[i]);
9564    
9565                                    if ((i + 1) < orderByConditionFields.length) {
9566                                            if (orderByComparator.isAscending() ^ previous) {
9567                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9568                                            }
9569                                            else {
9570                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9571                                            }
9572                                    }
9573                                    else {
9574                                            if (orderByComparator.isAscending() ^ previous) {
9575                                                    query.append(WHERE_GREATER_THAN);
9576                                            }
9577                                            else {
9578                                                    query.append(WHERE_LESSER_THAN);
9579                                            }
9580                                    }
9581                            }
9582    
9583                            query.append(ORDER_BY_CLAUSE);
9584    
9585                            String[] orderByFields = orderByComparator.getOrderByFields();
9586    
9587                            for (int i = 0; i < orderByFields.length; i++) {
9588                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9589                                    query.append(orderByFields[i]);
9590    
9591                                    if ((i + 1) < orderByFields.length) {
9592                                            if (orderByComparator.isAscending() ^ previous) {
9593                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9594                                            }
9595                                            else {
9596                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9597                                            }
9598                                    }
9599                                    else {
9600                                            if (orderByComparator.isAscending() ^ previous) {
9601                                                    query.append(ORDER_BY_ASC);
9602                                            }
9603                                            else {
9604                                                    query.append(ORDER_BY_DESC);
9605                                            }
9606                                    }
9607                            }
9608                    }
9609    
9610                    else {
9611                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9612                    }
9613    
9614                    String sql = query.toString();
9615    
9616                    Query q = session.createQuery(sql);
9617    
9618                    q.setFirstResult(0);
9619                    q.setMaxResults(2);
9620    
9621                    QueryPos qPos = QueryPos.getInstance(q);
9622    
9623                    qPos.add(groupId);
9624    
9625                    qPos.add(status);
9626    
9627                    if (orderByComparator != null) {
9628                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9629    
9630                            for (Object value : values) {
9631                                    qPos.add(value);
9632                            }
9633                    }
9634    
9635                    List<JournalArticle> list = q.list();
9636    
9637                    if (list.size() == 2) {
9638                            return list.get(1);
9639                    }
9640                    else {
9641                            return null;
9642                    }
9643            }
9644    
9645            /**
9646             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
9647             *
9648             * @param groupId the group ID
9649             * @param status the status
9650             * @return the matching journal articles that the user has permission to view
9651             * @throws SystemException if a system exception occurred
9652             */
9653            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
9654                    throws SystemException {
9655                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
9656                            QueryUtil.ALL_POS, null);
9657            }
9658    
9659            /**
9660             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
9661             *
9662             * <p>
9663             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9664             * </p>
9665             *
9666             * @param groupId the group ID
9667             * @param status the status
9668             * @param start the lower bound of the range of journal articles
9669             * @param end the upper bound of the range of journal articles (not inclusive)
9670             * @return the range of matching journal articles that the user has permission to view
9671             * @throws SystemException if a system exception occurred
9672             */
9673            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
9674                    int start, int end) throws SystemException {
9675                    return filterFindByG_ST(groupId, status, start, end, null);
9676            }
9677    
9678            /**
9679             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
9680             *
9681             * <p>
9682             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9683             * </p>
9684             *
9685             * @param groupId the group ID
9686             * @param status the status
9687             * @param start the lower bound of the range of journal articles
9688             * @param end the upper bound of the range of journal articles (not inclusive)
9689             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9690             * @return the ordered range of matching journal articles that the user has permission to view
9691             * @throws SystemException if a system exception occurred
9692             */
9693            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
9694                    int start, int end, OrderByComparator orderByComparator)
9695                    throws SystemException {
9696                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9697                            return findByG_ST(groupId, status, start, end, orderByComparator);
9698                    }
9699    
9700                    StringBundler query = null;
9701    
9702                    if (orderByComparator != null) {
9703                            query = new StringBundler(4 +
9704                                            (orderByComparator.getOrderByFields().length * 3));
9705                    }
9706                    else {
9707                            query = new StringBundler(4);
9708                    }
9709    
9710                    if (getDB().isSupportsInlineDistinct()) {
9711                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9712                    }
9713                    else {
9714                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9715                    }
9716    
9717                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
9718    
9719                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
9720    
9721                    if (!getDB().isSupportsInlineDistinct()) {
9722                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9723                    }
9724    
9725                    if (orderByComparator != null) {
9726                            if (getDB().isSupportsInlineDistinct()) {
9727                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9728                                            orderByComparator);
9729                            }
9730                            else {
9731                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9732                                            orderByComparator);
9733                            }
9734                    }
9735    
9736                    else {
9737                            if (getDB().isSupportsInlineDistinct()) {
9738                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9739                            }
9740                            else {
9741                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9742                            }
9743                    }
9744    
9745                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9746                                    JournalArticle.class.getName(),
9747                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9748    
9749                    Session session = null;
9750    
9751                    try {
9752                            session = openSession();
9753    
9754                            SQLQuery q = session.createSQLQuery(sql);
9755    
9756                            if (getDB().isSupportsInlineDistinct()) {
9757                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9758                            }
9759                            else {
9760                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9761                            }
9762    
9763                            QueryPos qPos = QueryPos.getInstance(q);
9764    
9765                            qPos.add(groupId);
9766    
9767                            qPos.add(status);
9768    
9769                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9770                                    end);
9771                    }
9772                    catch (Exception e) {
9773                            throw processException(e);
9774                    }
9775                    finally {
9776                            closeSession(session);
9777                    }
9778            }
9779    
9780            /**
9781             * 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;.
9782             *
9783             * @param id the primary key of the current journal article
9784             * @param groupId the group ID
9785             * @param status the status
9786             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9787             * @return the previous, current, and next journal article
9788             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9789             * @throws SystemException if a system exception occurred
9790             */
9791            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
9792                    int status, OrderByComparator orderByComparator)
9793                    throws NoSuchArticleException, SystemException {
9794                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9795                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
9796                    }
9797    
9798                    JournalArticle journalArticle = findByPrimaryKey(id);
9799    
9800                    Session session = null;
9801    
9802                    try {
9803                            session = openSession();
9804    
9805                            JournalArticle[] array = new JournalArticleImpl[3];
9806    
9807                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
9808                                            groupId, status, orderByComparator, true);
9809    
9810                            array[1] = journalArticle;
9811    
9812                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
9813                                            groupId, status, orderByComparator, false);
9814    
9815                            return array;
9816                    }
9817                    catch (Exception e) {
9818                            throw processException(e);
9819                    }
9820                    finally {
9821                            closeSession(session);
9822                    }
9823            }
9824    
9825            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
9826                    JournalArticle journalArticle, long groupId, int status,
9827                    OrderByComparator orderByComparator, boolean previous) {
9828                    StringBundler query = null;
9829    
9830                    if (orderByComparator != null) {
9831                            query = new StringBundler(6 +
9832                                            (orderByComparator.getOrderByFields().length * 6));
9833                    }
9834                    else {
9835                            query = new StringBundler(3);
9836                    }
9837    
9838                    if (getDB().isSupportsInlineDistinct()) {
9839                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9840                    }
9841                    else {
9842                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9843                    }
9844    
9845                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
9846    
9847                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
9848    
9849                    if (!getDB().isSupportsInlineDistinct()) {
9850                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9851                    }
9852    
9853                    if (orderByComparator != null) {
9854                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9855    
9856                            if (orderByConditionFields.length > 0) {
9857                                    query.append(WHERE_AND);
9858                            }
9859    
9860                            for (int i = 0; i < orderByConditionFields.length; i++) {
9861                                    if (getDB().isSupportsInlineDistinct()) {
9862                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9863                                    }
9864                                    else {
9865                                            query.append(_ORDER_BY_ENTITY_TABLE);
9866                                    }
9867    
9868                                    query.append(orderByConditionFields[i]);
9869    
9870                                    if ((i + 1) < orderByConditionFields.length) {
9871                                            if (orderByComparator.isAscending() ^ previous) {
9872                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9873                                            }
9874                                            else {
9875                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9876                                            }
9877                                    }
9878                                    else {
9879                                            if (orderByComparator.isAscending() ^ previous) {
9880                                                    query.append(WHERE_GREATER_THAN);
9881                                            }
9882                                            else {
9883                                                    query.append(WHERE_LESSER_THAN);
9884                                            }
9885                                    }
9886                            }
9887    
9888                            query.append(ORDER_BY_CLAUSE);
9889    
9890                            String[] orderByFields = orderByComparator.getOrderByFields();
9891    
9892                            for (int i = 0; i < orderByFields.length; i++) {
9893                                    if (getDB().isSupportsInlineDistinct()) {
9894                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9895                                    }
9896                                    else {
9897                                            query.append(_ORDER_BY_ENTITY_TABLE);
9898                                    }
9899    
9900                                    query.append(orderByFields[i]);
9901    
9902                                    if ((i + 1) < orderByFields.length) {
9903                                            if (orderByComparator.isAscending() ^ previous) {
9904                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9905                                            }
9906                                            else {
9907                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9908                                            }
9909                                    }
9910                                    else {
9911                                            if (orderByComparator.isAscending() ^ previous) {
9912                                                    query.append(ORDER_BY_ASC);
9913                                            }
9914                                            else {
9915                                                    query.append(ORDER_BY_DESC);
9916                                            }
9917                                    }
9918                            }
9919                    }
9920    
9921                    else {
9922                            if (getDB().isSupportsInlineDistinct()) {
9923                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9924                            }
9925                            else {
9926                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9927                            }
9928                    }
9929    
9930                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9931                                    JournalArticle.class.getName(),
9932                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9933    
9934                    SQLQuery q = session.createSQLQuery(sql);
9935    
9936                    q.setFirstResult(0);
9937                    q.setMaxResults(2);
9938    
9939                    if (getDB().isSupportsInlineDistinct()) {
9940                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9941                    }
9942                    else {
9943                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9944                    }
9945    
9946                    QueryPos qPos = QueryPos.getInstance(q);
9947    
9948                    qPos.add(groupId);
9949    
9950                    qPos.add(status);
9951    
9952                    if (orderByComparator != null) {
9953                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9954    
9955                            for (Object value : values) {
9956                                    qPos.add(value);
9957                            }
9958                    }
9959    
9960                    List<JournalArticle> list = q.list();
9961    
9962                    if (list.size() == 2) {
9963                            return list.get(1);
9964                    }
9965                    else {
9966                            return null;
9967                    }
9968            }
9969    
9970            /**
9971             * Returns all the journal articles where companyId = &#63; and version = &#63;.
9972             *
9973             * @param companyId the company ID
9974             * @param version the version
9975             * @return the matching journal articles
9976             * @throws SystemException if a system exception occurred
9977             */
9978            public List<JournalArticle> findByC_V(long companyId, double version)
9979                    throws SystemException {
9980                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
9981                            QueryUtil.ALL_POS, null);
9982            }
9983    
9984            /**
9985             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
9986             *
9987             * <p>
9988             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9989             * </p>
9990             *
9991             * @param companyId the company ID
9992             * @param version the version
9993             * @param start the lower bound of the range of journal articles
9994             * @param end the upper bound of the range of journal articles (not inclusive)
9995             * @return the range of matching journal articles
9996             * @throws SystemException if a system exception occurred
9997             */
9998            public List<JournalArticle> findByC_V(long companyId, double version,
9999                    int start, int end) throws SystemException {
10000                    return findByC_V(companyId, version, start, end, null);
10001            }
10002    
10003            /**
10004             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
10005             *
10006             * <p>
10007             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10008             * </p>
10009             *
10010             * @param companyId the company ID
10011             * @param version the version
10012             * @param start the lower bound of the range of journal articles
10013             * @param end the upper bound of the range of journal articles (not inclusive)
10014             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10015             * @return the ordered range of matching journal articles
10016             * @throws SystemException if a system exception occurred
10017             */
10018            public List<JournalArticle> findByC_V(long companyId, double version,
10019                    int start, int end, OrderByComparator orderByComparator)
10020                    throws SystemException {
10021                    FinderPath finderPath = null;
10022                    Object[] finderArgs = null;
10023    
10024                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10025                                    (orderByComparator == null)) {
10026                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
10027                            finderArgs = new Object[] { companyId, version };
10028                    }
10029                    else {
10030                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
10031                            finderArgs = new Object[] {
10032                                            companyId, version,
10033                                            
10034                                            start, end, orderByComparator
10035                                    };
10036                    }
10037    
10038                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10039                                    finderArgs, this);
10040    
10041                    if ((list != null) && !list.isEmpty()) {
10042                            for (JournalArticle journalArticle : list) {
10043                                    if ((companyId != journalArticle.getCompanyId()) ||
10044                                                    (version != journalArticle.getVersion())) {
10045                                            list = null;
10046    
10047                                            break;
10048                                    }
10049                            }
10050                    }
10051    
10052                    if (list == null) {
10053                            StringBundler query = null;
10054    
10055                            if (orderByComparator != null) {
10056                                    query = new StringBundler(4 +
10057                                                    (orderByComparator.getOrderByFields().length * 3));
10058                            }
10059                            else {
10060                                    query = new StringBundler(4);
10061                            }
10062    
10063                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10064    
10065                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
10066    
10067                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
10068    
10069                            if (orderByComparator != null) {
10070                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10071                                            orderByComparator);
10072                            }
10073    
10074                            else {
10075                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10076                            }
10077    
10078                            String sql = query.toString();
10079    
10080                            Session session = null;
10081    
10082                            try {
10083                                    session = openSession();
10084    
10085                                    Query q = session.createQuery(sql);
10086    
10087                                    QueryPos qPos = QueryPos.getInstance(q);
10088    
10089                                    qPos.add(companyId);
10090    
10091                                    qPos.add(version);
10092    
10093                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
10094                                                    start, end);
10095                            }
10096                            catch (Exception e) {
10097                                    throw processException(e);
10098                            }
10099                            finally {
10100                                    if (list == null) {
10101                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
10102                                    }
10103                                    else {
10104                                            cacheResult(list);
10105    
10106                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
10107                                    }
10108    
10109                                    closeSession(session);
10110                            }
10111                    }
10112    
10113                    return list;
10114            }
10115    
10116            /**
10117             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
10118             *
10119             * @param companyId the company ID
10120             * @param version the version
10121             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10122             * @return the first matching journal article
10123             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10124             * @throws SystemException if a system exception occurred
10125             */
10126            public JournalArticle findByC_V_First(long companyId, double version,
10127                    OrderByComparator orderByComparator)
10128                    throws NoSuchArticleException, SystemException {
10129                    JournalArticle journalArticle = fetchByC_V_First(companyId, version,
10130                                    orderByComparator);
10131    
10132                    if (journalArticle != null) {
10133                            return journalArticle;
10134                    }
10135    
10136                    StringBundler msg = new StringBundler(6);
10137    
10138                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10139    
10140                    msg.append("companyId=");
10141                    msg.append(companyId);
10142    
10143                    msg.append(", version=");
10144                    msg.append(version);
10145    
10146                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10147    
10148                    throw new NoSuchArticleException(msg.toString());
10149            }
10150    
10151            /**
10152             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
10153             *
10154             * @param companyId the company ID
10155             * @param version the version
10156             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10157             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10158             * @throws SystemException if a system exception occurred
10159             */
10160            public JournalArticle fetchByC_V_First(long companyId, double version,
10161                    OrderByComparator orderByComparator) throws SystemException {
10162                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
10163                                    orderByComparator);
10164    
10165                    if (!list.isEmpty()) {
10166                            return list.get(0);
10167                    }
10168    
10169                    return null;
10170            }
10171    
10172            /**
10173             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
10174             *
10175             * @param companyId the company ID
10176             * @param version the version
10177             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10178             * @return the last matching journal article
10179             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10180             * @throws SystemException if a system exception occurred
10181             */
10182            public JournalArticle findByC_V_Last(long companyId, double version,
10183                    OrderByComparator orderByComparator)
10184                    throws NoSuchArticleException, SystemException {
10185                    JournalArticle journalArticle = fetchByC_V_Last(companyId, version,
10186                                    orderByComparator);
10187    
10188                    if (journalArticle != null) {
10189                            return journalArticle;
10190                    }
10191    
10192                    StringBundler msg = new StringBundler(6);
10193    
10194                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10195    
10196                    msg.append("companyId=");
10197                    msg.append(companyId);
10198    
10199                    msg.append(", version=");
10200                    msg.append(version);
10201    
10202                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10203    
10204                    throw new NoSuchArticleException(msg.toString());
10205            }
10206    
10207            /**
10208             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
10209             *
10210             * @param companyId the company ID
10211             * @param version the version
10212             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10213             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10214             * @throws SystemException if a system exception occurred
10215             */
10216            public JournalArticle fetchByC_V_Last(long companyId, double version,
10217                    OrderByComparator orderByComparator) throws SystemException {
10218                    int count = countByC_V(companyId, version);
10219    
10220                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
10221                                    count, orderByComparator);
10222    
10223                    if (!list.isEmpty()) {
10224                            return list.get(0);
10225                    }
10226    
10227                    return null;
10228            }
10229    
10230            /**
10231             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
10232             *
10233             * @param id the primary key of the current journal article
10234             * @param companyId the company ID
10235             * @param version the version
10236             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10237             * @return the previous, current, and next journal article
10238             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10239             * @throws SystemException if a system exception occurred
10240             */
10241            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
10242                    double version, OrderByComparator orderByComparator)
10243                    throws NoSuchArticleException, SystemException {
10244                    JournalArticle journalArticle = findByPrimaryKey(id);
10245    
10246                    Session session = null;
10247    
10248                    try {
10249                            session = openSession();
10250    
10251                            JournalArticle[] array = new JournalArticleImpl[3];
10252    
10253                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
10254                                            version, orderByComparator, true);
10255    
10256                            array[1] = journalArticle;
10257    
10258                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
10259                                            version, orderByComparator, false);
10260    
10261                            return array;
10262                    }
10263                    catch (Exception e) {
10264                            throw processException(e);
10265                    }
10266                    finally {
10267                            closeSession(session);
10268                    }
10269            }
10270    
10271            protected JournalArticle getByC_V_PrevAndNext(Session session,
10272                    JournalArticle journalArticle, long companyId, double version,
10273                    OrderByComparator orderByComparator, boolean previous) {
10274                    StringBundler query = null;
10275    
10276                    if (orderByComparator != null) {
10277                            query = new StringBundler(6 +
10278                                            (orderByComparator.getOrderByFields().length * 6));
10279                    }
10280                    else {
10281                            query = new StringBundler(3);
10282                    }
10283    
10284                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10285    
10286                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
10287    
10288                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
10289    
10290                    if (orderByComparator != null) {
10291                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10292    
10293                            if (orderByConditionFields.length > 0) {
10294                                    query.append(WHERE_AND);
10295                            }
10296    
10297                            for (int i = 0; i < orderByConditionFields.length; i++) {
10298                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10299                                    query.append(orderByConditionFields[i]);
10300    
10301                                    if ((i + 1) < orderByConditionFields.length) {
10302                                            if (orderByComparator.isAscending() ^ previous) {
10303                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10304                                            }
10305                                            else {
10306                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10307                                            }
10308                                    }
10309                                    else {
10310                                            if (orderByComparator.isAscending() ^ previous) {
10311                                                    query.append(WHERE_GREATER_THAN);
10312                                            }
10313                                            else {
10314                                                    query.append(WHERE_LESSER_THAN);
10315                                            }
10316                                    }
10317                            }
10318    
10319                            query.append(ORDER_BY_CLAUSE);
10320    
10321                            String[] orderByFields = orderByComparator.getOrderByFields();
10322    
10323                            for (int i = 0; i < orderByFields.length; i++) {
10324                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10325                                    query.append(orderByFields[i]);
10326    
10327                                    if ((i + 1) < orderByFields.length) {
10328                                            if (orderByComparator.isAscending() ^ previous) {
10329                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10330                                            }
10331                                            else {
10332                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10333                                            }
10334                                    }
10335                                    else {
10336                                            if (orderByComparator.isAscending() ^ previous) {
10337                                                    query.append(ORDER_BY_ASC);
10338                                            }
10339                                            else {
10340                                                    query.append(ORDER_BY_DESC);
10341                                            }
10342                                    }
10343                            }
10344                    }
10345    
10346                    else {
10347                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10348                    }
10349    
10350                    String sql = query.toString();
10351    
10352                    Query q = session.createQuery(sql);
10353    
10354                    q.setFirstResult(0);
10355                    q.setMaxResults(2);
10356    
10357                    QueryPos qPos = QueryPos.getInstance(q);
10358    
10359                    qPos.add(companyId);
10360    
10361                    qPos.add(version);
10362    
10363                    if (orderByComparator != null) {
10364                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10365    
10366                            for (Object value : values) {
10367                                    qPos.add(value);
10368                            }
10369                    }
10370    
10371                    List<JournalArticle> list = q.list();
10372    
10373                    if (list.size() == 2) {
10374                            return list.get(1);
10375                    }
10376                    else {
10377                            return null;
10378                    }
10379            }
10380    
10381            /**
10382             * Returns all the journal articles where companyId = &#63; and status = &#63;.
10383             *
10384             * @param companyId the company ID
10385             * @param status the status
10386             * @return the matching journal articles
10387             * @throws SystemException if a system exception occurred
10388             */
10389            public List<JournalArticle> findByC_ST(long companyId, int status)
10390                    throws SystemException {
10391                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
10392                            QueryUtil.ALL_POS, null);
10393            }
10394    
10395            /**
10396             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
10397             *
10398             * <p>
10399             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10400             * </p>
10401             *
10402             * @param companyId the company ID
10403             * @param status the status
10404             * @param start the lower bound of the range of journal articles
10405             * @param end the upper bound of the range of journal articles (not inclusive)
10406             * @return the range of matching journal articles
10407             * @throws SystemException if a system exception occurred
10408             */
10409            public List<JournalArticle> findByC_ST(long companyId, int status,
10410                    int start, int end) throws SystemException {
10411                    return findByC_ST(companyId, status, start, end, null);
10412            }
10413    
10414            /**
10415             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
10416             *
10417             * <p>
10418             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10419             * </p>
10420             *
10421             * @param companyId the company ID
10422             * @param status the status
10423             * @param start the lower bound of the range of journal articles
10424             * @param end the upper bound of the range of journal articles (not inclusive)
10425             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10426             * @return the ordered range of matching journal articles
10427             * @throws SystemException if a system exception occurred
10428             */
10429            public List<JournalArticle> findByC_ST(long companyId, int status,
10430                    int start, int end, OrderByComparator orderByComparator)
10431                    throws SystemException {
10432                    FinderPath finderPath = null;
10433                    Object[] finderArgs = null;
10434    
10435                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10436                                    (orderByComparator == null)) {
10437                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
10438                            finderArgs = new Object[] { companyId, status };
10439                    }
10440                    else {
10441                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
10442                            finderArgs = new Object[] {
10443                                            companyId, status,
10444                                            
10445                                            start, end, orderByComparator
10446                                    };
10447                    }
10448    
10449                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10450                                    finderArgs, this);
10451    
10452                    if ((list != null) && !list.isEmpty()) {
10453                            for (JournalArticle journalArticle : list) {
10454                                    if ((companyId != journalArticle.getCompanyId()) ||
10455                                                    (status != journalArticle.getStatus())) {
10456                                            list = null;
10457    
10458                                            break;
10459                                    }
10460                            }
10461                    }
10462    
10463                    if (list == null) {
10464                            StringBundler query = null;
10465    
10466                            if (orderByComparator != null) {
10467                                    query = new StringBundler(4 +
10468                                                    (orderByComparator.getOrderByFields().length * 3));
10469                            }
10470                            else {
10471                                    query = new StringBundler(4);
10472                            }
10473    
10474                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10475    
10476                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
10477    
10478                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
10479    
10480                            if (orderByComparator != null) {
10481                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10482                                            orderByComparator);
10483                            }
10484    
10485                            else {
10486                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10487                            }
10488    
10489                            String sql = query.toString();
10490    
10491                            Session session = null;
10492    
10493                            try {
10494                                    session = openSession();
10495    
10496                                    Query q = session.createQuery(sql);
10497    
10498                                    QueryPos qPos = QueryPos.getInstance(q);
10499    
10500                                    qPos.add(companyId);
10501    
10502                                    qPos.add(status);
10503    
10504                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
10505                                                    start, end);
10506                            }
10507                            catch (Exception e) {
10508                                    throw processException(e);
10509                            }
10510                            finally {
10511                                    if (list == null) {
10512                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
10513                                    }
10514                                    else {
10515                                            cacheResult(list);
10516    
10517                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
10518                                    }
10519    
10520                                    closeSession(session);
10521                            }
10522                    }
10523    
10524                    return list;
10525            }
10526    
10527            /**
10528             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
10529             *
10530             * @param companyId the company ID
10531             * @param status the status
10532             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10533             * @return the first matching journal article
10534             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10535             * @throws SystemException if a system exception occurred
10536             */
10537            public JournalArticle findByC_ST_First(long companyId, int status,
10538                    OrderByComparator orderByComparator)
10539                    throws NoSuchArticleException, SystemException {
10540                    JournalArticle journalArticle = fetchByC_ST_First(companyId, status,
10541                                    orderByComparator);
10542    
10543                    if (journalArticle != null) {
10544                            return journalArticle;
10545                    }
10546    
10547                    StringBundler msg = new StringBundler(6);
10548    
10549                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10550    
10551                    msg.append("companyId=");
10552                    msg.append(companyId);
10553    
10554                    msg.append(", status=");
10555                    msg.append(status);
10556    
10557                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10558    
10559                    throw new NoSuchArticleException(msg.toString());
10560            }
10561    
10562            /**
10563             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
10564             *
10565             * @param companyId the company ID
10566             * @param status the status
10567             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10568             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10569             * @throws SystemException if a system exception occurred
10570             */
10571            public JournalArticle fetchByC_ST_First(long companyId, int status,
10572                    OrderByComparator orderByComparator) throws SystemException {
10573                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
10574                                    orderByComparator);
10575    
10576                    if (!list.isEmpty()) {
10577                            return list.get(0);
10578                    }
10579    
10580                    return null;
10581            }
10582    
10583            /**
10584             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
10585             *
10586             * @param companyId the company ID
10587             * @param status the status
10588             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10589             * @return the last matching journal article
10590             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10591             * @throws SystemException if a system exception occurred
10592             */
10593            public JournalArticle findByC_ST_Last(long companyId, int status,
10594                    OrderByComparator orderByComparator)
10595                    throws NoSuchArticleException, SystemException {
10596                    JournalArticle journalArticle = fetchByC_ST_Last(companyId, status,
10597                                    orderByComparator);
10598    
10599                    if (journalArticle != null) {
10600                            return journalArticle;
10601                    }
10602    
10603                    StringBundler msg = new StringBundler(6);
10604    
10605                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10606    
10607                    msg.append("companyId=");
10608                    msg.append(companyId);
10609    
10610                    msg.append(", status=");
10611                    msg.append(status);
10612    
10613                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10614    
10615                    throw new NoSuchArticleException(msg.toString());
10616            }
10617    
10618            /**
10619             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
10620             *
10621             * @param companyId the company ID
10622             * @param status the status
10623             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10624             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
10625             * @throws SystemException if a system exception occurred
10626             */
10627            public JournalArticle fetchByC_ST_Last(long companyId, int status,
10628                    OrderByComparator orderByComparator) throws SystemException {
10629                    int count = countByC_ST(companyId, status);
10630    
10631                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
10632                                    count, orderByComparator);
10633    
10634                    if (!list.isEmpty()) {
10635                            return list.get(0);
10636                    }
10637    
10638                    return null;
10639            }
10640    
10641            /**
10642             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
10643             *
10644             * @param id the primary key of the current journal article
10645             * @param companyId the company ID
10646             * @param status the status
10647             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10648             * @return the previous, current, and next journal article
10649             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10650             * @throws SystemException if a system exception occurred
10651             */
10652            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
10653                    int status, OrderByComparator orderByComparator)
10654                    throws NoSuchArticleException, SystemException {
10655                    JournalArticle journalArticle = findByPrimaryKey(id);
10656    
10657                    Session session = null;
10658    
10659                    try {
10660                            session = openSession();
10661    
10662                            JournalArticle[] array = new JournalArticleImpl[3];
10663    
10664                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
10665                                            companyId, status, orderByComparator, true);
10666    
10667                            array[1] = journalArticle;
10668    
10669                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
10670                                            companyId, status, orderByComparator, false);
10671    
10672                            return array;
10673                    }
10674                    catch (Exception e) {
10675                            throw processException(e);
10676                    }
10677                    finally {
10678                            closeSession(session);
10679                    }
10680            }
10681    
10682            protected JournalArticle getByC_ST_PrevAndNext(Session session,
10683                    JournalArticle journalArticle, long companyId, int status,
10684                    OrderByComparator orderByComparator, boolean previous) {
10685                    StringBundler query = null;
10686    
10687                    if (orderByComparator != null) {
10688                            query = new StringBundler(6 +
10689                                            (orderByComparator.getOrderByFields().length * 6));
10690                    }
10691                    else {
10692                            query = new StringBundler(3);
10693                    }
10694    
10695                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10696    
10697                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
10698    
10699                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
10700    
10701                    if (orderByComparator != null) {
10702                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10703    
10704                            if (orderByConditionFields.length > 0) {
10705                                    query.append(WHERE_AND);
10706                            }
10707    
10708                            for (int i = 0; i < orderByConditionFields.length; i++) {
10709                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10710                                    query.append(orderByConditionFields[i]);
10711    
10712                                    if ((i + 1) < orderByConditionFields.length) {
10713                                            if (orderByComparator.isAscending() ^ previous) {
10714                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10715                                            }
10716                                            else {
10717                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10718                                            }
10719                                    }
10720                                    else {
10721                                            if (orderByComparator.isAscending() ^ previous) {
10722                                                    query.append(WHERE_GREATER_THAN);
10723                                            }
10724                                            else {
10725                                                    query.append(WHERE_LESSER_THAN);
10726                                            }
10727                                    }
10728                            }
10729    
10730                            query.append(ORDER_BY_CLAUSE);
10731    
10732                            String[] orderByFields = orderByComparator.getOrderByFields();
10733    
10734                            for (int i = 0; i < orderByFields.length; i++) {
10735                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10736                                    query.append(orderByFields[i]);
10737    
10738                                    if ((i + 1) < orderByFields.length) {
10739                                            if (orderByComparator.isAscending() ^ previous) {
10740                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10741                                            }
10742                                            else {
10743                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10744                                            }
10745                                    }
10746                                    else {
10747                                            if (orderByComparator.isAscending() ^ previous) {
10748                                                    query.append(ORDER_BY_ASC);
10749                                            }
10750                                            else {
10751                                                    query.append(ORDER_BY_DESC);
10752                                            }
10753                                    }
10754                            }
10755                    }
10756    
10757                    else {
10758                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10759                    }
10760    
10761                    String sql = query.toString();
10762    
10763                    Query q = session.createQuery(sql);
10764    
10765                    q.setFirstResult(0);
10766                    q.setMaxResults(2);
10767    
10768                    QueryPos qPos = QueryPos.getInstance(q);
10769    
10770                    qPos.add(companyId);
10771    
10772                    qPos.add(status);
10773    
10774                    if (orderByComparator != null) {
10775                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10776    
10777                            for (Object value : values) {
10778                                    qPos.add(value);
10779                            }
10780                    }
10781    
10782                    List<JournalArticle> list = q.list();
10783    
10784                    if (list.size() == 2) {
10785                            return list.get(1);
10786                    }
10787                    else {
10788                            return null;
10789                    }
10790            }
10791    
10792            /**
10793             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10794             *
10795             * @param groupId the group ID
10796             * @param classNameId the class name ID
10797             * @param classPK the class p k
10798             * @return the matching journal articles
10799             * @throws SystemException if a system exception occurred
10800             */
10801            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
10802                    long classPK) throws SystemException {
10803                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
10804                            QueryUtil.ALL_POS, null);
10805            }
10806    
10807            /**
10808             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10809             *
10810             * <p>
10811             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10812             * </p>
10813             *
10814             * @param groupId the group ID
10815             * @param classNameId the class name ID
10816             * @param classPK the class p k
10817             * @param start the lower bound of the range of journal articles
10818             * @param end the upper bound of the range of journal articles (not inclusive)
10819             * @return the range of matching journal articles
10820             * @throws SystemException if a system exception occurred
10821             */
10822            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
10823                    long classPK, int start, int end) throws SystemException {
10824                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
10825            }
10826    
10827            /**
10828             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10829             *
10830             * <p>
10831             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10832             * </p>
10833             *
10834             * @param groupId the group ID
10835             * @param classNameId the class name ID
10836             * @param classPK the class p k
10837             * @param start the lower bound of the range of journal articles
10838             * @param end the upper bound of the range of journal articles (not inclusive)
10839             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10840             * @return the ordered range of matching journal articles
10841             * @throws SystemException if a system exception occurred
10842             */
10843            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
10844                    long classPK, int start, int end, OrderByComparator orderByComparator)
10845                    throws SystemException {
10846                    FinderPath finderPath = null;
10847                    Object[] finderArgs = null;
10848    
10849                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10850                                    (orderByComparator == null)) {
10851                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
10852                            finderArgs = new Object[] { groupId, classNameId, classPK };
10853                    }
10854                    else {
10855                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
10856                            finderArgs = new Object[] {
10857                                            groupId, classNameId, classPK,
10858                                            
10859                                            start, end, orderByComparator
10860                                    };
10861                    }
10862    
10863                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10864                                    finderArgs, this);
10865    
10866                    if ((list != null) && !list.isEmpty()) {
10867                            for (JournalArticle journalArticle : list) {
10868                                    if ((groupId != journalArticle.getGroupId()) ||
10869                                                    (classNameId != journalArticle.getClassNameId()) ||
10870                                                    (classPK != journalArticle.getClassPK())) {
10871                                            list = null;
10872    
10873                                            break;
10874                                    }
10875                            }
10876                    }
10877    
10878                    if (list == null) {
10879                            StringBundler query = null;
10880    
10881                            if (orderByComparator != null) {
10882                                    query = new StringBundler(5 +
10883                                                    (orderByComparator.getOrderByFields().length * 3));
10884                            }
10885                            else {
10886                                    query = new StringBundler(5);
10887                            }
10888    
10889                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10890    
10891                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
10892    
10893                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
10894    
10895                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
10896    
10897                            if (orderByComparator != null) {
10898                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10899                                            orderByComparator);
10900                            }
10901    
10902                            else {
10903                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10904                            }
10905    
10906                            String sql = query.toString();
10907    
10908                            Session session = null;
10909    
10910                            try {
10911                                    session = openSession();
10912    
10913                                    Query q = session.createQuery(sql);
10914    
10915                                    QueryPos qPos = QueryPos.getInstance(q);
10916    
10917                                    qPos.add(groupId);
10918    
10919                                    qPos.add(classNameId);
10920    
10921                                    qPos.add(classPK);
10922    
10923                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
10924                                                    start, end);
10925                            }
10926                            catch (Exception e) {
10927                                    throw processException(e);
10928                            }
10929                            finally {
10930                                    if (list == null) {
10931                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
10932                                    }
10933                                    else {
10934                                            cacheResult(list);
10935    
10936                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
10937                                    }
10938    
10939                                    closeSession(session);
10940                            }
10941                    }
10942    
10943                    return list;
10944            }
10945    
10946            /**
10947             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10948             *
10949             * @param groupId the group ID
10950             * @param classNameId the class name ID
10951             * @param classPK the class p k
10952             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10953             * @return the first matching journal article
10954             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10955             * @throws SystemException if a system exception occurred
10956             */
10957            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
10958                    long classPK, OrderByComparator orderByComparator)
10959                    throws NoSuchArticleException, SystemException {
10960                    JournalArticle journalArticle = fetchByG_C_C_First(groupId,
10961                                    classNameId, classPK, orderByComparator);
10962    
10963                    if (journalArticle != null) {
10964                            return journalArticle;
10965                    }
10966    
10967                    StringBundler msg = new StringBundler(8);
10968    
10969                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10970    
10971                    msg.append("groupId=");
10972                    msg.append(groupId);
10973    
10974                    msg.append(", classNameId=");
10975                    msg.append(classNameId);
10976    
10977                    msg.append(", classPK=");
10978                    msg.append(classPK);
10979    
10980                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10981    
10982                    throw new NoSuchArticleException(msg.toString());
10983            }
10984    
10985            /**
10986             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
10987             *
10988             * @param groupId the group ID
10989             * @param classNameId the class name ID
10990             * @param classPK the class p k
10991             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10992             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
10993             * @throws SystemException if a system exception occurred
10994             */
10995            public JournalArticle fetchByG_C_C_First(long groupId, long classNameId,
10996                    long classPK, OrderByComparator orderByComparator)
10997                    throws SystemException {
10998                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
10999                                    0, 1, orderByComparator);
11000    
11001                    if (!list.isEmpty()) {
11002                            return list.get(0);
11003                    }
11004    
11005                    return null;
11006            }
11007    
11008            /**
11009             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
11010             *
11011             * @param groupId the group ID
11012             * @param classNameId the class name ID
11013             * @param classPK the class p k
11014             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11015             * @return the last matching journal article
11016             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11017             * @throws SystemException if a system exception occurred
11018             */
11019            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
11020                    long classPK, OrderByComparator orderByComparator)
11021                    throws NoSuchArticleException, SystemException {
11022                    JournalArticle journalArticle = fetchByG_C_C_Last(groupId, classNameId,
11023                                    classPK, orderByComparator);
11024    
11025                    if (journalArticle != null) {
11026                            return journalArticle;
11027                    }
11028    
11029                    StringBundler msg = new StringBundler(8);
11030    
11031                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11032    
11033                    msg.append("groupId=");
11034                    msg.append(groupId);
11035    
11036                    msg.append(", classNameId=");
11037                    msg.append(classNameId);
11038    
11039                    msg.append(", classPK=");
11040                    msg.append(classPK);
11041    
11042                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11043    
11044                    throw new NoSuchArticleException(msg.toString());
11045            }
11046    
11047            /**
11048             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
11049             *
11050             * @param groupId the group ID
11051             * @param classNameId the class name ID
11052             * @param classPK the class p k
11053             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11054             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
11055             * @throws SystemException if a system exception occurred
11056             */
11057            public JournalArticle fetchByG_C_C_Last(long groupId, long classNameId,
11058                    long classPK, OrderByComparator orderByComparator)
11059                    throws SystemException {
11060                    int count = countByG_C_C(groupId, classNameId, classPK);
11061    
11062                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
11063                                    count - 1, count, orderByComparator);
11064    
11065                    if (!list.isEmpty()) {
11066                            return list.get(0);
11067                    }
11068    
11069                    return null;
11070            }
11071    
11072            /**
11073             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
11074             *
11075             * @param id the primary key of the current journal article
11076             * @param groupId the group ID
11077             * @param classNameId the class name ID
11078             * @param classPK the class p k
11079             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11080             * @return the previous, current, and next journal article
11081             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11082             * @throws SystemException if a system exception occurred
11083             */
11084            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
11085                    long classNameId, long classPK, OrderByComparator orderByComparator)
11086                    throws NoSuchArticleException, SystemException {
11087                    JournalArticle journalArticle = findByPrimaryKey(id);
11088    
11089                    Session session = null;
11090    
11091                    try {
11092                            session = openSession();
11093    
11094                            JournalArticle[] array = new JournalArticleImpl[3];
11095    
11096                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
11097                                            classNameId, classPK, orderByComparator, true);
11098    
11099                            array[1] = journalArticle;
11100    
11101                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
11102                                            classNameId, classPK, orderByComparator, false);
11103    
11104                            return array;
11105                    }
11106                    catch (Exception e) {
11107                            throw processException(e);
11108                    }
11109                    finally {
11110                            closeSession(session);
11111                    }
11112            }
11113    
11114            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
11115                    JournalArticle journalArticle, long groupId, long classNameId,
11116                    long classPK, OrderByComparator orderByComparator, boolean previous) {
11117                    StringBundler query = null;
11118    
11119                    if (orderByComparator != null) {
11120                            query = new StringBundler(6 +
11121                                            (orderByComparator.getOrderByFields().length * 6));
11122                    }
11123                    else {
11124                            query = new StringBundler(3);
11125                    }
11126    
11127                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11128    
11129                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
11130    
11131                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
11132    
11133                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
11134    
11135                    if (orderByComparator != null) {
11136                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11137    
11138                            if (orderByConditionFields.length > 0) {
11139                                    query.append(WHERE_AND);
11140                            }
11141    
11142                            for (int i = 0; i < orderByConditionFields.length; i++) {
11143                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11144                                    query.append(orderByConditionFields[i]);
11145    
11146                                    if ((i + 1) < orderByConditionFields.length) {
11147                                            if (orderByComparator.isAscending() ^ previous) {
11148                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11149                                            }
11150                                            else {
11151                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11152                                            }
11153                                    }
11154                                    else {
11155                                            if (orderByComparator.isAscending() ^ previous) {
11156                                                    query.append(WHERE_GREATER_THAN);
11157                                            }
11158                                            else {
11159                                                    query.append(WHERE_LESSER_THAN);
11160                                            }
11161                                    }
11162                            }
11163    
11164                            query.append(ORDER_BY_CLAUSE);
11165    
11166                            String[] orderByFields = orderByComparator.getOrderByFields();
11167    
11168                            for (int i = 0; i < orderByFields.length; i++) {
11169                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11170                                    query.append(orderByFields[i]);
11171    
11172                                    if ((i + 1) < orderByFields.length) {
11173                                            if (orderByComparator.isAscending() ^ previous) {
11174                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11175                                            }
11176                                            else {
11177                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11178                                            }
11179                                    }
11180                                    else {
11181                                            if (orderByComparator.isAscending() ^ previous) {
11182                                                    query.append(ORDER_BY_ASC);
11183                                            }
11184                                            else {
11185                                                    query.append(ORDER_BY_DESC);
11186                                            }
11187                                    }
11188                            }
11189                    }
11190    
11191                    else {
11192                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11193                    }
11194    
11195                    String sql = query.toString();
11196    
11197                    Query q = session.createQuery(sql);
11198    
11199                    q.setFirstResult(0);
11200                    q.setMaxResults(2);
11201    
11202                    QueryPos qPos = QueryPos.getInstance(q);
11203    
11204                    qPos.add(groupId);
11205    
11206                    qPos.add(classNameId);
11207    
11208                    qPos.add(classPK);
11209    
11210                    if (orderByComparator != null) {
11211                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11212    
11213                            for (Object value : values) {
11214                                    qPos.add(value);
11215                            }
11216                    }
11217    
11218                    List<JournalArticle> list = q.list();
11219    
11220                    if (list.size() == 2) {
11221                            return list.get(1);
11222                    }
11223                    else {
11224                            return null;
11225                    }
11226            }
11227    
11228            /**
11229             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
11230             *
11231             * @param groupId the group ID
11232             * @param classNameId the class name ID
11233             * @param classPK the class p k
11234             * @return the matching journal articles that the user has permission to view
11235             * @throws SystemException if a system exception occurred
11236             */
11237            public List<JournalArticle> filterFindByG_C_C(long groupId,
11238                    long classNameId, long classPK) throws SystemException {
11239                    return filterFindByG_C_C(groupId, classNameId, classPK,
11240                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11241            }
11242    
11243            /**
11244             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
11245             *
11246             * <p>
11247             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11248             * </p>
11249             *
11250             * @param groupId the group ID
11251             * @param classNameId the class name ID
11252             * @param classPK the class p k
11253             * @param start the lower bound of the range of journal articles
11254             * @param end the upper bound of the range of journal articles (not inclusive)
11255             * @return the range of matching journal articles that the user has permission to view
11256             * @throws SystemException if a system exception occurred
11257             */
11258            public List<JournalArticle> filterFindByG_C_C(long groupId,
11259                    long classNameId, long classPK, int start, int end)
11260                    throws SystemException {
11261                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
11262            }
11263    
11264            /**
11265             * 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;.
11266             *
11267             * <p>
11268             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11269             * </p>
11270             *
11271             * @param groupId the group ID
11272             * @param classNameId the class name ID
11273             * @param classPK the class p k
11274             * @param start the lower bound of the range of journal articles
11275             * @param end the upper bound of the range of journal articles (not inclusive)
11276             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11277             * @return the ordered range of matching journal articles that the user has permission to view
11278             * @throws SystemException if a system exception occurred
11279             */
11280            public List<JournalArticle> filterFindByG_C_C(long groupId,
11281                    long classNameId, long classPK, int start, int end,
11282                    OrderByComparator orderByComparator) throws SystemException {
11283                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11284                            return findByG_C_C(groupId, classNameId, classPK, start, end,
11285                                    orderByComparator);
11286                    }
11287    
11288                    StringBundler query = null;
11289    
11290                    if (orderByComparator != null) {
11291                            query = new StringBundler(5 +
11292                                            (orderByComparator.getOrderByFields().length * 3));
11293                    }
11294                    else {
11295                            query = new StringBundler(5);
11296                    }
11297    
11298                    if (getDB().isSupportsInlineDistinct()) {
11299                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11300                    }
11301                    else {
11302                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11303                    }
11304    
11305                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
11306    
11307                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
11308    
11309                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
11310    
11311                    if (!getDB().isSupportsInlineDistinct()) {
11312                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11313                    }
11314    
11315                    if (orderByComparator != null) {
11316                            if (getDB().isSupportsInlineDistinct()) {
11317                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11318                                            orderByComparator);
11319                            }
11320                            else {
11321                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11322                                            orderByComparator);
11323                            }
11324                    }
11325    
11326                    else {
11327                            if (getDB().isSupportsInlineDistinct()) {
11328                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11329                            }
11330                            else {
11331                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11332                            }
11333                    }
11334    
11335                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11336                                    JournalArticle.class.getName(),
11337                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11338    
11339                    Session session = null;
11340    
11341                    try {
11342                            session = openSession();
11343    
11344                            SQLQuery q = session.createSQLQuery(sql);
11345    
11346                            if (getDB().isSupportsInlineDistinct()) {
11347                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11348                            }
11349                            else {
11350                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11351                            }
11352    
11353                            QueryPos qPos = QueryPos.getInstance(q);
11354    
11355                            qPos.add(groupId);
11356    
11357                            qPos.add(classNameId);
11358    
11359                            qPos.add(classPK);
11360    
11361                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11362                                    end);
11363                    }
11364                    catch (Exception e) {
11365                            throw processException(e);
11366                    }
11367                    finally {
11368                            closeSession(session);
11369                    }
11370            }
11371    
11372            /**
11373             * 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;.
11374             *
11375             * @param id the primary key of the current journal article
11376             * @param groupId the group ID
11377             * @param classNameId the class name ID
11378             * @param classPK the class p k
11379             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11380             * @return the previous, current, and next journal article
11381             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11382             * @throws SystemException if a system exception occurred
11383             */
11384            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
11385                    long groupId, long classNameId, long classPK,
11386                    OrderByComparator orderByComparator)
11387                    throws NoSuchArticleException, SystemException {
11388                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11389                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
11390                                    orderByComparator);
11391                    }
11392    
11393                    JournalArticle journalArticle = findByPrimaryKey(id);
11394    
11395                    Session session = null;
11396    
11397                    try {
11398                            session = openSession();
11399    
11400                            JournalArticle[] array = new JournalArticleImpl[3];
11401    
11402                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
11403                                            groupId, classNameId, classPK, orderByComparator, true);
11404    
11405                            array[1] = journalArticle;
11406    
11407                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
11408                                            groupId, classNameId, classPK, orderByComparator, false);
11409    
11410                            return array;
11411                    }
11412                    catch (Exception e) {
11413                            throw processException(e);
11414                    }
11415                    finally {
11416                            closeSession(session);
11417                    }
11418            }
11419    
11420            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
11421                    JournalArticle journalArticle, long groupId, long classNameId,
11422                    long classPK, OrderByComparator orderByComparator, boolean previous) {
11423                    StringBundler query = null;
11424    
11425                    if (orderByComparator != null) {
11426                            query = new StringBundler(6 +
11427                                            (orderByComparator.getOrderByFields().length * 6));
11428                    }
11429                    else {
11430                            query = new StringBundler(3);
11431                    }
11432    
11433                    if (getDB().isSupportsInlineDistinct()) {
11434                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11435                    }
11436                    else {
11437                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11438                    }
11439    
11440                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
11441    
11442                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
11443    
11444                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
11445    
11446                    if (!getDB().isSupportsInlineDistinct()) {
11447                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11448                    }
11449    
11450                    if (orderByComparator != null) {
11451                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11452    
11453                            if (orderByConditionFields.length > 0) {
11454                                    query.append(WHERE_AND);
11455                            }
11456    
11457                            for (int i = 0; i < orderByConditionFields.length; i++) {
11458                                    if (getDB().isSupportsInlineDistinct()) {
11459                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11460                                    }
11461                                    else {
11462                                            query.append(_ORDER_BY_ENTITY_TABLE);
11463                                    }
11464    
11465                                    query.append(orderByConditionFields[i]);
11466    
11467                                    if ((i + 1) < orderByConditionFields.length) {
11468                                            if (orderByComparator.isAscending() ^ previous) {
11469                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11470                                            }
11471                                            else {
11472                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11473                                            }
11474                                    }
11475                                    else {
11476                                            if (orderByComparator.isAscending() ^ previous) {
11477                                                    query.append(WHERE_GREATER_THAN);
11478                                            }
11479                                            else {
11480                                                    query.append(WHERE_LESSER_THAN);
11481                                            }
11482                                    }
11483                            }
11484    
11485                            query.append(ORDER_BY_CLAUSE);
11486    
11487                            String[] orderByFields = orderByComparator.getOrderByFields();
11488    
11489                            for (int i = 0; i < orderByFields.length; i++) {
11490                                    if (getDB().isSupportsInlineDistinct()) {
11491                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11492                                    }
11493                                    else {
11494                                            query.append(_ORDER_BY_ENTITY_TABLE);
11495                                    }
11496    
11497                                    query.append(orderByFields[i]);
11498    
11499                                    if ((i + 1) < orderByFields.length) {
11500                                            if (orderByComparator.isAscending() ^ previous) {
11501                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11502                                            }
11503                                            else {
11504                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11505                                            }
11506                                    }
11507                                    else {
11508                                            if (orderByComparator.isAscending() ^ previous) {
11509                                                    query.append(ORDER_BY_ASC);
11510                                            }
11511                                            else {
11512                                                    query.append(ORDER_BY_DESC);
11513                                            }
11514                                    }
11515                            }
11516                    }
11517    
11518                    else {
11519                            if (getDB().isSupportsInlineDistinct()) {
11520                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11521                            }
11522                            else {
11523                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11524                            }
11525                    }
11526    
11527                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11528                                    JournalArticle.class.getName(),
11529                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11530    
11531                    SQLQuery q = session.createSQLQuery(sql);
11532    
11533                    q.setFirstResult(0);
11534                    q.setMaxResults(2);
11535    
11536                    if (getDB().isSupportsInlineDistinct()) {
11537                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11538                    }
11539                    else {
11540                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11541                    }
11542    
11543                    QueryPos qPos = QueryPos.getInstance(q);
11544    
11545                    qPos.add(groupId);
11546    
11547                    qPos.add(classNameId);
11548    
11549                    qPos.add(classPK);
11550    
11551                    if (orderByComparator != null) {
11552                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11553    
11554                            for (Object value : values) {
11555                                    qPos.add(value);
11556                            }
11557                    }
11558    
11559                    List<JournalArticle> list = q.list();
11560    
11561                    if (list.size() == 2) {
11562                            return list.get(1);
11563                    }
11564                    else {
11565                            return null;
11566                    }
11567            }
11568    
11569            /**
11570             * 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.
11571             *
11572             * @param groupId the group ID
11573             * @param classNameId the class name ID
11574             * @param structureId the structure ID
11575             * @return the matching journal article
11576             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11577             * @throws SystemException if a system exception occurred
11578             */
11579            public JournalArticle findByG_C_S(long groupId, long classNameId,
11580                    String structureId) throws NoSuchArticleException, SystemException {
11581                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
11582                                    structureId);
11583    
11584                    if (journalArticle == null) {
11585                            StringBundler msg = new StringBundler(8);
11586    
11587                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11588    
11589                            msg.append("groupId=");
11590                            msg.append(groupId);
11591    
11592                            msg.append(", classNameId=");
11593                            msg.append(classNameId);
11594    
11595                            msg.append(", structureId=");
11596                            msg.append(structureId);
11597    
11598                            msg.append(StringPool.CLOSE_CURLY_BRACE);
11599    
11600                            if (_log.isWarnEnabled()) {
11601                                    _log.warn(msg.toString());
11602                            }
11603    
11604                            throw new NoSuchArticleException(msg.toString());
11605                    }
11606    
11607                    return journalArticle;
11608            }
11609    
11610            /**
11611             * 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.
11612             *
11613             * @param groupId the group ID
11614             * @param classNameId the class name ID
11615             * @param structureId the structure ID
11616             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
11617             * @throws SystemException if a system exception occurred
11618             */
11619            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
11620                    String structureId) throws SystemException {
11621                    return fetchByG_C_S(groupId, classNameId, structureId, true);
11622            }
11623    
11624            /**
11625             * 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.
11626             *
11627             * @param groupId the group ID
11628             * @param classNameId the class name ID
11629             * @param structureId the structure ID
11630             * @param retrieveFromCache whether to use the finder cache
11631             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
11632             * @throws SystemException if a system exception occurred
11633             */
11634            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
11635                    String structureId, boolean retrieveFromCache)
11636                    throws SystemException {
11637                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
11638    
11639                    Object result = null;
11640    
11641                    if (retrieveFromCache) {
11642                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
11643                                            finderArgs, this);
11644                    }
11645    
11646                    if (result instanceof JournalArticle) {
11647                            JournalArticle journalArticle = (JournalArticle)result;
11648    
11649                            if ((groupId != journalArticle.getGroupId()) ||
11650                                            (classNameId != journalArticle.getClassNameId()) ||
11651                                            !Validator.equals(structureId,
11652                                                    journalArticle.getStructureId())) {
11653                                    result = null;
11654                            }
11655                    }
11656    
11657                    if (result == null) {
11658                            StringBundler query = new StringBundler(5);
11659    
11660                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11661    
11662                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
11663    
11664                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
11665    
11666                            if (structureId == null) {
11667                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
11668                            }
11669                            else {
11670                                    if (structureId.equals(StringPool.BLANK)) {
11671                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
11672                                    }
11673                                    else {
11674                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
11675                                    }
11676                            }
11677    
11678                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11679    
11680                            String sql = query.toString();
11681    
11682                            Session session = null;
11683    
11684                            try {
11685                                    session = openSession();
11686    
11687                                    Query q = session.createQuery(sql);
11688    
11689                                    QueryPos qPos = QueryPos.getInstance(q);
11690    
11691                                    qPos.add(groupId);
11692    
11693                                    qPos.add(classNameId);
11694    
11695                                    if (structureId != null) {
11696                                            qPos.add(structureId);
11697                                    }
11698    
11699                                    List<JournalArticle> list = q.list();
11700    
11701                                    result = list;
11702    
11703                                    JournalArticle journalArticle = null;
11704    
11705                                    if (list.isEmpty()) {
11706                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
11707                                                    finderArgs, list);
11708                                    }
11709                                    else {
11710                                            journalArticle = list.get(0);
11711    
11712                                            cacheResult(journalArticle);
11713    
11714                                            if ((journalArticle.getGroupId() != groupId) ||
11715                                                            (journalArticle.getClassNameId() != classNameId) ||
11716                                                            (journalArticle.getStructureId() == null) ||
11717                                                            !journalArticle.getStructureId().equals(structureId)) {
11718                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
11719                                                            finderArgs, journalArticle);
11720                                            }
11721                                    }
11722    
11723                                    return journalArticle;
11724                            }
11725                            catch (Exception e) {
11726                                    throw processException(e);
11727                            }
11728                            finally {
11729                                    if (result == null) {
11730                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
11731                                                    finderArgs);
11732                                    }
11733    
11734                                    closeSession(session);
11735                            }
11736                    }
11737                    else {
11738                            if (result instanceof List<?>) {
11739                                    return null;
11740                            }
11741                            else {
11742                                    return (JournalArticle)result;
11743                            }
11744                    }
11745            }
11746    
11747            /**
11748             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11749             *
11750             * @param groupId the group ID
11751             * @param classNameId the class name ID
11752             * @param templateId the template ID
11753             * @return the matching journal articles
11754             * @throws SystemException if a system exception occurred
11755             */
11756            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
11757                    String templateId) throws SystemException {
11758                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
11759                            QueryUtil.ALL_POS, null);
11760            }
11761    
11762            /**
11763             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11764             *
11765             * <p>
11766             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11767             * </p>
11768             *
11769             * @param groupId the group ID
11770             * @param classNameId the class name ID
11771             * @param templateId the template ID
11772             * @param start the lower bound of the range of journal articles
11773             * @param end the upper bound of the range of journal articles (not inclusive)
11774             * @return the range of matching journal articles
11775             * @throws SystemException if a system exception occurred
11776             */
11777            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
11778                    String templateId, int start, int end) throws SystemException {
11779                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
11780            }
11781    
11782            /**
11783             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11784             *
11785             * <p>
11786             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11787             * </p>
11788             *
11789             * @param groupId the group ID
11790             * @param classNameId the class name ID
11791             * @param templateId the template ID
11792             * @param start the lower bound of the range of journal articles
11793             * @param end the upper bound of the range of journal articles (not inclusive)
11794             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11795             * @return the ordered range of matching journal articles
11796             * @throws SystemException if a system exception occurred
11797             */
11798            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
11799                    String templateId, int start, int end,
11800                    OrderByComparator orderByComparator) throws SystemException {
11801                    FinderPath finderPath = null;
11802                    Object[] finderArgs = null;
11803    
11804                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11805                                    (orderByComparator == null)) {
11806                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
11807                            finderArgs = new Object[] { groupId, classNameId, templateId };
11808                    }
11809                    else {
11810                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
11811                            finderArgs = new Object[] {
11812                                            groupId, classNameId, templateId,
11813                                            
11814                                            start, end, orderByComparator
11815                                    };
11816                    }
11817    
11818                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11819                                    finderArgs, this);
11820    
11821                    if ((list != null) && !list.isEmpty()) {
11822                            for (JournalArticle journalArticle : list) {
11823                                    if ((groupId != journalArticle.getGroupId()) ||
11824                                                    (classNameId != journalArticle.getClassNameId()) ||
11825                                                    !Validator.equals(templateId,
11826                                                            journalArticle.getTemplateId())) {
11827                                            list = null;
11828    
11829                                            break;
11830                                    }
11831                            }
11832                    }
11833    
11834                    if (list == null) {
11835                            StringBundler query = null;
11836    
11837                            if (orderByComparator != null) {
11838                                    query = new StringBundler(5 +
11839                                                    (orderByComparator.getOrderByFields().length * 3));
11840                            }
11841                            else {
11842                                    query = new StringBundler(5);
11843                            }
11844    
11845                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11846    
11847                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
11848    
11849                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
11850    
11851                            if (templateId == null) {
11852                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
11853                            }
11854                            else {
11855                                    if (templateId.equals(StringPool.BLANK)) {
11856                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
11857                                    }
11858                                    else {
11859                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
11860                                    }
11861                            }
11862    
11863                            if (orderByComparator != null) {
11864                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11865                                            orderByComparator);
11866                            }
11867    
11868                            else {
11869                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11870                            }
11871    
11872                            String sql = query.toString();
11873    
11874                            Session session = null;
11875    
11876                            try {
11877                                    session = openSession();
11878    
11879                                    Query q = session.createQuery(sql);
11880    
11881                                    QueryPos qPos = QueryPos.getInstance(q);
11882    
11883                                    qPos.add(groupId);
11884    
11885                                    qPos.add(classNameId);
11886    
11887                                    if (templateId != null) {
11888                                            qPos.add(templateId);
11889                                    }
11890    
11891                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
11892                                                    start, end);
11893                            }
11894                            catch (Exception e) {
11895                                    throw processException(e);
11896                            }
11897                            finally {
11898                                    if (list == null) {
11899                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
11900                                    }
11901                                    else {
11902                                            cacheResult(list);
11903    
11904                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
11905                                    }
11906    
11907                                    closeSession(session);
11908                            }
11909                    }
11910    
11911                    return list;
11912            }
11913    
11914            /**
11915             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11916             *
11917             * @param groupId the group ID
11918             * @param classNameId the class name ID
11919             * @param templateId the template ID
11920             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11921             * @return the first matching journal article
11922             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11923             * @throws SystemException if a system exception occurred
11924             */
11925            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
11926                    String templateId, OrderByComparator orderByComparator)
11927                    throws NoSuchArticleException, SystemException {
11928                    JournalArticle journalArticle = fetchByG_C_T_First(groupId,
11929                                    classNameId, templateId, orderByComparator);
11930    
11931                    if (journalArticle != null) {
11932                            return journalArticle;
11933                    }
11934    
11935                    StringBundler msg = new StringBundler(8);
11936    
11937                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11938    
11939                    msg.append("groupId=");
11940                    msg.append(groupId);
11941    
11942                    msg.append(", classNameId=");
11943                    msg.append(classNameId);
11944    
11945                    msg.append(", templateId=");
11946                    msg.append(templateId);
11947    
11948                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11949    
11950                    throw new NoSuchArticleException(msg.toString());
11951            }
11952    
11953            /**
11954             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11955             *
11956             * @param groupId the group ID
11957             * @param classNameId the class name ID
11958             * @param templateId the template ID
11959             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11960             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
11961             * @throws SystemException if a system exception occurred
11962             */
11963            public JournalArticle fetchByG_C_T_First(long groupId, long classNameId,
11964                    String templateId, OrderByComparator orderByComparator)
11965                    throws SystemException {
11966                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
11967                                    templateId, 0, 1, orderByComparator);
11968    
11969                    if (!list.isEmpty()) {
11970                            return list.get(0);
11971                    }
11972    
11973                    return null;
11974            }
11975    
11976            /**
11977             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
11978             *
11979             * @param groupId the group ID
11980             * @param classNameId the class name ID
11981             * @param templateId the template ID
11982             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11983             * @return the last matching journal article
11984             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11985             * @throws SystemException if a system exception occurred
11986             */
11987            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
11988                    String templateId, OrderByComparator orderByComparator)
11989                    throws NoSuchArticleException, SystemException {
11990                    JournalArticle journalArticle = fetchByG_C_T_Last(groupId, classNameId,
11991                                    templateId, orderByComparator);
11992    
11993                    if (journalArticle != null) {
11994                            return journalArticle;
11995                    }
11996    
11997                    StringBundler msg = new StringBundler(8);
11998    
11999                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12000    
12001                    msg.append("groupId=");
12002                    msg.append(groupId);
12003    
12004                    msg.append(", classNameId=");
12005                    msg.append(classNameId);
12006    
12007                    msg.append(", templateId=");
12008                    msg.append(templateId);
12009    
12010                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12011    
12012                    throw new NoSuchArticleException(msg.toString());
12013            }
12014    
12015            /**
12016             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
12017             *
12018             * @param groupId the group ID
12019             * @param classNameId the class name ID
12020             * @param templateId the template ID
12021             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12022             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12023             * @throws SystemException if a system exception occurred
12024             */
12025            public JournalArticle fetchByG_C_T_Last(long groupId, long classNameId,
12026                    String templateId, OrderByComparator orderByComparator)
12027                    throws SystemException {
12028                    int count = countByG_C_T(groupId, classNameId, templateId);
12029    
12030                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
12031                                    templateId, count - 1, count, orderByComparator);
12032    
12033                    if (!list.isEmpty()) {
12034                            return list.get(0);
12035                    }
12036    
12037                    return null;
12038            }
12039    
12040            /**
12041             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
12042             *
12043             * @param id the primary key of the current journal article
12044             * @param groupId the group ID
12045             * @param classNameId the class name ID
12046             * @param templateId the template ID
12047             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12048             * @return the previous, current, and next journal article
12049             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12050             * @throws SystemException if a system exception occurred
12051             */
12052            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
12053                    long classNameId, String templateId, OrderByComparator orderByComparator)
12054                    throws NoSuchArticleException, SystemException {
12055                    JournalArticle journalArticle = findByPrimaryKey(id);
12056    
12057                    Session session = null;
12058    
12059                    try {
12060                            session = openSession();
12061    
12062                            JournalArticle[] array = new JournalArticleImpl[3];
12063    
12064                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
12065                                            classNameId, templateId, orderByComparator, true);
12066    
12067                            array[1] = journalArticle;
12068    
12069                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
12070                                            classNameId, templateId, orderByComparator, false);
12071    
12072                            return array;
12073                    }
12074                    catch (Exception e) {
12075                            throw processException(e);
12076                    }
12077                    finally {
12078                            closeSession(session);
12079                    }
12080            }
12081    
12082            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
12083                    JournalArticle journalArticle, long groupId, long classNameId,
12084                    String templateId, OrderByComparator orderByComparator, boolean previous) {
12085                    StringBundler query = null;
12086    
12087                    if (orderByComparator != null) {
12088                            query = new StringBundler(6 +
12089                                            (orderByComparator.getOrderByFields().length * 6));
12090                    }
12091                    else {
12092                            query = new StringBundler(3);
12093                    }
12094    
12095                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12096    
12097                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
12098    
12099                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
12100    
12101                    if (templateId == null) {
12102                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
12103                    }
12104                    else {
12105                            if (templateId.equals(StringPool.BLANK)) {
12106                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
12107                            }
12108                            else {
12109                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
12110                            }
12111                    }
12112    
12113                    if (orderByComparator != null) {
12114                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12115    
12116                            if (orderByConditionFields.length > 0) {
12117                                    query.append(WHERE_AND);
12118                            }
12119    
12120                            for (int i = 0; i < orderByConditionFields.length; i++) {
12121                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12122                                    query.append(orderByConditionFields[i]);
12123    
12124                                    if ((i + 1) < orderByConditionFields.length) {
12125                                            if (orderByComparator.isAscending() ^ previous) {
12126                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12127                                            }
12128                                            else {
12129                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12130                                            }
12131                                    }
12132                                    else {
12133                                            if (orderByComparator.isAscending() ^ previous) {
12134                                                    query.append(WHERE_GREATER_THAN);
12135                                            }
12136                                            else {
12137                                                    query.append(WHERE_LESSER_THAN);
12138                                            }
12139                                    }
12140                            }
12141    
12142                            query.append(ORDER_BY_CLAUSE);
12143    
12144                            String[] orderByFields = orderByComparator.getOrderByFields();
12145    
12146                            for (int i = 0; i < orderByFields.length; i++) {
12147                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12148                                    query.append(orderByFields[i]);
12149    
12150                                    if ((i + 1) < orderByFields.length) {
12151                                            if (orderByComparator.isAscending() ^ previous) {
12152                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12153                                            }
12154                                            else {
12155                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12156                                            }
12157                                    }
12158                                    else {
12159                                            if (orderByComparator.isAscending() ^ previous) {
12160                                                    query.append(ORDER_BY_ASC);
12161                                            }
12162                                            else {
12163                                                    query.append(ORDER_BY_DESC);
12164                                            }
12165                                    }
12166                            }
12167                    }
12168    
12169                    else {
12170                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12171                    }
12172    
12173                    String sql = query.toString();
12174    
12175                    Query q = session.createQuery(sql);
12176    
12177                    q.setFirstResult(0);
12178                    q.setMaxResults(2);
12179    
12180                    QueryPos qPos = QueryPos.getInstance(q);
12181    
12182                    qPos.add(groupId);
12183    
12184                    qPos.add(classNameId);
12185    
12186                    if (templateId != null) {
12187                            qPos.add(templateId);
12188                    }
12189    
12190                    if (orderByComparator != null) {
12191                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12192    
12193                            for (Object value : values) {
12194                                    qPos.add(value);
12195                            }
12196                    }
12197    
12198                    List<JournalArticle> list = q.list();
12199    
12200                    if (list.size() == 2) {
12201                            return list.get(1);
12202                    }
12203                    else {
12204                            return null;
12205                    }
12206            }
12207    
12208            /**
12209             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
12210             *
12211             * @param groupId the group ID
12212             * @param classNameId the class name ID
12213             * @param templateId the template ID
12214             * @return the matching journal articles that the user has permission to view
12215             * @throws SystemException if a system exception occurred
12216             */
12217            public List<JournalArticle> filterFindByG_C_T(long groupId,
12218                    long classNameId, String templateId) throws SystemException {
12219                    return filterFindByG_C_T(groupId, classNameId, templateId,
12220                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12221            }
12222    
12223            /**
12224             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
12225             *
12226             * <p>
12227             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12228             * </p>
12229             *
12230             * @param groupId the group ID
12231             * @param classNameId the class name ID
12232             * @param templateId the template ID
12233             * @param start the lower bound of the range of journal articles
12234             * @param end the upper bound of the range of journal articles (not inclusive)
12235             * @return the range of matching journal articles that the user has permission to view
12236             * @throws SystemException if a system exception occurred
12237             */
12238            public List<JournalArticle> filterFindByG_C_T(long groupId,
12239                    long classNameId, String templateId, int start, int end)
12240                    throws SystemException {
12241                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
12242                            null);
12243            }
12244    
12245            /**
12246             * 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;.
12247             *
12248             * <p>
12249             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12250             * </p>
12251             *
12252             * @param groupId the group ID
12253             * @param classNameId the class name ID
12254             * @param templateId the template ID
12255             * @param start the lower bound of the range of journal articles
12256             * @param end the upper bound of the range of journal articles (not inclusive)
12257             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12258             * @return the ordered range of matching journal articles that the user has permission to view
12259             * @throws SystemException if a system exception occurred
12260             */
12261            public List<JournalArticle> filterFindByG_C_T(long groupId,
12262                    long classNameId, String templateId, int start, int end,
12263                    OrderByComparator orderByComparator) throws SystemException {
12264                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12265                            return findByG_C_T(groupId, classNameId, templateId, start, end,
12266                                    orderByComparator);
12267                    }
12268    
12269                    StringBundler query = null;
12270    
12271                    if (orderByComparator != null) {
12272                            query = new StringBundler(5 +
12273                                            (orderByComparator.getOrderByFields().length * 3));
12274                    }
12275                    else {
12276                            query = new StringBundler(5);
12277                    }
12278    
12279                    if (getDB().isSupportsInlineDistinct()) {
12280                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12281                    }
12282                    else {
12283                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12284                    }
12285    
12286                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
12287    
12288                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
12289    
12290                    if (templateId == null) {
12291                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
12292                    }
12293                    else {
12294                            if (templateId.equals(StringPool.BLANK)) {
12295                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
12296                            }
12297                            else {
12298                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
12299                            }
12300                    }
12301    
12302                    if (!getDB().isSupportsInlineDistinct()) {
12303                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12304                    }
12305    
12306                    if (orderByComparator != null) {
12307                            if (getDB().isSupportsInlineDistinct()) {
12308                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12309                                            orderByComparator);
12310                            }
12311                            else {
12312                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12313                                            orderByComparator);
12314                            }
12315                    }
12316    
12317                    else {
12318                            if (getDB().isSupportsInlineDistinct()) {
12319                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12320                            }
12321                            else {
12322                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12323                            }
12324                    }
12325    
12326                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12327                                    JournalArticle.class.getName(),
12328                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12329    
12330                    Session session = null;
12331    
12332                    try {
12333                            session = openSession();
12334    
12335                            SQLQuery q = session.createSQLQuery(sql);
12336    
12337                            if (getDB().isSupportsInlineDistinct()) {
12338                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12339                            }
12340                            else {
12341                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12342                            }
12343    
12344                            QueryPos qPos = QueryPos.getInstance(q);
12345    
12346                            qPos.add(groupId);
12347    
12348                            qPos.add(classNameId);
12349    
12350                            if (templateId != null) {
12351                                    qPos.add(templateId);
12352                            }
12353    
12354                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12355                                    end);
12356                    }
12357                    catch (Exception e) {
12358                            throw processException(e);
12359                    }
12360                    finally {
12361                            closeSession(session);
12362                    }
12363            }
12364    
12365            /**
12366             * 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;.
12367             *
12368             * @param id the primary key of the current journal article
12369             * @param groupId the group ID
12370             * @param classNameId the class name ID
12371             * @param templateId the template ID
12372             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12373             * @return the previous, current, and next journal article
12374             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12375             * @throws SystemException if a system exception occurred
12376             */
12377            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
12378                    long groupId, long classNameId, String templateId,
12379                    OrderByComparator orderByComparator)
12380                    throws NoSuchArticleException, SystemException {
12381                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12382                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
12383                                    templateId, orderByComparator);
12384                    }
12385    
12386                    JournalArticle journalArticle = findByPrimaryKey(id);
12387    
12388                    Session session = null;
12389    
12390                    try {
12391                            session = openSession();
12392    
12393                            JournalArticle[] array = new JournalArticleImpl[3];
12394    
12395                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
12396                                            groupId, classNameId, templateId, orderByComparator, true);
12397    
12398                            array[1] = journalArticle;
12399    
12400                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
12401                                            groupId, classNameId, templateId, orderByComparator, false);
12402    
12403                            return array;
12404                    }
12405                    catch (Exception e) {
12406                            throw processException(e);
12407                    }
12408                    finally {
12409                            closeSession(session);
12410                    }
12411            }
12412    
12413            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
12414                    JournalArticle journalArticle, long groupId, long classNameId,
12415                    String templateId, OrderByComparator orderByComparator, boolean previous) {
12416                    StringBundler query = null;
12417    
12418                    if (orderByComparator != null) {
12419                            query = new StringBundler(6 +
12420                                            (orderByComparator.getOrderByFields().length * 6));
12421                    }
12422                    else {
12423                            query = new StringBundler(3);
12424                    }
12425    
12426                    if (getDB().isSupportsInlineDistinct()) {
12427                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12428                    }
12429                    else {
12430                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12431                    }
12432    
12433                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
12434    
12435                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
12436    
12437                    if (templateId == null) {
12438                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
12439                    }
12440                    else {
12441                            if (templateId.equals(StringPool.BLANK)) {
12442                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
12443                            }
12444                            else {
12445                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
12446                            }
12447                    }
12448    
12449                    if (!getDB().isSupportsInlineDistinct()) {
12450                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12451                    }
12452    
12453                    if (orderByComparator != null) {
12454                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12455    
12456                            if (orderByConditionFields.length > 0) {
12457                                    query.append(WHERE_AND);
12458                            }
12459    
12460                            for (int i = 0; i < orderByConditionFields.length; i++) {
12461                                    if (getDB().isSupportsInlineDistinct()) {
12462                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12463                                    }
12464                                    else {
12465                                            query.append(_ORDER_BY_ENTITY_TABLE);
12466                                    }
12467    
12468                                    query.append(orderByConditionFields[i]);
12469    
12470                                    if ((i + 1) < orderByConditionFields.length) {
12471                                            if (orderByComparator.isAscending() ^ previous) {
12472                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12473                                            }
12474                                            else {
12475                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12476                                            }
12477                                    }
12478                                    else {
12479                                            if (orderByComparator.isAscending() ^ previous) {
12480                                                    query.append(WHERE_GREATER_THAN);
12481                                            }
12482                                            else {
12483                                                    query.append(WHERE_LESSER_THAN);
12484                                            }
12485                                    }
12486                            }
12487    
12488                            query.append(ORDER_BY_CLAUSE);
12489    
12490                            String[] orderByFields = orderByComparator.getOrderByFields();
12491    
12492                            for (int i = 0; i < orderByFields.length; i++) {
12493                                    if (getDB().isSupportsInlineDistinct()) {
12494                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12495                                    }
12496                                    else {
12497                                            query.append(_ORDER_BY_ENTITY_TABLE);
12498                                    }
12499    
12500                                    query.append(orderByFields[i]);
12501    
12502                                    if ((i + 1) < orderByFields.length) {
12503                                            if (orderByComparator.isAscending() ^ previous) {
12504                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12505                                            }
12506                                            else {
12507                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12508                                            }
12509                                    }
12510                                    else {
12511                                            if (orderByComparator.isAscending() ^ previous) {
12512                                                    query.append(ORDER_BY_ASC);
12513                                            }
12514                                            else {
12515                                                    query.append(ORDER_BY_DESC);
12516                                            }
12517                                    }
12518                            }
12519                    }
12520    
12521                    else {
12522                            if (getDB().isSupportsInlineDistinct()) {
12523                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12524                            }
12525                            else {
12526                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12527                            }
12528                    }
12529    
12530                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12531                                    JournalArticle.class.getName(),
12532                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12533    
12534                    SQLQuery q = session.createSQLQuery(sql);
12535    
12536                    q.setFirstResult(0);
12537                    q.setMaxResults(2);
12538    
12539                    if (getDB().isSupportsInlineDistinct()) {
12540                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12541                    }
12542                    else {
12543                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12544                    }
12545    
12546                    QueryPos qPos = QueryPos.getInstance(q);
12547    
12548                    qPos.add(groupId);
12549    
12550                    qPos.add(classNameId);
12551    
12552                    if (templateId != null) {
12553                            qPos.add(templateId);
12554                    }
12555    
12556                    if (orderByComparator != null) {
12557                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12558    
12559                            for (Object value : values) {
12560                                    qPos.add(value);
12561                            }
12562                    }
12563    
12564                    List<JournalArticle> list = q.list();
12565    
12566                    if (list.size() == 2) {
12567                            return list.get(1);
12568                    }
12569                    else {
12570                            return null;
12571                    }
12572            }
12573    
12574            /**
12575             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12576             *
12577             * @param groupId the group ID
12578             * @param classNameId the class name ID
12579             * @param layoutUuid the layout uuid
12580             * @return the matching journal articles
12581             * @throws SystemException if a system exception occurred
12582             */
12583            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
12584                    String layoutUuid) throws SystemException {
12585                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
12586                            QueryUtil.ALL_POS, null);
12587            }
12588    
12589            /**
12590             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12591             *
12592             * <p>
12593             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12594             * </p>
12595             *
12596             * @param groupId the group ID
12597             * @param classNameId the class name ID
12598             * @param layoutUuid the layout uuid
12599             * @param start the lower bound of the range of journal articles
12600             * @param end the upper bound of the range of journal articles (not inclusive)
12601             * @return the range of matching journal articles
12602             * @throws SystemException if a system exception occurred
12603             */
12604            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
12605                    String layoutUuid, int start, int end) throws SystemException {
12606                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
12607            }
12608    
12609            /**
12610             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12611             *
12612             * <p>
12613             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12614             * </p>
12615             *
12616             * @param groupId the group ID
12617             * @param classNameId the class name ID
12618             * @param layoutUuid the layout uuid
12619             * @param start the lower bound of the range of journal articles
12620             * @param end the upper bound of the range of journal articles (not inclusive)
12621             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12622             * @return the ordered range of matching journal articles
12623             * @throws SystemException if a system exception occurred
12624             */
12625            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
12626                    String layoutUuid, int start, int end,
12627                    OrderByComparator orderByComparator) throws SystemException {
12628                    FinderPath finderPath = null;
12629                    Object[] finderArgs = null;
12630    
12631                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12632                                    (orderByComparator == null)) {
12633                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
12634                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
12635                    }
12636                    else {
12637                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
12638                            finderArgs = new Object[] {
12639                                            groupId, classNameId, layoutUuid,
12640                                            
12641                                            start, end, orderByComparator
12642                                    };
12643                    }
12644    
12645                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12646                                    finderArgs, this);
12647    
12648                    if ((list != null) && !list.isEmpty()) {
12649                            for (JournalArticle journalArticle : list) {
12650                                    if ((groupId != journalArticle.getGroupId()) ||
12651                                                    (classNameId != journalArticle.getClassNameId()) ||
12652                                                    !Validator.equals(layoutUuid,
12653                                                            journalArticle.getLayoutUuid())) {
12654                                            list = null;
12655    
12656                                            break;
12657                                    }
12658                            }
12659                    }
12660    
12661                    if (list == null) {
12662                            StringBundler query = null;
12663    
12664                            if (orderByComparator != null) {
12665                                    query = new StringBundler(5 +
12666                                                    (orderByComparator.getOrderByFields().length * 3));
12667                            }
12668                            else {
12669                                    query = new StringBundler(5);
12670                            }
12671    
12672                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12673    
12674                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
12675    
12676                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
12677    
12678                            if (layoutUuid == null) {
12679                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
12680                            }
12681                            else {
12682                                    if (layoutUuid.equals(StringPool.BLANK)) {
12683                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
12684                                    }
12685                                    else {
12686                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
12687                                    }
12688                            }
12689    
12690                            if (orderByComparator != null) {
12691                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12692                                            orderByComparator);
12693                            }
12694    
12695                            else {
12696                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12697                            }
12698    
12699                            String sql = query.toString();
12700    
12701                            Session session = null;
12702    
12703                            try {
12704                                    session = openSession();
12705    
12706                                    Query q = session.createQuery(sql);
12707    
12708                                    QueryPos qPos = QueryPos.getInstance(q);
12709    
12710                                    qPos.add(groupId);
12711    
12712                                    qPos.add(classNameId);
12713    
12714                                    if (layoutUuid != null) {
12715                                            qPos.add(layoutUuid);
12716                                    }
12717    
12718                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
12719                                                    start, end);
12720                            }
12721                            catch (Exception e) {
12722                                    throw processException(e);
12723                            }
12724                            finally {
12725                                    if (list == null) {
12726                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
12727                                    }
12728                                    else {
12729                                            cacheResult(list);
12730    
12731                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12732                                    }
12733    
12734                                    closeSession(session);
12735                            }
12736                    }
12737    
12738                    return list;
12739            }
12740    
12741            /**
12742             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12743             *
12744             * @param groupId the group ID
12745             * @param classNameId the class name ID
12746             * @param layoutUuid the layout uuid
12747             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12748             * @return the first matching journal article
12749             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12750             * @throws SystemException if a system exception occurred
12751             */
12752            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
12753                    String layoutUuid, OrderByComparator orderByComparator)
12754                    throws NoSuchArticleException, SystemException {
12755                    JournalArticle journalArticle = fetchByG_C_L_First(groupId,
12756                                    classNameId, layoutUuid, orderByComparator);
12757    
12758                    if (journalArticle != null) {
12759                            return journalArticle;
12760                    }
12761    
12762                    StringBundler msg = new StringBundler(8);
12763    
12764                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12765    
12766                    msg.append("groupId=");
12767                    msg.append(groupId);
12768    
12769                    msg.append(", classNameId=");
12770                    msg.append(classNameId);
12771    
12772                    msg.append(", layoutUuid=");
12773                    msg.append(layoutUuid);
12774    
12775                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12776    
12777                    throw new NoSuchArticleException(msg.toString());
12778            }
12779    
12780            /**
12781             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12782             *
12783             * @param groupId the group ID
12784             * @param classNameId the class name ID
12785             * @param layoutUuid the layout uuid
12786             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12787             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
12788             * @throws SystemException if a system exception occurred
12789             */
12790            public JournalArticle fetchByG_C_L_First(long groupId, long classNameId,
12791                    String layoutUuid, OrderByComparator orderByComparator)
12792                    throws SystemException {
12793                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
12794                                    layoutUuid, 0, 1, orderByComparator);
12795    
12796                    if (!list.isEmpty()) {
12797                            return list.get(0);
12798                    }
12799    
12800                    return null;
12801            }
12802    
12803            /**
12804             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12805             *
12806             * @param groupId the group ID
12807             * @param classNameId the class name ID
12808             * @param layoutUuid the layout uuid
12809             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12810             * @return the last matching journal article
12811             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12812             * @throws SystemException if a system exception occurred
12813             */
12814            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
12815                    String layoutUuid, OrderByComparator orderByComparator)
12816                    throws NoSuchArticleException, SystemException {
12817                    JournalArticle journalArticle = fetchByG_C_L_Last(groupId, classNameId,
12818                                    layoutUuid, orderByComparator);
12819    
12820                    if (journalArticle != null) {
12821                            return journalArticle;
12822                    }
12823    
12824                    StringBundler msg = new StringBundler(8);
12825    
12826                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12827    
12828                    msg.append("groupId=");
12829                    msg.append(groupId);
12830    
12831                    msg.append(", classNameId=");
12832                    msg.append(classNameId);
12833    
12834                    msg.append(", layoutUuid=");
12835                    msg.append(layoutUuid);
12836    
12837                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12838    
12839                    throw new NoSuchArticleException(msg.toString());
12840            }
12841    
12842            /**
12843             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12844             *
12845             * @param groupId the group ID
12846             * @param classNameId the class name ID
12847             * @param layoutUuid the layout uuid
12848             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12849             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
12850             * @throws SystemException if a system exception occurred
12851             */
12852            public JournalArticle fetchByG_C_L_Last(long groupId, long classNameId,
12853                    String layoutUuid, OrderByComparator orderByComparator)
12854                    throws SystemException {
12855                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
12856    
12857                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
12858                                    layoutUuid, count - 1, count, orderByComparator);
12859    
12860                    if (!list.isEmpty()) {
12861                            return list.get(0);
12862                    }
12863    
12864                    return null;
12865            }
12866    
12867            /**
12868             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
12869             *
12870             * @param id the primary key of the current journal article
12871             * @param groupId the group ID
12872             * @param classNameId the class name ID
12873             * @param layoutUuid the layout uuid
12874             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12875             * @return the previous, current, and next journal article
12876             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12877             * @throws SystemException if a system exception occurred
12878             */
12879            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
12880                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
12881                    throws NoSuchArticleException, SystemException {
12882                    JournalArticle journalArticle = findByPrimaryKey(id);
12883    
12884                    Session session = null;
12885    
12886                    try {
12887                            session = openSession();
12888    
12889                            JournalArticle[] array = new JournalArticleImpl[3];
12890    
12891                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
12892                                            classNameId, layoutUuid, orderByComparator, true);
12893    
12894                            array[1] = journalArticle;
12895    
12896                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
12897                                            classNameId, layoutUuid, orderByComparator, false);
12898    
12899                            return array;
12900                    }
12901                    catch (Exception e) {
12902                            throw processException(e);
12903                    }
12904                    finally {
12905                            closeSession(session);
12906                    }
12907            }
12908    
12909            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
12910                    JournalArticle journalArticle, long groupId, long classNameId,
12911                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
12912                    StringBundler query = null;
12913    
12914                    if (orderByComparator != null) {
12915                            query = new StringBundler(6 +
12916                                            (orderByComparator.getOrderByFields().length * 6));
12917                    }
12918                    else {
12919                            query = new StringBundler(3);
12920                    }
12921    
12922                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12923    
12924                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
12925    
12926                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
12927    
12928                    if (layoutUuid == null) {
12929                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
12930                    }
12931                    else {
12932                            if (layoutUuid.equals(StringPool.BLANK)) {
12933                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
12934                            }
12935                            else {
12936                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
12937                            }
12938                    }
12939    
12940                    if (orderByComparator != null) {
12941                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12942    
12943                            if (orderByConditionFields.length > 0) {
12944                                    query.append(WHERE_AND);
12945                            }
12946    
12947                            for (int i = 0; i < orderByConditionFields.length; i++) {
12948                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12949                                    query.append(orderByConditionFields[i]);
12950    
12951                                    if ((i + 1) < orderByConditionFields.length) {
12952                                            if (orderByComparator.isAscending() ^ previous) {
12953                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12954                                            }
12955                                            else {
12956                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12957                                            }
12958                                    }
12959                                    else {
12960                                            if (orderByComparator.isAscending() ^ previous) {
12961                                                    query.append(WHERE_GREATER_THAN);
12962                                            }
12963                                            else {
12964                                                    query.append(WHERE_LESSER_THAN);
12965                                            }
12966                                    }
12967                            }
12968    
12969                            query.append(ORDER_BY_CLAUSE);
12970    
12971                            String[] orderByFields = orderByComparator.getOrderByFields();
12972    
12973                            for (int i = 0; i < orderByFields.length; i++) {
12974                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12975                                    query.append(orderByFields[i]);
12976    
12977                                    if ((i + 1) < orderByFields.length) {
12978                                            if (orderByComparator.isAscending() ^ previous) {
12979                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12980                                            }
12981                                            else {
12982                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12983                                            }
12984                                    }
12985                                    else {
12986                                            if (orderByComparator.isAscending() ^ previous) {
12987                                                    query.append(ORDER_BY_ASC);
12988                                            }
12989                                            else {
12990                                                    query.append(ORDER_BY_DESC);
12991                                            }
12992                                    }
12993                            }
12994                    }
12995    
12996                    else {
12997                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12998                    }
12999    
13000                    String sql = query.toString();
13001    
13002                    Query q = session.createQuery(sql);
13003    
13004                    q.setFirstResult(0);
13005                    q.setMaxResults(2);
13006    
13007                    QueryPos qPos = QueryPos.getInstance(q);
13008    
13009                    qPos.add(groupId);
13010    
13011                    qPos.add(classNameId);
13012    
13013                    if (layoutUuid != null) {
13014                            qPos.add(layoutUuid);
13015                    }
13016    
13017                    if (orderByComparator != null) {
13018                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13019    
13020                            for (Object value : values) {
13021                                    qPos.add(value);
13022                            }
13023                    }
13024    
13025                    List<JournalArticle> list = q.list();
13026    
13027                    if (list.size() == 2) {
13028                            return list.get(1);
13029                    }
13030                    else {
13031                            return null;
13032                    }
13033            }
13034    
13035            /**
13036             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
13037             *
13038             * @param groupId the group ID
13039             * @param classNameId the class name ID
13040             * @param layoutUuid the layout uuid
13041             * @return the matching journal articles that the user has permission to view
13042             * @throws SystemException if a system exception occurred
13043             */
13044            public List<JournalArticle> filterFindByG_C_L(long groupId,
13045                    long classNameId, String layoutUuid) throws SystemException {
13046                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
13047                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13048            }
13049    
13050            /**
13051             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
13052             *
13053             * <p>
13054             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13055             * </p>
13056             *
13057             * @param groupId the group ID
13058             * @param classNameId the class name ID
13059             * @param layoutUuid the layout uuid
13060             * @param start the lower bound of the range of journal articles
13061             * @param end the upper bound of the range of journal articles (not inclusive)
13062             * @return the range of matching journal articles that the user has permission to view
13063             * @throws SystemException if a system exception occurred
13064             */
13065            public List<JournalArticle> filterFindByG_C_L(long groupId,
13066                    long classNameId, String layoutUuid, int start, int end)
13067                    throws SystemException {
13068                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
13069                            null);
13070            }
13071    
13072            /**
13073             * 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;.
13074             *
13075             * <p>
13076             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13077             * </p>
13078             *
13079             * @param groupId the group ID
13080             * @param classNameId the class name ID
13081             * @param layoutUuid the layout uuid
13082             * @param start the lower bound of the range of journal articles
13083             * @param end the upper bound of the range of journal articles (not inclusive)
13084             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13085             * @return the ordered range of matching journal articles that the user has permission to view
13086             * @throws SystemException if a system exception occurred
13087             */
13088            public List<JournalArticle> filterFindByG_C_L(long groupId,
13089                    long classNameId, String layoutUuid, int start, int end,
13090                    OrderByComparator orderByComparator) throws SystemException {
13091                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13092                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
13093                                    orderByComparator);
13094                    }
13095    
13096                    StringBundler query = null;
13097    
13098                    if (orderByComparator != null) {
13099                            query = new StringBundler(5 +
13100                                            (orderByComparator.getOrderByFields().length * 3));
13101                    }
13102                    else {
13103                            query = new StringBundler(5);
13104                    }
13105    
13106                    if (getDB().isSupportsInlineDistinct()) {
13107                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13108                    }
13109                    else {
13110                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13111                    }
13112    
13113                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
13114    
13115                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
13116    
13117                    if (layoutUuid == null) {
13118                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
13119                    }
13120                    else {
13121                            if (layoutUuid.equals(StringPool.BLANK)) {
13122                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
13123                            }
13124                            else {
13125                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
13126                            }
13127                    }
13128    
13129                    if (!getDB().isSupportsInlineDistinct()) {
13130                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13131                    }
13132    
13133                    if (orderByComparator != null) {
13134                            if (getDB().isSupportsInlineDistinct()) {
13135                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13136                                            orderByComparator);
13137                            }
13138                            else {
13139                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13140                                            orderByComparator);
13141                            }
13142                    }
13143    
13144                    else {
13145                            if (getDB().isSupportsInlineDistinct()) {
13146                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13147                            }
13148                            else {
13149                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13150                            }
13151                    }
13152    
13153                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13154                                    JournalArticle.class.getName(),
13155                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13156    
13157                    Session session = null;
13158    
13159                    try {
13160                            session = openSession();
13161    
13162                            SQLQuery q = session.createSQLQuery(sql);
13163    
13164                            if (getDB().isSupportsInlineDistinct()) {
13165                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13166                            }
13167                            else {
13168                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13169                            }
13170    
13171                            QueryPos qPos = QueryPos.getInstance(q);
13172    
13173                            qPos.add(groupId);
13174    
13175                            qPos.add(classNameId);
13176    
13177                            if (layoutUuid != null) {
13178                                    qPos.add(layoutUuid);
13179                            }
13180    
13181                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13182                                    end);
13183                    }
13184                    catch (Exception e) {
13185                            throw processException(e);
13186                    }
13187                    finally {
13188                            closeSession(session);
13189                    }
13190            }
13191    
13192            /**
13193             * 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;.
13194             *
13195             * @param id the primary key of the current journal article
13196             * @param groupId the group ID
13197             * @param classNameId the class name ID
13198             * @param layoutUuid the layout uuid
13199             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13200             * @return the previous, current, and next journal article
13201             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13202             * @throws SystemException if a system exception occurred
13203             */
13204            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
13205                    long groupId, long classNameId, String layoutUuid,
13206                    OrderByComparator orderByComparator)
13207                    throws NoSuchArticleException, SystemException {
13208                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13209                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
13210                                    layoutUuid, orderByComparator);
13211                    }
13212    
13213                    JournalArticle journalArticle = findByPrimaryKey(id);
13214    
13215                    Session session = null;
13216    
13217                    try {
13218                            session = openSession();
13219    
13220                            JournalArticle[] array = new JournalArticleImpl[3];
13221    
13222                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
13223                                            groupId, classNameId, layoutUuid, orderByComparator, true);
13224    
13225                            array[1] = journalArticle;
13226    
13227                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
13228                                            groupId, classNameId, layoutUuid, orderByComparator, false);
13229    
13230                            return array;
13231                    }
13232                    catch (Exception e) {
13233                            throw processException(e);
13234                    }
13235                    finally {
13236                            closeSession(session);
13237                    }
13238            }
13239    
13240            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
13241                    JournalArticle journalArticle, long groupId, long classNameId,
13242                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
13243                    StringBundler query = null;
13244    
13245                    if (orderByComparator != null) {
13246                            query = new StringBundler(6 +
13247                                            (orderByComparator.getOrderByFields().length * 6));
13248                    }
13249                    else {
13250                            query = new StringBundler(3);
13251                    }
13252    
13253                    if (getDB().isSupportsInlineDistinct()) {
13254                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13255                    }
13256                    else {
13257                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13258                    }
13259    
13260                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
13261    
13262                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
13263    
13264                    if (layoutUuid == null) {
13265                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
13266                    }
13267                    else {
13268                            if (layoutUuid.equals(StringPool.BLANK)) {
13269                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
13270                            }
13271                            else {
13272                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
13273                            }
13274                    }
13275    
13276                    if (!getDB().isSupportsInlineDistinct()) {
13277                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13278                    }
13279    
13280                    if (orderByComparator != null) {
13281                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13282    
13283                            if (orderByConditionFields.length > 0) {
13284                                    query.append(WHERE_AND);
13285                            }
13286    
13287                            for (int i = 0; i < orderByConditionFields.length; i++) {
13288                                    if (getDB().isSupportsInlineDistinct()) {
13289                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13290                                    }
13291                                    else {
13292                                            query.append(_ORDER_BY_ENTITY_TABLE);
13293                                    }
13294    
13295                                    query.append(orderByConditionFields[i]);
13296    
13297                                    if ((i + 1) < orderByConditionFields.length) {
13298                                            if (orderByComparator.isAscending() ^ previous) {
13299                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13300                                            }
13301                                            else {
13302                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13303                                            }
13304                                    }
13305                                    else {
13306                                            if (orderByComparator.isAscending() ^ previous) {
13307                                                    query.append(WHERE_GREATER_THAN);
13308                                            }
13309                                            else {
13310                                                    query.append(WHERE_LESSER_THAN);
13311                                            }
13312                                    }
13313                            }
13314    
13315                            query.append(ORDER_BY_CLAUSE);
13316    
13317                            String[] orderByFields = orderByComparator.getOrderByFields();
13318    
13319                            for (int i = 0; i < orderByFields.length; i++) {
13320                                    if (getDB().isSupportsInlineDistinct()) {
13321                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13322                                    }
13323                                    else {
13324                                            query.append(_ORDER_BY_ENTITY_TABLE);
13325                                    }
13326    
13327                                    query.append(orderByFields[i]);
13328    
13329                                    if ((i + 1) < orderByFields.length) {
13330                                            if (orderByComparator.isAscending() ^ previous) {
13331                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13332                                            }
13333                                            else {
13334                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13335                                            }
13336                                    }
13337                                    else {
13338                                            if (orderByComparator.isAscending() ^ previous) {
13339                                                    query.append(ORDER_BY_ASC);
13340                                            }
13341                                            else {
13342                                                    query.append(ORDER_BY_DESC);
13343                                            }
13344                                    }
13345                            }
13346                    }
13347    
13348                    else {
13349                            if (getDB().isSupportsInlineDistinct()) {
13350                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13351                            }
13352                            else {
13353                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13354                            }
13355                    }
13356    
13357                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13358                                    JournalArticle.class.getName(),
13359                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13360    
13361                    SQLQuery q = session.createSQLQuery(sql);
13362    
13363                    q.setFirstResult(0);
13364                    q.setMaxResults(2);
13365    
13366                    if (getDB().isSupportsInlineDistinct()) {
13367                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13368                    }
13369                    else {
13370                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13371                    }
13372    
13373                    QueryPos qPos = QueryPos.getInstance(q);
13374    
13375                    qPos.add(groupId);
13376    
13377                    qPos.add(classNameId);
13378    
13379                    if (layoutUuid != null) {
13380                            qPos.add(layoutUuid);
13381                    }
13382    
13383                    if (orderByComparator != null) {
13384                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13385    
13386                            for (Object value : values) {
13387                                    qPos.add(value);
13388                            }
13389                    }
13390    
13391                    List<JournalArticle> list = q.list();
13392    
13393                    if (list.size() == 2) {
13394                            return list.get(1);
13395                    }
13396                    else {
13397                            return null;
13398                    }
13399            }
13400    
13401            /**
13402             * 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.
13403             *
13404             * @param groupId the group ID
13405             * @param articleId the article ID
13406             * @param version the version
13407             * @return the matching journal article
13408             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13409             * @throws SystemException if a system exception occurred
13410             */
13411            public JournalArticle findByG_A_V(long groupId, String articleId,
13412                    double version) throws NoSuchArticleException, SystemException {
13413                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
13414    
13415                    if (journalArticle == null) {
13416                            StringBundler msg = new StringBundler(8);
13417    
13418                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13419    
13420                            msg.append("groupId=");
13421                            msg.append(groupId);
13422    
13423                            msg.append(", articleId=");
13424                            msg.append(articleId);
13425    
13426                            msg.append(", version=");
13427                            msg.append(version);
13428    
13429                            msg.append(StringPool.CLOSE_CURLY_BRACE);
13430    
13431                            if (_log.isWarnEnabled()) {
13432                                    _log.warn(msg.toString());
13433                            }
13434    
13435                            throw new NoSuchArticleException(msg.toString());
13436                    }
13437    
13438                    return journalArticle;
13439            }
13440    
13441            /**
13442             * 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.
13443             *
13444             * @param groupId the group ID
13445             * @param articleId the article ID
13446             * @param version the version
13447             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
13448             * @throws SystemException if a system exception occurred
13449             */
13450            public JournalArticle fetchByG_A_V(long groupId, String articleId,
13451                    double version) throws SystemException {
13452                    return fetchByG_A_V(groupId, articleId, version, true);
13453            }
13454    
13455            /**
13456             * 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.
13457             *
13458             * @param groupId the group ID
13459             * @param articleId the article ID
13460             * @param version the version
13461             * @param retrieveFromCache whether to use the finder cache
13462             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
13463             * @throws SystemException if a system exception occurred
13464             */
13465            public JournalArticle fetchByG_A_V(long groupId, String articleId,
13466                    double version, boolean retrieveFromCache) throws SystemException {
13467                    Object[] finderArgs = new Object[] { groupId, articleId, version };
13468    
13469                    Object result = null;
13470    
13471                    if (retrieveFromCache) {
13472                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
13473                                            finderArgs, this);
13474                    }
13475    
13476                    if (result instanceof JournalArticle) {
13477                            JournalArticle journalArticle = (JournalArticle)result;
13478    
13479                            if ((groupId != journalArticle.getGroupId()) ||
13480                                            !Validator.equals(articleId, journalArticle.getArticleId()) ||
13481                                            (version != journalArticle.getVersion())) {
13482                                    result = null;
13483                            }
13484                    }
13485    
13486                    if (result == null) {
13487                            StringBundler query = new StringBundler(5);
13488    
13489                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13490    
13491                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
13492    
13493                            if (articleId == null) {
13494                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
13495                            }
13496                            else {
13497                                    if (articleId.equals(StringPool.BLANK)) {
13498                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
13499                                    }
13500                                    else {
13501                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
13502                                    }
13503                            }
13504    
13505                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
13506    
13507                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13508    
13509                            String sql = query.toString();
13510    
13511                            Session session = null;
13512    
13513                            try {
13514                                    session = openSession();
13515    
13516                                    Query q = session.createQuery(sql);
13517    
13518                                    QueryPos qPos = QueryPos.getInstance(q);
13519    
13520                                    qPos.add(groupId);
13521    
13522                                    if (articleId != null) {
13523                                            qPos.add(articleId);
13524                                    }
13525    
13526                                    qPos.add(version);
13527    
13528                                    List<JournalArticle> list = q.list();
13529    
13530                                    result = list;
13531    
13532                                    JournalArticle journalArticle = null;
13533    
13534                                    if (list.isEmpty()) {
13535                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
13536                                                    finderArgs, list);
13537                                    }
13538                                    else {
13539                                            journalArticle = list.get(0);
13540    
13541                                            cacheResult(journalArticle);
13542    
13543                                            if ((journalArticle.getGroupId() != groupId) ||
13544                                                            (journalArticle.getArticleId() == null) ||
13545                                                            !journalArticle.getArticleId().equals(articleId) ||
13546                                                            (journalArticle.getVersion() != version)) {
13547                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
13548                                                            finderArgs, journalArticle);
13549                                            }
13550                                    }
13551    
13552                                    return journalArticle;
13553                            }
13554                            catch (Exception e) {
13555                                    throw processException(e);
13556                            }
13557                            finally {
13558                                    if (result == null) {
13559                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
13560                                                    finderArgs);
13561                                    }
13562    
13563                                    closeSession(session);
13564                            }
13565                    }
13566                    else {
13567                            if (result instanceof List<?>) {
13568                                    return null;
13569                            }
13570                            else {
13571                                    return (JournalArticle)result;
13572                            }
13573                    }
13574            }
13575    
13576            /**
13577             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
13578             *
13579             * @param groupId the group ID
13580             * @param articleId the article ID
13581             * @param status the status
13582             * @return the matching journal articles
13583             * @throws SystemException if a system exception occurred
13584             */
13585            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
13586                    int status) throws SystemException {
13587                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
13588                            QueryUtil.ALL_POS, null);
13589            }
13590    
13591            /**
13592             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
13593             *
13594             * <p>
13595             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13596             * </p>
13597             *
13598             * @param groupId the group ID
13599             * @param articleId the article ID
13600             * @param status the status
13601             * @param start the lower bound of the range of journal articles
13602             * @param end the upper bound of the range of journal articles (not inclusive)
13603             * @return the range of matching journal articles
13604             * @throws SystemException if a system exception occurred
13605             */
13606            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
13607                    int status, int start, int end) throws SystemException {
13608                    return findByG_A_ST(groupId, articleId, status, start, end, null);
13609            }
13610    
13611            /**
13612             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
13613             *
13614             * <p>
13615             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13616             * </p>
13617             *
13618             * @param groupId the group ID
13619             * @param articleId the article ID
13620             * @param status the status
13621             * @param start the lower bound of the range of journal articles
13622             * @param end the upper bound of the range of journal articles (not inclusive)
13623             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13624             * @return the ordered range of matching journal articles
13625             * @throws SystemException if a system exception occurred
13626             */
13627            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
13628                    int status, int start, int end, OrderByComparator orderByComparator)
13629                    throws SystemException {
13630                    FinderPath finderPath = null;
13631                    Object[] finderArgs = null;
13632    
13633                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13634                                    (orderByComparator == null)) {
13635                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
13636                            finderArgs = new Object[] { groupId, articleId, status };
13637                    }
13638                    else {
13639                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
13640                            finderArgs = new Object[] {
13641                                            groupId, articleId, status,
13642                                            
13643                                            start, end, orderByComparator
13644                                    };
13645                    }
13646    
13647                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13648                                    finderArgs, this);
13649    
13650                    if ((list != null) && !list.isEmpty()) {
13651                            for (JournalArticle journalArticle : list) {
13652                                    if ((groupId != journalArticle.getGroupId()) ||
13653                                                    !Validator.equals(articleId,
13654                                                            journalArticle.getArticleId()) ||
13655                                                    (status != journalArticle.getStatus())) {
13656                                            list = null;
13657    
13658                                            break;
13659                                    }
13660                            }
13661                    }
13662    
13663                    if (list == null) {
13664                            StringBundler query = null;
13665    
13666                            if (orderByComparator != null) {
13667                                    query = new StringBundler(5 +
13668                                                    (orderByComparator.getOrderByFields().length * 3));
13669                            }
13670                            else {
13671                                    query = new StringBundler(5);
13672                            }
13673    
13674                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13675    
13676                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
13677    
13678                            if (articleId == null) {
13679                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
13680                            }
13681                            else {
13682                                    if (articleId.equals(StringPool.BLANK)) {
13683                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
13684                                    }
13685                                    else {
13686                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
13687                                    }
13688                            }
13689    
13690                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
13691    
13692                            if (orderByComparator != null) {
13693                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13694                                            orderByComparator);
13695                            }
13696    
13697                            else {
13698                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13699                            }
13700    
13701                            String sql = query.toString();
13702    
13703                            Session session = null;
13704    
13705                            try {
13706                                    session = openSession();
13707    
13708                                    Query q = session.createQuery(sql);
13709    
13710                                    QueryPos qPos = QueryPos.getInstance(q);
13711    
13712                                    qPos.add(groupId);
13713    
13714                                    if (articleId != null) {
13715                                            qPos.add(articleId);
13716                                    }
13717    
13718                                    qPos.add(status);
13719    
13720                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
13721                                                    start, end);
13722                            }
13723                            catch (Exception e) {
13724                                    throw processException(e);
13725                            }
13726                            finally {
13727                                    if (list == null) {
13728                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
13729                                    }
13730                                    else {
13731                                            cacheResult(list);
13732    
13733                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
13734                                    }
13735    
13736                                    closeSession(session);
13737                            }
13738                    }
13739    
13740                    return list;
13741            }
13742    
13743            /**
13744             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
13745             *
13746             * @param groupId the group ID
13747             * @param articleId the article ID
13748             * @param status the status
13749             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13750             * @return the first matching journal article
13751             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13752             * @throws SystemException if a system exception occurred
13753             */
13754            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
13755                    int status, OrderByComparator orderByComparator)
13756                    throws NoSuchArticleException, SystemException {
13757                    JournalArticle journalArticle = fetchByG_A_ST_First(groupId, articleId,
13758                                    status, orderByComparator);
13759    
13760                    if (journalArticle != null) {
13761                            return journalArticle;
13762                    }
13763    
13764                    StringBundler msg = new StringBundler(8);
13765    
13766                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13767    
13768                    msg.append("groupId=");
13769                    msg.append(groupId);
13770    
13771                    msg.append(", articleId=");
13772                    msg.append(articleId);
13773    
13774                    msg.append(", status=");
13775                    msg.append(status);
13776    
13777                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13778    
13779                    throw new NoSuchArticleException(msg.toString());
13780            }
13781    
13782            /**
13783             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
13784             *
13785             * @param groupId the group ID
13786             * @param articleId the article ID
13787             * @param status the status
13788             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13789             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
13790             * @throws SystemException if a system exception occurred
13791             */
13792            public JournalArticle fetchByG_A_ST_First(long groupId, String articleId,
13793                    int status, OrderByComparator orderByComparator)
13794                    throws SystemException {
13795                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
13796                                    1, orderByComparator);
13797    
13798                    if (!list.isEmpty()) {
13799                            return list.get(0);
13800                    }
13801    
13802                    return null;
13803            }
13804    
13805            /**
13806             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
13807             *
13808             * @param groupId the group ID
13809             * @param articleId the article ID
13810             * @param status the status
13811             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13812             * @return the last matching journal article
13813             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13814             * @throws SystemException if a system exception occurred
13815             */
13816            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
13817                    int status, OrderByComparator orderByComparator)
13818                    throws NoSuchArticleException, SystemException {
13819                    JournalArticle journalArticle = fetchByG_A_ST_Last(groupId, articleId,
13820                                    status, orderByComparator);
13821    
13822                    if (journalArticle != null) {
13823                            return journalArticle;
13824                    }
13825    
13826                    StringBundler msg = new StringBundler(8);
13827    
13828                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13829    
13830                    msg.append("groupId=");
13831                    msg.append(groupId);
13832    
13833                    msg.append(", articleId=");
13834                    msg.append(articleId);
13835    
13836                    msg.append(", status=");
13837                    msg.append(status);
13838    
13839                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13840    
13841                    throw new NoSuchArticleException(msg.toString());
13842            }
13843    
13844            /**
13845             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
13846             *
13847             * @param groupId the group ID
13848             * @param articleId the article ID
13849             * @param status the status
13850             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13851             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
13852             * @throws SystemException if a system exception occurred
13853             */
13854            public JournalArticle fetchByG_A_ST_Last(long groupId, String articleId,
13855                    int status, OrderByComparator orderByComparator)
13856                    throws SystemException {
13857                    int count = countByG_A_ST(groupId, articleId, status);
13858    
13859                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
13860                                    count - 1, count, orderByComparator);
13861    
13862                    if (!list.isEmpty()) {
13863                            return list.get(0);
13864                    }
13865    
13866                    return null;
13867            }
13868    
13869            /**
13870             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
13871             *
13872             * @param id the primary key of the current journal article
13873             * @param groupId the group ID
13874             * @param articleId the article ID
13875             * @param status the status
13876             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13877             * @return the previous, current, and next journal article
13878             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13879             * @throws SystemException if a system exception occurred
13880             */
13881            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
13882                    String articleId, int status, OrderByComparator orderByComparator)
13883                    throws NoSuchArticleException, SystemException {
13884                    JournalArticle journalArticle = findByPrimaryKey(id);
13885    
13886                    Session session = null;
13887    
13888                    try {
13889                            session = openSession();
13890    
13891                            JournalArticle[] array = new JournalArticleImpl[3];
13892    
13893                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
13894                                            groupId, articleId, status, orderByComparator, true);
13895    
13896                            array[1] = journalArticle;
13897    
13898                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
13899                                            groupId, articleId, status, orderByComparator, false);
13900    
13901                            return array;
13902                    }
13903                    catch (Exception e) {
13904                            throw processException(e);
13905                    }
13906                    finally {
13907                            closeSession(session);
13908                    }
13909            }
13910    
13911            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
13912                    JournalArticle journalArticle, long groupId, String articleId,
13913                    int status, OrderByComparator orderByComparator, boolean previous) {
13914                    StringBundler query = null;
13915    
13916                    if (orderByComparator != null) {
13917                            query = new StringBundler(6 +
13918                                            (orderByComparator.getOrderByFields().length * 6));
13919                    }
13920                    else {
13921                            query = new StringBundler(3);
13922                    }
13923    
13924                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13925    
13926                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
13927    
13928                    if (articleId == null) {
13929                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
13930                    }
13931                    else {
13932                            if (articleId.equals(StringPool.BLANK)) {
13933                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
13934                            }
13935                            else {
13936                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
13937                            }
13938                    }
13939    
13940                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
13941    
13942                    if (orderByComparator != null) {
13943                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13944    
13945                            if (orderByConditionFields.length > 0) {
13946                                    query.append(WHERE_AND);
13947                            }
13948    
13949                            for (int i = 0; i < orderByConditionFields.length; i++) {
13950                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13951                                    query.append(orderByConditionFields[i]);
13952    
13953                                    if ((i + 1) < orderByConditionFields.length) {
13954                                            if (orderByComparator.isAscending() ^ previous) {
13955                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13956                                            }
13957                                            else {
13958                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13959                                            }
13960                                    }
13961                                    else {
13962                                            if (orderByComparator.isAscending() ^ previous) {
13963                                                    query.append(WHERE_GREATER_THAN);
13964                                            }
13965                                            else {
13966                                                    query.append(WHERE_LESSER_THAN);
13967                                            }
13968                                    }
13969                            }
13970    
13971                            query.append(ORDER_BY_CLAUSE);
13972    
13973                            String[] orderByFields = orderByComparator.getOrderByFields();
13974    
13975                            for (int i = 0; i < orderByFields.length; i++) {
13976                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13977                                    query.append(orderByFields[i]);
13978    
13979                                    if ((i + 1) < orderByFields.length) {
13980                                            if (orderByComparator.isAscending() ^ previous) {
13981                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13982                                            }
13983                                            else {
13984                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13985                                            }
13986                                    }
13987                                    else {
13988                                            if (orderByComparator.isAscending() ^ previous) {
13989                                                    query.append(ORDER_BY_ASC);
13990                                            }
13991                                            else {
13992                                                    query.append(ORDER_BY_DESC);
13993                                            }
13994                                    }
13995                            }
13996                    }
13997    
13998                    else {
13999                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14000                    }
14001    
14002                    String sql = query.toString();
14003    
14004                    Query q = session.createQuery(sql);
14005    
14006                    q.setFirstResult(0);
14007                    q.setMaxResults(2);
14008    
14009                    QueryPos qPos = QueryPos.getInstance(q);
14010    
14011                    qPos.add(groupId);
14012    
14013                    if (articleId != null) {
14014                            qPos.add(articleId);
14015                    }
14016    
14017                    qPos.add(status);
14018    
14019                    if (orderByComparator != null) {
14020                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14021    
14022                            for (Object value : values) {
14023                                    qPos.add(value);
14024                            }
14025                    }
14026    
14027                    List<JournalArticle> list = q.list();
14028    
14029                    if (list.size() == 2) {
14030                            return list.get(1);
14031                    }
14032                    else {
14033                            return null;
14034                    }
14035            }
14036    
14037            /**
14038             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
14039             *
14040             * <p>
14041             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14042             * </p>
14043             *
14044             * @param groupId the group ID
14045             * @param articleId the article ID
14046             * @param statuses the statuses
14047             * @return the matching journal articles
14048             * @throws SystemException if a system exception occurred
14049             */
14050            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
14051                    int[] statuses) throws SystemException {
14052                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
14053                            QueryUtil.ALL_POS, null);
14054            }
14055    
14056            /**
14057             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
14058             *
14059             * <p>
14060             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14061             * </p>
14062             *
14063             * @param groupId the group ID
14064             * @param articleId the article ID
14065             * @param statuses the statuses
14066             * @param start the lower bound of the range of journal articles
14067             * @param end the upper bound of the range of journal articles (not inclusive)
14068             * @return the range of matching journal articles
14069             * @throws SystemException if a system exception occurred
14070             */
14071            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
14072                    int[] statuses, int start, int end) throws SystemException {
14073                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
14074            }
14075    
14076            /**
14077             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
14078             *
14079             * <p>
14080             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14081             * </p>
14082             *
14083             * @param groupId the group ID
14084             * @param articleId the article ID
14085             * @param statuses the statuses
14086             * @param start the lower bound of the range of journal articles
14087             * @param end the upper bound of the range of journal articles (not inclusive)
14088             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14089             * @return the ordered range of matching journal articles
14090             * @throws SystemException if a system exception occurred
14091             */
14092            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
14093                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
14094                    throws SystemException {
14095                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
14096                    Object[] finderArgs = null;
14097    
14098                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14099                                    (orderByComparator == null)) {
14100                            finderArgs = new Object[] {
14101                                            groupId, articleId, StringUtil.merge(statuses)
14102                                    };
14103                    }
14104                    else {
14105                            finderArgs = new Object[] {
14106                                            groupId, articleId, StringUtil.merge(statuses),
14107                                            
14108                                            start, end, orderByComparator
14109                                    };
14110                    }
14111    
14112                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14113                                    finderArgs, this);
14114    
14115                    if ((list != null) && !list.isEmpty()) {
14116                            for (JournalArticle journalArticle : list) {
14117                                    if ((groupId != journalArticle.getGroupId()) ||
14118                                                    !Validator.equals(articleId,
14119                                                            journalArticle.getArticleId()) ||
14120                                                    !ArrayUtil.contains(statuses, journalArticle.getStatus())) {
14121                                            list = null;
14122    
14123                                            break;
14124                                    }
14125                            }
14126                    }
14127    
14128                    if (list == null) {
14129                            StringBundler query = new StringBundler();
14130    
14131                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14132    
14133                            boolean conjunctionable = false;
14134    
14135                            if (conjunctionable) {
14136                                    query.append(WHERE_AND);
14137                            }
14138    
14139                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
14140    
14141                            conjunctionable = true;
14142    
14143                            if (conjunctionable) {
14144                                    query.append(WHERE_AND);
14145                            }
14146    
14147                            if (articleId == null) {
14148                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
14149                            }
14150                            else {
14151                                    if (articleId.equals(StringPool.BLANK)) {
14152                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
14153                                    }
14154                                    else {
14155                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
14156                                    }
14157                            }
14158    
14159                            conjunctionable = true;
14160    
14161                            if ((statuses == null) || (statuses.length > 0)) {
14162                                    if (conjunctionable) {
14163                                            query.append(WHERE_AND);
14164                                    }
14165    
14166                                    query.append(StringPool.OPEN_PARENTHESIS);
14167    
14168                                    for (int i = 0; i < statuses.length; i++) {
14169                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
14170    
14171                                            if ((i + 1) < statuses.length) {
14172                                                    query.append(WHERE_OR);
14173                                            }
14174                                    }
14175    
14176                                    query.append(StringPool.CLOSE_PARENTHESIS);
14177    
14178                                    conjunctionable = true;
14179                            }
14180    
14181                            if (orderByComparator != null) {
14182                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14183                                            orderByComparator);
14184                            }
14185    
14186                            else {
14187                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14188                            }
14189    
14190                            String sql = query.toString();
14191    
14192                            Session session = null;
14193    
14194                            try {
14195                                    session = openSession();
14196    
14197                                    Query q = session.createQuery(sql);
14198    
14199                                    QueryPos qPos = QueryPos.getInstance(q);
14200    
14201                                    qPos.add(groupId);
14202    
14203                                    if (articleId != null) {
14204                                            qPos.add(articleId);
14205                                    }
14206    
14207                                    if (statuses != null) {
14208                                            qPos.add(statuses);
14209                                    }
14210    
14211                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
14212                                                    start, end);
14213                            }
14214                            catch (Exception e) {
14215                                    throw processException(e);
14216                            }
14217                            finally {
14218                                    if (list == null) {
14219                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
14220                                    }
14221                                    else {
14222                                            cacheResult(list);
14223    
14224                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
14225                                    }
14226    
14227                                    closeSession(session);
14228                            }
14229                    }
14230    
14231                    return list;
14232            }
14233    
14234            /**
14235             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
14236             *
14237             * @param groupId the group ID
14238             * @param articleId the article ID
14239             * @param status the status
14240             * @return the matching journal articles that the user has permission to view
14241             * @throws SystemException if a system exception occurred
14242             */
14243            public List<JournalArticle> filterFindByG_A_ST(long groupId,
14244                    String articleId, int status) throws SystemException {
14245                    return filterFindByG_A_ST(groupId, articleId, status,
14246                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14247            }
14248    
14249            /**
14250             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
14251             *
14252             * <p>
14253             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14254             * </p>
14255             *
14256             * @param groupId the group ID
14257             * @param articleId the article ID
14258             * @param status the status
14259             * @param start the lower bound of the range of journal articles
14260             * @param end the upper bound of the range of journal articles (not inclusive)
14261             * @return the range of matching journal articles that the user has permission to view
14262             * @throws SystemException if a system exception occurred
14263             */
14264            public List<JournalArticle> filterFindByG_A_ST(long groupId,
14265                    String articleId, int status, int start, int end)
14266                    throws SystemException {
14267                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
14268            }
14269    
14270            /**
14271             * 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;.
14272             *
14273             * <p>
14274             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14275             * </p>
14276             *
14277             * @param groupId the group ID
14278             * @param articleId the article ID
14279             * @param status the status
14280             * @param start the lower bound of the range of journal articles
14281             * @param end the upper bound of the range of journal articles (not inclusive)
14282             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14283             * @return the ordered range of matching journal articles that the user has permission to view
14284             * @throws SystemException if a system exception occurred
14285             */
14286            public List<JournalArticle> filterFindByG_A_ST(long groupId,
14287                    String articleId, int status, int start, int end,
14288                    OrderByComparator orderByComparator) throws SystemException {
14289                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14290                            return findByG_A_ST(groupId, articleId, status, start, end,
14291                                    orderByComparator);
14292                    }
14293    
14294                    StringBundler query = null;
14295    
14296                    if (orderByComparator != null) {
14297                            query = new StringBundler(5 +
14298                                            (orderByComparator.getOrderByFields().length * 3));
14299                    }
14300                    else {
14301                            query = new StringBundler(5);
14302                    }
14303    
14304                    if (getDB().isSupportsInlineDistinct()) {
14305                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14306                    }
14307                    else {
14308                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14309                    }
14310    
14311                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
14312    
14313                    if (articleId == null) {
14314                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
14315                    }
14316                    else {
14317                            if (articleId.equals(StringPool.BLANK)) {
14318                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
14319                            }
14320                            else {
14321                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
14322                            }
14323                    }
14324    
14325                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
14326    
14327                    if (!getDB().isSupportsInlineDistinct()) {
14328                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14329                    }
14330    
14331                    if (orderByComparator != null) {
14332                            if (getDB().isSupportsInlineDistinct()) {
14333                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14334                                            orderByComparator);
14335                            }
14336                            else {
14337                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14338                                            orderByComparator);
14339                            }
14340                    }
14341    
14342                    else {
14343                            if (getDB().isSupportsInlineDistinct()) {
14344                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14345                            }
14346                            else {
14347                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14348                            }
14349                    }
14350    
14351                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14352                                    JournalArticle.class.getName(),
14353                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14354    
14355                    Session session = null;
14356    
14357                    try {
14358                            session = openSession();
14359    
14360                            SQLQuery q = session.createSQLQuery(sql);
14361    
14362                            if (getDB().isSupportsInlineDistinct()) {
14363                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14364                            }
14365                            else {
14366                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14367                            }
14368    
14369                            QueryPos qPos = QueryPos.getInstance(q);
14370    
14371                            qPos.add(groupId);
14372    
14373                            if (articleId != null) {
14374                                    qPos.add(articleId);
14375                            }
14376    
14377                            qPos.add(status);
14378    
14379                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14380                                    end);
14381                    }
14382                    catch (Exception e) {
14383                            throw processException(e);
14384                    }
14385                    finally {
14386                            closeSession(session);
14387                    }
14388            }
14389    
14390            /**
14391             * 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;.
14392             *
14393             * @param id the primary key of the current journal article
14394             * @param groupId the group ID
14395             * @param articleId the article ID
14396             * @param status the status
14397             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14398             * @return the previous, current, and next journal article
14399             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14400             * @throws SystemException if a system exception occurred
14401             */
14402            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
14403                    long groupId, String articleId, int status,
14404                    OrderByComparator orderByComparator)
14405                    throws NoSuchArticleException, SystemException {
14406                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14407                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
14408                                    orderByComparator);
14409                    }
14410    
14411                    JournalArticle journalArticle = findByPrimaryKey(id);
14412    
14413                    Session session = null;
14414    
14415                    try {
14416                            session = openSession();
14417    
14418                            JournalArticle[] array = new JournalArticleImpl[3];
14419    
14420                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
14421                                            groupId, articleId, status, orderByComparator, true);
14422    
14423                            array[1] = journalArticle;
14424    
14425                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
14426                                            groupId, articleId, status, orderByComparator, false);
14427    
14428                            return array;
14429                    }
14430                    catch (Exception e) {
14431                            throw processException(e);
14432                    }
14433                    finally {
14434                            closeSession(session);
14435                    }
14436            }
14437    
14438            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
14439                    JournalArticle journalArticle, long groupId, String articleId,
14440                    int status, OrderByComparator orderByComparator, boolean previous) {
14441                    StringBundler query = null;
14442    
14443                    if (orderByComparator != null) {
14444                            query = new StringBundler(6 +
14445                                            (orderByComparator.getOrderByFields().length * 6));
14446                    }
14447                    else {
14448                            query = new StringBundler(3);
14449                    }
14450    
14451                    if (getDB().isSupportsInlineDistinct()) {
14452                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14453                    }
14454                    else {
14455                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14456                    }
14457    
14458                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
14459    
14460                    if (articleId == null) {
14461                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
14462                    }
14463                    else {
14464                            if (articleId.equals(StringPool.BLANK)) {
14465                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
14466                            }
14467                            else {
14468                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
14469                            }
14470                    }
14471    
14472                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
14473    
14474                    if (!getDB().isSupportsInlineDistinct()) {
14475                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14476                    }
14477    
14478                    if (orderByComparator != null) {
14479                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14480    
14481                            if (orderByConditionFields.length > 0) {
14482                                    query.append(WHERE_AND);
14483                            }
14484    
14485                            for (int i = 0; i < orderByConditionFields.length; i++) {
14486                                    if (getDB().isSupportsInlineDistinct()) {
14487                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14488                                    }
14489                                    else {
14490                                            query.append(_ORDER_BY_ENTITY_TABLE);
14491                                    }
14492    
14493                                    query.append(orderByConditionFields[i]);
14494    
14495                                    if ((i + 1) < orderByConditionFields.length) {
14496                                            if (orderByComparator.isAscending() ^ previous) {
14497                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14498                                            }
14499                                            else {
14500                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14501                                            }
14502                                    }
14503                                    else {
14504                                            if (orderByComparator.isAscending() ^ previous) {
14505                                                    query.append(WHERE_GREATER_THAN);
14506                                            }
14507                                            else {
14508                                                    query.append(WHERE_LESSER_THAN);
14509                                            }
14510                                    }
14511                            }
14512    
14513                            query.append(ORDER_BY_CLAUSE);
14514    
14515                            String[] orderByFields = orderByComparator.getOrderByFields();
14516    
14517                            for (int i = 0; i < orderByFields.length; i++) {
14518                                    if (getDB().isSupportsInlineDistinct()) {
14519                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14520                                    }
14521                                    else {
14522                                            query.append(_ORDER_BY_ENTITY_TABLE);
14523                                    }
14524    
14525                                    query.append(orderByFields[i]);
14526    
14527                                    if ((i + 1) < orderByFields.length) {
14528                                            if (orderByComparator.isAscending() ^ previous) {
14529                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14530                                            }
14531                                            else {
14532                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14533                                            }
14534                                    }
14535                                    else {
14536                                            if (orderByComparator.isAscending() ^ previous) {
14537                                                    query.append(ORDER_BY_ASC);
14538                                            }
14539                                            else {
14540                                                    query.append(ORDER_BY_DESC);
14541                                            }
14542                                    }
14543                            }
14544                    }
14545    
14546                    else {
14547                            if (getDB().isSupportsInlineDistinct()) {
14548                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14549                            }
14550                            else {
14551                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14552                            }
14553                    }
14554    
14555                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14556                                    JournalArticle.class.getName(),
14557                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14558    
14559                    SQLQuery q = session.createSQLQuery(sql);
14560    
14561                    q.setFirstResult(0);
14562                    q.setMaxResults(2);
14563    
14564                    if (getDB().isSupportsInlineDistinct()) {
14565                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14566                    }
14567                    else {
14568                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14569                    }
14570    
14571                    QueryPos qPos = QueryPos.getInstance(q);
14572    
14573                    qPos.add(groupId);
14574    
14575                    if (articleId != null) {
14576                            qPos.add(articleId);
14577                    }
14578    
14579                    qPos.add(status);
14580    
14581                    if (orderByComparator != null) {
14582                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14583    
14584                            for (Object value : values) {
14585                                    qPos.add(value);
14586                            }
14587                    }
14588    
14589                    List<JournalArticle> list = q.list();
14590    
14591                    if (list.size() == 2) {
14592                            return list.get(1);
14593                    }
14594                    else {
14595                            return null;
14596                    }
14597            }
14598    
14599            /**
14600             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
14601             *
14602             * @param groupId the group ID
14603             * @param articleId the article ID
14604             * @param statuses the statuses
14605             * @return the matching journal articles that the user has permission to view
14606             * @throws SystemException if a system exception occurred
14607             */
14608            public List<JournalArticle> filterFindByG_A_ST(long groupId,
14609                    String articleId, int[] statuses) throws SystemException {
14610                    return filterFindByG_A_ST(groupId, articleId, statuses,
14611                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14612            }
14613    
14614            /**
14615             * 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;.
14616             *
14617             * <p>
14618             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14619             * </p>
14620             *
14621             * @param groupId the group ID
14622             * @param articleId the article ID
14623             * @param statuses the statuses
14624             * @param start the lower bound of the range of journal articles
14625             * @param end the upper bound of the range of journal articles (not inclusive)
14626             * @return the range of matching journal articles that the user has permission to view
14627             * @throws SystemException if a system exception occurred
14628             */
14629            public List<JournalArticle> filterFindByG_A_ST(long groupId,
14630                    String articleId, int[] statuses, int start, int end)
14631                    throws SystemException {
14632                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
14633            }
14634    
14635            /**
14636             * 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;.
14637             *
14638             * <p>
14639             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14640             * </p>
14641             *
14642             * @param groupId the group ID
14643             * @param articleId the article ID
14644             * @param statuses the statuses
14645             * @param start the lower bound of the range of journal articles
14646             * @param end the upper bound of the range of journal articles (not inclusive)
14647             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14648             * @return the ordered range of matching journal articles that the user has permission to view
14649             * @throws SystemException if a system exception occurred
14650             */
14651            public List<JournalArticle> filterFindByG_A_ST(long groupId,
14652                    String articleId, int[] statuses, int start, int end,
14653                    OrderByComparator orderByComparator) throws SystemException {
14654                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14655                            return findByG_A_ST(groupId, articleId, statuses, start, end,
14656                                    orderByComparator);
14657                    }
14658    
14659                    StringBundler query = new StringBundler();
14660    
14661                    if (getDB().isSupportsInlineDistinct()) {
14662                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
14663                    }
14664                    else {
14665                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
14666                    }
14667    
14668                    boolean conjunctionable = false;
14669    
14670                    if (conjunctionable) {
14671                            query.append(WHERE_AND);
14672                    }
14673    
14674                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
14675    
14676                    conjunctionable = true;
14677    
14678                    if (conjunctionable) {
14679                            query.append(WHERE_AND);
14680                    }
14681    
14682                    if (articleId == null) {
14683                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
14684                    }
14685                    else {
14686                            if (articleId.equals(StringPool.BLANK)) {
14687                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
14688                            }
14689                            else {
14690                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
14691                            }
14692                    }
14693    
14694                    conjunctionable = true;
14695    
14696                    if ((statuses == null) || (statuses.length > 0)) {
14697                            if (conjunctionable) {
14698                                    query.append(WHERE_AND);
14699                            }
14700    
14701                            query.append(StringPool.OPEN_PARENTHESIS);
14702    
14703                            for (int i = 0; i < statuses.length; i++) {
14704                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
14705    
14706                                    if ((i + 1) < statuses.length) {
14707                                            query.append(WHERE_OR);
14708                                    }
14709                            }
14710    
14711                            query.append(StringPool.CLOSE_PARENTHESIS);
14712    
14713                            conjunctionable = true;
14714                    }
14715    
14716                    if (!getDB().isSupportsInlineDistinct()) {
14717                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
14718                    }
14719    
14720                    if (orderByComparator != null) {
14721                            if (getDB().isSupportsInlineDistinct()) {
14722                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14723                                            orderByComparator);
14724                            }
14725                            else {
14726                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14727                                            orderByComparator);
14728                            }
14729                    }
14730    
14731                    else {
14732                            if (getDB().isSupportsInlineDistinct()) {
14733                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14734                            }
14735                            else {
14736                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
14737                            }
14738                    }
14739    
14740                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14741                                    JournalArticle.class.getName(),
14742                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14743    
14744                    Session session = null;
14745    
14746                    try {
14747                            session = openSession();
14748    
14749                            SQLQuery q = session.createSQLQuery(sql);
14750    
14751                            if (getDB().isSupportsInlineDistinct()) {
14752                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
14753                            }
14754                            else {
14755                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
14756                            }
14757    
14758                            QueryPos qPos = QueryPos.getInstance(q);
14759    
14760                            qPos.add(groupId);
14761    
14762                            if (articleId != null) {
14763                                    qPos.add(articleId);
14764                            }
14765    
14766                            if (statuses != null) {
14767                                    qPos.add(statuses);
14768                            }
14769    
14770                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
14771                                    end);
14772                    }
14773                    catch (Exception e) {
14774                            throw processException(e);
14775                    }
14776                    finally {
14777                            closeSession(session);
14778                    }
14779            }
14780    
14781            /**
14782             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14783             *
14784             * @param groupId the group ID
14785             * @param urlTitle the url title
14786             * @param status the status
14787             * @return the matching journal articles
14788             * @throws SystemException if a system exception occurred
14789             */
14790            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
14791                    int status) throws SystemException {
14792                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
14793                            QueryUtil.ALL_POS, null);
14794            }
14795    
14796            /**
14797             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14798             *
14799             * <p>
14800             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14801             * </p>
14802             *
14803             * @param groupId the group ID
14804             * @param urlTitle the url title
14805             * @param status the status
14806             * @param start the lower bound of the range of journal articles
14807             * @param end the upper bound of the range of journal articles (not inclusive)
14808             * @return the range of matching journal articles
14809             * @throws SystemException if a system exception occurred
14810             */
14811            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
14812                    int status, int start, int end) throws SystemException {
14813                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
14814            }
14815    
14816            /**
14817             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14818             *
14819             * <p>
14820             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14821             * </p>
14822             *
14823             * @param groupId the group ID
14824             * @param urlTitle the url title
14825             * @param status the status
14826             * @param start the lower bound of the range of journal articles
14827             * @param end the upper bound of the range of journal articles (not inclusive)
14828             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14829             * @return the ordered range of matching journal articles
14830             * @throws SystemException if a system exception occurred
14831             */
14832            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
14833                    int status, int start, int end, OrderByComparator orderByComparator)
14834                    throws SystemException {
14835                    FinderPath finderPath = null;
14836                    Object[] finderArgs = null;
14837    
14838                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14839                                    (orderByComparator == null)) {
14840                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
14841                            finderArgs = new Object[] { groupId, urlTitle, status };
14842                    }
14843                    else {
14844                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
14845                            finderArgs = new Object[] {
14846                                            groupId, urlTitle, status,
14847                                            
14848                                            start, end, orderByComparator
14849                                    };
14850                    }
14851    
14852                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14853                                    finderArgs, this);
14854    
14855                    if ((list != null) && !list.isEmpty()) {
14856                            for (JournalArticle journalArticle : list) {
14857                                    if ((groupId != journalArticle.getGroupId()) ||
14858                                                    !Validator.equals(urlTitle, journalArticle.getUrlTitle()) ||
14859                                                    (status != journalArticle.getStatus())) {
14860                                            list = null;
14861    
14862                                            break;
14863                                    }
14864                            }
14865                    }
14866    
14867                    if (list == null) {
14868                            StringBundler query = null;
14869    
14870                            if (orderByComparator != null) {
14871                                    query = new StringBundler(5 +
14872                                                    (orderByComparator.getOrderByFields().length * 3));
14873                            }
14874                            else {
14875                                    query = new StringBundler(5);
14876                            }
14877    
14878                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14879    
14880                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
14881    
14882                            if (urlTitle == null) {
14883                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
14884                            }
14885                            else {
14886                                    if (urlTitle.equals(StringPool.BLANK)) {
14887                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
14888                                    }
14889                                    else {
14890                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
14891                                    }
14892                            }
14893    
14894                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
14895    
14896                            if (orderByComparator != null) {
14897                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14898                                            orderByComparator);
14899                            }
14900    
14901                            else {
14902                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14903                            }
14904    
14905                            String sql = query.toString();
14906    
14907                            Session session = null;
14908    
14909                            try {
14910                                    session = openSession();
14911    
14912                                    Query q = session.createQuery(sql);
14913    
14914                                    QueryPos qPos = QueryPos.getInstance(q);
14915    
14916                                    qPos.add(groupId);
14917    
14918                                    if (urlTitle != null) {
14919                                            qPos.add(urlTitle);
14920                                    }
14921    
14922                                    qPos.add(status);
14923    
14924                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
14925                                                    start, end);
14926                            }
14927                            catch (Exception e) {
14928                                    throw processException(e);
14929                            }
14930                            finally {
14931                                    if (list == null) {
14932                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
14933                                    }
14934                                    else {
14935                                            cacheResult(list);
14936    
14937                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
14938                                    }
14939    
14940                                    closeSession(session);
14941                            }
14942                    }
14943    
14944                    return list;
14945            }
14946    
14947            /**
14948             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14949             *
14950             * @param groupId the group ID
14951             * @param urlTitle the url title
14952             * @param status the status
14953             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14954             * @return the first matching journal article
14955             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14956             * @throws SystemException if a system exception occurred
14957             */
14958            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
14959                    int status, OrderByComparator orderByComparator)
14960                    throws NoSuchArticleException, SystemException {
14961                    JournalArticle journalArticle = fetchByG_UT_ST_First(groupId, urlTitle,
14962                                    status, orderByComparator);
14963    
14964                    if (journalArticle != null) {
14965                            return journalArticle;
14966                    }
14967    
14968                    StringBundler msg = new StringBundler(8);
14969    
14970                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14971    
14972                    msg.append("groupId=");
14973                    msg.append(groupId);
14974    
14975                    msg.append(", urlTitle=");
14976                    msg.append(urlTitle);
14977    
14978                    msg.append(", status=");
14979                    msg.append(status);
14980    
14981                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14982    
14983                    throw new NoSuchArticleException(msg.toString());
14984            }
14985    
14986            /**
14987             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
14988             *
14989             * @param groupId the group ID
14990             * @param urlTitle the url title
14991             * @param status the status
14992             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14993             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
14994             * @throws SystemException if a system exception occurred
14995             */
14996            public JournalArticle fetchByG_UT_ST_First(long groupId, String urlTitle,
14997                    int status, OrderByComparator orderByComparator)
14998                    throws SystemException {
14999                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
15000                                    1, orderByComparator);
15001    
15002                    if (!list.isEmpty()) {
15003                            return list.get(0);
15004                    }
15005    
15006                    return null;
15007            }
15008    
15009            /**
15010             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
15011             *
15012             * @param groupId the group ID
15013             * @param urlTitle the url title
15014             * @param status the status
15015             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15016             * @return the last matching journal article
15017             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15018             * @throws SystemException if a system exception occurred
15019             */
15020            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
15021                    int status, OrderByComparator orderByComparator)
15022                    throws NoSuchArticleException, SystemException {
15023                    JournalArticle journalArticle = fetchByG_UT_ST_Last(groupId, urlTitle,
15024                                    status, orderByComparator);
15025    
15026                    if (journalArticle != null) {
15027                            return journalArticle;
15028                    }
15029    
15030                    StringBundler msg = new StringBundler(8);
15031    
15032                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15033    
15034                    msg.append("groupId=");
15035                    msg.append(groupId);
15036    
15037                    msg.append(", urlTitle=");
15038                    msg.append(urlTitle);
15039    
15040                    msg.append(", status=");
15041                    msg.append(status);
15042    
15043                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15044    
15045                    throw new NoSuchArticleException(msg.toString());
15046            }
15047    
15048            /**
15049             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
15050             *
15051             * @param groupId the group ID
15052             * @param urlTitle the url title
15053             * @param status the status
15054             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15055             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15056             * @throws SystemException if a system exception occurred
15057             */
15058            public JournalArticle fetchByG_UT_ST_Last(long groupId, String urlTitle,
15059                    int status, OrderByComparator orderByComparator)
15060                    throws SystemException {
15061                    int count = countByG_UT_ST(groupId, urlTitle, status);
15062    
15063                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
15064                                    count - 1, count, orderByComparator);
15065    
15066                    if (!list.isEmpty()) {
15067                            return list.get(0);
15068                    }
15069    
15070                    return null;
15071            }
15072    
15073            /**
15074             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
15075             *
15076             * @param id the primary key of the current journal article
15077             * @param groupId the group ID
15078             * @param urlTitle the url title
15079             * @param status the status
15080             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15081             * @return the previous, current, and next journal article
15082             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15083             * @throws SystemException if a system exception occurred
15084             */
15085            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
15086                    String urlTitle, int status, OrderByComparator orderByComparator)
15087                    throws NoSuchArticleException, SystemException {
15088                    JournalArticle journalArticle = findByPrimaryKey(id);
15089    
15090                    Session session = null;
15091    
15092                    try {
15093                            session = openSession();
15094    
15095                            JournalArticle[] array = new JournalArticleImpl[3];
15096    
15097                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
15098                                            groupId, urlTitle, status, orderByComparator, true);
15099    
15100                            array[1] = journalArticle;
15101    
15102                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
15103                                            groupId, urlTitle, status, orderByComparator, false);
15104    
15105                            return array;
15106                    }
15107                    catch (Exception e) {
15108                            throw processException(e);
15109                    }
15110                    finally {
15111                            closeSession(session);
15112                    }
15113            }
15114    
15115            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
15116                    JournalArticle journalArticle, long groupId, String urlTitle,
15117                    int status, OrderByComparator orderByComparator, boolean previous) {
15118                    StringBundler query = null;
15119    
15120                    if (orderByComparator != null) {
15121                            query = new StringBundler(6 +
15122                                            (orderByComparator.getOrderByFields().length * 6));
15123                    }
15124                    else {
15125                            query = new StringBundler(3);
15126                    }
15127    
15128                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15129    
15130                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
15131    
15132                    if (urlTitle == null) {
15133                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
15134                    }
15135                    else {
15136                            if (urlTitle.equals(StringPool.BLANK)) {
15137                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
15138                            }
15139                            else {
15140                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
15141                            }
15142                    }
15143    
15144                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
15145    
15146                    if (orderByComparator != null) {
15147                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15148    
15149                            if (orderByConditionFields.length > 0) {
15150                                    query.append(WHERE_AND);
15151                            }
15152    
15153                            for (int i = 0; i < orderByConditionFields.length; i++) {
15154                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15155                                    query.append(orderByConditionFields[i]);
15156    
15157                                    if ((i + 1) < orderByConditionFields.length) {
15158                                            if (orderByComparator.isAscending() ^ previous) {
15159                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15160                                            }
15161                                            else {
15162                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15163                                            }
15164                                    }
15165                                    else {
15166                                            if (orderByComparator.isAscending() ^ previous) {
15167                                                    query.append(WHERE_GREATER_THAN);
15168                                            }
15169                                            else {
15170                                                    query.append(WHERE_LESSER_THAN);
15171                                            }
15172                                    }
15173                            }
15174    
15175                            query.append(ORDER_BY_CLAUSE);
15176    
15177                            String[] orderByFields = orderByComparator.getOrderByFields();
15178    
15179                            for (int i = 0; i < orderByFields.length; i++) {
15180                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15181                                    query.append(orderByFields[i]);
15182    
15183                                    if ((i + 1) < orderByFields.length) {
15184                                            if (orderByComparator.isAscending() ^ previous) {
15185                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15186                                            }
15187                                            else {
15188                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15189                                            }
15190                                    }
15191                                    else {
15192                                            if (orderByComparator.isAscending() ^ previous) {
15193                                                    query.append(ORDER_BY_ASC);
15194                                            }
15195                                            else {
15196                                                    query.append(ORDER_BY_DESC);
15197                                            }
15198                                    }
15199                            }
15200                    }
15201    
15202                    else {
15203                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15204                    }
15205    
15206                    String sql = query.toString();
15207    
15208                    Query q = session.createQuery(sql);
15209    
15210                    q.setFirstResult(0);
15211                    q.setMaxResults(2);
15212    
15213                    QueryPos qPos = QueryPos.getInstance(q);
15214    
15215                    qPos.add(groupId);
15216    
15217                    if (urlTitle != null) {
15218                            qPos.add(urlTitle);
15219                    }
15220    
15221                    qPos.add(status);
15222    
15223                    if (orderByComparator != null) {
15224                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15225    
15226                            for (Object value : values) {
15227                                    qPos.add(value);
15228                            }
15229                    }
15230    
15231                    List<JournalArticle> list = q.list();
15232    
15233                    if (list.size() == 2) {
15234                            return list.get(1);
15235                    }
15236                    else {
15237                            return null;
15238                    }
15239            }
15240    
15241            /**
15242             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
15243             *
15244             * @param groupId the group ID
15245             * @param urlTitle the url title
15246             * @param status the status
15247             * @return the matching journal articles that the user has permission to view
15248             * @throws SystemException if a system exception occurred
15249             */
15250            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
15251                    String urlTitle, int status) throws SystemException {
15252                    return filterFindByG_UT_ST(groupId, urlTitle, status,
15253                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15254            }
15255    
15256            /**
15257             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
15258             *
15259             * <p>
15260             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15261             * </p>
15262             *
15263             * @param groupId the group ID
15264             * @param urlTitle the url title
15265             * @param status the status
15266             * @param start the lower bound of the range of journal articles
15267             * @param end the upper bound of the range of journal articles (not inclusive)
15268             * @return the range of matching journal articles that the user has permission to view
15269             * @throws SystemException if a system exception occurred
15270             */
15271            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
15272                    String urlTitle, int status, int start, int end)
15273                    throws SystemException {
15274                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
15275            }
15276    
15277            /**
15278             * 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;.
15279             *
15280             * <p>
15281             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15282             * </p>
15283             *
15284             * @param groupId the group ID
15285             * @param urlTitle the url title
15286             * @param status the status
15287             * @param start the lower bound of the range of journal articles
15288             * @param end the upper bound of the range of journal articles (not inclusive)
15289             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15290             * @return the ordered range of matching journal articles that the user has permission to view
15291             * @throws SystemException if a system exception occurred
15292             */
15293            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
15294                    String urlTitle, int status, int start, int end,
15295                    OrderByComparator orderByComparator) throws SystemException {
15296                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15297                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
15298                                    orderByComparator);
15299                    }
15300    
15301                    StringBundler query = null;
15302    
15303                    if (orderByComparator != null) {
15304                            query = new StringBundler(5 +
15305                                            (orderByComparator.getOrderByFields().length * 3));
15306                    }
15307                    else {
15308                            query = new StringBundler(5);
15309                    }
15310    
15311                    if (getDB().isSupportsInlineDistinct()) {
15312                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15313                    }
15314                    else {
15315                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15316                    }
15317    
15318                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
15319    
15320                    if (urlTitle == null) {
15321                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
15322                    }
15323                    else {
15324                            if (urlTitle.equals(StringPool.BLANK)) {
15325                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
15326                            }
15327                            else {
15328                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
15329                            }
15330                    }
15331    
15332                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
15333    
15334                    if (!getDB().isSupportsInlineDistinct()) {
15335                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15336                    }
15337    
15338                    if (orderByComparator != null) {
15339                            if (getDB().isSupportsInlineDistinct()) {
15340                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15341                                            orderByComparator);
15342                            }
15343                            else {
15344                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15345                                            orderByComparator);
15346                            }
15347                    }
15348    
15349                    else {
15350                            if (getDB().isSupportsInlineDistinct()) {
15351                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15352                            }
15353                            else {
15354                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15355                            }
15356                    }
15357    
15358                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15359                                    JournalArticle.class.getName(),
15360                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15361    
15362                    Session session = null;
15363    
15364                    try {
15365                            session = openSession();
15366    
15367                            SQLQuery q = session.createSQLQuery(sql);
15368    
15369                            if (getDB().isSupportsInlineDistinct()) {
15370                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15371                            }
15372                            else {
15373                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15374                            }
15375    
15376                            QueryPos qPos = QueryPos.getInstance(q);
15377    
15378                            qPos.add(groupId);
15379    
15380                            if (urlTitle != null) {
15381                                    qPos.add(urlTitle);
15382                            }
15383    
15384                            qPos.add(status);
15385    
15386                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
15387                                    end);
15388                    }
15389                    catch (Exception e) {
15390                            throw processException(e);
15391                    }
15392                    finally {
15393                            closeSession(session);
15394                    }
15395            }
15396    
15397            /**
15398             * 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;.
15399             *
15400             * @param id the primary key of the current journal article
15401             * @param groupId the group ID
15402             * @param urlTitle the url title
15403             * @param status the status
15404             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15405             * @return the previous, current, and next journal article
15406             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15407             * @throws SystemException if a system exception occurred
15408             */
15409            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
15410                    long groupId, String urlTitle, int status,
15411                    OrderByComparator orderByComparator)
15412                    throws NoSuchArticleException, SystemException {
15413                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15414                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
15415                                    orderByComparator);
15416                    }
15417    
15418                    JournalArticle journalArticle = findByPrimaryKey(id);
15419    
15420                    Session session = null;
15421    
15422                    try {
15423                            session = openSession();
15424    
15425                            JournalArticle[] array = new JournalArticleImpl[3];
15426    
15427                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
15428                                            groupId, urlTitle, status, orderByComparator, true);
15429    
15430                            array[1] = journalArticle;
15431    
15432                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
15433                                            groupId, urlTitle, status, orderByComparator, false);
15434    
15435                            return array;
15436                    }
15437                    catch (Exception e) {
15438                            throw processException(e);
15439                    }
15440                    finally {
15441                            closeSession(session);
15442                    }
15443            }
15444    
15445            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
15446                    JournalArticle journalArticle, long groupId, String urlTitle,
15447                    int status, OrderByComparator orderByComparator, boolean previous) {
15448                    StringBundler query = null;
15449    
15450                    if (orderByComparator != null) {
15451                            query = new StringBundler(6 +
15452                                            (orderByComparator.getOrderByFields().length * 6));
15453                    }
15454                    else {
15455                            query = new StringBundler(3);
15456                    }
15457    
15458                    if (getDB().isSupportsInlineDistinct()) {
15459                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
15460                    }
15461                    else {
15462                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
15463                    }
15464    
15465                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
15466    
15467                    if (urlTitle == null) {
15468                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
15469                    }
15470                    else {
15471                            if (urlTitle.equals(StringPool.BLANK)) {
15472                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
15473                            }
15474                            else {
15475                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
15476                            }
15477                    }
15478    
15479                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
15480    
15481                    if (!getDB().isSupportsInlineDistinct()) {
15482                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
15483                    }
15484    
15485                    if (orderByComparator != null) {
15486                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15487    
15488                            if (orderByConditionFields.length > 0) {
15489                                    query.append(WHERE_AND);
15490                            }
15491    
15492                            for (int i = 0; i < orderByConditionFields.length; i++) {
15493                                    if (getDB().isSupportsInlineDistinct()) {
15494                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15495                                    }
15496                                    else {
15497                                            query.append(_ORDER_BY_ENTITY_TABLE);
15498                                    }
15499    
15500                                    query.append(orderByConditionFields[i]);
15501    
15502                                    if ((i + 1) < orderByConditionFields.length) {
15503                                            if (orderByComparator.isAscending() ^ previous) {
15504                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15505                                            }
15506                                            else {
15507                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15508                                            }
15509                                    }
15510                                    else {
15511                                            if (orderByComparator.isAscending() ^ previous) {
15512                                                    query.append(WHERE_GREATER_THAN);
15513                                            }
15514                                            else {
15515                                                    query.append(WHERE_LESSER_THAN);
15516                                            }
15517                                    }
15518                            }
15519    
15520                            query.append(ORDER_BY_CLAUSE);
15521    
15522                            String[] orderByFields = orderByComparator.getOrderByFields();
15523    
15524                            for (int i = 0; i < orderByFields.length; i++) {
15525                                    if (getDB().isSupportsInlineDistinct()) {
15526                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15527                                    }
15528                                    else {
15529                                            query.append(_ORDER_BY_ENTITY_TABLE);
15530                                    }
15531    
15532                                    query.append(orderByFields[i]);
15533    
15534                                    if ((i + 1) < orderByFields.length) {
15535                                            if (orderByComparator.isAscending() ^ previous) {
15536                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15537                                            }
15538                                            else {
15539                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15540                                            }
15541                                    }
15542                                    else {
15543                                            if (orderByComparator.isAscending() ^ previous) {
15544                                                    query.append(ORDER_BY_ASC);
15545                                            }
15546                                            else {
15547                                                    query.append(ORDER_BY_DESC);
15548                                            }
15549                                    }
15550                            }
15551                    }
15552    
15553                    else {
15554                            if (getDB().isSupportsInlineDistinct()) {
15555                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15556                            }
15557                            else {
15558                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
15559                            }
15560                    }
15561    
15562                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15563                                    JournalArticle.class.getName(),
15564                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15565    
15566                    SQLQuery q = session.createSQLQuery(sql);
15567    
15568                    q.setFirstResult(0);
15569                    q.setMaxResults(2);
15570    
15571                    if (getDB().isSupportsInlineDistinct()) {
15572                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
15573                    }
15574                    else {
15575                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
15576                    }
15577    
15578                    QueryPos qPos = QueryPos.getInstance(q);
15579    
15580                    qPos.add(groupId);
15581    
15582                    if (urlTitle != null) {
15583                            qPos.add(urlTitle);
15584                    }
15585    
15586                    qPos.add(status);
15587    
15588                    if (orderByComparator != null) {
15589                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
15590    
15591                            for (Object value : values) {
15592                                    qPos.add(value);
15593                            }
15594                    }
15595    
15596                    List<JournalArticle> list = q.list();
15597    
15598                    if (list.size() == 2) {
15599                            return list.get(1);
15600                    }
15601                    else {
15602                            return null;
15603                    }
15604            }
15605    
15606            /**
15607             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
15608             *
15609             * @param companyId the company ID
15610             * @param version the version
15611             * @param status the status
15612             * @return the matching journal articles
15613             * @throws SystemException if a system exception occurred
15614             */
15615            public List<JournalArticle> findByC_V_ST(long companyId, double version,
15616                    int status) throws SystemException {
15617                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
15618                            QueryUtil.ALL_POS, null);
15619            }
15620    
15621            /**
15622             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
15623             *
15624             * <p>
15625             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15626             * </p>
15627             *
15628             * @param companyId the company ID
15629             * @param version the version
15630             * @param status the status
15631             * @param start the lower bound of the range of journal articles
15632             * @param end the upper bound of the range of journal articles (not inclusive)
15633             * @return the range of matching journal articles
15634             * @throws SystemException if a system exception occurred
15635             */
15636            public List<JournalArticle> findByC_V_ST(long companyId, double version,
15637                    int status, int start, int end) throws SystemException {
15638                    return findByC_V_ST(companyId, version, status, start, end, null);
15639            }
15640    
15641            /**
15642             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
15643             *
15644             * <p>
15645             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15646             * </p>
15647             *
15648             * @param companyId the company ID
15649             * @param version the version
15650             * @param status the status
15651             * @param start the lower bound of the range of journal articles
15652             * @param end the upper bound of the range of journal articles (not inclusive)
15653             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15654             * @return the ordered range of matching journal articles
15655             * @throws SystemException if a system exception occurred
15656             */
15657            public List<JournalArticle> findByC_V_ST(long companyId, double version,
15658                    int status, int start, int end, OrderByComparator orderByComparator)
15659                    throws SystemException {
15660                    FinderPath finderPath = null;
15661                    Object[] finderArgs = null;
15662    
15663                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15664                                    (orderByComparator == null)) {
15665                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
15666                            finderArgs = new Object[] { companyId, version, status };
15667                    }
15668                    else {
15669                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
15670                            finderArgs = new Object[] {
15671                                            companyId, version, status,
15672                                            
15673                                            start, end, orderByComparator
15674                                    };
15675                    }
15676    
15677                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
15678                                    finderArgs, this);
15679    
15680                    if ((list != null) && !list.isEmpty()) {
15681                            for (JournalArticle journalArticle : list) {
15682                                    if ((companyId != journalArticle.getCompanyId()) ||
15683                                                    (version != journalArticle.getVersion()) ||
15684                                                    (status != journalArticle.getStatus())) {
15685                                            list = null;
15686    
15687                                            break;
15688                                    }
15689                            }
15690                    }
15691    
15692                    if (list == null) {
15693                            StringBundler query = null;
15694    
15695                            if (orderByComparator != null) {
15696                                    query = new StringBundler(5 +
15697                                                    (orderByComparator.getOrderByFields().length * 3));
15698                            }
15699                            else {
15700                                    query = new StringBundler(5);
15701                            }
15702    
15703                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15704    
15705                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
15706    
15707                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
15708    
15709                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
15710    
15711                            if (orderByComparator != null) {
15712                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15713                                            orderByComparator);
15714                            }
15715    
15716                            else {
15717                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
15718                            }
15719    
15720                            String sql = query.toString();
15721    
15722                            Session session = null;
15723    
15724                            try {
15725                                    session = openSession();
15726    
15727                                    Query q = session.createQuery(sql);
15728    
15729                                    QueryPos qPos = QueryPos.getInstance(q);
15730    
15731                                    qPos.add(companyId);
15732    
15733                                    qPos.add(version);
15734    
15735                                    qPos.add(status);
15736    
15737                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
15738                                                    start, end);
15739                            }
15740                            catch (Exception e) {
15741                                    throw processException(e);
15742                            }
15743                            finally {
15744                                    if (list == null) {
15745                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
15746                                    }
15747                                    else {
15748                                            cacheResult(list);
15749    
15750                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
15751                                    }
15752    
15753                                    closeSession(session);
15754                            }
15755                    }
15756    
15757                    return list;
15758            }
15759    
15760            /**
15761             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
15762             *
15763             * @param companyId the company ID
15764             * @param version the version
15765             * @param status the status
15766             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15767             * @return the first matching journal article
15768             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15769             * @throws SystemException if a system exception occurred
15770             */
15771            public JournalArticle findByC_V_ST_First(long companyId, double version,
15772                    int status, OrderByComparator orderByComparator)
15773                    throws NoSuchArticleException, SystemException {
15774                    JournalArticle journalArticle = fetchByC_V_ST_First(companyId, version,
15775                                    status, orderByComparator);
15776    
15777                    if (journalArticle != null) {
15778                            return journalArticle;
15779                    }
15780    
15781                    StringBundler msg = new StringBundler(8);
15782    
15783                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15784    
15785                    msg.append("companyId=");
15786                    msg.append(companyId);
15787    
15788                    msg.append(", version=");
15789                    msg.append(version);
15790    
15791                    msg.append(", status=");
15792                    msg.append(status);
15793    
15794                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15795    
15796                    throw new NoSuchArticleException(msg.toString());
15797            }
15798    
15799            /**
15800             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
15801             *
15802             * @param companyId the company ID
15803             * @param version the version
15804             * @param status the status
15805             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15806             * @return the first matching journal article, or <code>null</code> if a matching journal article could not be found
15807             * @throws SystemException if a system exception occurred
15808             */
15809            public JournalArticle fetchByC_V_ST_First(long companyId, double version,
15810                    int status, OrderByComparator orderByComparator)
15811                    throws SystemException {
15812                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
15813                                    1, orderByComparator);
15814    
15815                    if (!list.isEmpty()) {
15816                            return list.get(0);
15817                    }
15818    
15819                    return null;
15820            }
15821    
15822            /**
15823             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
15824             *
15825             * @param companyId the company ID
15826             * @param version the version
15827             * @param status the status
15828             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15829             * @return the last matching journal article
15830             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
15831             * @throws SystemException if a system exception occurred
15832             */
15833            public JournalArticle findByC_V_ST_Last(long companyId, double version,
15834                    int status, OrderByComparator orderByComparator)
15835                    throws NoSuchArticleException, SystemException {
15836                    JournalArticle journalArticle = fetchByC_V_ST_Last(companyId, version,
15837                                    status, orderByComparator);
15838    
15839                    if (journalArticle != null) {
15840                            return journalArticle;
15841                    }
15842    
15843                    StringBundler msg = new StringBundler(8);
15844    
15845                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15846    
15847                    msg.append("companyId=");
15848                    msg.append(companyId);
15849    
15850                    msg.append(", version=");
15851                    msg.append(version);
15852    
15853                    msg.append(", status=");
15854                    msg.append(status);
15855    
15856                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15857    
15858                    throw new NoSuchArticleException(msg.toString());
15859            }
15860    
15861            /**
15862             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
15863             *
15864             * @param companyId the company ID
15865             * @param version the version
15866             * @param status the status
15867             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15868             * @return the last matching journal article, or <code>null</code> if a matching journal article could not be found
15869             * @throws SystemException if a system exception occurred
15870             */
15871            public JournalArticle fetchByC_V_ST_Last(long companyId, double version,
15872                    int status, OrderByComparator orderByComparator)
15873                    throws SystemException {
15874                    int count = countByC_V_ST(companyId, version, status);
15875    
15876                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
15877                                    count - 1, count, orderByComparator);
15878    
15879                    if (!list.isEmpty()) {
15880                            return list.get(0);
15881                    }
15882    
15883                    return null;
15884            }
15885    
15886            /**
15887             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
15888             *
15889             * @param id the primary key of the current journal article
15890             * @param companyId the company ID
15891             * @param version the version
15892             * @param status the status
15893             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15894             * @return the previous, current, and next journal article
15895             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
15896             * @throws SystemException if a system exception occurred
15897             */
15898            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
15899                    double version, int status, OrderByComparator orderByComparator)
15900                    throws NoSuchArticleException, SystemException {
15901                    JournalArticle journalArticle = findByPrimaryKey(id);
15902    
15903                    Session session = null;
15904    
15905                    try {
15906                            session = openSession();
15907    
15908                            JournalArticle[] array = new JournalArticleImpl[3];
15909    
15910                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
15911                                            companyId, version, status, orderByComparator, true);
15912    
15913                            array[1] = journalArticle;
15914    
15915                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
15916                                            companyId, version, status, orderByComparator, false);
15917    
15918                            return array;
15919                    }
15920                    catch (Exception e) {
15921                            throw processException(e);
15922                    }
15923                    finally {
15924                            closeSession(session);
15925                    }
15926            }
15927    
15928            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
15929                    JournalArticle journalArticle, long companyId, double version,
15930                    int status, OrderByComparator orderByComparator, boolean previous) {
15931                    StringBundler query = null;
15932    
15933                    if (orderByComparator != null) {
15934                            query = new StringBundler(6 +
15935                                            (orderByComparator.getOrderByFields().length * 6));
15936                    }
15937                    else {
15938                            query = new StringBundler(3);
15939                    }
15940    
15941                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
15942    
15943                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
15944    
15945                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
15946    
15947                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
15948    
15949                    if (orderByComparator != null) {
15950                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15951    
15952                            if (orderByConditionFields.length > 0) {
15953                                    query.append(WHERE_AND);
15954                            }
15955    
15956                            for (int i = 0; i < orderByConditionFields.length; i++) {
15957                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15958                                    query.append(orderByConditionFields[i]);
15959    
15960                                    if ((i + 1) < orderByConditionFields.length) {
15961                                            if (orderByComparator.isAscending() ^ previous) {
15962                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15963                                            }
15964                                            else {
15965                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15966                                            }
15967                                    }
15968                                    else {
15969                                            if (orderByComparator.isAscending() ^ previous) {
15970                                                    query.append(WHERE_GREATER_THAN);
15971                                            }
15972                                            else {
15973                                                    query.append(WHERE_LESSER_THAN);
15974                                            }
15975                                    }
15976                            }
15977    
15978                            query.append(ORDER_BY_CLAUSE);
15979    
15980                            String[] orderByFields = orderByComparator.getOrderByFields();
15981    
15982                            for (int i = 0; i < orderByFields.length; i++) {
15983                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15984                                    query.append(orderByFields[i]);
15985    
15986                                    if ((i + 1) < orderByFields.length) {
15987                                            if (orderByComparator.isAscending() ^ previous) {
15988                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15989                                            }
15990                                            else {
15991                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15992                                            }
15993                                    }
15994                                    else {
15995                                            if (orderByComparator.isAscending() ^ previous) {
15996                                                    query.append(ORDER_BY_ASC);
15997                                            }
15998                                            else {
15999                                                    query.append(ORDER_BY_DESC);
16000                                            }
16001                                    }
16002                            }
16003                    }
16004    
16005                    else {
16006                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
16007                    }
16008    
16009                    String sql = query.toString();
16010    
16011                    Query q = session.createQuery(sql);
16012    
16013                    q.setFirstResult(0);
16014                    q.setMaxResults(2);
16015    
16016                    QueryPos qPos = QueryPos.getInstance(q);
16017    
16018                    qPos.add(companyId);
16019    
16020                    qPos.add(version);
16021    
16022                    qPos.add(status);
16023    
16024                    if (orderByComparator != null) {
16025                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
16026    
16027                            for (Object value : values) {
16028                                    qPos.add(value);
16029                            }
16030                    }
16031    
16032                    List<JournalArticle> list = q.list();
16033    
16034                    if (list.size() == 2) {
16035                            return list.get(1);
16036                    }
16037                    else {
16038                            return null;
16039                    }
16040            }
16041    
16042            /**
16043             * Returns all the journal articles.
16044             *
16045             * @return the journal articles
16046             * @throws SystemException if a system exception occurred
16047             */
16048            public List<JournalArticle> findAll() throws SystemException {
16049                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16050            }
16051    
16052            /**
16053             * Returns a range of all the journal articles.
16054             *
16055             * <p>
16056             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
16057             * </p>
16058             *
16059             * @param start the lower bound of the range of journal articles
16060             * @param end the upper bound of the range of journal articles (not inclusive)
16061             * @return the range of journal articles
16062             * @throws SystemException if a system exception occurred
16063             */
16064            public List<JournalArticle> findAll(int start, int end)
16065                    throws SystemException {
16066                    return findAll(start, end, null);
16067            }
16068    
16069            /**
16070             * Returns an ordered range of all the journal articles.
16071             *
16072             * <p>
16073             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
16074             * </p>
16075             *
16076             * @param start the lower bound of the range of journal articles
16077             * @param end the upper bound of the range of journal articles (not inclusive)
16078             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16079             * @return the ordered range of journal articles
16080             * @throws SystemException if a system exception occurred
16081             */
16082            public List<JournalArticle> findAll(int start, int end,
16083                    OrderByComparator orderByComparator) throws SystemException {
16084                    FinderPath finderPath = null;
16085                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
16086    
16087                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
16088                                    (orderByComparator == null)) {
16089                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
16090                            finderArgs = FINDER_ARGS_EMPTY;
16091                    }
16092                    else {
16093                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
16094                            finderArgs = new Object[] { start, end, orderByComparator };
16095                    }
16096    
16097                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
16098                                    finderArgs, this);
16099    
16100                    if (list == null) {
16101                            StringBundler query = null;
16102                            String sql = null;
16103    
16104                            if (orderByComparator != null) {
16105                                    query = new StringBundler(2 +
16106                                                    (orderByComparator.getOrderByFields().length * 3));
16107    
16108                                    query.append(_SQL_SELECT_JOURNALARTICLE);
16109    
16110                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16111                                            orderByComparator);
16112    
16113                                    sql = query.toString();
16114                            }
16115                            else {
16116                                    sql = _SQL_SELECT_JOURNALARTICLE.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
16117                            }
16118    
16119                            Session session = null;
16120    
16121                            try {
16122                                    session = openSession();
16123    
16124                                    Query q = session.createQuery(sql);
16125    
16126                                    if (orderByComparator == null) {
16127                                            list = (List<JournalArticle>)QueryUtil.list(q,
16128                                                            getDialect(), start, end, false);
16129    
16130                                            Collections.sort(list);
16131                                    }
16132                                    else {
16133                                            list = (List<JournalArticle>)QueryUtil.list(q,
16134                                                            getDialect(), start, end);
16135                                    }
16136                            }
16137                            catch (Exception e) {
16138                                    throw processException(e);
16139                            }
16140                            finally {
16141                                    if (list == null) {
16142                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
16143                                    }
16144                                    else {
16145                                            cacheResult(list);
16146    
16147                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
16148                                    }
16149    
16150                                    closeSession(session);
16151                            }
16152                    }
16153    
16154                    return list;
16155            }
16156    
16157            /**
16158             * Removes all the journal articles where uuid = &#63; from the database.
16159             *
16160             * @param uuid the uuid
16161             * @throws SystemException if a system exception occurred
16162             */
16163            public void removeByUuid(String uuid) throws SystemException {
16164                    for (JournalArticle journalArticle : findByUuid(uuid)) {
16165                            remove(journalArticle);
16166                    }
16167            }
16168    
16169            /**
16170             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
16171             *
16172             * @param uuid the uuid
16173             * @param groupId the group ID
16174             * @return the journal article that was removed
16175             * @throws SystemException if a system exception occurred
16176             */
16177            public JournalArticle removeByUUID_G(String uuid, long groupId)
16178                    throws NoSuchArticleException, SystemException {
16179                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
16180    
16181                    return remove(journalArticle);
16182            }
16183    
16184            /**
16185             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
16186             *
16187             * @param resourcePrimKey the resource prim key
16188             * @throws SystemException if a system exception occurred
16189             */
16190            public void removeByResourcePrimKey(long resourcePrimKey)
16191                    throws SystemException {
16192                    for (JournalArticle journalArticle : findByResourcePrimKey(
16193                                    resourcePrimKey)) {
16194                            remove(journalArticle);
16195                    }
16196            }
16197    
16198            /**
16199             * Removes all the journal articles where groupId = &#63; from the database.
16200             *
16201             * @param groupId the group ID
16202             * @throws SystemException if a system exception occurred
16203             */
16204            public void removeByGroupId(long groupId) throws SystemException {
16205                    for (JournalArticle journalArticle : findByGroupId(groupId)) {
16206                            remove(journalArticle);
16207                    }
16208            }
16209    
16210            /**
16211             * Removes all the journal articles where companyId = &#63; from the database.
16212             *
16213             * @param companyId the company ID
16214             * @throws SystemException if a system exception occurred
16215             */
16216            public void removeByCompanyId(long companyId) throws SystemException {
16217                    for (JournalArticle journalArticle : findByCompanyId(companyId)) {
16218                            remove(journalArticle);
16219                    }
16220            }
16221    
16222            /**
16223             * Removes all the journal articles where structureId = &#63; from the database.
16224             *
16225             * @param structureId the structure ID
16226             * @throws SystemException if a system exception occurred
16227             */
16228            public void removeByStructureId(String structureId)
16229                    throws SystemException {
16230                    for (JournalArticle journalArticle : findByStructureId(structureId)) {
16231                            remove(journalArticle);
16232                    }
16233            }
16234    
16235            /**
16236             * Removes all the journal articles where templateId = &#63; from the database.
16237             *
16238             * @param templateId the template ID
16239             * @throws SystemException if a system exception occurred
16240             */
16241            public void removeByTemplateId(String templateId) throws SystemException {
16242                    for (JournalArticle journalArticle : findByTemplateId(templateId)) {
16243                            remove(journalArticle);
16244                    }
16245            }
16246    
16247            /**
16248             * Removes all the journal articles where smallImageId = &#63; from the database.
16249             *
16250             * @param smallImageId the small image ID
16251             * @throws SystemException if a system exception occurred
16252             */
16253            public void removeBySmallImageId(long smallImageId)
16254                    throws SystemException {
16255                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId)) {
16256                            remove(journalArticle);
16257                    }
16258            }
16259    
16260            /**
16261             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
16262             *
16263             * @param resourcePrimKey the resource prim key
16264             * @param status the status
16265             * @throws SystemException if a system exception occurred
16266             */
16267            public void removeByR_ST(long resourcePrimKey, int status)
16268                    throws SystemException {
16269                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey, status)) {
16270                            remove(journalArticle);
16271                    }
16272            }
16273    
16274            /**
16275             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
16276             *
16277             * @param groupId the group ID
16278             * @param articleId the article ID
16279             * @throws SystemException if a system exception occurred
16280             */
16281            public void removeByG_A(long groupId, String articleId)
16282                    throws SystemException {
16283                    for (JournalArticle journalArticle : findByG_A(groupId, articleId)) {
16284                            remove(journalArticle);
16285                    }
16286            }
16287    
16288            /**
16289             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
16290             *
16291             * @param groupId the group ID
16292             * @param urlTitle the url title
16293             * @throws SystemException if a system exception occurred
16294             */
16295            public void removeByG_UT(long groupId, String urlTitle)
16296                    throws SystemException {
16297                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle)) {
16298                            remove(journalArticle);
16299                    }
16300            }
16301    
16302            /**
16303             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
16304             *
16305             * @param groupId the group ID
16306             * @param structureId the structure ID
16307             * @throws SystemException if a system exception occurred
16308             */
16309            public void removeByG_S(long groupId, String structureId)
16310                    throws SystemException {
16311                    for (JournalArticle journalArticle : findByG_S(groupId, structureId)) {
16312                            remove(journalArticle);
16313                    }
16314            }
16315    
16316            /**
16317             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
16318             *
16319             * @param groupId the group ID
16320             * @param templateId the template ID
16321             * @throws SystemException if a system exception occurred
16322             */
16323            public void removeByG_T(long groupId, String templateId)
16324                    throws SystemException {
16325                    for (JournalArticle journalArticle : findByG_T(groupId, templateId)) {
16326                            remove(journalArticle);
16327                    }
16328            }
16329    
16330            /**
16331             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
16332             *
16333             * @param groupId the group ID
16334             * @param layoutUuid the layout uuid
16335             * @throws SystemException if a system exception occurred
16336             */
16337            public void removeByG_L(long groupId, String layoutUuid)
16338                    throws SystemException {
16339                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid)) {
16340                            remove(journalArticle);
16341                    }
16342            }
16343    
16344            /**
16345             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
16346             *
16347             * @param groupId the group ID
16348             * @param status the status
16349             * @throws SystemException if a system exception occurred
16350             */
16351            public void removeByG_ST(long groupId, int status)
16352                    throws SystemException {
16353                    for (JournalArticle journalArticle : findByG_ST(groupId, status)) {
16354                            remove(journalArticle);
16355                    }
16356            }
16357    
16358            /**
16359             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
16360             *
16361             * @param companyId the company ID
16362             * @param version the version
16363             * @throws SystemException if a system exception occurred
16364             */
16365            public void removeByC_V(long companyId, double version)
16366                    throws SystemException {
16367                    for (JournalArticle journalArticle : findByC_V(companyId, version)) {
16368                            remove(journalArticle);
16369                    }
16370            }
16371    
16372            /**
16373             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
16374             *
16375             * @param companyId the company ID
16376             * @param status the status
16377             * @throws SystemException if a system exception occurred
16378             */
16379            public void removeByC_ST(long companyId, int status)
16380                    throws SystemException {
16381                    for (JournalArticle journalArticle : findByC_ST(companyId, status)) {
16382                            remove(journalArticle);
16383                    }
16384            }
16385    
16386            /**
16387             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
16388             *
16389             * @param groupId the group ID
16390             * @param classNameId the class name ID
16391             * @param classPK the class p k
16392             * @throws SystemException if a system exception occurred
16393             */
16394            public void removeByG_C_C(long groupId, long classNameId, long classPK)
16395                    throws SystemException {
16396                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
16397                                    classPK)) {
16398                            remove(journalArticle);
16399                    }
16400            }
16401    
16402            /**
16403             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
16404             *
16405             * @param groupId the group ID
16406             * @param classNameId the class name ID
16407             * @param structureId the structure ID
16408             * @return the journal article that was removed
16409             * @throws SystemException if a system exception occurred
16410             */
16411            public JournalArticle removeByG_C_S(long groupId, long classNameId,
16412                    String structureId) throws NoSuchArticleException, SystemException {
16413                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
16414                                    structureId);
16415    
16416                    return remove(journalArticle);
16417            }
16418    
16419            /**
16420             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
16421             *
16422             * @param groupId the group ID
16423             * @param classNameId the class name ID
16424             * @param templateId the template ID
16425             * @throws SystemException if a system exception occurred
16426             */
16427            public void removeByG_C_T(long groupId, long classNameId, String templateId)
16428                    throws SystemException {
16429                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
16430                                    templateId)) {
16431                            remove(journalArticle);
16432                    }
16433            }
16434    
16435            /**
16436             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
16437             *
16438             * @param groupId the group ID
16439             * @param classNameId the class name ID
16440             * @param layoutUuid the layout uuid
16441             * @throws SystemException if a system exception occurred
16442             */
16443            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
16444                    throws SystemException {
16445                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
16446                                    layoutUuid)) {
16447                            remove(journalArticle);
16448                    }
16449            }
16450    
16451            /**
16452             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
16453             *
16454             * @param groupId the group ID
16455             * @param articleId the article ID
16456             * @param version the version
16457             * @return the journal article that was removed
16458             * @throws SystemException if a system exception occurred
16459             */
16460            public JournalArticle removeByG_A_V(long groupId, String articleId,
16461                    double version) throws NoSuchArticleException, SystemException {
16462                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
16463    
16464                    return remove(journalArticle);
16465            }
16466    
16467            /**
16468             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
16469             *
16470             * @param groupId the group ID
16471             * @param articleId the article ID
16472             * @param status the status
16473             * @throws SystemException if a system exception occurred
16474             */
16475            public void removeByG_A_ST(long groupId, String articleId, int status)
16476                    throws SystemException {
16477                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
16478                                    status)) {
16479                            remove(journalArticle);
16480                    }
16481            }
16482    
16483            /**
16484             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
16485             *
16486             * @param groupId the group ID
16487             * @param urlTitle the url title
16488             * @param status the status
16489             * @throws SystemException if a system exception occurred
16490             */
16491            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
16492                    throws SystemException {
16493                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
16494                                    status)) {
16495                            remove(journalArticle);
16496                    }
16497            }
16498    
16499            /**
16500             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
16501             *
16502             * @param companyId the company ID
16503             * @param version the version
16504             * @param status the status
16505             * @throws SystemException if a system exception occurred
16506             */
16507            public void removeByC_V_ST(long companyId, double version, int status)
16508                    throws SystemException {
16509                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
16510                                    status)) {
16511                            remove(journalArticle);
16512                    }
16513            }
16514    
16515            /**
16516             * Removes all the journal articles from the database.
16517             *
16518             * @throws SystemException if a system exception occurred
16519             */
16520            public void removeAll() throws SystemException {
16521                    for (JournalArticle journalArticle : findAll()) {
16522                            remove(journalArticle);
16523                    }
16524            }
16525    
16526            /**
16527             * Returns the number of journal articles where uuid = &#63;.
16528             *
16529             * @param uuid the uuid
16530             * @return the number of matching journal articles
16531             * @throws SystemException if a system exception occurred
16532             */
16533            public int countByUuid(String uuid) throws SystemException {
16534                    Object[] finderArgs = new Object[] { uuid };
16535    
16536                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
16537                                    finderArgs, this);
16538    
16539                    if (count == null) {
16540                            StringBundler query = new StringBundler(2);
16541    
16542                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16543    
16544                            if (uuid == null) {
16545                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
16546                            }
16547                            else {
16548                                    if (uuid.equals(StringPool.BLANK)) {
16549                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
16550                                    }
16551                                    else {
16552                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
16553                                    }
16554                            }
16555    
16556                            String sql = query.toString();
16557    
16558                            Session session = null;
16559    
16560                            try {
16561                                    session = openSession();
16562    
16563                                    Query q = session.createQuery(sql);
16564    
16565                                    QueryPos qPos = QueryPos.getInstance(q);
16566    
16567                                    if (uuid != null) {
16568                                            qPos.add(uuid);
16569                                    }
16570    
16571                                    count = (Long)q.uniqueResult();
16572                            }
16573                            catch (Exception e) {
16574                                    throw processException(e);
16575                            }
16576                            finally {
16577                                    if (count == null) {
16578                                            count = Long.valueOf(0);
16579                                    }
16580    
16581                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
16582                                            finderArgs, count);
16583    
16584                                    closeSession(session);
16585                            }
16586                    }
16587    
16588                    return count.intValue();
16589            }
16590    
16591            /**
16592             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
16593             *
16594             * @param uuid the uuid
16595             * @param groupId the group ID
16596             * @return the number of matching journal articles
16597             * @throws SystemException if a system exception occurred
16598             */
16599            public int countByUUID_G(String uuid, long groupId)
16600                    throws SystemException {
16601                    Object[] finderArgs = new Object[] { uuid, groupId };
16602    
16603                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
16604                                    finderArgs, this);
16605    
16606                    if (count == null) {
16607                            StringBundler query = new StringBundler(3);
16608    
16609                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16610    
16611                            if (uuid == null) {
16612                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
16613                            }
16614                            else {
16615                                    if (uuid.equals(StringPool.BLANK)) {
16616                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
16617                                    }
16618                                    else {
16619                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
16620                                    }
16621                            }
16622    
16623                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
16624    
16625                            String sql = query.toString();
16626    
16627                            Session session = null;
16628    
16629                            try {
16630                                    session = openSession();
16631    
16632                                    Query q = session.createQuery(sql);
16633    
16634                                    QueryPos qPos = QueryPos.getInstance(q);
16635    
16636                                    if (uuid != null) {
16637                                            qPos.add(uuid);
16638                                    }
16639    
16640                                    qPos.add(groupId);
16641    
16642                                    count = (Long)q.uniqueResult();
16643                            }
16644                            catch (Exception e) {
16645                                    throw processException(e);
16646                            }
16647                            finally {
16648                                    if (count == null) {
16649                                            count = Long.valueOf(0);
16650                                    }
16651    
16652                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
16653                                            finderArgs, count);
16654    
16655                                    closeSession(session);
16656                            }
16657                    }
16658    
16659                    return count.intValue();
16660            }
16661    
16662            /**
16663             * Returns the number of journal articles where resourcePrimKey = &#63;.
16664             *
16665             * @param resourcePrimKey the resource prim key
16666             * @return the number of matching journal articles
16667             * @throws SystemException if a system exception occurred
16668             */
16669            public int countByResourcePrimKey(long resourcePrimKey)
16670                    throws SystemException {
16671                    Object[] finderArgs = new Object[] { resourcePrimKey };
16672    
16673                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
16674                                    finderArgs, this);
16675    
16676                    if (count == null) {
16677                            StringBundler query = new StringBundler(2);
16678    
16679                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16680    
16681                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
16682    
16683                            String sql = query.toString();
16684    
16685                            Session session = null;
16686    
16687                            try {
16688                                    session = openSession();
16689    
16690                                    Query q = session.createQuery(sql);
16691    
16692                                    QueryPos qPos = QueryPos.getInstance(q);
16693    
16694                                    qPos.add(resourcePrimKey);
16695    
16696                                    count = (Long)q.uniqueResult();
16697                            }
16698                            catch (Exception e) {
16699                                    throw processException(e);
16700                            }
16701                            finally {
16702                                    if (count == null) {
16703                                            count = Long.valueOf(0);
16704                                    }
16705    
16706                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
16707                                            finderArgs, count);
16708    
16709                                    closeSession(session);
16710                            }
16711                    }
16712    
16713                    return count.intValue();
16714            }
16715    
16716            /**
16717             * Returns the number of journal articles where groupId = &#63;.
16718             *
16719             * @param groupId the group ID
16720             * @return the number of matching journal articles
16721             * @throws SystemException if a system exception occurred
16722             */
16723            public int countByGroupId(long groupId) throws SystemException {
16724                    Object[] finderArgs = new Object[] { groupId };
16725    
16726                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
16727                                    finderArgs, this);
16728    
16729                    if (count == null) {
16730                            StringBundler query = new StringBundler(2);
16731    
16732                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16733    
16734                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
16735    
16736                            String sql = query.toString();
16737    
16738                            Session session = null;
16739    
16740                            try {
16741                                    session = openSession();
16742    
16743                                    Query q = session.createQuery(sql);
16744    
16745                                    QueryPos qPos = QueryPos.getInstance(q);
16746    
16747                                    qPos.add(groupId);
16748    
16749                                    count = (Long)q.uniqueResult();
16750                            }
16751                            catch (Exception e) {
16752                                    throw processException(e);
16753                            }
16754                            finally {
16755                                    if (count == null) {
16756                                            count = Long.valueOf(0);
16757                                    }
16758    
16759                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
16760                                            finderArgs, count);
16761    
16762                                    closeSession(session);
16763                            }
16764                    }
16765    
16766                    return count.intValue();
16767            }
16768    
16769            /**
16770             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
16771             *
16772             * @param groupId the group ID
16773             * @return the number of matching journal articles that the user has permission to view
16774             * @throws SystemException if a system exception occurred
16775             */
16776            public int filterCountByGroupId(long groupId) throws SystemException {
16777                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16778                            return countByGroupId(groupId);
16779                    }
16780    
16781                    StringBundler query = new StringBundler(2);
16782    
16783                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16784    
16785                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
16786    
16787                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16788                                    JournalArticle.class.getName(),
16789                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16790    
16791                    Session session = null;
16792    
16793                    try {
16794                            session = openSession();
16795    
16796                            SQLQuery q = session.createSQLQuery(sql);
16797    
16798                            q.addScalar(COUNT_COLUMN_NAME,
16799                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16800    
16801                            QueryPos qPos = QueryPos.getInstance(q);
16802    
16803                            qPos.add(groupId);
16804    
16805                            Long count = (Long)q.uniqueResult();
16806    
16807                            return count.intValue();
16808                    }
16809                    catch (Exception e) {
16810                            throw processException(e);
16811                    }
16812                    finally {
16813                            closeSession(session);
16814                    }
16815            }
16816    
16817            /**
16818             * Returns the number of journal articles where companyId = &#63;.
16819             *
16820             * @param companyId the company ID
16821             * @return the number of matching journal articles
16822             * @throws SystemException if a system exception occurred
16823             */
16824            public int countByCompanyId(long companyId) throws SystemException {
16825                    Object[] finderArgs = new Object[] { companyId };
16826    
16827                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
16828                                    finderArgs, this);
16829    
16830                    if (count == null) {
16831                            StringBundler query = new StringBundler(2);
16832    
16833                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16834    
16835                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
16836    
16837                            String sql = query.toString();
16838    
16839                            Session session = null;
16840    
16841                            try {
16842                                    session = openSession();
16843    
16844                                    Query q = session.createQuery(sql);
16845    
16846                                    QueryPos qPos = QueryPos.getInstance(q);
16847    
16848                                    qPos.add(companyId);
16849    
16850                                    count = (Long)q.uniqueResult();
16851                            }
16852                            catch (Exception e) {
16853                                    throw processException(e);
16854                            }
16855                            finally {
16856                                    if (count == null) {
16857                                            count = Long.valueOf(0);
16858                                    }
16859    
16860                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
16861                                            finderArgs, count);
16862    
16863                                    closeSession(session);
16864                            }
16865                    }
16866    
16867                    return count.intValue();
16868            }
16869    
16870            /**
16871             * Returns the number of journal articles where structureId = &#63;.
16872             *
16873             * @param structureId the structure ID
16874             * @return the number of matching journal articles
16875             * @throws SystemException if a system exception occurred
16876             */
16877            public int countByStructureId(String structureId) throws SystemException {
16878                    Object[] finderArgs = new Object[] { structureId };
16879    
16880                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
16881                                    finderArgs, this);
16882    
16883                    if (count == null) {
16884                            StringBundler query = new StringBundler(2);
16885    
16886                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16887    
16888                            if (structureId == null) {
16889                                    query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
16890                            }
16891                            else {
16892                                    if (structureId.equals(StringPool.BLANK)) {
16893                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
16894                                    }
16895                                    else {
16896                                            query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
16897                                    }
16898                            }
16899    
16900                            String sql = query.toString();
16901    
16902                            Session session = null;
16903    
16904                            try {
16905                                    session = openSession();
16906    
16907                                    Query q = session.createQuery(sql);
16908    
16909                                    QueryPos qPos = QueryPos.getInstance(q);
16910    
16911                                    if (structureId != null) {
16912                                            qPos.add(structureId);
16913                                    }
16914    
16915                                    count = (Long)q.uniqueResult();
16916                            }
16917                            catch (Exception e) {
16918                                    throw processException(e);
16919                            }
16920                            finally {
16921                                    if (count == null) {
16922                                            count = Long.valueOf(0);
16923                                    }
16924    
16925                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
16926                                            finderArgs, count);
16927    
16928                                    closeSession(session);
16929                            }
16930                    }
16931    
16932                    return count.intValue();
16933            }
16934    
16935            /**
16936             * Returns the number of journal articles where templateId = &#63;.
16937             *
16938             * @param templateId the template ID
16939             * @return the number of matching journal articles
16940             * @throws SystemException if a system exception occurred
16941             */
16942            public int countByTemplateId(String templateId) throws SystemException {
16943                    Object[] finderArgs = new Object[] { templateId };
16944    
16945                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
16946                                    finderArgs, this);
16947    
16948                    if (count == null) {
16949                            StringBundler query = new StringBundler(2);
16950    
16951                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16952    
16953                            if (templateId == null) {
16954                                    query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1);
16955                            }
16956                            else {
16957                                    if (templateId.equals(StringPool.BLANK)) {
16958                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3);
16959                                    }
16960                                    else {
16961                                            query.append(_FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2);
16962                                    }
16963                            }
16964    
16965                            String sql = query.toString();
16966    
16967                            Session session = null;
16968    
16969                            try {
16970                                    session = openSession();
16971    
16972                                    Query q = session.createQuery(sql);
16973    
16974                                    QueryPos qPos = QueryPos.getInstance(q);
16975    
16976                                    if (templateId != null) {
16977                                            qPos.add(templateId);
16978                                    }
16979    
16980                                    count = (Long)q.uniqueResult();
16981                            }
16982                            catch (Exception e) {
16983                                    throw processException(e);
16984                            }
16985                            finally {
16986                                    if (count == null) {
16987                                            count = Long.valueOf(0);
16988                                    }
16989    
16990                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TEMPLATEID,
16991                                            finderArgs, count);
16992    
16993                                    closeSession(session);
16994                            }
16995                    }
16996    
16997                    return count.intValue();
16998            }
16999    
17000            /**
17001             * Returns the number of journal articles where smallImageId = &#63;.
17002             *
17003             * @param smallImageId the small image ID
17004             * @return the number of matching journal articles
17005             * @throws SystemException if a system exception occurred
17006             */
17007            public int countBySmallImageId(long smallImageId) throws SystemException {
17008                    Object[] finderArgs = new Object[] { smallImageId };
17009    
17010                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
17011                                    finderArgs, this);
17012    
17013                    if (count == null) {
17014                            StringBundler query = new StringBundler(2);
17015    
17016                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17017    
17018                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
17019    
17020                            String sql = query.toString();
17021    
17022                            Session session = null;
17023    
17024                            try {
17025                                    session = openSession();
17026    
17027                                    Query q = session.createQuery(sql);
17028    
17029                                    QueryPos qPos = QueryPos.getInstance(q);
17030    
17031                                    qPos.add(smallImageId);
17032    
17033                                    count = (Long)q.uniqueResult();
17034                            }
17035                            catch (Exception e) {
17036                                    throw processException(e);
17037                            }
17038                            finally {
17039                                    if (count == null) {
17040                                            count = Long.valueOf(0);
17041                                    }
17042    
17043                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
17044                                            finderArgs, count);
17045    
17046                                    closeSession(session);
17047                            }
17048                    }
17049    
17050                    return count.intValue();
17051            }
17052    
17053            /**
17054             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
17055             *
17056             * @param resourcePrimKey the resource prim key
17057             * @param status the status
17058             * @return the number of matching journal articles
17059             * @throws SystemException if a system exception occurred
17060             */
17061            public int countByR_ST(long resourcePrimKey, int status)
17062                    throws SystemException {
17063                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
17064    
17065                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_ST,
17066                                    finderArgs, this);
17067    
17068                    if (count == null) {
17069                            StringBundler query = new StringBundler(3);
17070    
17071                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17072    
17073                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
17074    
17075                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
17076    
17077                            String sql = query.toString();
17078    
17079                            Session session = null;
17080    
17081                            try {
17082                                    session = openSession();
17083    
17084                                    Query q = session.createQuery(sql);
17085    
17086                                    QueryPos qPos = QueryPos.getInstance(q);
17087    
17088                                    qPos.add(resourcePrimKey);
17089    
17090                                    qPos.add(status);
17091    
17092                                    count = (Long)q.uniqueResult();
17093                            }
17094                            catch (Exception e) {
17095                                    throw processException(e);
17096                            }
17097                            finally {
17098                                    if (count == null) {
17099                                            count = Long.valueOf(0);
17100                                    }
17101    
17102                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_ST,
17103                                            finderArgs, count);
17104    
17105                                    closeSession(session);
17106                            }
17107                    }
17108    
17109                    return count.intValue();
17110            }
17111    
17112            /**
17113             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
17114             *
17115             * @param groupId the group ID
17116             * @param articleId the article ID
17117             * @return the number of matching journal articles
17118             * @throws SystemException if a system exception occurred
17119             */
17120            public int countByG_A(long groupId, String articleId)
17121                    throws SystemException {
17122                    Object[] finderArgs = new Object[] { groupId, articleId };
17123    
17124                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
17125                                    finderArgs, this);
17126    
17127                    if (count == null) {
17128                            StringBundler query = new StringBundler(3);
17129    
17130                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17131    
17132                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
17133    
17134                            if (articleId == null) {
17135                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
17136                            }
17137                            else {
17138                                    if (articleId.equals(StringPool.BLANK)) {
17139                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
17140                                    }
17141                                    else {
17142                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
17143                                    }
17144                            }
17145    
17146                            String sql = query.toString();
17147    
17148                            Session session = null;
17149    
17150                            try {
17151                                    session = openSession();
17152    
17153                                    Query q = session.createQuery(sql);
17154    
17155                                    QueryPos qPos = QueryPos.getInstance(q);
17156    
17157                                    qPos.add(groupId);
17158    
17159                                    if (articleId != null) {
17160                                            qPos.add(articleId);
17161                                    }
17162    
17163                                    count = (Long)q.uniqueResult();
17164                            }
17165                            catch (Exception e) {
17166                                    throw processException(e);
17167                            }
17168                            finally {
17169                                    if (count == null) {
17170                                            count = Long.valueOf(0);
17171                                    }
17172    
17173                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
17174                                            count);
17175    
17176                                    closeSession(session);
17177                            }
17178                    }
17179    
17180                    return count.intValue();
17181            }
17182    
17183            /**
17184             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
17185             *
17186             * @param groupId the group ID
17187             * @param articleId the article ID
17188             * @return the number of matching journal articles that the user has permission to view
17189             * @throws SystemException if a system exception occurred
17190             */
17191            public int filterCountByG_A(long groupId, String articleId)
17192                    throws SystemException {
17193                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17194                            return countByG_A(groupId, articleId);
17195                    }
17196    
17197                    StringBundler query = new StringBundler(3);
17198    
17199                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17200    
17201                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
17202    
17203                    if (articleId == null) {
17204                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
17205                    }
17206                    else {
17207                            if (articleId.equals(StringPool.BLANK)) {
17208                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
17209                            }
17210                            else {
17211                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
17212                            }
17213                    }
17214    
17215                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17216                                    JournalArticle.class.getName(),
17217                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17218    
17219                    Session session = null;
17220    
17221                    try {
17222                            session = openSession();
17223    
17224                            SQLQuery q = session.createSQLQuery(sql);
17225    
17226                            q.addScalar(COUNT_COLUMN_NAME,
17227                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17228    
17229                            QueryPos qPos = QueryPos.getInstance(q);
17230    
17231                            qPos.add(groupId);
17232    
17233                            if (articleId != null) {
17234                                    qPos.add(articleId);
17235                            }
17236    
17237                            Long count = (Long)q.uniqueResult();
17238    
17239                            return count.intValue();
17240                    }
17241                    catch (Exception e) {
17242                            throw processException(e);
17243                    }
17244                    finally {
17245                            closeSession(session);
17246                    }
17247            }
17248    
17249            /**
17250             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
17251             *
17252             * @param groupId the group ID
17253             * @param urlTitle the url title
17254             * @return the number of matching journal articles
17255             * @throws SystemException if a system exception occurred
17256             */
17257            public int countByG_UT(long groupId, String urlTitle)
17258                    throws SystemException {
17259                    Object[] finderArgs = new Object[] { groupId, urlTitle };
17260    
17261                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT,
17262                                    finderArgs, this);
17263    
17264                    if (count == null) {
17265                            StringBundler query = new StringBundler(3);
17266    
17267                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17268    
17269                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
17270    
17271                            if (urlTitle == null) {
17272                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
17273                            }
17274                            else {
17275                                    if (urlTitle.equals(StringPool.BLANK)) {
17276                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
17277                                    }
17278                                    else {
17279                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
17280                                    }
17281                            }
17282    
17283                            String sql = query.toString();
17284    
17285                            Session session = null;
17286    
17287                            try {
17288                                    session = openSession();
17289    
17290                                    Query q = session.createQuery(sql);
17291    
17292                                    QueryPos qPos = QueryPos.getInstance(q);
17293    
17294                                    qPos.add(groupId);
17295    
17296                                    if (urlTitle != null) {
17297                                            qPos.add(urlTitle);
17298                                    }
17299    
17300                                    count = (Long)q.uniqueResult();
17301                            }
17302                            catch (Exception e) {
17303                                    throw processException(e);
17304                            }
17305                            finally {
17306                                    if (count == null) {
17307                                            count = Long.valueOf(0);
17308                                    }
17309    
17310                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT,
17311                                            finderArgs, count);
17312    
17313                                    closeSession(session);
17314                            }
17315                    }
17316    
17317                    return count.intValue();
17318            }
17319    
17320            /**
17321             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
17322             *
17323             * @param groupId the group ID
17324             * @param urlTitle the url title
17325             * @return the number of matching journal articles that the user has permission to view
17326             * @throws SystemException if a system exception occurred
17327             */
17328            public int filterCountByG_UT(long groupId, String urlTitle)
17329                    throws SystemException {
17330                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17331                            return countByG_UT(groupId, urlTitle);
17332                    }
17333    
17334                    StringBundler query = new StringBundler(3);
17335    
17336                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17337    
17338                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
17339    
17340                    if (urlTitle == null) {
17341                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
17342                    }
17343                    else {
17344                            if (urlTitle.equals(StringPool.BLANK)) {
17345                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
17346                            }
17347                            else {
17348                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
17349                            }
17350                    }
17351    
17352                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17353                                    JournalArticle.class.getName(),
17354                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17355    
17356                    Session session = null;
17357    
17358                    try {
17359                            session = openSession();
17360    
17361                            SQLQuery q = session.createSQLQuery(sql);
17362    
17363                            q.addScalar(COUNT_COLUMN_NAME,
17364                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17365    
17366                            QueryPos qPos = QueryPos.getInstance(q);
17367    
17368                            qPos.add(groupId);
17369    
17370                            if (urlTitle != null) {
17371                                    qPos.add(urlTitle);
17372                            }
17373    
17374                            Long count = (Long)q.uniqueResult();
17375    
17376                            return count.intValue();
17377                    }
17378                    catch (Exception e) {
17379                            throw processException(e);
17380                    }
17381                    finally {
17382                            closeSession(session);
17383                    }
17384            }
17385    
17386            /**
17387             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
17388             *
17389             * @param groupId the group ID
17390             * @param structureId the structure ID
17391             * @return the number of matching journal articles
17392             * @throws SystemException if a system exception occurred
17393             */
17394            public int countByG_S(long groupId, String structureId)
17395                    throws SystemException {
17396                    Object[] finderArgs = new Object[] { groupId, structureId };
17397    
17398                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
17399                                    finderArgs, this);
17400    
17401                    if (count == null) {
17402                            StringBundler query = new StringBundler(3);
17403    
17404                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17405    
17406                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
17407    
17408                            if (structureId == null) {
17409                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
17410                            }
17411                            else {
17412                                    if (structureId.equals(StringPool.BLANK)) {
17413                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
17414                                    }
17415                                    else {
17416                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
17417                                    }
17418                            }
17419    
17420                            String sql = query.toString();
17421    
17422                            Session session = null;
17423    
17424                            try {
17425                                    session = openSession();
17426    
17427                                    Query q = session.createQuery(sql);
17428    
17429                                    QueryPos qPos = QueryPos.getInstance(q);
17430    
17431                                    qPos.add(groupId);
17432    
17433                                    if (structureId != null) {
17434                                            qPos.add(structureId);
17435                                    }
17436    
17437                                    count = (Long)q.uniqueResult();
17438                            }
17439                            catch (Exception e) {
17440                                    throw processException(e);
17441                            }
17442                            finally {
17443                                    if (count == null) {
17444                                            count = Long.valueOf(0);
17445                                    }
17446    
17447                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
17448                                            count);
17449    
17450                                    closeSession(session);
17451                            }
17452                    }
17453    
17454                    return count.intValue();
17455            }
17456    
17457            /**
17458             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
17459             *
17460             * @param groupId the group ID
17461             * @param structureId the structure ID
17462             * @return the number of matching journal articles that the user has permission to view
17463             * @throws SystemException if a system exception occurred
17464             */
17465            public int filterCountByG_S(long groupId, String structureId)
17466                    throws SystemException {
17467                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17468                            return countByG_S(groupId, structureId);
17469                    }
17470    
17471                    StringBundler query = new StringBundler(3);
17472    
17473                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17474    
17475                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
17476    
17477                    if (structureId == null) {
17478                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
17479                    }
17480                    else {
17481                            if (structureId.equals(StringPool.BLANK)) {
17482                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
17483                            }
17484                            else {
17485                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
17486                            }
17487                    }
17488    
17489                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17490                                    JournalArticle.class.getName(),
17491                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17492    
17493                    Session session = null;
17494    
17495                    try {
17496                            session = openSession();
17497    
17498                            SQLQuery q = session.createSQLQuery(sql);
17499    
17500                            q.addScalar(COUNT_COLUMN_NAME,
17501                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17502    
17503                            QueryPos qPos = QueryPos.getInstance(q);
17504    
17505                            qPos.add(groupId);
17506    
17507                            if (structureId != null) {
17508                                    qPos.add(structureId);
17509                            }
17510    
17511                            Long count = (Long)q.uniqueResult();
17512    
17513                            return count.intValue();
17514                    }
17515                    catch (Exception e) {
17516                            throw processException(e);
17517                    }
17518                    finally {
17519                            closeSession(session);
17520                    }
17521            }
17522    
17523            /**
17524             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
17525             *
17526             * @param groupId the group ID
17527             * @param templateId the template ID
17528             * @return the number of matching journal articles
17529             * @throws SystemException if a system exception occurred
17530             */
17531            public int countByG_T(long groupId, String templateId)
17532                    throws SystemException {
17533                    Object[] finderArgs = new Object[] { groupId, templateId };
17534    
17535                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T,
17536                                    finderArgs, this);
17537    
17538                    if (count == null) {
17539                            StringBundler query = new StringBundler(3);
17540    
17541                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17542    
17543                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
17544    
17545                            if (templateId == null) {
17546                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
17547                            }
17548                            else {
17549                                    if (templateId.equals(StringPool.BLANK)) {
17550                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
17551                                    }
17552                                    else {
17553                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
17554                                    }
17555                            }
17556    
17557                            String sql = query.toString();
17558    
17559                            Session session = null;
17560    
17561                            try {
17562                                    session = openSession();
17563    
17564                                    Query q = session.createQuery(sql);
17565    
17566                                    QueryPos qPos = QueryPos.getInstance(q);
17567    
17568                                    qPos.add(groupId);
17569    
17570                                    if (templateId != null) {
17571                                            qPos.add(templateId);
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_T, finderArgs,
17585                                            count);
17586    
17587                                    closeSession(session);
17588                            }
17589                    }
17590    
17591                    return count.intValue();
17592            }
17593    
17594            /**
17595             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
17596             *
17597             * @param groupId the group ID
17598             * @param templateId the template ID
17599             * @return the number of matching journal articles that the user has permission to view
17600             * @throws SystemException if a system exception occurred
17601             */
17602            public int filterCountByG_T(long groupId, String templateId)
17603                    throws SystemException {
17604                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17605                            return countByG_T(groupId, templateId);
17606                    }
17607    
17608                    StringBundler query = new StringBundler(3);
17609    
17610                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17611    
17612                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
17613    
17614                    if (templateId == null) {
17615                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
17616                    }
17617                    else {
17618                            if (templateId.equals(StringPool.BLANK)) {
17619                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
17620                            }
17621                            else {
17622                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
17623                            }
17624                    }
17625    
17626                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17627                                    JournalArticle.class.getName(),
17628                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17629    
17630                    Session session = null;
17631    
17632                    try {
17633                            session = openSession();
17634    
17635                            SQLQuery q = session.createSQLQuery(sql);
17636    
17637                            q.addScalar(COUNT_COLUMN_NAME,
17638                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17639    
17640                            QueryPos qPos = QueryPos.getInstance(q);
17641    
17642                            qPos.add(groupId);
17643    
17644                            if (templateId != null) {
17645                                    qPos.add(templateId);
17646                            }
17647    
17648                            Long count = (Long)q.uniqueResult();
17649    
17650                            return count.intValue();
17651                    }
17652                    catch (Exception e) {
17653                            throw processException(e);
17654                    }
17655                    finally {
17656                            closeSession(session);
17657                    }
17658            }
17659    
17660            /**
17661             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
17662             *
17663             * @param groupId the group ID
17664             * @param layoutUuid the layout uuid
17665             * @return the number of matching journal articles
17666             * @throws SystemException if a system exception occurred
17667             */
17668            public int countByG_L(long groupId, String layoutUuid)
17669                    throws SystemException {
17670                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
17671    
17672                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_L,
17673                                    finderArgs, this);
17674    
17675                    if (count == null) {
17676                            StringBundler query = new StringBundler(3);
17677    
17678                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17679    
17680                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
17681    
17682                            if (layoutUuid == null) {
17683                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
17684                            }
17685                            else {
17686                                    if (layoutUuid.equals(StringPool.BLANK)) {
17687                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
17688                                    }
17689                                    else {
17690                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
17691                                    }
17692                            }
17693    
17694                            String sql = query.toString();
17695    
17696                            Session session = null;
17697    
17698                            try {
17699                                    session = openSession();
17700    
17701                                    Query q = session.createQuery(sql);
17702    
17703                                    QueryPos qPos = QueryPos.getInstance(q);
17704    
17705                                    qPos.add(groupId);
17706    
17707                                    if (layoutUuid != null) {
17708                                            qPos.add(layoutUuid);
17709                                    }
17710    
17711                                    count = (Long)q.uniqueResult();
17712                            }
17713                            catch (Exception e) {
17714                                    throw processException(e);
17715                            }
17716                            finally {
17717                                    if (count == null) {
17718                                            count = Long.valueOf(0);
17719                                    }
17720    
17721                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_L, finderArgs,
17722                                            count);
17723    
17724                                    closeSession(session);
17725                            }
17726                    }
17727    
17728                    return count.intValue();
17729            }
17730    
17731            /**
17732             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
17733             *
17734             * @param groupId the group ID
17735             * @param layoutUuid the layout uuid
17736             * @return the number of matching journal articles that the user has permission to view
17737             * @throws SystemException if a system exception occurred
17738             */
17739            public int filterCountByG_L(long groupId, String layoutUuid)
17740                    throws SystemException {
17741                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17742                            return countByG_L(groupId, layoutUuid);
17743                    }
17744    
17745                    StringBundler query = new StringBundler(3);
17746    
17747                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17748    
17749                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
17750    
17751                    if (layoutUuid == null) {
17752                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
17753                    }
17754                    else {
17755                            if (layoutUuid.equals(StringPool.BLANK)) {
17756                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
17757                            }
17758                            else {
17759                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
17760                            }
17761                    }
17762    
17763                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17764                                    JournalArticle.class.getName(),
17765                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17766    
17767                    Session session = null;
17768    
17769                    try {
17770                            session = openSession();
17771    
17772                            SQLQuery q = session.createSQLQuery(sql);
17773    
17774                            q.addScalar(COUNT_COLUMN_NAME,
17775                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17776    
17777                            QueryPos qPos = QueryPos.getInstance(q);
17778    
17779                            qPos.add(groupId);
17780    
17781                            if (layoutUuid != null) {
17782                                    qPos.add(layoutUuid);
17783                            }
17784    
17785                            Long count = (Long)q.uniqueResult();
17786    
17787                            return count.intValue();
17788                    }
17789                    catch (Exception e) {
17790                            throw processException(e);
17791                    }
17792                    finally {
17793                            closeSession(session);
17794                    }
17795            }
17796    
17797            /**
17798             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
17799             *
17800             * @param groupId the group ID
17801             * @param status the status
17802             * @return the number of matching journal articles
17803             * @throws SystemException if a system exception occurred
17804             */
17805            public int countByG_ST(long groupId, int status) throws SystemException {
17806                    Object[] finderArgs = new Object[] { groupId, status };
17807    
17808                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_ST,
17809                                    finderArgs, this);
17810    
17811                    if (count == null) {
17812                            StringBundler query = new StringBundler(3);
17813    
17814                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17815    
17816                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
17817    
17818                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
17819    
17820                            String sql = query.toString();
17821    
17822                            Session session = null;
17823    
17824                            try {
17825                                    session = openSession();
17826    
17827                                    Query q = session.createQuery(sql);
17828    
17829                                    QueryPos qPos = QueryPos.getInstance(q);
17830    
17831                                    qPos.add(groupId);
17832    
17833                                    qPos.add(status);
17834    
17835                                    count = (Long)q.uniqueResult();
17836                            }
17837                            catch (Exception e) {
17838                                    throw processException(e);
17839                            }
17840                            finally {
17841                                    if (count == null) {
17842                                            count = Long.valueOf(0);
17843                                    }
17844    
17845                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_ST,
17846                                            finderArgs, count);
17847    
17848                                    closeSession(session);
17849                            }
17850                    }
17851    
17852                    return count.intValue();
17853            }
17854    
17855            /**
17856             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
17857             *
17858             * @param groupId the group ID
17859             * @param status the status
17860             * @return the number of matching journal articles that the user has permission to view
17861             * @throws SystemException if a system exception occurred
17862             */
17863            public int filterCountByG_ST(long groupId, int status)
17864                    throws SystemException {
17865                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17866                            return countByG_ST(groupId, status);
17867                    }
17868    
17869                    StringBundler query = new StringBundler(3);
17870    
17871                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17872    
17873                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
17874    
17875                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
17876    
17877                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17878                                    JournalArticle.class.getName(),
17879                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17880    
17881                    Session session = null;
17882    
17883                    try {
17884                            session = openSession();
17885    
17886                            SQLQuery q = session.createSQLQuery(sql);
17887    
17888                            q.addScalar(COUNT_COLUMN_NAME,
17889                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17890    
17891                            QueryPos qPos = QueryPos.getInstance(q);
17892    
17893                            qPos.add(groupId);
17894    
17895                            qPos.add(status);
17896    
17897                            Long count = (Long)q.uniqueResult();
17898    
17899                            return count.intValue();
17900                    }
17901                    catch (Exception e) {
17902                            throw processException(e);
17903                    }
17904                    finally {
17905                            closeSession(session);
17906                    }
17907            }
17908    
17909            /**
17910             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
17911             *
17912             * @param companyId the company ID
17913             * @param version the version
17914             * @return the number of matching journal articles
17915             * @throws SystemException if a system exception occurred
17916             */
17917            public int countByC_V(long companyId, double version)
17918                    throws SystemException {
17919                    Object[] finderArgs = new Object[] { companyId, version };
17920    
17921                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V,
17922                                    finderArgs, this);
17923    
17924                    if (count == null) {
17925                            StringBundler query = new StringBundler(3);
17926    
17927                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17928    
17929                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
17930    
17931                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
17932    
17933                            String sql = query.toString();
17934    
17935                            Session session = null;
17936    
17937                            try {
17938                                    session = openSession();
17939    
17940                                    Query q = session.createQuery(sql);
17941    
17942                                    QueryPos qPos = QueryPos.getInstance(q);
17943    
17944                                    qPos.add(companyId);
17945    
17946                                    qPos.add(version);
17947    
17948                                    count = (Long)q.uniqueResult();
17949                            }
17950                            catch (Exception e) {
17951                                    throw processException(e);
17952                            }
17953                            finally {
17954                                    if (count == null) {
17955                                            count = Long.valueOf(0);
17956                                    }
17957    
17958                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V, finderArgs,
17959                                            count);
17960    
17961                                    closeSession(session);
17962                            }
17963                    }
17964    
17965                    return count.intValue();
17966            }
17967    
17968            /**
17969             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
17970             *
17971             * @param companyId the company ID
17972             * @param status the status
17973             * @return the number of matching journal articles
17974             * @throws SystemException if a system exception occurred
17975             */
17976            public int countByC_ST(long companyId, int status)
17977                    throws SystemException {
17978                    Object[] finderArgs = new Object[] { companyId, status };
17979    
17980                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_ST,
17981                                    finderArgs, this);
17982    
17983                    if (count == null) {
17984                            StringBundler query = new StringBundler(3);
17985    
17986                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17987    
17988                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
17989    
17990                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
17991    
17992                            String sql = query.toString();
17993    
17994                            Session session = null;
17995    
17996                            try {
17997                                    session = openSession();
17998    
17999                                    Query q = session.createQuery(sql);
18000    
18001                                    QueryPos qPos = QueryPos.getInstance(q);
18002    
18003                                    qPos.add(companyId);
18004    
18005                                    qPos.add(status);
18006    
18007                                    count = (Long)q.uniqueResult();
18008                            }
18009                            catch (Exception e) {
18010                                    throw processException(e);
18011                            }
18012                            finally {
18013                                    if (count == null) {
18014                                            count = Long.valueOf(0);
18015                                    }
18016    
18017                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_ST,
18018                                            finderArgs, count);
18019    
18020                                    closeSession(session);
18021                            }
18022                    }
18023    
18024                    return count.intValue();
18025            }
18026    
18027            /**
18028             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18029             *
18030             * @param groupId the group ID
18031             * @param classNameId the class name ID
18032             * @param classPK the class p k
18033             * @return the number of matching journal articles
18034             * @throws SystemException if a system exception occurred
18035             */
18036            public int countByG_C_C(long groupId, long classNameId, long classPK)
18037                    throws SystemException {
18038                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
18039    
18040                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C,
18041                                    finderArgs, this);
18042    
18043                    if (count == null) {
18044                            StringBundler query = new StringBundler(4);
18045    
18046                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18047    
18048                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
18049    
18050                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
18051    
18052                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
18053    
18054                            String sql = query.toString();
18055    
18056                            Session session = null;
18057    
18058                            try {
18059                                    session = openSession();
18060    
18061                                    Query q = session.createQuery(sql);
18062    
18063                                    QueryPos qPos = QueryPos.getInstance(q);
18064    
18065                                    qPos.add(groupId);
18066    
18067                                    qPos.add(classNameId);
18068    
18069                                    qPos.add(classPK);
18070    
18071                                    count = (Long)q.uniqueResult();
18072                            }
18073                            catch (Exception e) {
18074                                    throw processException(e);
18075                            }
18076                            finally {
18077                                    if (count == null) {
18078                                            count = Long.valueOf(0);
18079                                    }
18080    
18081                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C,
18082                                            finderArgs, count);
18083    
18084                                    closeSession(session);
18085                            }
18086                    }
18087    
18088                    return count.intValue();
18089            }
18090    
18091            /**
18092             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
18093             *
18094             * @param groupId the group ID
18095             * @param classNameId the class name ID
18096             * @param classPK the class p k
18097             * @return the number of matching journal articles that the user has permission to view
18098             * @throws SystemException if a system exception occurred
18099             */
18100            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
18101                    throws SystemException {
18102                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18103                            return countByG_C_C(groupId, classNameId, classPK);
18104                    }
18105    
18106                    StringBundler query = new StringBundler(4);
18107    
18108                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18109    
18110                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
18111    
18112                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
18113    
18114                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
18115    
18116                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18117                                    JournalArticle.class.getName(),
18118                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18119    
18120                    Session session = null;
18121    
18122                    try {
18123                            session = openSession();
18124    
18125                            SQLQuery q = session.createSQLQuery(sql);
18126    
18127                            q.addScalar(COUNT_COLUMN_NAME,
18128                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18129    
18130                            QueryPos qPos = QueryPos.getInstance(q);
18131    
18132                            qPos.add(groupId);
18133    
18134                            qPos.add(classNameId);
18135    
18136                            qPos.add(classPK);
18137    
18138                            Long count = (Long)q.uniqueResult();
18139    
18140                            return count.intValue();
18141                    }
18142                    catch (Exception e) {
18143                            throw processException(e);
18144                    }
18145                    finally {
18146                            closeSession(session);
18147                    }
18148            }
18149    
18150            /**
18151             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
18152             *
18153             * @param groupId the group ID
18154             * @param classNameId the class name ID
18155             * @param structureId the structure ID
18156             * @return the number of matching journal articles
18157             * @throws SystemException if a system exception occurred
18158             */
18159            public int countByG_C_S(long groupId, long classNameId, String structureId)
18160                    throws SystemException {
18161                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
18162    
18163                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
18164                                    finderArgs, this);
18165    
18166                    if (count == null) {
18167                            StringBundler query = new StringBundler(4);
18168    
18169                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18170    
18171                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
18172    
18173                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
18174    
18175                            if (structureId == null) {
18176                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
18177                            }
18178                            else {
18179                                    if (structureId.equals(StringPool.BLANK)) {
18180                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
18181                                    }
18182                                    else {
18183                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
18184                                    }
18185                            }
18186    
18187                            String sql = query.toString();
18188    
18189                            Session session = null;
18190    
18191                            try {
18192                                    session = openSession();
18193    
18194                                    Query q = session.createQuery(sql);
18195    
18196                                    QueryPos qPos = QueryPos.getInstance(q);
18197    
18198                                    qPos.add(groupId);
18199    
18200                                    qPos.add(classNameId);
18201    
18202                                    if (structureId != null) {
18203                                            qPos.add(structureId);
18204                                    }
18205    
18206                                    count = (Long)q.uniqueResult();
18207                            }
18208                            catch (Exception e) {
18209                                    throw processException(e);
18210                            }
18211                            finally {
18212                                    if (count == null) {
18213                                            count = Long.valueOf(0);
18214                                    }
18215    
18216                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
18217                                            finderArgs, count);
18218    
18219                                    closeSession(session);
18220                            }
18221                    }
18222    
18223                    return count.intValue();
18224            }
18225    
18226            /**
18227             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18228             *
18229             * @param groupId the group ID
18230             * @param classNameId the class name ID
18231             * @param templateId the template ID
18232             * @return the number of matching journal articles
18233             * @throws SystemException if a system exception occurred
18234             */
18235            public int countByG_C_T(long groupId, long classNameId, String templateId)
18236                    throws SystemException {
18237                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
18238    
18239                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_T,
18240                                    finderArgs, this);
18241    
18242                    if (count == null) {
18243                            StringBundler query = new StringBundler(4);
18244    
18245                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18246    
18247                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18248    
18249                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18250    
18251                            if (templateId == null) {
18252                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18253                            }
18254                            else {
18255                                    if (templateId.equals(StringPool.BLANK)) {
18256                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18257                                    }
18258                                    else {
18259                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18260                                    }
18261                            }
18262    
18263                            String sql = query.toString();
18264    
18265                            Session session = null;
18266    
18267                            try {
18268                                    session = openSession();
18269    
18270                                    Query q = session.createQuery(sql);
18271    
18272                                    QueryPos qPos = QueryPos.getInstance(q);
18273    
18274                                    qPos.add(groupId);
18275    
18276                                    qPos.add(classNameId);
18277    
18278                                    if (templateId != null) {
18279                                            qPos.add(templateId);
18280                                    }
18281    
18282                                    count = (Long)q.uniqueResult();
18283                            }
18284                            catch (Exception e) {
18285                                    throw processException(e);
18286                            }
18287                            finally {
18288                                    if (count == null) {
18289                                            count = Long.valueOf(0);
18290                                    }
18291    
18292                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_T,
18293                                            finderArgs, count);
18294    
18295                                    closeSession(session);
18296                            }
18297                    }
18298    
18299                    return count.intValue();
18300            }
18301    
18302            /**
18303             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
18304             *
18305             * @param groupId the group ID
18306             * @param classNameId the class name ID
18307             * @param templateId the template ID
18308             * @return the number of matching journal articles that the user has permission to view
18309             * @throws SystemException if a system exception occurred
18310             */
18311            public int filterCountByG_C_T(long groupId, long classNameId,
18312                    String templateId) throws SystemException {
18313                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18314                            return countByG_C_T(groupId, classNameId, templateId);
18315                    }
18316    
18317                    StringBundler query = new StringBundler(4);
18318    
18319                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18320    
18321                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
18322    
18323                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
18324    
18325                    if (templateId == null) {
18326                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
18327                    }
18328                    else {
18329                            if (templateId.equals(StringPool.BLANK)) {
18330                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
18331                            }
18332                            else {
18333                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
18334                            }
18335                    }
18336    
18337                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18338                                    JournalArticle.class.getName(),
18339                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18340    
18341                    Session session = null;
18342    
18343                    try {
18344                            session = openSession();
18345    
18346                            SQLQuery q = session.createSQLQuery(sql);
18347    
18348                            q.addScalar(COUNT_COLUMN_NAME,
18349                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18350    
18351                            QueryPos qPos = QueryPos.getInstance(q);
18352    
18353                            qPos.add(groupId);
18354    
18355                            qPos.add(classNameId);
18356    
18357                            if (templateId != null) {
18358                                    qPos.add(templateId);
18359                            }
18360    
18361                            Long count = (Long)q.uniqueResult();
18362    
18363                            return count.intValue();
18364                    }
18365                    catch (Exception e) {
18366                            throw processException(e);
18367                    }
18368                    finally {
18369                            closeSession(session);
18370                    }
18371            }
18372    
18373            /**
18374             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
18375             *
18376             * @param groupId the group ID
18377             * @param classNameId the class name ID
18378             * @param layoutUuid the layout uuid
18379             * @return the number of matching journal articles
18380             * @throws SystemException if a system exception occurred
18381             */
18382            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
18383                    throws SystemException {
18384                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
18385    
18386                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_L,
18387                                    finderArgs, this);
18388    
18389                    if (count == null) {
18390                            StringBundler query = new StringBundler(4);
18391    
18392                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18393    
18394                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
18395    
18396                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
18397    
18398                            if (layoutUuid == null) {
18399                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
18400                            }
18401                            else {
18402                                    if (layoutUuid.equals(StringPool.BLANK)) {
18403                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
18404                                    }
18405                                    else {
18406                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
18407                                    }
18408                            }
18409    
18410                            String sql = query.toString();
18411    
18412                            Session session = null;
18413    
18414                            try {
18415                                    session = openSession();
18416    
18417                                    Query q = session.createQuery(sql);
18418    
18419                                    QueryPos qPos = QueryPos.getInstance(q);
18420    
18421                                    qPos.add(groupId);
18422    
18423                                    qPos.add(classNameId);
18424    
18425                                    if (layoutUuid != null) {
18426                                            qPos.add(layoutUuid);
18427                                    }
18428    
18429                                    count = (Long)q.uniqueResult();
18430                            }
18431                            catch (Exception e) {
18432                                    throw processException(e);
18433                            }
18434                            finally {
18435                                    if (count == null) {
18436                                            count = Long.valueOf(0);
18437                                    }
18438    
18439                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_L,
18440                                            finderArgs, count);
18441    
18442                                    closeSession(session);
18443                            }
18444                    }
18445    
18446                    return count.intValue();
18447            }
18448    
18449            /**
18450             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
18451             *
18452             * @param groupId the group ID
18453             * @param classNameId the class name ID
18454             * @param layoutUuid the layout uuid
18455             * @return the number of matching journal articles that the user has permission to view
18456             * @throws SystemException if a system exception occurred
18457             */
18458            public int filterCountByG_C_L(long groupId, long classNameId,
18459                    String layoutUuid) throws SystemException {
18460                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18461                            return countByG_C_L(groupId, classNameId, layoutUuid);
18462                    }
18463    
18464                    StringBundler query = new StringBundler(4);
18465    
18466                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18467    
18468                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
18469    
18470                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
18471    
18472                    if (layoutUuid == null) {
18473                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
18474                    }
18475                    else {
18476                            if (layoutUuid.equals(StringPool.BLANK)) {
18477                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
18478                            }
18479                            else {
18480                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
18481                            }
18482                    }
18483    
18484                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18485                                    JournalArticle.class.getName(),
18486                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18487    
18488                    Session session = null;
18489    
18490                    try {
18491                            session = openSession();
18492    
18493                            SQLQuery q = session.createSQLQuery(sql);
18494    
18495                            q.addScalar(COUNT_COLUMN_NAME,
18496                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18497    
18498                            QueryPos qPos = QueryPos.getInstance(q);
18499    
18500                            qPos.add(groupId);
18501    
18502                            qPos.add(classNameId);
18503    
18504                            if (layoutUuid != null) {
18505                                    qPos.add(layoutUuid);
18506                            }
18507    
18508                            Long count = (Long)q.uniqueResult();
18509    
18510                            return count.intValue();
18511                    }
18512                    catch (Exception e) {
18513                            throw processException(e);
18514                    }
18515                    finally {
18516                            closeSession(session);
18517                    }
18518            }
18519    
18520            /**
18521             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
18522             *
18523             * @param groupId the group ID
18524             * @param articleId the article ID
18525             * @param version the version
18526             * @return the number of matching journal articles
18527             * @throws SystemException if a system exception occurred
18528             */
18529            public int countByG_A_V(long groupId, String articleId, double version)
18530                    throws SystemException {
18531                    Object[] finderArgs = new Object[] { groupId, articleId, version };
18532    
18533                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_V,
18534                                    finderArgs, this);
18535    
18536                    if (count == null) {
18537                            StringBundler query = new StringBundler(4);
18538    
18539                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18540    
18541                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
18542    
18543                            if (articleId == null) {
18544                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
18545                            }
18546                            else {
18547                                    if (articleId.equals(StringPool.BLANK)) {
18548                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
18549                                    }
18550                                    else {
18551                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
18552                                    }
18553                            }
18554    
18555                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
18556    
18557                            String sql = query.toString();
18558    
18559                            Session session = null;
18560    
18561                            try {
18562                                    session = openSession();
18563    
18564                                    Query q = session.createQuery(sql);
18565    
18566                                    QueryPos qPos = QueryPos.getInstance(q);
18567    
18568                                    qPos.add(groupId);
18569    
18570                                    if (articleId != null) {
18571                                            qPos.add(articleId);
18572                                    }
18573    
18574                                    qPos.add(version);
18575    
18576                                    count = (Long)q.uniqueResult();
18577                            }
18578                            catch (Exception e) {
18579                                    throw processException(e);
18580                            }
18581                            finally {
18582                                    if (count == null) {
18583                                            count = Long.valueOf(0);
18584                                    }
18585    
18586                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V,
18587                                            finderArgs, count);
18588    
18589                                    closeSession(session);
18590                            }
18591                    }
18592    
18593                    return count.intValue();
18594            }
18595    
18596            /**
18597             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
18598             *
18599             * @param groupId the group ID
18600             * @param articleId the article ID
18601             * @param status the status
18602             * @return the number of matching journal articles
18603             * @throws SystemException if a system exception occurred
18604             */
18605            public int countByG_A_ST(long groupId, String articleId, int status)
18606                    throws SystemException {
18607                    Object[] finderArgs = new Object[] { groupId, articleId, status };
18608    
18609                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_ST,
18610                                    finderArgs, this);
18611    
18612                    if (count == null) {
18613                            StringBundler query = new StringBundler(4);
18614    
18615                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18616    
18617                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
18618    
18619                            if (articleId == null) {
18620                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
18621                            }
18622                            else {
18623                                    if (articleId.equals(StringPool.BLANK)) {
18624                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
18625                                    }
18626                                    else {
18627                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
18628                                    }
18629                            }
18630    
18631                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
18632    
18633                            String sql = query.toString();
18634    
18635                            Session session = null;
18636    
18637                            try {
18638                                    session = openSession();
18639    
18640                                    Query q = session.createQuery(sql);
18641    
18642                                    QueryPos qPos = QueryPos.getInstance(q);
18643    
18644                                    qPos.add(groupId);
18645    
18646                                    if (articleId != null) {
18647                                            qPos.add(articleId);
18648                                    }
18649    
18650                                    qPos.add(status);
18651    
18652                                    count = (Long)q.uniqueResult();
18653                            }
18654                            catch (Exception e) {
18655                                    throw processException(e);
18656                            }
18657                            finally {
18658                                    if (count == null) {
18659                                            count = Long.valueOf(0);
18660                                    }
18661    
18662                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_ST,
18663                                            finderArgs, count);
18664    
18665                                    closeSession(session);
18666                            }
18667                    }
18668    
18669                    return count.intValue();
18670            }
18671    
18672            /**
18673             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
18674             *
18675             * @param groupId the group ID
18676             * @param articleId the article ID
18677             * @param statuses the statuses
18678             * @return the number of matching journal articles
18679             * @throws SystemException if a system exception occurred
18680             */
18681            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
18682                    throws SystemException {
18683                    Object[] finderArgs = new Object[] {
18684                                    groupId, articleId, StringUtil.merge(statuses)
18685                            };
18686    
18687                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
18688                                    finderArgs, this);
18689    
18690                    if (count == null) {
18691                            StringBundler query = new StringBundler();
18692    
18693                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18694    
18695                            boolean conjunctionable = false;
18696    
18697                            if (conjunctionable) {
18698                                    query.append(WHERE_AND);
18699                            }
18700    
18701                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
18702    
18703                            conjunctionable = true;
18704    
18705                            if (conjunctionable) {
18706                                    query.append(WHERE_AND);
18707                            }
18708    
18709                            if (articleId == null) {
18710                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
18711                            }
18712                            else {
18713                                    if (articleId.equals(StringPool.BLANK)) {
18714                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
18715                                    }
18716                                    else {
18717                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
18718                                    }
18719                            }
18720    
18721                            conjunctionable = true;
18722    
18723                            if ((statuses == null) || (statuses.length > 0)) {
18724                                    if (conjunctionable) {
18725                                            query.append(WHERE_AND);
18726                                    }
18727    
18728                                    query.append(StringPool.OPEN_PARENTHESIS);
18729    
18730                                    for (int i = 0; i < statuses.length; i++) {
18731                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
18732    
18733                                            if ((i + 1) < statuses.length) {
18734                                                    query.append(WHERE_OR);
18735                                            }
18736                                    }
18737    
18738                                    query.append(StringPool.CLOSE_PARENTHESIS);
18739    
18740                                    conjunctionable = true;
18741                            }
18742    
18743                            String sql = query.toString();
18744    
18745                            Session session = null;
18746    
18747                            try {
18748                                    session = openSession();
18749    
18750                                    Query q = session.createQuery(sql);
18751    
18752                                    QueryPos qPos = QueryPos.getInstance(q);
18753    
18754                                    qPos.add(groupId);
18755    
18756                                    if (articleId != null) {
18757                                            qPos.add(articleId);
18758                                    }
18759    
18760                                    if (statuses != null) {
18761                                            qPos.add(statuses);
18762                                    }
18763    
18764                                    count = (Long)q.uniqueResult();
18765                            }
18766                            catch (Exception e) {
18767                                    throw processException(e);
18768                            }
18769                            finally {
18770                                    if (count == null) {
18771                                            count = Long.valueOf(0);
18772                                    }
18773    
18774                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_A_ST,
18775                                            finderArgs, count);
18776    
18777                                    closeSession(session);
18778                            }
18779                    }
18780    
18781                    return count.intValue();
18782            }
18783    
18784            /**
18785             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
18786             *
18787             * @param groupId the group ID
18788             * @param articleId the article ID
18789             * @param status the status
18790             * @return the number of matching journal articles that the user has permission to view
18791             * @throws SystemException if a system exception occurred
18792             */
18793            public int filterCountByG_A_ST(long groupId, String articleId, int status)
18794                    throws SystemException {
18795                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18796                            return countByG_A_ST(groupId, articleId, status);
18797                    }
18798    
18799                    StringBundler query = new StringBundler(4);
18800    
18801                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18802    
18803                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
18804    
18805                    if (articleId == null) {
18806                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
18807                    }
18808                    else {
18809                            if (articleId.equals(StringPool.BLANK)) {
18810                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
18811                            }
18812                            else {
18813                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
18814                            }
18815                    }
18816    
18817                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
18818    
18819                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18820                                    JournalArticle.class.getName(),
18821                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18822    
18823                    Session session = null;
18824    
18825                    try {
18826                            session = openSession();
18827    
18828                            SQLQuery q = session.createSQLQuery(sql);
18829    
18830                            q.addScalar(COUNT_COLUMN_NAME,
18831                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18832    
18833                            QueryPos qPos = QueryPos.getInstance(q);
18834    
18835                            qPos.add(groupId);
18836    
18837                            if (articleId != null) {
18838                                    qPos.add(articleId);
18839                            }
18840    
18841                            qPos.add(status);
18842    
18843                            Long count = (Long)q.uniqueResult();
18844    
18845                            return count.intValue();
18846                    }
18847                    catch (Exception e) {
18848                            throw processException(e);
18849                    }
18850                    finally {
18851                            closeSession(session);
18852                    }
18853            }
18854    
18855            /**
18856             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
18857             *
18858             * @param groupId the group ID
18859             * @param articleId the article ID
18860             * @param statuses the statuses
18861             * @return the number of matching journal articles that the user has permission to view
18862             * @throws SystemException if a system exception occurred
18863             */
18864            public int filterCountByG_A_ST(long groupId, String articleId,
18865                    int[] statuses) throws SystemException {
18866                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18867                            return countByG_A_ST(groupId, articleId, statuses);
18868                    }
18869    
18870                    StringBundler query = new StringBundler();
18871    
18872                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
18873    
18874                    boolean conjunctionable = false;
18875    
18876                    if (conjunctionable) {
18877                            query.append(WHERE_AND);
18878                    }
18879    
18880                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
18881    
18882                    conjunctionable = true;
18883    
18884                    if (conjunctionable) {
18885                            query.append(WHERE_AND);
18886                    }
18887    
18888                    if (articleId == null) {
18889                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
18890                    }
18891                    else {
18892                            if (articleId.equals(StringPool.BLANK)) {
18893                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
18894                            }
18895                            else {
18896                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
18897                            }
18898                    }
18899    
18900                    conjunctionable = true;
18901    
18902                    if ((statuses == null) || (statuses.length > 0)) {
18903                            if (conjunctionable) {
18904                                    query.append(WHERE_AND);
18905                            }
18906    
18907                            query.append(StringPool.OPEN_PARENTHESIS);
18908    
18909                            for (int i = 0; i < statuses.length; i++) {
18910                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
18911    
18912                                    if ((i + 1) < statuses.length) {
18913                                            query.append(WHERE_OR);
18914                                    }
18915                            }
18916    
18917                            query.append(StringPool.CLOSE_PARENTHESIS);
18918    
18919                            conjunctionable = true;
18920                    }
18921    
18922                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18923                                    JournalArticle.class.getName(),
18924                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18925    
18926                    Session session = null;
18927    
18928                    try {
18929                            session = openSession();
18930    
18931                            SQLQuery q = session.createSQLQuery(sql);
18932    
18933                            q.addScalar(COUNT_COLUMN_NAME,
18934                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18935    
18936                            QueryPos qPos = QueryPos.getInstance(q);
18937    
18938                            qPos.add(groupId);
18939    
18940                            if (articleId != null) {
18941                                    qPos.add(articleId);
18942                            }
18943    
18944                            if (statuses != null) {
18945                                    qPos.add(statuses);
18946                            }
18947    
18948                            Long count = (Long)q.uniqueResult();
18949    
18950                            return count.intValue();
18951                    }
18952                    catch (Exception e) {
18953                            throw processException(e);
18954                    }
18955                    finally {
18956                            closeSession(session);
18957                    }
18958            }
18959    
18960            /**
18961             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
18962             *
18963             * @param groupId the group ID
18964             * @param urlTitle the url title
18965             * @param status the status
18966             * @return the number of matching journal articles
18967             * @throws SystemException if a system exception occurred
18968             */
18969            public int countByG_UT_ST(long groupId, String urlTitle, int status)
18970                    throws SystemException {
18971                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
18972    
18973                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT_ST,
18974                                    finderArgs, this);
18975    
18976                    if (count == null) {
18977                            StringBundler query = new StringBundler(4);
18978    
18979                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
18980    
18981                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
18982    
18983                            if (urlTitle == null) {
18984                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
18985                            }
18986                            else {
18987                                    if (urlTitle.equals(StringPool.BLANK)) {
18988                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
18989                                    }
18990                                    else {
18991                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
18992                                    }
18993                            }
18994    
18995                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
18996    
18997                            String sql = query.toString();
18998    
18999                            Session session = null;
19000    
19001                            try {
19002                                    session = openSession();
19003    
19004                                    Query q = session.createQuery(sql);
19005    
19006                                    QueryPos qPos = QueryPos.getInstance(q);
19007    
19008                                    qPos.add(groupId);
19009    
19010                                    if (urlTitle != null) {
19011                                            qPos.add(urlTitle);
19012                                    }
19013    
19014                                    qPos.add(status);
19015    
19016                                    count = (Long)q.uniqueResult();
19017                            }
19018                            catch (Exception e) {
19019                                    throw processException(e);
19020                            }
19021                            finally {
19022                                    if (count == null) {
19023                                            count = Long.valueOf(0);
19024                                    }
19025    
19026                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT_ST,
19027                                            finderArgs, count);
19028    
19029                                    closeSession(session);
19030                            }
19031                    }
19032    
19033                    return count.intValue();
19034            }
19035    
19036            /**
19037             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
19038             *
19039             * @param groupId the group ID
19040             * @param urlTitle the url title
19041             * @param status the status
19042             * @return the number of matching journal articles that the user has permission to view
19043             * @throws SystemException if a system exception occurred
19044             */
19045            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
19046                    throws SystemException {
19047                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
19048                            return countByG_UT_ST(groupId, urlTitle, status);
19049                    }
19050    
19051                    StringBundler query = new StringBundler(4);
19052    
19053                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
19054    
19055                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
19056    
19057                    if (urlTitle == null) {
19058                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
19059                    }
19060                    else {
19061                            if (urlTitle.equals(StringPool.BLANK)) {
19062                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
19063                            }
19064                            else {
19065                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
19066                            }
19067                    }
19068    
19069                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
19070    
19071                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
19072                                    JournalArticle.class.getName(),
19073                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
19074    
19075                    Session session = null;
19076    
19077                    try {
19078                            session = openSession();
19079    
19080                            SQLQuery q = session.createSQLQuery(sql);
19081    
19082                            q.addScalar(COUNT_COLUMN_NAME,
19083                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
19084    
19085                            QueryPos qPos = QueryPos.getInstance(q);
19086    
19087                            qPos.add(groupId);
19088    
19089                            if (urlTitle != null) {
19090                                    qPos.add(urlTitle);
19091                            }
19092    
19093                            qPos.add(status);
19094    
19095                            Long count = (Long)q.uniqueResult();
19096    
19097                            return count.intValue();
19098                    }
19099                    catch (Exception e) {
19100                            throw processException(e);
19101                    }
19102                    finally {
19103                            closeSession(session);
19104                    }
19105            }
19106    
19107            /**
19108             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
19109             *
19110             * @param companyId the company ID
19111             * @param version the version
19112             * @param status the status
19113             * @return the number of matching journal articles
19114             * @throws SystemException if a system exception occurred
19115             */
19116            public int countByC_V_ST(long companyId, double version, int status)
19117                    throws SystemException {
19118                    Object[] finderArgs = new Object[] { companyId, version, status };
19119    
19120                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V_ST,
19121                                    finderArgs, this);
19122    
19123                    if (count == null) {
19124                            StringBundler query = new StringBundler(4);
19125    
19126                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
19127    
19128                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
19129    
19130                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
19131    
19132                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
19133    
19134                            String sql = query.toString();
19135    
19136                            Session session = null;
19137    
19138                            try {
19139                                    session = openSession();
19140    
19141                                    Query q = session.createQuery(sql);
19142    
19143                                    QueryPos qPos = QueryPos.getInstance(q);
19144    
19145                                    qPos.add(companyId);
19146    
19147                                    qPos.add(version);
19148    
19149                                    qPos.add(status);
19150    
19151                                    count = (Long)q.uniqueResult();
19152                            }
19153                            catch (Exception e) {
19154                                    throw processException(e);
19155                            }
19156                            finally {
19157                                    if (count == null) {
19158                                            count = Long.valueOf(0);
19159                                    }
19160    
19161                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V_ST,
19162                                            finderArgs, count);
19163    
19164                                    closeSession(session);
19165                            }
19166                    }
19167    
19168                    return count.intValue();
19169            }
19170    
19171            /**
19172             * Returns the number of journal articles.
19173             *
19174             * @return the number of journal articles
19175             * @throws SystemException if a system exception occurred
19176             */
19177            public int countAll() throws SystemException {
19178                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
19179                                    FINDER_ARGS_EMPTY, this);
19180    
19181                    if (count == null) {
19182                            Session session = null;
19183    
19184                            try {
19185                                    session = openSession();
19186    
19187                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
19188    
19189                                    count = (Long)q.uniqueResult();
19190                            }
19191                            catch (Exception e) {
19192                                    throw processException(e);
19193                            }
19194                            finally {
19195                                    if (count == null) {
19196                                            count = Long.valueOf(0);
19197                                    }
19198    
19199                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
19200                                            FINDER_ARGS_EMPTY, count);
19201    
19202                                    closeSession(session);
19203                            }
19204                    }
19205    
19206                    return count.intValue();
19207            }
19208    
19209            /**
19210             * Initializes the journal article persistence.
19211             */
19212            public void afterPropertiesSet() {
19213                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
19214                                            com.liferay.portal.util.PropsUtil.get(
19215                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
19216    
19217                    if (listenerClassNames.length > 0) {
19218                            try {
19219                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
19220    
19221                                    for (String listenerClassName : listenerClassNames) {
19222                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
19223                                                            listenerClassName));
19224                                    }
19225    
19226                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
19227                            }
19228                            catch (Exception e) {
19229                                    _log.error(e);
19230                            }
19231                    }
19232            }
19233    
19234            public void destroy() {
19235                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
19236                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
19237                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
19238            }
19239    
19240            @BeanReference(type = JournalArticlePersistence.class)
19241            protected JournalArticlePersistence journalArticlePersistence;
19242            @BeanReference(type = JournalArticleImagePersistence.class)
19243            protected JournalArticleImagePersistence journalArticleImagePersistence;
19244            @BeanReference(type = JournalArticleResourcePersistence.class)
19245            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
19246            @BeanReference(type = JournalContentSearchPersistence.class)
19247            protected JournalContentSearchPersistence journalContentSearchPersistence;
19248            @BeanReference(type = JournalFeedPersistence.class)
19249            protected JournalFeedPersistence journalFeedPersistence;
19250            @BeanReference(type = JournalStructurePersistence.class)
19251            protected JournalStructurePersistence journalStructurePersistence;
19252            @BeanReference(type = JournalTemplatePersistence.class)
19253            protected JournalTemplatePersistence journalTemplatePersistence;
19254            @BeanReference(type = CompanyPersistence.class)
19255            protected CompanyPersistence companyPersistence;
19256            @BeanReference(type = GroupPersistence.class)
19257            protected GroupPersistence groupPersistence;
19258            @BeanReference(type = ImagePersistence.class)
19259            protected ImagePersistence imagePersistence;
19260            @BeanReference(type = PortletPreferencesPersistence.class)
19261            protected PortletPreferencesPersistence portletPreferencesPersistence;
19262            @BeanReference(type = ResourcePersistence.class)
19263            protected ResourcePersistence resourcePersistence;
19264            @BeanReference(type = SubscriptionPersistence.class)
19265            protected SubscriptionPersistence subscriptionPersistence;
19266            @BeanReference(type = UserPersistence.class)
19267            protected UserPersistence userPersistence;
19268            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
19269            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
19270            @BeanReference(type = AssetCategoryPersistence.class)
19271            protected AssetCategoryPersistence assetCategoryPersistence;
19272            @BeanReference(type = AssetEntryPersistence.class)
19273            protected AssetEntryPersistence assetEntryPersistence;
19274            @BeanReference(type = AssetLinkPersistence.class)
19275            protected AssetLinkPersistence assetLinkPersistence;
19276            @BeanReference(type = AssetTagPersistence.class)
19277            protected AssetTagPersistence assetTagPersistence;
19278            @BeanReference(type = ExpandoValuePersistence.class)
19279            protected ExpandoValuePersistence expandoValuePersistence;
19280            @BeanReference(type = MBMessagePersistence.class)
19281            protected MBMessagePersistence mbMessagePersistence;
19282            @BeanReference(type = RatingsStatsPersistence.class)
19283            protected RatingsStatsPersistence ratingsStatsPersistence;
19284            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
19285            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
19286            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
19287            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
19288            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
19289            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
19290            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?)";
19291            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
19292            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
19293            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?) AND ";
19294            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
19295            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
19296                    "journalArticle.resourcePrimKey = ?";
19297            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
19298            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
19299            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
19300            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalArticle.structureId = ?";
19301            private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
19302            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
19303            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_2 = "journalArticle.templateId = ?";
19304            private static final String _FINDER_COLUMN_TEMPLATEID_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
19305            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
19306            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
19307            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
19308            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
19309            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
19310            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
19311            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?)";
19312            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
19313            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
19314            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
19315            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?)";
19316            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
19317            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
19318            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
19319            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
19320            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
19321            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
19322            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
19323            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
19324            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
19325            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
19326            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
19327            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
19328            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
19329            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
19330            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
19331            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
19332            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
19333            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
19334            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
19335            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
19336            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
19337            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
19338            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
19339            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
19340            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
19341            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
19342            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
19343            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
19344            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
19345            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
19346            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
19347            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
19348            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
19349            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
19350            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
19351            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
19352            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
19353            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
19354            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
19355            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
19356            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
19357            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
19358            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
19359                    _removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
19360            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
19361            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
19362            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
19363            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
19364                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
19365            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
19366                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
19367            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
19368                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
19369            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
19370            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
19371                    _removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
19372            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
19373            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
19374            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
19375            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?) AND ";
19376            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
19377            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
19378            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
19379            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
19380    
19381            private static String _removeConjunction(String sql) {
19382                    int pos = sql.indexOf(" AND ");
19383    
19384                    if (pos != -1) {
19385                            sql = sql.substring(0, pos);
19386                    }
19387    
19388                    return sql;
19389            }
19390    
19391            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
19392            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
19393            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
19394                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
19395            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
19396                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
19397            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
19398            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
19399            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
19400            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
19401            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
19402            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
19403            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
19404            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
19405            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
19406            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
19407                            @Override
19408                            public Object clone() {
19409                                    return this;
19410                            }
19411    
19412                            @Override
19413                            public CacheModel<JournalArticle> toCacheModel() {
19414                                    return _nullJournalArticleCacheModel;
19415                            }
19416                    };
19417    
19418            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
19419                            public JournalArticle toEntityModel() {
19420                                    return _nullJournalArticle;
19421                            }
19422                    };
19423    }