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