001    /**
002     * Copyright (c) 2000-2011 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.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.CacheModel;
040    import com.liferay.portal.model.ModelListener;
041    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.persistence.BatchSessionUtil;
043    import com.liferay.portal.service.persistence.CompanyPersistence;
044    import com.liferay.portal.service.persistence.GroupPersistence;
045    import com.liferay.portal.service.persistence.ImagePersistence;
046    import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
047    import com.liferay.portal.service.persistence.ResourcePersistence;
048    import com.liferay.portal.service.persistence.SubscriptionPersistence;
049    import com.liferay.portal.service.persistence.UserPersistence;
050    import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
051    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052    
053    import com.liferay.portlet.asset.service.persistence.AssetCategoryPersistence;
054    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
055    import com.liferay.portlet.asset.service.persistence.AssetLinkPersistence;
056    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
057    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
058    import com.liferay.portlet.journal.NoSuchArticleException;
059    import com.liferay.portlet.journal.model.JournalArticle;
060    import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
061    import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
062    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
063    import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
064    
065    import java.io.Serializable;
066    
067    import java.util.ArrayList;
068    import java.util.Collections;
069    import java.util.List;
070    
071    /**
072     * The persistence implementation for the journal article service.
073     *
074     * <p>
075     * Caching information and settings can be found in <code>portal.properties</code>
076     * </p>
077     *
078     * @author Brian Wing Shun Chan
079     * @see JournalArticlePersistence
080     * @see JournalArticleUtil
081     * @generated
082     */
083    public class JournalArticlePersistenceImpl extends BasePersistenceImpl<JournalArticle>
084            implements JournalArticlePersistence {
085            /*
086             * NOTE FOR DEVELOPERS:
087             *
088             * 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.
089             */
090            public static final String FINDER_CLASS_NAME_ENTITY = JournalArticleImpl.class.getName();
091            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
092                    ".List1";
093            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
094                    ".List2";
095            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
096                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
097                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
098                            "findByUuid",
099                            new String[] {
100                                    String.class.getName(),
101                                    
102                            "java.lang.Integer", "java.lang.Integer",
103                                    "com.liferay.portal.kernel.util.OrderByComparator"
104                            });
105            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
106                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
107                            JournalArticleImpl.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
109                            new String[] { String.class.getName() },
110                            JournalArticleModelImpl.UUID_COLUMN_BITMASK);
111            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
112                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
113                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
114                            new String[] { String.class.getName() });
115            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
116                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
117                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY,
118                            "fetchByUUID_G",
119                            new String[] { String.class.getName(), Long.class.getName() },
120                            JournalArticleModelImpl.UUID_COLUMN_BITMASK |
121                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
122            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
123                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
124                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
125                            new String[] { String.class.getName(), Long.class.getName() });
126            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
127                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
128                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
129                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
130                            "findByResourcePrimKey",
131                            new String[] {
132                                    Long.class.getName(),
133                                    
134                            "java.lang.Integer", "java.lang.Integer",
135                                    "com.liferay.portal.kernel.util.OrderByComparator"
136                            });
137            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY =
138                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
139                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
140                            JournalArticleImpl.class,
141                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourcePrimKey",
142                            new String[] { Long.class.getName() },
143                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK);
144            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
145                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
146                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
147                            "countByResourcePrimKey", new String[] { Long.class.getName() });
148            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
149                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
150                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
151                            "findByGroupId",
152                            new String[] {
153                                    Long.class.getName(),
154                                    
155                            "java.lang.Integer", "java.lang.Integer",
156                                    "com.liferay.portal.kernel.util.OrderByComparator"
157                            });
158            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
159                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
160                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
161                            JournalArticleImpl.class,
162                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
163                            new String[] { Long.class.getName() },
164                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK);
165            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
166                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
167                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
168                            new String[] { Long.class.getName() });
169            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
170                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
171                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
172                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
173                            "findByCompanyId",
174                            new String[] {
175                                    Long.class.getName(),
176                                    
177                            "java.lang.Integer", "java.lang.Integer",
178                                    "com.liferay.portal.kernel.util.OrderByComparator"
179                            });
180            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
181                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
182                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
183                            JournalArticleImpl.class,
184                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
185                            new String[] { Long.class.getName() },
186                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK);
187            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
188                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
189                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
190                            new String[] { Long.class.getName() });
191            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID =
192                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
193                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
194                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
195                            "findBySmallImageId",
196                            new String[] {
197                                    Long.class.getName(),
198                                    
199                            "java.lang.Integer", "java.lang.Integer",
200                                    "com.liferay.portal.kernel.util.OrderByComparator"
201                            });
202            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID =
203                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
204                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
205                            JournalArticleImpl.class,
206                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySmallImageId",
207                            new String[] { Long.class.getName() },
208                            JournalArticleModelImpl.SMALLIMAGEID_COLUMN_BITMASK);
209            public static final FinderPath FINDER_PATH_COUNT_BY_SMALLIMAGEID = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
210                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
211                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySmallImageId",
212                            new String[] { Long.class.getName() });
213            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
214                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
215                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
216                            "findByR_ST",
217                            new String[] {
218                                    Long.class.getName(), Integer.class.getName(),
219                                    
220                            "java.lang.Integer", "java.lang.Integer",
221                                    "com.liferay.portal.kernel.util.OrderByComparator"
222                            });
223            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
224                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
225                            JournalArticleImpl.class,
226                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_ST",
227                            new String[] { Long.class.getName(), Integer.class.getName() },
228                            JournalArticleModelImpl.RESOURCEPRIMKEY_COLUMN_BITMASK |
229                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
230            public static final FinderPath FINDER_PATH_COUNT_BY_R_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
231                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
232                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_ST",
233                            new String[] { Long.class.getName(), Integer.class.getName() });
234            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
235                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
236                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
237                            "findByG_A",
238                            new String[] {
239                                    Long.class.getName(), String.class.getName(),
240                                    
241                            "java.lang.Integer", "java.lang.Integer",
242                                    "com.liferay.portal.kernel.util.OrderByComparator"
243                            });
244            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
245                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
246                            JournalArticleImpl.class,
247                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A",
248                            new String[] { Long.class.getName(), String.class.getName() },
249                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
250                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK);
251            public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
252                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
253                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A",
254                            new String[] { Long.class.getName(), String.class.getName() });
255            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
256                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
257                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
258                            "findByG_UT",
259                            new String[] {
260                                    Long.class.getName(), String.class.getName(),
261                                    
262                            "java.lang.Integer", "java.lang.Integer",
263                                    "com.liferay.portal.kernel.util.OrderByComparator"
264                            });
265            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
266                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
267                            JournalArticleImpl.class,
268                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT",
269                            new String[] { Long.class.getName(), String.class.getName() },
270                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
271                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK);
272            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
273                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
274                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
275                            new String[] { Long.class.getName(), String.class.getName() });
276            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
277                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
278                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
279                            "findByG_S",
280                            new String[] {
281                                    Long.class.getName(), String.class.getName(),
282                                    
283                            "java.lang.Integer", "java.lang.Integer",
284                                    "com.liferay.portal.kernel.util.OrderByComparator"
285                            });
286            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
287                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
288                            JournalArticleImpl.class,
289                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
290                            new String[] { Long.class.getName(), String.class.getName() },
291                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
292                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
293            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
294                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
295                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
296                            new String[] { Long.class.getName(), String.class.getName() });
297            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
298                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
299                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
300                            "findByG_T",
301                            new String[] {
302                                    Long.class.getName(), String.class.getName(),
303                                    
304                            "java.lang.Integer", "java.lang.Integer",
305                                    "com.liferay.portal.kernel.util.OrderByComparator"
306                            });
307            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
308                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
309                            JournalArticleImpl.class,
310                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
311                            new String[] { Long.class.getName(), String.class.getName() },
312                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
313                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK);
314            public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
315                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
316                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_T",
317                            new String[] { Long.class.getName(), String.class.getName() });
318            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
319                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
320                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
321                            "findByG_L",
322                            new String[] {
323                                    Long.class.getName(), String.class.getName(),
324                                    
325                            "java.lang.Integer", "java.lang.Integer",
326                                    "com.liferay.portal.kernel.util.OrderByComparator"
327                            });
328            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
329                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
330                            JournalArticleImpl.class,
331                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_L",
332                            new String[] { Long.class.getName(), String.class.getName() },
333                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
334                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK);
335            public static final FinderPath FINDER_PATH_COUNT_BY_G_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
336                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
337                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_L",
338                            new String[] { Long.class.getName(), String.class.getName() });
339            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
340                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
341                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
342                            "findByG_ST",
343                            new String[] {
344                                    Long.class.getName(), Integer.class.getName(),
345                                    
346                            "java.lang.Integer", "java.lang.Integer",
347                                    "com.liferay.portal.kernel.util.OrderByComparator"
348                            });
349            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
350                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
351                            JournalArticleImpl.class,
352                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_ST",
353                            new String[] { Long.class.getName(), Integer.class.getName() },
354                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
355                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
356            public static final FinderPath FINDER_PATH_COUNT_BY_G_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
357                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
358                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_ST",
359                            new String[] { Long.class.getName(), Integer.class.getName() });
360            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
361                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
362                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
363                            "findByC_V",
364                            new String[] {
365                                    Long.class.getName(), Double.class.getName(),
366                                    
367                            "java.lang.Integer", "java.lang.Integer",
368                                    "com.liferay.portal.kernel.util.OrderByComparator"
369                            });
370            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
371                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
372                            JournalArticleImpl.class,
373                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V",
374                            new String[] { Long.class.getName(), Double.class.getName() },
375                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
376                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
377            public static final FinderPath FINDER_PATH_COUNT_BY_C_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
378                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
379                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V",
380                            new String[] { Long.class.getName(), Double.class.getName() });
381            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
382                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
383                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
384                            "findByC_ST",
385                            new String[] {
386                                    Long.class.getName(), Integer.class.getName(),
387                                    
388                            "java.lang.Integer", "java.lang.Integer",
389                                    "com.liferay.portal.kernel.util.OrderByComparator"
390                            });
391            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
392                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
393                            JournalArticleImpl.class,
394                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_ST",
395                            new String[] { Long.class.getName(), Integer.class.getName() },
396                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
397                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
398            public static final FinderPath FINDER_PATH_COUNT_BY_C_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
399                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
400                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ST",
401                            new String[] { Long.class.getName(), Integer.class.getName() });
402            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
403                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
404                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
405                            "findByG_C_C",
406                            new String[] {
407                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
408                                    
409                            "java.lang.Integer", "java.lang.Integer",
410                                    "com.liferay.portal.kernel.util.OrderByComparator"
411                            });
412            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
413                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
414                            JournalArticleImpl.class,
415                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
416                            new String[] {
417                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
418                            },
419                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
420                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
421                            JournalArticleModelImpl.CLASSPK_COLUMN_BITMASK);
422            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
423                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
424                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
425                            new String[] {
426                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
427                            });
428            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
429                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
430                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C_S",
431                            new String[] {
432                                    Long.class.getName(), Long.class.getName(),
433                                    String.class.getName()
434                            },
435                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
436                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
437                            JournalArticleModelImpl.STRUCTUREID_COLUMN_BITMASK);
438            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_S = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
439                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
440                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_S",
441                            new String[] {
442                                    Long.class.getName(), Long.class.getName(),
443                                    String.class.getName()
444                            });
445            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
446                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
447                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
448                            "findByG_C_T",
449                            new String[] {
450                                    Long.class.getName(), Long.class.getName(),
451                                    String.class.getName(),
452                                    
453                            "java.lang.Integer", "java.lang.Integer",
454                                    "com.liferay.portal.kernel.util.OrderByComparator"
455                            });
456            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
457                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
458                            JournalArticleImpl.class,
459                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_T",
460                            new String[] {
461                                    Long.class.getName(), Long.class.getName(),
462                                    String.class.getName()
463                            },
464                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
465                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
466                            JournalArticleModelImpl.TEMPLATEID_COLUMN_BITMASK);
467            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_T = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
468                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
469                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_T",
470                            new String[] {
471                                    Long.class.getName(), Long.class.getName(),
472                                    String.class.getName()
473                            });
474            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
475                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
476                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
477                            "findByG_C_L",
478                            new String[] {
479                                    Long.class.getName(), Long.class.getName(),
480                                    String.class.getName(),
481                                    
482                            "java.lang.Integer", "java.lang.Integer",
483                                    "com.liferay.portal.kernel.util.OrderByComparator"
484                            });
485            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
486                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
487                            JournalArticleImpl.class,
488                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_L",
489                            new String[] {
490                                    Long.class.getName(), Long.class.getName(),
491                                    String.class.getName()
492                            },
493                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
494                            JournalArticleModelImpl.CLASSNAMEID_COLUMN_BITMASK |
495                            JournalArticleModelImpl.LAYOUTUUID_COLUMN_BITMASK);
496            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_L = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
497                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
498                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_L",
499                            new String[] {
500                                    Long.class.getName(), Long.class.getName(),
501                                    String.class.getName()
502                            });
503            public static final FinderPath FINDER_PATH_FETCH_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
504                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
505                            JournalArticleImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_A_V",
506                            new String[] {
507                                    Long.class.getName(), String.class.getName(),
508                                    Double.class.getName()
509                            },
510                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
511                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
512                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK);
513            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_V = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
514                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
515                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_V",
516                            new String[] {
517                                    Long.class.getName(), String.class.getName(),
518                                    Double.class.getName()
519                            });
520            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
521                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
522                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
523                            "findByG_A_ST",
524                            new String[] {
525                                    Long.class.getName(), String.class.getName(),
526                                    Integer.class.getName(),
527                                    
528                            "java.lang.Integer", "java.lang.Integer",
529                                    "com.liferay.portal.kernel.util.OrderByComparator"
530                            });
531            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST =
532                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
533                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
534                            JournalArticleImpl.class,
535                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_A_ST",
536                            new String[] {
537                                    Long.class.getName(), String.class.getName(),
538                                    Integer.class.getName()
539                            },
540                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
541                            JournalArticleModelImpl.ARTICLEID_COLUMN_BITMASK |
542                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
543            public static final FinderPath FINDER_PATH_COUNT_BY_G_A_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
544                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
545                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_A_ST",
546                            new String[] {
547                                    Long.class.getName(), String.class.getName(),
548                                    Integer.class.getName()
549                            });
550            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
551                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
552                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
553                            "findByG_UT_ST",
554                            new String[] {
555                                    Long.class.getName(), String.class.getName(),
556                                    Integer.class.getName(),
557                                    
558                            "java.lang.Integer", "java.lang.Integer",
559                                    "com.liferay.portal.kernel.util.OrderByComparator"
560                            });
561            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST =
562                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
563                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
564                            JournalArticleImpl.class,
565                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_UT_ST",
566                            new String[] {
567                                    Long.class.getName(), String.class.getName(),
568                                    Integer.class.getName()
569                            },
570                            JournalArticleModelImpl.GROUPID_COLUMN_BITMASK |
571                            JournalArticleModelImpl.URLTITLE_COLUMN_BITMASK |
572                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
573            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
574                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
575                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT_ST",
576                            new String[] {
577                                    Long.class.getName(), String.class.getName(),
578                                    Integer.class.getName()
579                            });
580            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
581                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
582                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
583                            "findByC_V_ST",
584                            new String[] {
585                                    Long.class.getName(), Double.class.getName(),
586                                    Integer.class.getName(),
587                                    
588                            "java.lang.Integer", "java.lang.Integer",
589                                    "com.liferay.portal.kernel.util.OrderByComparator"
590                            });
591            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST =
592                    new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
593                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
594                            JournalArticleImpl.class,
595                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_V_ST",
596                            new String[] {
597                                    Long.class.getName(), Double.class.getName(),
598                                    Integer.class.getName()
599                            },
600                            JournalArticleModelImpl.COMPANYID_COLUMN_BITMASK |
601                            JournalArticleModelImpl.VERSION_COLUMN_BITMASK |
602                            JournalArticleModelImpl.STATUS_COLUMN_BITMASK);
603            public static final FinderPath FINDER_PATH_COUNT_BY_C_V_ST = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
604                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
605                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_V_ST",
606                            new String[] {
607                                    Long.class.getName(), Double.class.getName(),
608                                    Integer.class.getName()
609                            });
610            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
611                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
612                            JournalArticleImpl.class,
613                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
614            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
615                            JournalArticleModelImpl.FINDER_CACHE_ENABLED,
616                            JournalArticleImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
617                            "findAll", new String[0]);
618            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
619                            JournalArticleModelImpl.FINDER_CACHE_ENABLED, Long.class,
620                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
621    
622            /**
623             * Caches the journal article in the entity cache if it is enabled.
624             *
625             * @param journalArticle the journal article
626             */
627            public void cacheResult(JournalArticle journalArticle) {
628                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
629                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
630                            journalArticle);
631    
632                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
633                            new Object[] {
634                                    journalArticle.getUuid(),
635                                    Long.valueOf(journalArticle.getGroupId())
636                            }, journalArticle);
637    
638                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
639                            new Object[] {
640                                    Long.valueOf(journalArticle.getGroupId()),
641                                    Long.valueOf(journalArticle.getClassNameId()),
642                                    
643                            journalArticle.getStructureId()
644                            }, journalArticle);
645    
646                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
647                            new Object[] {
648                                    Long.valueOf(journalArticle.getGroupId()),
649                                    
650                            journalArticle.getArticleId(),
651                                    Double.valueOf(journalArticle.getVersion())
652                            }, journalArticle);
653    
654                    journalArticle.resetOriginalValues();
655            }
656    
657            /**
658             * Caches the journal articles in the entity cache if it is enabled.
659             *
660             * @param journalArticles the journal articles
661             */
662            public void cacheResult(List<JournalArticle> journalArticles) {
663                    for (JournalArticle journalArticle : journalArticles) {
664                            if (EntityCacheUtil.getResult(
665                                                    JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
666                                                    JournalArticleImpl.class, journalArticle.getPrimaryKey()) == null) {
667                                    cacheResult(journalArticle);
668                            }
669                            else {
670                                    journalArticle.resetOriginalValues();
671                            }
672                    }
673            }
674    
675            /**
676             * Clears the cache for all journal articles.
677             *
678             * <p>
679             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
680             * </p>
681             */
682            @Override
683            public void clearCache() {
684                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
685                            CacheRegistryUtil.clear(JournalArticleImpl.class.getName());
686                    }
687    
688                    EntityCacheUtil.clearCache(JournalArticleImpl.class.getName());
689    
690                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
691                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
692                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
693            }
694    
695            /**
696             * Clears the cache for the journal article.
697             *
698             * <p>
699             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
700             * </p>
701             */
702            @Override
703            public void clearCache(JournalArticle journalArticle) {
704                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
705                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
706    
707                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
708                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
709    
710                    clearUniqueFindersCache(journalArticle);
711            }
712    
713            @Override
714            public void clearCache(List<JournalArticle> journalArticles) {
715                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
716                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
717    
718                    for (JournalArticle journalArticle : journalArticles) {
719                            EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
720                                    JournalArticleImpl.class, journalArticle.getPrimaryKey());
721    
722                            clearUniqueFindersCache(journalArticle);
723                    }
724            }
725    
726            protected void clearUniqueFindersCache(JournalArticle journalArticle) {
727                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
728                            new Object[] {
729                                    journalArticle.getUuid(),
730                                    Long.valueOf(journalArticle.getGroupId())
731                            });
732    
733                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
734                            new Object[] {
735                                    Long.valueOf(journalArticle.getGroupId()),
736                                    Long.valueOf(journalArticle.getClassNameId()),
737                                    
738                            journalArticle.getStructureId()
739                            });
740    
741                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
742                            new Object[] {
743                                    Long.valueOf(journalArticle.getGroupId()),
744                                    
745                            journalArticle.getArticleId(),
746                                    Double.valueOf(journalArticle.getVersion())
747                            });
748            }
749    
750            /**
751             * Creates a new journal article with the primary key. Does not add the journal article to the database.
752             *
753             * @param id the primary key for the new journal article
754             * @return the new journal article
755             */
756            public JournalArticle create(long id) {
757                    JournalArticle journalArticle = new JournalArticleImpl();
758    
759                    journalArticle.setNew(true);
760                    journalArticle.setPrimaryKey(id);
761    
762                    String uuid = PortalUUIDUtil.generate();
763    
764                    journalArticle.setUuid(uuid);
765    
766                    return journalArticle;
767            }
768    
769            /**
770             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
771             *
772             * @param id the primary key of the journal article
773             * @return the journal article that was removed
774             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
775             * @throws SystemException if a system exception occurred
776             */
777            public JournalArticle remove(long id)
778                    throws NoSuchArticleException, SystemException {
779                    return remove(Long.valueOf(id));
780            }
781    
782            /**
783             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
784             *
785             * @param primaryKey the primary key of the journal article
786             * @return the journal article that was removed
787             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
788             * @throws SystemException if a system exception occurred
789             */
790            @Override
791            public JournalArticle remove(Serializable primaryKey)
792                    throws NoSuchArticleException, SystemException {
793                    Session session = null;
794    
795                    try {
796                            session = openSession();
797    
798                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
799                                            primaryKey);
800    
801                            if (journalArticle == null) {
802                                    if (_log.isWarnEnabled()) {
803                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
804                                    }
805    
806                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
807                                            primaryKey);
808                            }
809    
810                            return remove(journalArticle);
811                    }
812                    catch (NoSuchArticleException nsee) {
813                            throw nsee;
814                    }
815                    catch (Exception e) {
816                            throw processException(e);
817                    }
818                    finally {
819                            closeSession(session);
820                    }
821            }
822    
823            @Override
824            protected JournalArticle removeImpl(JournalArticle journalArticle)
825                    throws SystemException {
826                    journalArticle = toUnwrappedModel(journalArticle);
827    
828                    Session session = null;
829    
830                    try {
831                            session = openSession();
832    
833                            BatchSessionUtil.delete(session, journalArticle);
834                    }
835                    catch (Exception e) {
836                            throw processException(e);
837                    }
838                    finally {
839                            closeSession(session);
840                    }
841    
842                    clearCache(journalArticle);
843    
844                    return journalArticle;
845            }
846    
847            @Override
848            public JournalArticle updateImpl(
849                    com.liferay.portlet.journal.model.JournalArticle journalArticle,
850                    boolean merge) throws SystemException {
851                    journalArticle = toUnwrappedModel(journalArticle);
852    
853                    boolean isNew = journalArticle.isNew();
854    
855                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
856    
857                    if (Validator.isNull(journalArticle.getUuid())) {
858                            String uuid = PortalUUIDUtil.generate();
859    
860                            journalArticle.setUuid(uuid);
861                    }
862    
863                    Session session = null;
864    
865                    try {
866                            session = openSession();
867    
868                            BatchSessionUtil.update(session, journalArticle, merge);
869    
870                            journalArticle.setNew(false);
871                    }
872                    catch (Exception e) {
873                            throw processException(e);
874                    }
875                    finally {
876                            closeSession(session);
877                    }
878    
879                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
880    
881                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
882                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
883                    }
884    
885                    else {
886                            if ((journalArticleModelImpl.getColumnBitmask() &
887                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
888                                    Object[] args = new Object[] {
889                                                    journalArticleModelImpl.getOriginalUuid()
890                                            };
891    
892                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
893                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
894                                            args);
895    
896                                    args = new Object[] { journalArticleModelImpl.getUuid() };
897    
898                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
899                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
900                                            args);
901                            }
902    
903                            if ((journalArticleModelImpl.getColumnBitmask() &
904                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
905                                    Object[] args = new Object[] {
906                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey())
907                                            };
908    
909                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
910                                            args);
911                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
912                                            args);
913    
914                                    args = new Object[] {
915                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey())
916                                            };
917    
918                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
919                                            args);
920                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
921                                            args);
922                            }
923    
924                            if ((journalArticleModelImpl.getColumnBitmask() &
925                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
926                                    Object[] args = new Object[] {
927                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
928                                            };
929    
930                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
931                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
932                                            args);
933    
934                                    args = new Object[] {
935                                                    Long.valueOf(journalArticleModelImpl.getGroupId())
936                                            };
937    
938                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
939                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
940                                            args);
941                            }
942    
943                            if ((journalArticleModelImpl.getColumnBitmask() &
944                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
945                                    Object[] args = new Object[] {
946                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId())
947                                            };
948    
949                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
950                                            args);
951                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
952                                            args);
953    
954                                    args = new Object[] {
955                                                    Long.valueOf(journalArticleModelImpl.getCompanyId())
956                                            };
957    
958                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
959                                            args);
960                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
961                                            args);
962                            }
963    
964                            if ((journalArticleModelImpl.getColumnBitmask() &
965                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
966                                    Object[] args = new Object[] {
967                                                    Long.valueOf(journalArticleModelImpl.getOriginalSmallImageId())
968                                            };
969    
970                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
971                                            args);
972                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
973                                            args);
974    
975                                    args = new Object[] {
976                                                    Long.valueOf(journalArticleModelImpl.getSmallImageId())
977                                            };
978    
979                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
980                                            args);
981                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
982                                            args);
983                            }
984    
985                            if ((journalArticleModelImpl.getColumnBitmask() &
986                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
987                                    Object[] args = new Object[] {
988                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey()),
989                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
990                                            };
991    
992                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
993                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
994                                            args);
995    
996                                    args = new Object[] {
997                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey()),
998                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
999                                            };
1000    
1001                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
1002                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
1003                                            args);
1004                            }
1005    
1006                            if ((journalArticleModelImpl.getColumnBitmask() &
1007                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
1008                                    Object[] args = new Object[] {
1009                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1010                                                    
1011                                                    journalArticleModelImpl.getOriginalArticleId()
1012                                            };
1013    
1014                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1015                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
1016                                            args);
1017    
1018                                    args = new Object[] {
1019                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1020                                                    
1021                                                    journalArticleModelImpl.getArticleId()
1022                                            };
1023    
1024                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1025                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
1026                                            args);
1027                            }
1028    
1029                            if ((journalArticleModelImpl.getColumnBitmask() &
1030                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
1031                                    Object[] args = new Object[] {
1032                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1033                                                    
1034                                                    journalArticleModelImpl.getOriginalUrlTitle()
1035                                            };
1036    
1037                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
1038                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
1039                                            args);
1040    
1041                                    args = new Object[] {
1042                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1043                                                    
1044                                                    journalArticleModelImpl.getUrlTitle()
1045                                            };
1046    
1047                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
1048                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
1049                                            args);
1050                            }
1051    
1052                            if ((journalArticleModelImpl.getColumnBitmask() &
1053                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
1054                                    Object[] args = new Object[] {
1055                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1056                                                    
1057                                                    journalArticleModelImpl.getOriginalStructureId()
1058                                            };
1059    
1060                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1061                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1062                                            args);
1063    
1064                                    args = new Object[] {
1065                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1066                                                    
1067                                                    journalArticleModelImpl.getStructureId()
1068                                            };
1069    
1070                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1071                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1072                                            args);
1073                            }
1074    
1075                            if ((journalArticleModelImpl.getColumnBitmask() &
1076                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
1077                                    Object[] args = new Object[] {
1078                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1079                                                    
1080                                                    journalArticleModelImpl.getOriginalTemplateId()
1081                                            };
1082    
1083                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
1084                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
1085                                            args);
1086    
1087                                    args = new Object[] {
1088                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1089                                                    
1090                                                    journalArticleModelImpl.getTemplateId()
1091                                            };
1092    
1093                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
1094                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
1095                                            args);
1096                            }
1097    
1098                            if ((journalArticleModelImpl.getColumnBitmask() &
1099                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
1100                                    Object[] args = new Object[] {
1101                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1102                                                    
1103                                                    journalArticleModelImpl.getOriginalLayoutUuid()
1104                                            };
1105    
1106                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
1107                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
1108                                            args);
1109    
1110                                    args = new Object[] {
1111                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1112                                                    
1113                                                    journalArticleModelImpl.getLayoutUuid()
1114                                            };
1115    
1116                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
1117                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
1118                                            args);
1119                            }
1120    
1121                            if ((journalArticleModelImpl.getColumnBitmask() &
1122                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
1123                                    Object[] args = new Object[] {
1124                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1125                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1126                                            };
1127    
1128                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
1129                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
1130                                            args);
1131    
1132                                    args = new Object[] {
1133                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1134                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1135                                            };
1136    
1137                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
1138                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
1139                                            args);
1140                            }
1141    
1142                            if ((journalArticleModelImpl.getColumnBitmask() &
1143                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
1144                                    Object[] args = new Object[] {
1145                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1146                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion())
1147                                            };
1148    
1149                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
1150                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
1151                                            args);
1152    
1153                                    args = new Object[] {
1154                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1155                                                    Double.valueOf(journalArticleModelImpl.getVersion())
1156                                            };
1157    
1158                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
1159                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
1160                                            args);
1161                            }
1162    
1163                            if ((journalArticleModelImpl.getColumnBitmask() &
1164                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
1165                                    Object[] args = new Object[] {
1166                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1167                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1168                                            };
1169    
1170                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
1171                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
1172                                            args);
1173    
1174                                    args = new Object[] {
1175                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1176                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1177                                            };
1178    
1179                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
1180                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
1181                                            args);
1182                            }
1183    
1184                            if ((journalArticleModelImpl.getColumnBitmask() &
1185                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
1186                                    Object[] args = new Object[] {
1187                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1188                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1189                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassPK())
1190                                            };
1191    
1192                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
1193                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
1194                                            args);
1195    
1196                                    args = new Object[] {
1197                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1198                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1199                                                    Long.valueOf(journalArticleModelImpl.getClassPK())
1200                                            };
1201    
1202                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
1203                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
1204                                            args);
1205                            }
1206    
1207                            if ((journalArticleModelImpl.getColumnBitmask() &
1208                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
1209                                    Object[] args = new Object[] {
1210                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1211                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1212                                                    
1213                                                    journalArticleModelImpl.getOriginalTemplateId()
1214                                            };
1215    
1216                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1217                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1218                                            args);
1219    
1220                                    args = new Object[] {
1221                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1222                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1223                                                    
1224                                                    journalArticleModelImpl.getTemplateId()
1225                                            };
1226    
1227                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1228                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1229                                            args);
1230                            }
1231    
1232                            if ((journalArticleModelImpl.getColumnBitmask() &
1233                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
1234                                    Object[] args = new Object[] {
1235                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1236                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1237                                                    
1238                                                    journalArticleModelImpl.getOriginalLayoutUuid()
1239                                            };
1240    
1241                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
1242                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
1243                                            args);
1244    
1245                                    args = new Object[] {
1246                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1247                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1248                                                    
1249                                                    journalArticleModelImpl.getLayoutUuid()
1250                                            };
1251    
1252                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
1253                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
1254                                            args);
1255                            }
1256    
1257                            if ((journalArticleModelImpl.getColumnBitmask() &
1258                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
1259                                    Object[] args = new Object[] {
1260                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1261                                                    
1262                                                    journalArticleModelImpl.getOriginalArticleId(),
1263                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1264                                            };
1265    
1266                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
1267                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
1268                                            args);
1269    
1270                                    args = new Object[] {
1271                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1272                                                    
1273                                                    journalArticleModelImpl.getArticleId(),
1274                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1275                                            };
1276    
1277                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
1278                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
1279                                            args);
1280                            }
1281    
1282                            if ((journalArticleModelImpl.getColumnBitmask() &
1283                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
1284                                    Object[] args = new Object[] {
1285                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1286                                                    
1287                                                    journalArticleModelImpl.getOriginalUrlTitle(),
1288                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1289                                            };
1290    
1291                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
1292                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
1293                                            args);
1294    
1295                                    args = new Object[] {
1296                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1297                                                    
1298                                                    journalArticleModelImpl.getUrlTitle(),
1299                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1300                                            };
1301    
1302                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
1303                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
1304                                            args);
1305                            }
1306    
1307                            if ((journalArticleModelImpl.getColumnBitmask() &
1308                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
1309                                    Object[] args = new Object[] {
1310                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1311                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion()),
1312                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1313                                            };
1314    
1315                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
1316                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
1317                                            args);
1318    
1319                                    args = new Object[] {
1320                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1321                                                    Double.valueOf(journalArticleModelImpl.getVersion()),
1322                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1323                                            };
1324    
1325                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
1326                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
1327                                            args);
1328                            }
1329                    }
1330    
1331                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1332                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
1333                            journalArticle);
1334    
1335                    if (isNew) {
1336                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1337                                    new Object[] {
1338                                            journalArticle.getUuid(),
1339                                            Long.valueOf(journalArticle.getGroupId())
1340                                    }, journalArticle);
1341    
1342                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
1343                                    new Object[] {
1344                                            Long.valueOf(journalArticle.getGroupId()),
1345                                            Long.valueOf(journalArticle.getClassNameId()),
1346                                            
1347                                    journalArticle.getStructureId()
1348                                    }, journalArticle);
1349    
1350                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
1351                                    new Object[] {
1352                                            Long.valueOf(journalArticle.getGroupId()),
1353                                            
1354                                    journalArticle.getArticleId(),
1355                                            Double.valueOf(journalArticle.getVersion())
1356                                    }, journalArticle);
1357                    }
1358                    else {
1359                            if ((journalArticleModelImpl.getColumnBitmask() &
1360                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
1361                                    Object[] args = new Object[] {
1362                                                    journalArticleModelImpl.getOriginalUuid(),
1363                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
1364                                            };
1365    
1366                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
1367                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
1368    
1369                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1370                                            new Object[] {
1371                                                    journalArticle.getUuid(),
1372                                                    Long.valueOf(journalArticle.getGroupId())
1373                                            }, journalArticle);
1374                            }
1375    
1376                            if ((journalArticleModelImpl.getColumnBitmask() &
1377                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
1378                                    Object[] args = new Object[] {
1379                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1380                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1381                                                    
1382                                                    journalArticleModelImpl.getOriginalStructureId()
1383                                            };
1384    
1385                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
1386                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
1387    
1388                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
1389                                            new Object[] {
1390                                                    Long.valueOf(journalArticle.getGroupId()),
1391                                                    Long.valueOf(journalArticle.getClassNameId()),
1392                                                    
1393                                            journalArticle.getStructureId()
1394                                            }, journalArticle);
1395                            }
1396    
1397                            if ((journalArticleModelImpl.getColumnBitmask() &
1398                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
1399                                    Object[] args = new Object[] {
1400                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1401                                                    
1402                                                    journalArticleModelImpl.getOriginalArticleId(),
1403                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion())
1404                                            };
1405    
1406                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
1407                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
1408    
1409                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
1410                                            new Object[] {
1411                                                    Long.valueOf(journalArticle.getGroupId()),
1412                                                    
1413                                            journalArticle.getArticleId(),
1414                                                    Double.valueOf(journalArticle.getVersion())
1415                                            }, journalArticle);
1416                            }
1417                    }
1418    
1419                    return journalArticle;
1420            }
1421    
1422            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
1423                    if (journalArticle instanceof JournalArticleImpl) {
1424                            return journalArticle;
1425                    }
1426    
1427                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
1428    
1429                    journalArticleImpl.setNew(journalArticle.isNew());
1430                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
1431    
1432                    journalArticleImpl.setUuid(journalArticle.getUuid());
1433                    journalArticleImpl.setId(journalArticle.getId());
1434                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
1435                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
1436                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
1437                    journalArticleImpl.setUserId(journalArticle.getUserId());
1438                    journalArticleImpl.setUserName(journalArticle.getUserName());
1439                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
1440                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
1441                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
1442                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
1443                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
1444                    journalArticleImpl.setVersion(journalArticle.getVersion());
1445                    journalArticleImpl.setTitle(journalArticle.getTitle());
1446                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
1447                    journalArticleImpl.setDescription(journalArticle.getDescription());
1448                    journalArticleImpl.setContent(journalArticle.getContent());
1449                    journalArticleImpl.setType(journalArticle.getType());
1450                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
1451                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
1452                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
1453                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
1454                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
1455                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
1456                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
1457                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
1458                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
1459                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
1460                    journalArticleImpl.setStatus(journalArticle.getStatus());
1461                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
1462                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
1463                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
1464    
1465                    return journalArticleImpl;
1466            }
1467    
1468            /**
1469             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
1470             *
1471             * @param primaryKey the primary key of the journal article
1472             * @return the journal article
1473             * @throws com.liferay.portal.NoSuchModelException if a journal article with the primary key could not be found
1474             * @throws SystemException if a system exception occurred
1475             */
1476            @Override
1477            public JournalArticle findByPrimaryKey(Serializable primaryKey)
1478                    throws NoSuchModelException, SystemException {
1479                    return findByPrimaryKey(((Long)primaryKey).longValue());
1480            }
1481    
1482            /**
1483             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
1484             *
1485             * @param id the primary key of the journal article
1486             * @return the journal article
1487             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1488             * @throws SystemException if a system exception occurred
1489             */
1490            public JournalArticle findByPrimaryKey(long id)
1491                    throws NoSuchArticleException, SystemException {
1492                    JournalArticle journalArticle = fetchByPrimaryKey(id);
1493    
1494                    if (journalArticle == null) {
1495                            if (_log.isWarnEnabled()) {
1496                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
1497                            }
1498    
1499                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1500                                    id);
1501                    }
1502    
1503                    return journalArticle;
1504            }
1505    
1506            /**
1507             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
1508             *
1509             * @param primaryKey the primary key of the journal article
1510             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
1511             * @throws SystemException if a system exception occurred
1512             */
1513            @Override
1514            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
1515                    throws SystemException {
1516                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
1517            }
1518    
1519            /**
1520             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
1521             *
1522             * @param id the primary key of the journal article
1523             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
1524             * @throws SystemException if a system exception occurred
1525             */
1526            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
1527                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1528                                    JournalArticleImpl.class, id);
1529    
1530                    if (journalArticle == _nullJournalArticle) {
1531                            return null;
1532                    }
1533    
1534                    if (journalArticle == null) {
1535                            Session session = null;
1536    
1537                            boolean hasException = false;
1538    
1539                            try {
1540                                    session = openSession();
1541    
1542                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
1543                                                    Long.valueOf(id));
1544                            }
1545                            catch (Exception e) {
1546                                    hasException = true;
1547    
1548                                    throw processException(e);
1549                            }
1550                            finally {
1551                                    if (journalArticle != null) {
1552                                            cacheResult(journalArticle);
1553                                    }
1554                                    else if (!hasException) {
1555                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1556                                                    JournalArticleImpl.class, id, _nullJournalArticle);
1557                                    }
1558    
1559                                    closeSession(session);
1560                            }
1561                    }
1562    
1563                    return journalArticle;
1564            }
1565    
1566            /**
1567             * Returns all the journal articles where uuid = &#63;.
1568             *
1569             * @param uuid the uuid
1570             * @return the matching journal articles
1571             * @throws SystemException if a system exception occurred
1572             */
1573            public List<JournalArticle> findByUuid(String uuid)
1574                    throws SystemException {
1575                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1576            }
1577    
1578            /**
1579             * Returns a range of all the journal articles where uuid = &#63;.
1580             *
1581             * <p>
1582             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1583             * </p>
1584             *
1585             * @param uuid the uuid
1586             * @param start the lower bound of the range of journal articles
1587             * @param end the upper bound of the range of journal articles (not inclusive)
1588             * @return the range of matching journal articles
1589             * @throws SystemException if a system exception occurred
1590             */
1591            public List<JournalArticle> findByUuid(String uuid, int start, int end)
1592                    throws SystemException {
1593                    return findByUuid(uuid, start, end, null);
1594            }
1595    
1596            /**
1597             * Returns an ordered range of all the journal articles where uuid = &#63;.
1598             *
1599             * <p>
1600             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1601             * </p>
1602             *
1603             * @param uuid the uuid
1604             * @param start the lower bound of the range of journal articles
1605             * @param end the upper bound of the range of journal articles (not inclusive)
1606             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1607             * @return the ordered range of matching journal articles
1608             * @throws SystemException if a system exception occurred
1609             */
1610            public List<JournalArticle> findByUuid(String uuid, int start, int end,
1611                    OrderByComparator orderByComparator) throws SystemException {
1612                    FinderPath finderPath = null;
1613                    Object[] finderArgs = null;
1614    
1615                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1616                                    (orderByComparator == null)) {
1617                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1618                            finderArgs = new Object[] { uuid };
1619                    }
1620                    else {
1621                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1622                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1623                    }
1624    
1625                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1626                                    finderArgs, this);
1627    
1628                    if (list == null) {
1629                            StringBundler query = null;
1630    
1631                            if (orderByComparator != null) {
1632                                    query = new StringBundler(3 +
1633                                                    (orderByComparator.getOrderByFields().length * 3));
1634                            }
1635                            else {
1636                                    query = new StringBundler(3);
1637                            }
1638    
1639                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1640    
1641                            if (uuid == null) {
1642                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1643                            }
1644                            else {
1645                                    if (uuid.equals(StringPool.BLANK)) {
1646                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1647                                    }
1648                                    else {
1649                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1650                                    }
1651                            }
1652    
1653                            if (orderByComparator != null) {
1654                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1655                                            orderByComparator);
1656                            }
1657    
1658                            else {
1659                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1660                            }
1661    
1662                            String sql = query.toString();
1663    
1664                            Session session = null;
1665    
1666                            try {
1667                                    session = openSession();
1668    
1669                                    Query q = session.createQuery(sql);
1670    
1671                                    QueryPos qPos = QueryPos.getInstance(q);
1672    
1673                                    if (uuid != null) {
1674                                            qPos.add(uuid);
1675                                    }
1676    
1677                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
1678                                                    start, end);
1679                            }
1680                            catch (Exception e) {
1681                                    throw processException(e);
1682                            }
1683                            finally {
1684                                    if (list == null) {
1685                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1686                                    }
1687                                    else {
1688                                            cacheResult(list);
1689    
1690                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1691                                    }
1692    
1693                                    closeSession(session);
1694                            }
1695                    }
1696    
1697                    return list;
1698            }
1699    
1700            /**
1701             * Returns the first journal article in the ordered set where uuid = &#63;.
1702             *
1703             * <p>
1704             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1705             * </p>
1706             *
1707             * @param uuid the uuid
1708             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1709             * @return the first matching journal article
1710             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1711             * @throws SystemException if a system exception occurred
1712             */
1713            public JournalArticle findByUuid_First(String uuid,
1714                    OrderByComparator orderByComparator)
1715                    throws NoSuchArticleException, SystemException {
1716                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
1717    
1718                    if (list.isEmpty()) {
1719                            StringBundler msg = new StringBundler(4);
1720    
1721                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1722    
1723                            msg.append("uuid=");
1724                            msg.append(uuid);
1725    
1726                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1727    
1728                            throw new NoSuchArticleException(msg.toString());
1729                    }
1730                    else {
1731                            return list.get(0);
1732                    }
1733            }
1734    
1735            /**
1736             * Returns the last journal article in the ordered set where uuid = &#63;.
1737             *
1738             * <p>
1739             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1740             * </p>
1741             *
1742             * @param uuid the uuid
1743             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1744             * @return the last matching journal article
1745             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1746             * @throws SystemException if a system exception occurred
1747             */
1748            public JournalArticle findByUuid_Last(String uuid,
1749                    OrderByComparator orderByComparator)
1750                    throws NoSuchArticleException, SystemException {
1751                    int count = countByUuid(uuid);
1752    
1753                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
1754                                    orderByComparator);
1755    
1756                    if (list.isEmpty()) {
1757                            StringBundler msg = new StringBundler(4);
1758    
1759                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1760    
1761                            msg.append("uuid=");
1762                            msg.append(uuid);
1763    
1764                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1765    
1766                            throw new NoSuchArticleException(msg.toString());
1767                    }
1768                    else {
1769                            return list.get(0);
1770                    }
1771            }
1772    
1773            /**
1774             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
1775             *
1776             * <p>
1777             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1778             * </p>
1779             *
1780             * @param id the primary key of the current journal article
1781             * @param uuid the uuid
1782             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1783             * @return the previous, current, and next journal article
1784             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1785             * @throws SystemException if a system exception occurred
1786             */
1787            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
1788                    OrderByComparator orderByComparator)
1789                    throws NoSuchArticleException, SystemException {
1790                    JournalArticle journalArticle = findByPrimaryKey(id);
1791    
1792                    Session session = null;
1793    
1794                    try {
1795                            session = openSession();
1796    
1797                            JournalArticle[] array = new JournalArticleImpl[3];
1798    
1799                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
1800                                            orderByComparator, true);
1801    
1802                            array[1] = journalArticle;
1803    
1804                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
1805                                            orderByComparator, false);
1806    
1807                            return array;
1808                    }
1809                    catch (Exception e) {
1810                            throw processException(e);
1811                    }
1812                    finally {
1813                            closeSession(session);
1814                    }
1815            }
1816    
1817            protected JournalArticle getByUuid_PrevAndNext(Session session,
1818                    JournalArticle journalArticle, String uuid,
1819                    OrderByComparator orderByComparator, boolean previous) {
1820                    StringBundler query = null;
1821    
1822                    if (orderByComparator != null) {
1823                            query = new StringBundler(6 +
1824                                            (orderByComparator.getOrderByFields().length * 6));
1825                    }
1826                    else {
1827                            query = new StringBundler(3);
1828                    }
1829    
1830                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1831    
1832                    if (uuid == null) {
1833                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1834                    }
1835                    else {
1836                            if (uuid.equals(StringPool.BLANK)) {
1837                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1838                            }
1839                            else {
1840                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1841                            }
1842                    }
1843    
1844                    if (orderByComparator != null) {
1845                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1846    
1847                            if (orderByConditionFields.length > 0) {
1848                                    query.append(WHERE_AND);
1849                            }
1850    
1851                            for (int i = 0; i < orderByConditionFields.length; i++) {
1852                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1853                                    query.append(orderByConditionFields[i]);
1854    
1855                                    if ((i + 1) < orderByConditionFields.length) {
1856                                            if (orderByComparator.isAscending() ^ previous) {
1857                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1858                                            }
1859                                            else {
1860                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1861                                            }
1862                                    }
1863                                    else {
1864                                            if (orderByComparator.isAscending() ^ previous) {
1865                                                    query.append(WHERE_GREATER_THAN);
1866                                            }
1867                                            else {
1868                                                    query.append(WHERE_LESSER_THAN);
1869                                            }
1870                                    }
1871                            }
1872    
1873                            query.append(ORDER_BY_CLAUSE);
1874    
1875                            String[] orderByFields = orderByComparator.getOrderByFields();
1876    
1877                            for (int i = 0; i < orderByFields.length; i++) {
1878                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1879                                    query.append(orderByFields[i]);
1880    
1881                                    if ((i + 1) < orderByFields.length) {
1882                                            if (orderByComparator.isAscending() ^ previous) {
1883                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1884                                            }
1885                                            else {
1886                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1887                                            }
1888                                    }
1889                                    else {
1890                                            if (orderByComparator.isAscending() ^ previous) {
1891                                                    query.append(ORDER_BY_ASC);
1892                                            }
1893                                            else {
1894                                                    query.append(ORDER_BY_DESC);
1895                                            }
1896                                    }
1897                            }
1898                    }
1899    
1900                    else {
1901                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1902                    }
1903    
1904                    String sql = query.toString();
1905    
1906                    Query q = session.createQuery(sql);
1907    
1908                    q.setFirstResult(0);
1909                    q.setMaxResults(2);
1910    
1911                    QueryPos qPos = QueryPos.getInstance(q);
1912    
1913                    if (uuid != null) {
1914                            qPos.add(uuid);
1915                    }
1916    
1917                    if (orderByComparator != null) {
1918                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1919    
1920                            for (Object value : values) {
1921                                    qPos.add(value);
1922                            }
1923                    }
1924    
1925                    List<JournalArticle> list = q.list();
1926    
1927                    if (list.size() == 2) {
1928                            return list.get(1);
1929                    }
1930                    else {
1931                            return null;
1932                    }
1933            }
1934    
1935            /**
1936             * 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.
1937             *
1938             * @param uuid the uuid
1939             * @param groupId the group ID
1940             * @return the matching journal article
1941             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1942             * @throws SystemException if a system exception occurred
1943             */
1944            public JournalArticle findByUUID_G(String uuid, long groupId)
1945                    throws NoSuchArticleException, SystemException {
1946                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
1947    
1948                    if (journalArticle == null) {
1949                            StringBundler msg = new StringBundler(6);
1950    
1951                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1952    
1953                            msg.append("uuid=");
1954                            msg.append(uuid);
1955    
1956                            msg.append(", groupId=");
1957                            msg.append(groupId);
1958    
1959                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1960    
1961                            if (_log.isWarnEnabled()) {
1962                                    _log.warn(msg.toString());
1963                            }
1964    
1965                            throw new NoSuchArticleException(msg.toString());
1966                    }
1967    
1968                    return journalArticle;
1969            }
1970    
1971            /**
1972             * 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.
1973             *
1974             * @param uuid the uuid
1975             * @param groupId the group ID
1976             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
1977             * @throws SystemException if a system exception occurred
1978             */
1979            public JournalArticle fetchByUUID_G(String uuid, long groupId)
1980                    throws SystemException {
1981                    return fetchByUUID_G(uuid, groupId, true);
1982            }
1983    
1984            /**
1985             * 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.
1986             *
1987             * @param uuid the uuid
1988             * @param groupId the group ID
1989             * @param retrieveFromCache whether to use the finder cache
1990             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
1991             * @throws SystemException if a system exception occurred
1992             */
1993            public JournalArticle fetchByUUID_G(String uuid, long groupId,
1994                    boolean retrieveFromCache) throws SystemException {
1995                    Object[] finderArgs = new Object[] { uuid, groupId };
1996    
1997                    Object result = null;
1998    
1999                    if (retrieveFromCache) {
2000                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
2001                                            finderArgs, this);
2002                    }
2003    
2004                    if (result == null) {
2005                            StringBundler query = new StringBundler(4);
2006    
2007                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2008    
2009                            if (uuid == null) {
2010                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2011                            }
2012                            else {
2013                                    if (uuid.equals(StringPool.BLANK)) {
2014                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2015                                    }
2016                                    else {
2017                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2018                                    }
2019                            }
2020    
2021                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2022    
2023                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2024    
2025                            String sql = query.toString();
2026    
2027                            Session session = null;
2028    
2029                            try {
2030                                    session = openSession();
2031    
2032                                    Query q = session.createQuery(sql);
2033    
2034                                    QueryPos qPos = QueryPos.getInstance(q);
2035    
2036                                    if (uuid != null) {
2037                                            qPos.add(uuid);
2038                                    }
2039    
2040                                    qPos.add(groupId);
2041    
2042                                    List<JournalArticle> list = q.list();
2043    
2044                                    result = list;
2045    
2046                                    JournalArticle journalArticle = null;
2047    
2048                                    if (list.isEmpty()) {
2049                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2050                                                    finderArgs, list);
2051                                    }
2052                                    else {
2053                                            journalArticle = list.get(0);
2054    
2055                                            cacheResult(journalArticle);
2056    
2057                                            if ((journalArticle.getUuid() == null) ||
2058                                                            !journalArticle.getUuid().equals(uuid) ||
2059                                                            (journalArticle.getGroupId() != groupId)) {
2060                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2061                                                            finderArgs, journalArticle);
2062                                            }
2063                                    }
2064    
2065                                    return journalArticle;
2066                            }
2067                            catch (Exception e) {
2068                                    throw processException(e);
2069                            }
2070                            finally {
2071                                    if (result == null) {
2072                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
2073                                                    finderArgs);
2074                                    }
2075    
2076                                    closeSession(session);
2077                            }
2078                    }
2079                    else {
2080                            if (result instanceof List<?>) {
2081                                    return null;
2082                            }
2083                            else {
2084                                    return (JournalArticle)result;
2085                            }
2086                    }
2087            }
2088    
2089            /**
2090             * Returns all the journal articles where resourcePrimKey = &#63;.
2091             *
2092             * @param resourcePrimKey the resource prim key
2093             * @return the matching journal articles
2094             * @throws SystemException if a system exception occurred
2095             */
2096            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
2097                    throws SystemException {
2098                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
2099                            QueryUtil.ALL_POS, null);
2100            }
2101    
2102            /**
2103             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
2104             *
2105             * <p>
2106             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2107             * </p>
2108             *
2109             * @param resourcePrimKey the resource prim key
2110             * @param start the lower bound of the range of journal articles
2111             * @param end the upper bound of the range of journal articles (not inclusive)
2112             * @return the range of matching journal articles
2113             * @throws SystemException if a system exception occurred
2114             */
2115            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
2116                    int start, int end) throws SystemException {
2117                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
2118            }
2119    
2120            /**
2121             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
2122             *
2123             * <p>
2124             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2125             * </p>
2126             *
2127             * @param resourcePrimKey the resource prim key
2128             * @param start the lower bound of the range of journal articles
2129             * @param end the upper bound of the range of journal articles (not inclusive)
2130             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2131             * @return the ordered range of matching journal articles
2132             * @throws SystemException if a system exception occurred
2133             */
2134            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
2135                    int start, int end, OrderByComparator orderByComparator)
2136                    throws SystemException {
2137                    FinderPath finderPath = null;
2138                    Object[] finderArgs = null;
2139    
2140                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2141                                    (orderByComparator == null)) {
2142                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
2143                            finderArgs = new Object[] { resourcePrimKey };
2144                    }
2145                    else {
2146                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
2147                            finderArgs = new Object[] {
2148                                            resourcePrimKey,
2149                                            
2150                                            start, end, orderByComparator
2151                                    };
2152                    }
2153    
2154                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2155                                    finderArgs, this);
2156    
2157                    if (list == null) {
2158                            StringBundler query = null;
2159    
2160                            if (orderByComparator != null) {
2161                                    query = new StringBundler(3 +
2162                                                    (orderByComparator.getOrderByFields().length * 3));
2163                            }
2164                            else {
2165                                    query = new StringBundler(3);
2166                            }
2167    
2168                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2169    
2170                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
2171    
2172                            if (orderByComparator != null) {
2173                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2174                                            orderByComparator);
2175                            }
2176    
2177                            else {
2178                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2179                            }
2180    
2181                            String sql = query.toString();
2182    
2183                            Session session = null;
2184    
2185                            try {
2186                                    session = openSession();
2187    
2188                                    Query q = session.createQuery(sql);
2189    
2190                                    QueryPos qPos = QueryPos.getInstance(q);
2191    
2192                                    qPos.add(resourcePrimKey);
2193    
2194                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2195                                                    start, end);
2196                            }
2197                            catch (Exception e) {
2198                                    throw processException(e);
2199                            }
2200                            finally {
2201                                    if (list == null) {
2202                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2203                                    }
2204                                    else {
2205                                            cacheResult(list);
2206    
2207                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2208                                    }
2209    
2210                                    closeSession(session);
2211                            }
2212                    }
2213    
2214                    return list;
2215            }
2216    
2217            /**
2218             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
2219             *
2220             * <p>
2221             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2222             * </p>
2223             *
2224             * @param resourcePrimKey the resource prim key
2225             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2226             * @return the first matching journal article
2227             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2228             * @throws SystemException if a system exception occurred
2229             */
2230            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
2231                    OrderByComparator orderByComparator)
2232                    throws NoSuchArticleException, SystemException {
2233                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
2234                                    1, orderByComparator);
2235    
2236                    if (list.isEmpty()) {
2237                            StringBundler msg = new StringBundler(4);
2238    
2239                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2240    
2241                            msg.append("resourcePrimKey=");
2242                            msg.append(resourcePrimKey);
2243    
2244                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2245    
2246                            throw new NoSuchArticleException(msg.toString());
2247                    }
2248                    else {
2249                            return list.get(0);
2250                    }
2251            }
2252    
2253            /**
2254             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
2255             *
2256             * <p>
2257             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2258             * </p>
2259             *
2260             * @param resourcePrimKey the resource prim key
2261             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2262             * @return the last matching journal article
2263             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2264             * @throws SystemException if a system exception occurred
2265             */
2266            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
2267                    OrderByComparator orderByComparator)
2268                    throws NoSuchArticleException, SystemException {
2269                    int count = countByResourcePrimKey(resourcePrimKey);
2270    
2271                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
2272                                    count - 1, count, orderByComparator);
2273    
2274                    if (list.isEmpty()) {
2275                            StringBundler msg = new StringBundler(4);
2276    
2277                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2278    
2279                            msg.append("resourcePrimKey=");
2280                            msg.append(resourcePrimKey);
2281    
2282                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2283    
2284                            throw new NoSuchArticleException(msg.toString());
2285                    }
2286                    else {
2287                            return list.get(0);
2288                    }
2289            }
2290    
2291            /**
2292             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
2293             *
2294             * <p>
2295             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2296             * </p>
2297             *
2298             * @param id the primary key of the current journal article
2299             * @param resourcePrimKey the resource prim key
2300             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2301             * @return the previous, current, and next journal article
2302             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2303             * @throws SystemException if a system exception occurred
2304             */
2305            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
2306                    long resourcePrimKey, OrderByComparator orderByComparator)
2307                    throws NoSuchArticleException, SystemException {
2308                    JournalArticle journalArticle = findByPrimaryKey(id);
2309    
2310                    Session session = null;
2311    
2312                    try {
2313                            session = openSession();
2314    
2315                            JournalArticle[] array = new JournalArticleImpl[3];
2316    
2317                            array[0] = getByResourcePrimKey_PrevAndNext(session,
2318                                            journalArticle, resourcePrimKey, orderByComparator, true);
2319    
2320                            array[1] = journalArticle;
2321    
2322                            array[2] = getByResourcePrimKey_PrevAndNext(session,
2323                                            journalArticle, resourcePrimKey, orderByComparator, false);
2324    
2325                            return array;
2326                    }
2327                    catch (Exception e) {
2328                            throw processException(e);
2329                    }
2330                    finally {
2331                            closeSession(session);
2332                    }
2333            }
2334    
2335            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
2336                    JournalArticle journalArticle, long resourcePrimKey,
2337                    OrderByComparator orderByComparator, boolean previous) {
2338                    StringBundler query = null;
2339    
2340                    if (orderByComparator != null) {
2341                            query = new StringBundler(6 +
2342                                            (orderByComparator.getOrderByFields().length * 6));
2343                    }
2344                    else {
2345                            query = new StringBundler(3);
2346                    }
2347    
2348                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2349    
2350                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
2351    
2352                    if (orderByComparator != null) {
2353                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2354    
2355                            if (orderByConditionFields.length > 0) {
2356                                    query.append(WHERE_AND);
2357                            }
2358    
2359                            for (int i = 0; i < orderByConditionFields.length; i++) {
2360                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2361                                    query.append(orderByConditionFields[i]);
2362    
2363                                    if ((i + 1) < orderByConditionFields.length) {
2364                                            if (orderByComparator.isAscending() ^ previous) {
2365                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2366                                            }
2367                                            else {
2368                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2369                                            }
2370                                    }
2371                                    else {
2372                                            if (orderByComparator.isAscending() ^ previous) {
2373                                                    query.append(WHERE_GREATER_THAN);
2374                                            }
2375                                            else {
2376                                                    query.append(WHERE_LESSER_THAN);
2377                                            }
2378                                    }
2379                            }
2380    
2381                            query.append(ORDER_BY_CLAUSE);
2382    
2383                            String[] orderByFields = orderByComparator.getOrderByFields();
2384    
2385                            for (int i = 0; i < orderByFields.length; i++) {
2386                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2387                                    query.append(orderByFields[i]);
2388    
2389                                    if ((i + 1) < orderByFields.length) {
2390                                            if (orderByComparator.isAscending() ^ previous) {
2391                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2392                                            }
2393                                            else {
2394                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2395                                            }
2396                                    }
2397                                    else {
2398                                            if (orderByComparator.isAscending() ^ previous) {
2399                                                    query.append(ORDER_BY_ASC);
2400                                            }
2401                                            else {
2402                                                    query.append(ORDER_BY_DESC);
2403                                            }
2404                                    }
2405                            }
2406                    }
2407    
2408                    else {
2409                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2410                    }
2411    
2412                    String sql = query.toString();
2413    
2414                    Query q = session.createQuery(sql);
2415    
2416                    q.setFirstResult(0);
2417                    q.setMaxResults(2);
2418    
2419                    QueryPos qPos = QueryPos.getInstance(q);
2420    
2421                    qPos.add(resourcePrimKey);
2422    
2423                    if (orderByComparator != null) {
2424                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2425    
2426                            for (Object value : values) {
2427                                    qPos.add(value);
2428                            }
2429                    }
2430    
2431                    List<JournalArticle> list = q.list();
2432    
2433                    if (list.size() == 2) {
2434                            return list.get(1);
2435                    }
2436                    else {
2437                            return null;
2438                    }
2439            }
2440    
2441            /**
2442             * Returns all the journal articles where groupId = &#63;.
2443             *
2444             * @param groupId the group ID
2445             * @return the matching journal articles
2446             * @throws SystemException if a system exception occurred
2447             */
2448            public List<JournalArticle> findByGroupId(long groupId)
2449                    throws SystemException {
2450                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2451            }
2452    
2453            /**
2454             * Returns a range of all the journal articles where groupId = &#63;.
2455             *
2456             * <p>
2457             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2458             * </p>
2459             *
2460             * @param groupId the group ID
2461             * @param start the lower bound of the range of journal articles
2462             * @param end the upper bound of the range of journal articles (not inclusive)
2463             * @return the range of matching journal articles
2464             * @throws SystemException if a system exception occurred
2465             */
2466            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
2467                    throws SystemException {
2468                    return findByGroupId(groupId, start, end, null);
2469            }
2470    
2471            /**
2472             * Returns an ordered range of all the journal articles where groupId = &#63;.
2473             *
2474             * <p>
2475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2476             * </p>
2477             *
2478             * @param groupId the group ID
2479             * @param start the lower bound of the range of journal articles
2480             * @param end the upper bound of the range of journal articles (not inclusive)
2481             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2482             * @return the ordered range of matching journal articles
2483             * @throws SystemException if a system exception occurred
2484             */
2485            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
2486                    OrderByComparator orderByComparator) throws SystemException {
2487                    FinderPath finderPath = null;
2488                    Object[] finderArgs = null;
2489    
2490                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2491                                    (orderByComparator == null)) {
2492                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2493                            finderArgs = new Object[] { groupId };
2494                    }
2495                    else {
2496                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2497                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2498                    }
2499    
2500                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2501                                    finderArgs, this);
2502    
2503                    if (list == null) {
2504                            StringBundler query = null;
2505    
2506                            if (orderByComparator != null) {
2507                                    query = new StringBundler(3 +
2508                                                    (orderByComparator.getOrderByFields().length * 3));
2509                            }
2510                            else {
2511                                    query = new StringBundler(3);
2512                            }
2513    
2514                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2515    
2516                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2517    
2518                            if (orderByComparator != null) {
2519                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2520                                            orderByComparator);
2521                            }
2522    
2523                            else {
2524                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2525                            }
2526    
2527                            String sql = query.toString();
2528    
2529                            Session session = null;
2530    
2531                            try {
2532                                    session = openSession();
2533    
2534                                    Query q = session.createQuery(sql);
2535    
2536                                    QueryPos qPos = QueryPos.getInstance(q);
2537    
2538                                    qPos.add(groupId);
2539    
2540                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2541                                                    start, end);
2542                            }
2543                            catch (Exception e) {
2544                                    throw processException(e);
2545                            }
2546                            finally {
2547                                    if (list == null) {
2548                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2549                                    }
2550                                    else {
2551                                            cacheResult(list);
2552    
2553                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2554                                    }
2555    
2556                                    closeSession(session);
2557                            }
2558                    }
2559    
2560                    return list;
2561            }
2562    
2563            /**
2564             * Returns the first journal article in the ordered set where groupId = &#63;.
2565             *
2566             * <p>
2567             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2568             * </p>
2569             *
2570             * @param groupId the group ID
2571             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2572             * @return the first matching journal article
2573             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2574             * @throws SystemException if a system exception occurred
2575             */
2576            public JournalArticle findByGroupId_First(long groupId,
2577                    OrderByComparator orderByComparator)
2578                    throws NoSuchArticleException, SystemException {
2579                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2580                                    orderByComparator);
2581    
2582                    if (list.isEmpty()) {
2583                            StringBundler msg = new StringBundler(4);
2584    
2585                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2586    
2587                            msg.append("groupId=");
2588                            msg.append(groupId);
2589    
2590                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2591    
2592                            throw new NoSuchArticleException(msg.toString());
2593                    }
2594                    else {
2595                            return list.get(0);
2596                    }
2597            }
2598    
2599            /**
2600             * Returns the last journal article in the ordered set where groupId = &#63;.
2601             *
2602             * <p>
2603             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2604             * </p>
2605             *
2606             * @param groupId the group ID
2607             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2608             * @return the last matching journal article
2609             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2610             * @throws SystemException if a system exception occurred
2611             */
2612            public JournalArticle findByGroupId_Last(long groupId,
2613                    OrderByComparator orderByComparator)
2614                    throws NoSuchArticleException, SystemException {
2615                    int count = countByGroupId(groupId);
2616    
2617                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2618                                    orderByComparator);
2619    
2620                    if (list.isEmpty()) {
2621                            StringBundler msg = new StringBundler(4);
2622    
2623                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2624    
2625                            msg.append("groupId=");
2626                            msg.append(groupId);
2627    
2628                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2629    
2630                            throw new NoSuchArticleException(msg.toString());
2631                    }
2632                    else {
2633                            return list.get(0);
2634                    }
2635            }
2636    
2637            /**
2638             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2639             *
2640             * <p>
2641             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2642             * </p>
2643             *
2644             * @param id the primary key of the current journal article
2645             * @param groupId the group ID
2646             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2647             * @return the previous, current, and next journal article
2648             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2649             * @throws SystemException if a system exception occurred
2650             */
2651            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2652                    OrderByComparator orderByComparator)
2653                    throws NoSuchArticleException, SystemException {
2654                    JournalArticle journalArticle = findByPrimaryKey(id);
2655    
2656                    Session session = null;
2657    
2658                    try {
2659                            session = openSession();
2660    
2661                            JournalArticle[] array = new JournalArticleImpl[3];
2662    
2663                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2664                                            groupId, orderByComparator, true);
2665    
2666                            array[1] = journalArticle;
2667    
2668                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2669                                            groupId, orderByComparator, false);
2670    
2671                            return array;
2672                    }
2673                    catch (Exception e) {
2674                            throw processException(e);
2675                    }
2676                    finally {
2677                            closeSession(session);
2678                    }
2679            }
2680    
2681            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2682                    JournalArticle journalArticle, long groupId,
2683                    OrderByComparator orderByComparator, boolean previous) {
2684                    StringBundler query = null;
2685    
2686                    if (orderByComparator != null) {
2687                            query = new StringBundler(6 +
2688                                            (orderByComparator.getOrderByFields().length * 6));
2689                    }
2690                    else {
2691                            query = new StringBundler(3);
2692                    }
2693    
2694                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2695    
2696                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2697    
2698                    if (orderByComparator != null) {
2699                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2700    
2701                            if (orderByConditionFields.length > 0) {
2702                                    query.append(WHERE_AND);
2703                            }
2704    
2705                            for (int i = 0; i < orderByConditionFields.length; i++) {
2706                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2707                                    query.append(orderByConditionFields[i]);
2708    
2709                                    if ((i + 1) < orderByConditionFields.length) {
2710                                            if (orderByComparator.isAscending() ^ previous) {
2711                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2712                                            }
2713                                            else {
2714                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2715                                            }
2716                                    }
2717                                    else {
2718                                            if (orderByComparator.isAscending() ^ previous) {
2719                                                    query.append(WHERE_GREATER_THAN);
2720                                            }
2721                                            else {
2722                                                    query.append(WHERE_LESSER_THAN);
2723                                            }
2724                                    }
2725                            }
2726    
2727                            query.append(ORDER_BY_CLAUSE);
2728    
2729                            String[] orderByFields = orderByComparator.getOrderByFields();
2730    
2731                            for (int i = 0; i < orderByFields.length; i++) {
2732                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2733                                    query.append(orderByFields[i]);
2734    
2735                                    if ((i + 1) < orderByFields.length) {
2736                                            if (orderByComparator.isAscending() ^ previous) {
2737                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2738                                            }
2739                                            else {
2740                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2741                                            }
2742                                    }
2743                                    else {
2744                                            if (orderByComparator.isAscending() ^ previous) {
2745                                                    query.append(ORDER_BY_ASC);
2746                                            }
2747                                            else {
2748                                                    query.append(ORDER_BY_DESC);
2749                                            }
2750                                    }
2751                            }
2752                    }
2753    
2754                    else {
2755                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2756                    }
2757    
2758                    String sql = query.toString();
2759    
2760                    Query q = session.createQuery(sql);
2761    
2762                    q.setFirstResult(0);
2763                    q.setMaxResults(2);
2764    
2765                    QueryPos qPos = QueryPos.getInstance(q);
2766    
2767                    qPos.add(groupId);
2768    
2769                    if (orderByComparator != null) {
2770                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2771    
2772                            for (Object value : values) {
2773                                    qPos.add(value);
2774                            }
2775                    }
2776    
2777                    List<JournalArticle> list = q.list();
2778    
2779                    if (list.size() == 2) {
2780                            return list.get(1);
2781                    }
2782                    else {
2783                            return null;
2784                    }
2785            }
2786    
2787            /**
2788             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2789             *
2790             * @param groupId the group ID
2791             * @return the matching journal articles that the user has permission to view
2792             * @throws SystemException if a system exception occurred
2793             */
2794            public List<JournalArticle> filterFindByGroupId(long groupId)
2795                    throws SystemException {
2796                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2797                            QueryUtil.ALL_POS, null);
2798            }
2799    
2800            /**
2801             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
2802             *
2803             * <p>
2804             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2805             * </p>
2806             *
2807             * @param groupId the group ID
2808             * @param start the lower bound of the range of journal articles
2809             * @param end the upper bound of the range of journal articles (not inclusive)
2810             * @return the range of matching journal articles that the user has permission to view
2811             * @throws SystemException if a system exception occurred
2812             */
2813            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2814                    int end) throws SystemException {
2815                    return filterFindByGroupId(groupId, start, end, null);
2816            }
2817    
2818            /**
2819             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
2820             *
2821             * <p>
2822             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2823             * </p>
2824             *
2825             * @param groupId the group ID
2826             * @param start the lower bound of the range of journal articles
2827             * @param end the upper bound of the range of journal articles (not inclusive)
2828             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2829             * @return the ordered range of matching journal articles that the user has permission to view
2830             * @throws SystemException if a system exception occurred
2831             */
2832            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2833                    int end, OrderByComparator orderByComparator) throws SystemException {
2834                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2835                            return findByGroupId(groupId, start, end, orderByComparator);
2836                    }
2837    
2838                    StringBundler query = null;
2839    
2840                    if (orderByComparator != null) {
2841                            query = new StringBundler(3 +
2842                                            (orderByComparator.getOrderByFields().length * 3));
2843                    }
2844                    else {
2845                            query = new StringBundler(3);
2846                    }
2847    
2848                    if (getDB().isSupportsInlineDistinct()) {
2849                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2850                    }
2851                    else {
2852                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2853                    }
2854    
2855                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2856    
2857                    if (!getDB().isSupportsInlineDistinct()) {
2858                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2859                    }
2860    
2861                    if (orderByComparator != null) {
2862                            if (getDB().isSupportsInlineDistinct()) {
2863                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2864                                            orderByComparator);
2865                            }
2866                            else {
2867                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2868                                            orderByComparator);
2869                            }
2870                    }
2871    
2872                    else {
2873                            if (getDB().isSupportsInlineDistinct()) {
2874                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2875                            }
2876                            else {
2877                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2878                            }
2879                    }
2880    
2881                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2882                                    JournalArticle.class.getName(),
2883                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2884    
2885                    Session session = null;
2886    
2887                    try {
2888                            session = openSession();
2889    
2890                            SQLQuery q = session.createSQLQuery(sql);
2891    
2892                            if (getDB().isSupportsInlineDistinct()) {
2893                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2894                            }
2895                            else {
2896                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2897                            }
2898    
2899                            QueryPos qPos = QueryPos.getInstance(q);
2900    
2901                            qPos.add(groupId);
2902    
2903                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
2904                                    end);
2905                    }
2906                    catch (Exception e) {
2907                            throw processException(e);
2908                    }
2909                    finally {
2910                            closeSession(session);
2911                    }
2912            }
2913    
2914            /**
2915             * 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;.
2916             *
2917             * @param id the primary key of the current journal article
2918             * @param groupId the group ID
2919             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2920             * @return the previous, current, and next journal article
2921             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2922             * @throws SystemException if a system exception occurred
2923             */
2924            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
2925                    long groupId, OrderByComparator orderByComparator)
2926                    throws NoSuchArticleException, SystemException {
2927                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2928                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
2929                    }
2930    
2931                    JournalArticle journalArticle = findByPrimaryKey(id);
2932    
2933                    Session session = null;
2934    
2935                    try {
2936                            session = openSession();
2937    
2938                            JournalArticle[] array = new JournalArticleImpl[3];
2939    
2940                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2941                                            groupId, orderByComparator, true);
2942    
2943                            array[1] = journalArticle;
2944    
2945                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2946                                            groupId, orderByComparator, false);
2947    
2948                            return array;
2949                    }
2950                    catch (Exception e) {
2951                            throw processException(e);
2952                    }
2953                    finally {
2954                            closeSession(session);
2955                    }
2956            }
2957    
2958            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
2959                    JournalArticle journalArticle, long groupId,
2960                    OrderByComparator orderByComparator, boolean previous) {
2961                    StringBundler query = null;
2962    
2963                    if (orderByComparator != null) {
2964                            query = new StringBundler(6 +
2965                                            (orderByComparator.getOrderByFields().length * 6));
2966                    }
2967                    else {
2968                            query = new StringBundler(3);
2969                    }
2970    
2971                    if (getDB().isSupportsInlineDistinct()) {
2972                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2973                    }
2974                    else {
2975                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2976                    }
2977    
2978                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2979    
2980                    if (!getDB().isSupportsInlineDistinct()) {
2981                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2982                    }
2983    
2984                    if (orderByComparator != null) {
2985                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2986    
2987                            if (orderByConditionFields.length > 0) {
2988                                    query.append(WHERE_AND);
2989                            }
2990    
2991                            for (int i = 0; i < orderByConditionFields.length; i++) {
2992                                    if (getDB().isSupportsInlineDistinct()) {
2993                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2994                                    }
2995                                    else {
2996                                            query.append(_ORDER_BY_ENTITY_TABLE);
2997                                    }
2998    
2999                                    query.append(orderByConditionFields[i]);
3000    
3001                                    if ((i + 1) < orderByConditionFields.length) {
3002                                            if (orderByComparator.isAscending() ^ previous) {
3003                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3004                                            }
3005                                            else {
3006                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3007                                            }
3008                                    }
3009                                    else {
3010                                            if (orderByComparator.isAscending() ^ previous) {
3011                                                    query.append(WHERE_GREATER_THAN);
3012                                            }
3013                                            else {
3014                                                    query.append(WHERE_LESSER_THAN);
3015                                            }
3016                                    }
3017                            }
3018    
3019                            query.append(ORDER_BY_CLAUSE);
3020    
3021                            String[] orderByFields = orderByComparator.getOrderByFields();
3022    
3023                            for (int i = 0; i < orderByFields.length; i++) {
3024                                    if (getDB().isSupportsInlineDistinct()) {
3025                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3026                                    }
3027                                    else {
3028                                            query.append(_ORDER_BY_ENTITY_TABLE);
3029                                    }
3030    
3031                                    query.append(orderByFields[i]);
3032    
3033                                    if ((i + 1) < orderByFields.length) {
3034                                            if (orderByComparator.isAscending() ^ previous) {
3035                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3036                                            }
3037                                            else {
3038                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3039                                            }
3040                                    }
3041                                    else {
3042                                            if (orderByComparator.isAscending() ^ previous) {
3043                                                    query.append(ORDER_BY_ASC);
3044                                            }
3045                                            else {
3046                                                    query.append(ORDER_BY_DESC);
3047                                            }
3048                                    }
3049                            }
3050                    }
3051    
3052                    else {
3053                            if (getDB().isSupportsInlineDistinct()) {
3054                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3055                            }
3056                            else {
3057                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
3058                            }
3059                    }
3060    
3061                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3062                                    JournalArticle.class.getName(),
3063                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3064    
3065                    SQLQuery q = session.createSQLQuery(sql);
3066    
3067                    q.setFirstResult(0);
3068                    q.setMaxResults(2);
3069    
3070                    if (getDB().isSupportsInlineDistinct()) {
3071                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
3072                    }
3073                    else {
3074                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
3075                    }
3076    
3077                    QueryPos qPos = QueryPos.getInstance(q);
3078    
3079                    qPos.add(groupId);
3080    
3081                    if (orderByComparator != null) {
3082                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3083    
3084                            for (Object value : values) {
3085                                    qPos.add(value);
3086                            }
3087                    }
3088    
3089                    List<JournalArticle> list = q.list();
3090    
3091                    if (list.size() == 2) {
3092                            return list.get(1);
3093                    }
3094                    else {
3095                            return null;
3096                    }
3097            }
3098    
3099            /**
3100             * Returns all the journal articles where companyId = &#63;.
3101             *
3102             * @param companyId the company ID
3103             * @return the matching journal articles
3104             * @throws SystemException if a system exception occurred
3105             */
3106            public List<JournalArticle> findByCompanyId(long companyId)
3107                    throws SystemException {
3108                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3109                            null);
3110            }
3111    
3112            /**
3113             * Returns a range of all the journal articles where companyId = &#63;.
3114             *
3115             * <p>
3116             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3117             * </p>
3118             *
3119             * @param companyId the company ID
3120             * @param start the lower bound of the range of journal articles
3121             * @param end the upper bound of the range of journal articles (not inclusive)
3122             * @return the range of matching journal articles
3123             * @throws SystemException if a system exception occurred
3124             */
3125            public List<JournalArticle> findByCompanyId(long companyId, int start,
3126                    int end) throws SystemException {
3127                    return findByCompanyId(companyId, start, end, null);
3128            }
3129    
3130            /**
3131             * Returns an ordered range of all the journal articles where companyId = &#63;.
3132             *
3133             * <p>
3134             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3135             * </p>
3136             *
3137             * @param companyId the company ID
3138             * @param start the lower bound of the range of journal articles
3139             * @param end the upper bound of the range of journal articles (not inclusive)
3140             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3141             * @return the ordered range of matching journal articles
3142             * @throws SystemException if a system exception occurred
3143             */
3144            public List<JournalArticle> findByCompanyId(long companyId, int start,
3145                    int end, OrderByComparator orderByComparator) throws SystemException {
3146                    FinderPath finderPath = null;
3147                    Object[] finderArgs = null;
3148    
3149                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3150                                    (orderByComparator == null)) {
3151                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
3152                            finderArgs = new Object[] { companyId };
3153                    }
3154                    else {
3155                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
3156                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
3157                    }
3158    
3159                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3160                                    finderArgs, this);
3161    
3162                    if (list == null) {
3163                            StringBundler query = null;
3164    
3165                            if (orderByComparator != null) {
3166                                    query = new StringBundler(3 +
3167                                                    (orderByComparator.getOrderByFields().length * 3));
3168                            }
3169                            else {
3170                                    query = new StringBundler(3);
3171                            }
3172    
3173                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3174    
3175                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3176    
3177                            if (orderByComparator != null) {
3178                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3179                                            orderByComparator);
3180                            }
3181    
3182                            else {
3183                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3184                            }
3185    
3186                            String sql = query.toString();
3187    
3188                            Session session = null;
3189    
3190                            try {
3191                                    session = openSession();
3192    
3193                                    Query q = session.createQuery(sql);
3194    
3195                                    QueryPos qPos = QueryPos.getInstance(q);
3196    
3197                                    qPos.add(companyId);
3198    
3199                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3200                                                    start, end);
3201                            }
3202                            catch (Exception e) {
3203                                    throw processException(e);
3204                            }
3205                            finally {
3206                                    if (list == null) {
3207                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3208                                    }
3209                                    else {
3210                                            cacheResult(list);
3211    
3212                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3213                                    }
3214    
3215                                    closeSession(session);
3216                            }
3217                    }
3218    
3219                    return list;
3220            }
3221    
3222            /**
3223             * Returns the first journal article in the ordered set where companyId = &#63;.
3224             *
3225             * <p>
3226             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3227             * </p>
3228             *
3229             * @param companyId the company ID
3230             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3231             * @return the first matching journal article
3232             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3233             * @throws SystemException if a system exception occurred
3234             */
3235            public JournalArticle findByCompanyId_First(long companyId,
3236                    OrderByComparator orderByComparator)
3237                    throws NoSuchArticleException, SystemException {
3238                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
3239                                    orderByComparator);
3240    
3241                    if (list.isEmpty()) {
3242                            StringBundler msg = new StringBundler(4);
3243    
3244                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3245    
3246                            msg.append("companyId=");
3247                            msg.append(companyId);
3248    
3249                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3250    
3251                            throw new NoSuchArticleException(msg.toString());
3252                    }
3253                    else {
3254                            return list.get(0);
3255                    }
3256            }
3257    
3258            /**
3259             * Returns the last journal article in the ordered set where companyId = &#63;.
3260             *
3261             * <p>
3262             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3263             * </p>
3264             *
3265             * @param companyId the company ID
3266             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3267             * @return the last matching journal article
3268             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3269             * @throws SystemException if a system exception occurred
3270             */
3271            public JournalArticle findByCompanyId_Last(long companyId,
3272                    OrderByComparator orderByComparator)
3273                    throws NoSuchArticleException, SystemException {
3274                    int count = countByCompanyId(companyId);
3275    
3276                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3277                                    count, orderByComparator);
3278    
3279                    if (list.isEmpty()) {
3280                            StringBundler msg = new StringBundler(4);
3281    
3282                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3283    
3284                            msg.append("companyId=");
3285                            msg.append(companyId);
3286    
3287                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3288    
3289                            throw new NoSuchArticleException(msg.toString());
3290                    }
3291                    else {
3292                            return list.get(0);
3293                    }
3294            }
3295    
3296            /**
3297             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3298             *
3299             * <p>
3300             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3301             * </p>
3302             *
3303             * @param id the primary key of the current journal article
3304             * @param companyId the company ID
3305             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3306             * @return the previous, current, and next journal article
3307             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3308             * @throws SystemException if a system exception occurred
3309             */
3310            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3311                    long companyId, OrderByComparator orderByComparator)
3312                    throws NoSuchArticleException, SystemException {
3313                    JournalArticle journalArticle = findByPrimaryKey(id);
3314    
3315                    Session session = null;
3316    
3317                    try {
3318                            session = openSession();
3319    
3320                            JournalArticle[] array = new JournalArticleImpl[3];
3321    
3322                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3323                                            companyId, orderByComparator, true);
3324    
3325                            array[1] = journalArticle;
3326    
3327                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3328                                            companyId, orderByComparator, false);
3329    
3330                            return array;
3331                    }
3332                    catch (Exception e) {
3333                            throw processException(e);
3334                    }
3335                    finally {
3336                            closeSession(session);
3337                    }
3338            }
3339    
3340            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3341                    JournalArticle journalArticle, long companyId,
3342                    OrderByComparator orderByComparator, boolean previous) {
3343                    StringBundler query = null;
3344    
3345                    if (orderByComparator != null) {
3346                            query = new StringBundler(6 +
3347                                            (orderByComparator.getOrderByFields().length * 6));
3348                    }
3349                    else {
3350                            query = new StringBundler(3);
3351                    }
3352    
3353                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3354    
3355                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3356    
3357                    if (orderByComparator != null) {
3358                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3359    
3360                            if (orderByConditionFields.length > 0) {
3361                                    query.append(WHERE_AND);
3362                            }
3363    
3364                            for (int i = 0; i < orderByConditionFields.length; i++) {
3365                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3366                                    query.append(orderByConditionFields[i]);
3367    
3368                                    if ((i + 1) < orderByConditionFields.length) {
3369                                            if (orderByComparator.isAscending() ^ previous) {
3370                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3371                                            }
3372                                            else {
3373                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3374                                            }
3375                                    }
3376                                    else {
3377                                            if (orderByComparator.isAscending() ^ previous) {
3378                                                    query.append(WHERE_GREATER_THAN);
3379                                            }
3380                                            else {
3381                                                    query.append(WHERE_LESSER_THAN);
3382                                            }
3383                                    }
3384                            }
3385    
3386                            query.append(ORDER_BY_CLAUSE);
3387    
3388                            String[] orderByFields = orderByComparator.getOrderByFields();
3389    
3390                            for (int i = 0; i < orderByFields.length; i++) {
3391                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3392                                    query.append(orderByFields[i]);
3393    
3394                                    if ((i + 1) < orderByFields.length) {
3395                                            if (orderByComparator.isAscending() ^ previous) {
3396                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3397                                            }
3398                                            else {
3399                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3400                                            }
3401                                    }
3402                                    else {
3403                                            if (orderByComparator.isAscending() ^ previous) {
3404                                                    query.append(ORDER_BY_ASC);
3405                                            }
3406                                            else {
3407                                                    query.append(ORDER_BY_DESC);
3408                                            }
3409                                    }
3410                            }
3411                    }
3412    
3413                    else {
3414                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3415                    }
3416    
3417                    String sql = query.toString();
3418    
3419                    Query q = session.createQuery(sql);
3420    
3421                    q.setFirstResult(0);
3422                    q.setMaxResults(2);
3423    
3424                    QueryPos qPos = QueryPos.getInstance(q);
3425    
3426                    qPos.add(companyId);
3427    
3428                    if (orderByComparator != null) {
3429                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3430    
3431                            for (Object value : values) {
3432                                    qPos.add(value);
3433                            }
3434                    }
3435    
3436                    List<JournalArticle> list = q.list();
3437    
3438                    if (list.size() == 2) {
3439                            return list.get(1);
3440                    }
3441                    else {
3442                            return null;
3443                    }
3444            }
3445    
3446            /**
3447             * Returns all the journal articles where smallImageId = &#63;.
3448             *
3449             * @param smallImageId the small image ID
3450             * @return the matching journal articles
3451             * @throws SystemException if a system exception occurred
3452             */
3453            public List<JournalArticle> findBySmallImageId(long smallImageId)
3454                    throws SystemException {
3455                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
3456                            QueryUtil.ALL_POS, null);
3457            }
3458    
3459            /**
3460             * Returns a range of all the journal articles where smallImageId = &#63;.
3461             *
3462             * <p>
3463             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3464             * </p>
3465             *
3466             * @param smallImageId the small image ID
3467             * @param start the lower bound of the range of journal articles
3468             * @param end the upper bound of the range of journal articles (not inclusive)
3469             * @return the range of matching journal articles
3470             * @throws SystemException if a system exception occurred
3471             */
3472            public List<JournalArticle> findBySmallImageId(long smallImageId,
3473                    int start, int end) throws SystemException {
3474                    return findBySmallImageId(smallImageId, start, end, null);
3475            }
3476    
3477            /**
3478             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
3479             *
3480             * <p>
3481             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3482             * </p>
3483             *
3484             * @param smallImageId the small image ID
3485             * @param start the lower bound of the range of journal articles
3486             * @param end the upper bound of the range of journal articles (not inclusive)
3487             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3488             * @return the ordered range of matching journal articles
3489             * @throws SystemException if a system exception occurred
3490             */
3491            public List<JournalArticle> findBySmallImageId(long smallImageId,
3492                    int start, int end, OrderByComparator orderByComparator)
3493                    throws SystemException {
3494                    FinderPath finderPath = null;
3495                    Object[] finderArgs = null;
3496    
3497                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3498                                    (orderByComparator == null)) {
3499                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
3500                            finderArgs = new Object[] { smallImageId };
3501                    }
3502                    else {
3503                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
3504                            finderArgs = new Object[] {
3505                                            smallImageId,
3506                                            
3507                                            start, end, orderByComparator
3508                                    };
3509                    }
3510    
3511                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3512                                    finderArgs, this);
3513    
3514                    if (list == null) {
3515                            StringBundler query = null;
3516    
3517                            if (orderByComparator != null) {
3518                                    query = new StringBundler(3 +
3519                                                    (orderByComparator.getOrderByFields().length * 3));
3520                            }
3521                            else {
3522                                    query = new StringBundler(3);
3523                            }
3524    
3525                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3526    
3527                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
3528    
3529                            if (orderByComparator != null) {
3530                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3531                                            orderByComparator);
3532                            }
3533    
3534                            else {
3535                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3536                            }
3537    
3538                            String sql = query.toString();
3539    
3540                            Session session = null;
3541    
3542                            try {
3543                                    session = openSession();
3544    
3545                                    Query q = session.createQuery(sql);
3546    
3547                                    QueryPos qPos = QueryPos.getInstance(q);
3548    
3549                                    qPos.add(smallImageId);
3550    
3551                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3552                                                    start, end);
3553                            }
3554                            catch (Exception e) {
3555                                    throw processException(e);
3556                            }
3557                            finally {
3558                                    if (list == null) {
3559                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3560                                    }
3561                                    else {
3562                                            cacheResult(list);
3563    
3564                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3565                                    }
3566    
3567                                    closeSession(session);
3568                            }
3569                    }
3570    
3571                    return list;
3572            }
3573    
3574            /**
3575             * Returns the first journal article in the ordered set where smallImageId = &#63;.
3576             *
3577             * <p>
3578             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3579             * </p>
3580             *
3581             * @param smallImageId the small image ID
3582             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3583             * @return the first matching journal article
3584             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3585             * @throws SystemException if a system exception occurred
3586             */
3587            public JournalArticle findBySmallImageId_First(long smallImageId,
3588                    OrderByComparator orderByComparator)
3589                    throws NoSuchArticleException, SystemException {
3590                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
3591                                    orderByComparator);
3592    
3593                    if (list.isEmpty()) {
3594                            StringBundler msg = new StringBundler(4);
3595    
3596                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3597    
3598                            msg.append("smallImageId=");
3599                            msg.append(smallImageId);
3600    
3601                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3602    
3603                            throw new NoSuchArticleException(msg.toString());
3604                    }
3605                    else {
3606                            return list.get(0);
3607                    }
3608            }
3609    
3610            /**
3611             * Returns the last journal article in the ordered set where smallImageId = &#63;.
3612             *
3613             * <p>
3614             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3615             * </p>
3616             *
3617             * @param smallImageId the small image ID
3618             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3619             * @return the last matching journal article
3620             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3621             * @throws SystemException if a system exception occurred
3622             */
3623            public JournalArticle findBySmallImageId_Last(long smallImageId,
3624                    OrderByComparator orderByComparator)
3625                    throws NoSuchArticleException, SystemException {
3626                    int count = countBySmallImageId(smallImageId);
3627    
3628                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
3629                                    count, orderByComparator);
3630    
3631                    if (list.isEmpty()) {
3632                            StringBundler msg = new StringBundler(4);
3633    
3634                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3635    
3636                            msg.append("smallImageId=");
3637                            msg.append(smallImageId);
3638    
3639                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3640    
3641                            throw new NoSuchArticleException(msg.toString());
3642                    }
3643                    else {
3644                            return list.get(0);
3645                    }
3646            }
3647    
3648            /**
3649             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
3650             *
3651             * <p>
3652             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3653             * </p>
3654             *
3655             * @param id the primary key of the current journal article
3656             * @param smallImageId the small image ID
3657             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3658             * @return the previous, current, and next journal article
3659             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3660             * @throws SystemException if a system exception occurred
3661             */
3662            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
3663                    long smallImageId, OrderByComparator orderByComparator)
3664                    throws NoSuchArticleException, SystemException {
3665                    JournalArticle journalArticle = findByPrimaryKey(id);
3666    
3667                    Session session = null;
3668    
3669                    try {
3670                            session = openSession();
3671    
3672                            JournalArticle[] array = new JournalArticleImpl[3];
3673    
3674                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
3675                                            smallImageId, orderByComparator, true);
3676    
3677                            array[1] = journalArticle;
3678    
3679                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
3680                                            smallImageId, orderByComparator, false);
3681    
3682                            return array;
3683                    }
3684                    catch (Exception e) {
3685                            throw processException(e);
3686                    }
3687                    finally {
3688                            closeSession(session);
3689                    }
3690            }
3691    
3692            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
3693                    JournalArticle journalArticle, long smallImageId,
3694                    OrderByComparator orderByComparator, boolean previous) {
3695                    StringBundler query = null;
3696    
3697                    if (orderByComparator != null) {
3698                            query = new StringBundler(6 +
3699                                            (orderByComparator.getOrderByFields().length * 6));
3700                    }
3701                    else {
3702                            query = new StringBundler(3);
3703                    }
3704    
3705                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3706    
3707                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
3708    
3709                    if (orderByComparator != null) {
3710                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3711    
3712                            if (orderByConditionFields.length > 0) {
3713                                    query.append(WHERE_AND);
3714                            }
3715    
3716                            for (int i = 0; i < orderByConditionFields.length; i++) {
3717                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3718                                    query.append(orderByConditionFields[i]);
3719    
3720                                    if ((i + 1) < orderByConditionFields.length) {
3721                                            if (orderByComparator.isAscending() ^ previous) {
3722                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3723                                            }
3724                                            else {
3725                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3726                                            }
3727                                    }
3728                                    else {
3729                                            if (orderByComparator.isAscending() ^ previous) {
3730                                                    query.append(WHERE_GREATER_THAN);
3731                                            }
3732                                            else {
3733                                                    query.append(WHERE_LESSER_THAN);
3734                                            }
3735                                    }
3736                            }
3737    
3738                            query.append(ORDER_BY_CLAUSE);
3739    
3740                            String[] orderByFields = orderByComparator.getOrderByFields();
3741    
3742                            for (int i = 0; i < orderByFields.length; i++) {
3743                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3744                                    query.append(orderByFields[i]);
3745    
3746                                    if ((i + 1) < orderByFields.length) {
3747                                            if (orderByComparator.isAscending() ^ previous) {
3748                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3749                                            }
3750                                            else {
3751                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3752                                            }
3753                                    }
3754                                    else {
3755                                            if (orderByComparator.isAscending() ^ previous) {
3756                                                    query.append(ORDER_BY_ASC);
3757                                            }
3758                                            else {
3759                                                    query.append(ORDER_BY_DESC);
3760                                            }
3761                                    }
3762                            }
3763                    }
3764    
3765                    else {
3766                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3767                    }
3768    
3769                    String sql = query.toString();
3770    
3771                    Query q = session.createQuery(sql);
3772    
3773                    q.setFirstResult(0);
3774                    q.setMaxResults(2);
3775    
3776                    QueryPos qPos = QueryPos.getInstance(q);
3777    
3778                    qPos.add(smallImageId);
3779    
3780                    if (orderByComparator != null) {
3781                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3782    
3783                            for (Object value : values) {
3784                                    qPos.add(value);
3785                            }
3786                    }
3787    
3788                    List<JournalArticle> list = q.list();
3789    
3790                    if (list.size() == 2) {
3791                            return list.get(1);
3792                    }
3793                    else {
3794                            return null;
3795                    }
3796            }
3797    
3798            /**
3799             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
3800             *
3801             * @param resourcePrimKey the resource prim key
3802             * @param status the status
3803             * @return the matching journal articles
3804             * @throws SystemException if a system exception occurred
3805             */
3806            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
3807                    throws SystemException {
3808                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
3809                            QueryUtil.ALL_POS, null);
3810            }
3811    
3812            /**
3813             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
3814             *
3815             * <p>
3816             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3817             * </p>
3818             *
3819             * @param resourcePrimKey the resource prim key
3820             * @param status the status
3821             * @param start the lower bound of the range of journal articles
3822             * @param end the upper bound of the range of journal articles (not inclusive)
3823             * @return the range of matching journal articles
3824             * @throws SystemException if a system exception occurred
3825             */
3826            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
3827                    int start, int end) throws SystemException {
3828                    return findByR_ST(resourcePrimKey, status, start, end, null);
3829            }
3830    
3831            /**
3832             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
3833             *
3834             * <p>
3835             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3836             * </p>
3837             *
3838             * @param resourcePrimKey the resource prim key
3839             * @param status the status
3840             * @param start the lower bound of the range of journal articles
3841             * @param end the upper bound of the range of journal articles (not inclusive)
3842             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3843             * @return the ordered range of matching journal articles
3844             * @throws SystemException if a system exception occurred
3845             */
3846            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
3847                    int start, int end, OrderByComparator orderByComparator)
3848                    throws SystemException {
3849                    FinderPath finderPath = null;
3850                    Object[] finderArgs = null;
3851    
3852                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3853                                    (orderByComparator == null)) {
3854                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
3855                            finderArgs = new Object[] { resourcePrimKey, status };
3856                    }
3857                    else {
3858                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
3859                            finderArgs = new Object[] {
3860                                            resourcePrimKey, status,
3861                                            
3862                                            start, end, orderByComparator
3863                                    };
3864                    }
3865    
3866                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3867                                    finderArgs, this);
3868    
3869                    if (list == null) {
3870                            StringBundler query = null;
3871    
3872                            if (orderByComparator != null) {
3873                                    query = new StringBundler(4 +
3874                                                    (orderByComparator.getOrderByFields().length * 3));
3875                            }
3876                            else {
3877                                    query = new StringBundler(4);
3878                            }
3879    
3880                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3881    
3882                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
3883    
3884                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
3885    
3886                            if (orderByComparator != null) {
3887                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3888                                            orderByComparator);
3889                            }
3890    
3891                            else {
3892                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3893                            }
3894    
3895                            String sql = query.toString();
3896    
3897                            Session session = null;
3898    
3899                            try {
3900                                    session = openSession();
3901    
3902                                    Query q = session.createQuery(sql);
3903    
3904                                    QueryPos qPos = QueryPos.getInstance(q);
3905    
3906                                    qPos.add(resourcePrimKey);
3907    
3908                                    qPos.add(status);
3909    
3910                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3911                                                    start, end);
3912                            }
3913                            catch (Exception e) {
3914                                    throw processException(e);
3915                            }
3916                            finally {
3917                                    if (list == null) {
3918                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3919                                    }
3920                                    else {
3921                                            cacheResult(list);
3922    
3923                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3924                                    }
3925    
3926                                    closeSession(session);
3927                            }
3928                    }
3929    
3930                    return list;
3931            }
3932    
3933            /**
3934             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
3935             *
3936             * <p>
3937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3938             * </p>
3939             *
3940             * @param resourcePrimKey the resource prim key
3941             * @param status the status
3942             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3943             * @return the first matching journal article
3944             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3945             * @throws SystemException if a system exception occurred
3946             */
3947            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
3948                    OrderByComparator orderByComparator)
3949                    throws NoSuchArticleException, SystemException {
3950                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
3951                                    orderByComparator);
3952    
3953                    if (list.isEmpty()) {
3954                            StringBundler msg = new StringBundler(6);
3955    
3956                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3957    
3958                            msg.append("resourcePrimKey=");
3959                            msg.append(resourcePrimKey);
3960    
3961                            msg.append(", status=");
3962                            msg.append(status);
3963    
3964                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3965    
3966                            throw new NoSuchArticleException(msg.toString());
3967                    }
3968                    else {
3969                            return list.get(0);
3970                    }
3971            }
3972    
3973            /**
3974             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
3975             *
3976             * <p>
3977             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3978             * </p>
3979             *
3980             * @param resourcePrimKey the resource prim key
3981             * @param status the status
3982             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3983             * @return the last matching journal article
3984             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3985             * @throws SystemException if a system exception occurred
3986             */
3987            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
3988                    OrderByComparator orderByComparator)
3989                    throws NoSuchArticleException, SystemException {
3990                    int count = countByR_ST(resourcePrimKey, status);
3991    
3992                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
3993                                    count - 1, count, orderByComparator);
3994    
3995                    if (list.isEmpty()) {
3996                            StringBundler msg = new StringBundler(6);
3997    
3998                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3999    
4000                            msg.append("resourcePrimKey=");
4001                            msg.append(resourcePrimKey);
4002    
4003                            msg.append(", status=");
4004                            msg.append(status);
4005    
4006                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4007    
4008                            throw new NoSuchArticleException(msg.toString());
4009                    }
4010                    else {
4011                            return list.get(0);
4012                    }
4013            }
4014    
4015            /**
4016             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
4017             *
4018             * <p>
4019             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4020             * </p>
4021             *
4022             * @param id the primary key of the current journal article
4023             * @param resourcePrimKey the resource prim key
4024             * @param status the status
4025             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4026             * @return the previous, current, and next journal article
4027             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4028             * @throws SystemException if a system exception occurred
4029             */
4030            public JournalArticle[] findByR_ST_PrevAndNext(long id,
4031                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
4032                    throws NoSuchArticleException, SystemException {
4033                    JournalArticle journalArticle = findByPrimaryKey(id);
4034    
4035                    Session session = null;
4036    
4037                    try {
4038                            session = openSession();
4039    
4040                            JournalArticle[] array = new JournalArticleImpl[3];
4041    
4042                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
4043                                            resourcePrimKey, status, orderByComparator, true);
4044    
4045                            array[1] = journalArticle;
4046    
4047                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
4048                                            resourcePrimKey, status, orderByComparator, false);
4049    
4050                            return array;
4051                    }
4052                    catch (Exception e) {
4053                            throw processException(e);
4054                    }
4055                    finally {
4056                            closeSession(session);
4057                    }
4058            }
4059    
4060            protected JournalArticle getByR_ST_PrevAndNext(Session session,
4061                    JournalArticle journalArticle, long resourcePrimKey, int status,
4062                    OrderByComparator orderByComparator, boolean previous) {
4063                    StringBundler query = null;
4064    
4065                    if (orderByComparator != null) {
4066                            query = new StringBundler(6 +
4067                                            (orderByComparator.getOrderByFields().length * 6));
4068                    }
4069                    else {
4070                            query = new StringBundler(3);
4071                    }
4072    
4073                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4074    
4075                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
4076    
4077                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
4078    
4079                    if (orderByComparator != null) {
4080                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4081    
4082                            if (orderByConditionFields.length > 0) {
4083                                    query.append(WHERE_AND);
4084                            }
4085    
4086                            for (int i = 0; i < orderByConditionFields.length; i++) {
4087                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4088                                    query.append(orderByConditionFields[i]);
4089    
4090                                    if ((i + 1) < orderByConditionFields.length) {
4091                                            if (orderByComparator.isAscending() ^ previous) {
4092                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4093                                            }
4094                                            else {
4095                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4096                                            }
4097                                    }
4098                                    else {
4099                                            if (orderByComparator.isAscending() ^ previous) {
4100                                                    query.append(WHERE_GREATER_THAN);
4101                                            }
4102                                            else {
4103                                                    query.append(WHERE_LESSER_THAN);
4104                                            }
4105                                    }
4106                            }
4107    
4108                            query.append(ORDER_BY_CLAUSE);
4109    
4110                            String[] orderByFields = orderByComparator.getOrderByFields();
4111    
4112                            for (int i = 0; i < orderByFields.length; i++) {
4113                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4114                                    query.append(orderByFields[i]);
4115    
4116                                    if ((i + 1) < orderByFields.length) {
4117                                            if (orderByComparator.isAscending() ^ previous) {
4118                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4119                                            }
4120                                            else {
4121                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4122                                            }
4123                                    }
4124                                    else {
4125                                            if (orderByComparator.isAscending() ^ previous) {
4126                                                    query.append(ORDER_BY_ASC);
4127                                            }
4128                                            else {
4129                                                    query.append(ORDER_BY_DESC);
4130                                            }
4131                                    }
4132                            }
4133                    }
4134    
4135                    else {
4136                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4137                    }
4138    
4139                    String sql = query.toString();
4140    
4141                    Query q = session.createQuery(sql);
4142    
4143                    q.setFirstResult(0);
4144                    q.setMaxResults(2);
4145    
4146                    QueryPos qPos = QueryPos.getInstance(q);
4147    
4148                    qPos.add(resourcePrimKey);
4149    
4150                    qPos.add(status);
4151    
4152                    if (orderByComparator != null) {
4153                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4154    
4155                            for (Object value : values) {
4156                                    qPos.add(value);
4157                            }
4158                    }
4159    
4160                    List<JournalArticle> list = q.list();
4161    
4162                    if (list.size() == 2) {
4163                            return list.get(1);
4164                    }
4165                    else {
4166                            return null;
4167                    }
4168            }
4169    
4170            /**
4171             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
4172             *
4173             * @param groupId the group ID
4174             * @param articleId the article ID
4175             * @return the matching journal articles
4176             * @throws SystemException if a system exception occurred
4177             */
4178            public List<JournalArticle> findByG_A(long groupId, String articleId)
4179                    throws SystemException {
4180                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
4181                            QueryUtil.ALL_POS, null);
4182            }
4183    
4184            /**
4185             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
4186             *
4187             * <p>
4188             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4189             * </p>
4190             *
4191             * @param groupId the group ID
4192             * @param articleId the article ID
4193             * @param start the lower bound of the range of journal articles
4194             * @param end the upper bound of the range of journal articles (not inclusive)
4195             * @return the range of matching journal articles
4196             * @throws SystemException if a system exception occurred
4197             */
4198            public List<JournalArticle> findByG_A(long groupId, String articleId,
4199                    int start, int end) throws SystemException {
4200                    return findByG_A(groupId, articleId, start, end, null);
4201            }
4202    
4203            /**
4204             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
4205             *
4206             * <p>
4207             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4208             * </p>
4209             *
4210             * @param groupId the group ID
4211             * @param articleId the article ID
4212             * @param start the lower bound of the range of journal articles
4213             * @param end the upper bound of the range of journal articles (not inclusive)
4214             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4215             * @return the ordered range of matching journal articles
4216             * @throws SystemException if a system exception occurred
4217             */
4218            public List<JournalArticle> findByG_A(long groupId, String articleId,
4219                    int start, int end, OrderByComparator orderByComparator)
4220                    throws SystemException {
4221                    FinderPath finderPath = null;
4222                    Object[] finderArgs = null;
4223    
4224                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4225                                    (orderByComparator == null)) {
4226                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
4227                            finderArgs = new Object[] { groupId, articleId };
4228                    }
4229                    else {
4230                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
4231                            finderArgs = new Object[] {
4232                                            groupId, articleId,
4233                                            
4234                                            start, end, orderByComparator
4235                                    };
4236                    }
4237    
4238                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4239                                    finderArgs, this);
4240    
4241                    if (list == null) {
4242                            StringBundler query = null;
4243    
4244                            if (orderByComparator != null) {
4245                                    query = new StringBundler(4 +
4246                                                    (orderByComparator.getOrderByFields().length * 3));
4247                            }
4248                            else {
4249                                    query = new StringBundler(4);
4250                            }
4251    
4252                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4253    
4254                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
4255    
4256                            if (articleId == null) {
4257                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
4258                            }
4259                            else {
4260                                    if (articleId.equals(StringPool.BLANK)) {
4261                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
4262                                    }
4263                                    else {
4264                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
4265                                    }
4266                            }
4267    
4268                            if (orderByComparator != null) {
4269                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4270                                            orderByComparator);
4271                            }
4272    
4273                            else {
4274                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4275                            }
4276    
4277                            String sql = query.toString();
4278    
4279                            Session session = null;
4280    
4281                            try {
4282                                    session = openSession();
4283    
4284                                    Query q = session.createQuery(sql);
4285    
4286                                    QueryPos qPos = QueryPos.getInstance(q);
4287    
4288                                    qPos.add(groupId);
4289    
4290                                    if (articleId != null) {
4291                                            qPos.add(articleId);
4292                                    }
4293    
4294                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4295                                                    start, end);
4296                            }
4297                            catch (Exception e) {
4298                                    throw processException(e);
4299                            }
4300                            finally {
4301                                    if (list == null) {
4302                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4303                                    }
4304                                    else {
4305                                            cacheResult(list);
4306    
4307                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4308                                    }
4309    
4310                                    closeSession(session);
4311                            }
4312                    }
4313    
4314                    return list;
4315            }
4316    
4317            /**
4318             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
4319             *
4320             * <p>
4321             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4322             * </p>
4323             *
4324             * @param groupId the group ID
4325             * @param articleId the article ID
4326             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4327             * @return the first matching journal article
4328             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4329             * @throws SystemException if a system exception occurred
4330             */
4331            public JournalArticle findByG_A_First(long groupId, String articleId,
4332                    OrderByComparator orderByComparator)
4333                    throws NoSuchArticleException, SystemException {
4334                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
4335                                    orderByComparator);
4336    
4337                    if (list.isEmpty()) {
4338                            StringBundler msg = new StringBundler(6);
4339    
4340                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4341    
4342                            msg.append("groupId=");
4343                            msg.append(groupId);
4344    
4345                            msg.append(", articleId=");
4346                            msg.append(articleId);
4347    
4348                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4349    
4350                            throw new NoSuchArticleException(msg.toString());
4351                    }
4352                    else {
4353                            return list.get(0);
4354                    }
4355            }
4356    
4357            /**
4358             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
4359             *
4360             * <p>
4361             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4362             * </p>
4363             *
4364             * @param groupId the group ID
4365             * @param articleId the article ID
4366             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4367             * @return the last matching journal article
4368             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4369             * @throws SystemException if a system exception occurred
4370             */
4371            public JournalArticle findByG_A_Last(long groupId, String articleId,
4372                    OrderByComparator orderByComparator)
4373                    throws NoSuchArticleException, SystemException {
4374                    int count = countByG_A(groupId, articleId);
4375    
4376                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
4377                                    count, orderByComparator);
4378    
4379                    if (list.isEmpty()) {
4380                            StringBundler msg = new StringBundler(6);
4381    
4382                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4383    
4384                            msg.append("groupId=");
4385                            msg.append(groupId);
4386    
4387                            msg.append(", articleId=");
4388                            msg.append(articleId);
4389    
4390                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4391    
4392                            throw new NoSuchArticleException(msg.toString());
4393                    }
4394                    else {
4395                            return list.get(0);
4396                    }
4397            }
4398    
4399            /**
4400             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
4401             *
4402             * <p>
4403             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4404             * </p>
4405             *
4406             * @param id the primary key of the current journal article
4407             * @param groupId the group ID
4408             * @param articleId the article ID
4409             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4410             * @return the previous, current, and next journal article
4411             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4412             * @throws SystemException if a system exception occurred
4413             */
4414            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
4415                    String articleId, OrderByComparator orderByComparator)
4416                    throws NoSuchArticleException, SystemException {
4417                    JournalArticle journalArticle = findByPrimaryKey(id);
4418    
4419                    Session session = null;
4420    
4421                    try {
4422                            session = openSession();
4423    
4424                            JournalArticle[] array = new JournalArticleImpl[3];
4425    
4426                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
4427                                            articleId, orderByComparator, true);
4428    
4429                            array[1] = journalArticle;
4430    
4431                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
4432                                            articleId, orderByComparator, false);
4433    
4434                            return array;
4435                    }
4436                    catch (Exception e) {
4437                            throw processException(e);
4438                    }
4439                    finally {
4440                            closeSession(session);
4441                    }
4442            }
4443    
4444            protected JournalArticle getByG_A_PrevAndNext(Session session,
4445                    JournalArticle journalArticle, long groupId, String articleId,
4446                    OrderByComparator orderByComparator, boolean previous) {
4447                    StringBundler query = null;
4448    
4449                    if (orderByComparator != null) {
4450                            query = new StringBundler(6 +
4451                                            (orderByComparator.getOrderByFields().length * 6));
4452                    }
4453                    else {
4454                            query = new StringBundler(3);
4455                    }
4456    
4457                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4458    
4459                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
4460    
4461                    if (articleId == null) {
4462                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
4463                    }
4464                    else {
4465                            if (articleId.equals(StringPool.BLANK)) {
4466                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
4467                            }
4468                            else {
4469                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
4470                            }
4471                    }
4472    
4473                    if (orderByComparator != null) {
4474                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4475    
4476                            if (orderByConditionFields.length > 0) {
4477                                    query.append(WHERE_AND);
4478                            }
4479    
4480                            for (int i = 0; i < orderByConditionFields.length; i++) {
4481                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4482                                    query.append(orderByConditionFields[i]);
4483    
4484                                    if ((i + 1) < orderByConditionFields.length) {
4485                                            if (orderByComparator.isAscending() ^ previous) {
4486                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4487                                            }
4488                                            else {
4489                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4490                                            }
4491                                    }
4492                                    else {
4493                                            if (orderByComparator.isAscending() ^ previous) {
4494                                                    query.append(WHERE_GREATER_THAN);
4495                                            }
4496                                            else {
4497                                                    query.append(WHERE_LESSER_THAN);
4498                                            }
4499                                    }
4500                            }
4501    
4502                            query.append(ORDER_BY_CLAUSE);
4503    
4504                            String[] orderByFields = orderByComparator.getOrderByFields();
4505    
4506                            for (int i = 0; i < orderByFields.length; i++) {
4507                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4508                                    query.append(orderByFields[i]);
4509    
4510                                    if ((i + 1) < orderByFields.length) {
4511                                            if (orderByComparator.isAscending() ^ previous) {
4512                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4513                                            }
4514                                            else {
4515                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4516                                            }
4517                                    }
4518                                    else {
4519                                            if (orderByComparator.isAscending() ^ previous) {
4520                                                    query.append(ORDER_BY_ASC);
4521                                            }
4522                                            else {
4523                                                    query.append(ORDER_BY_DESC);
4524                                            }
4525                                    }
4526                            }
4527                    }
4528    
4529                    else {
4530                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4531                    }
4532    
4533                    String sql = query.toString();
4534    
4535                    Query q = session.createQuery(sql);
4536    
4537                    q.setFirstResult(0);
4538                    q.setMaxResults(2);
4539    
4540                    QueryPos qPos = QueryPos.getInstance(q);
4541    
4542                    qPos.add(groupId);
4543    
4544                    if (articleId != null) {
4545                            qPos.add(articleId);
4546                    }
4547    
4548                    if (orderByComparator != null) {
4549                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4550    
4551                            for (Object value : values) {
4552                                    qPos.add(value);
4553                            }
4554                    }
4555    
4556                    List<JournalArticle> list = q.list();
4557    
4558                    if (list.size() == 2) {
4559                            return list.get(1);
4560                    }
4561                    else {
4562                            return null;
4563                    }
4564            }
4565    
4566            /**
4567             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
4568             *
4569             * @param groupId the group ID
4570             * @param articleId the article ID
4571             * @return the matching journal articles that the user has permission to view
4572             * @throws SystemException if a system exception occurred
4573             */
4574            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
4575                    throws SystemException {
4576                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
4577                            QueryUtil.ALL_POS, null);
4578            }
4579    
4580            /**
4581             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
4582             *
4583             * <p>
4584             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4585             * </p>
4586             *
4587             * @param groupId the group ID
4588             * @param articleId the article ID
4589             * @param start the lower bound of the range of journal articles
4590             * @param end the upper bound of the range of journal articles (not inclusive)
4591             * @return the range of matching journal articles that the user has permission to view
4592             * @throws SystemException if a system exception occurred
4593             */
4594            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
4595                    int start, int end) throws SystemException {
4596                    return filterFindByG_A(groupId, articleId, start, end, null);
4597            }
4598    
4599            /**
4600             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
4601             *
4602             * <p>
4603             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4604             * </p>
4605             *
4606             * @param groupId the group ID
4607             * @param articleId the article ID
4608             * @param start the lower bound of the range of journal articles
4609             * @param end the upper bound of the range of journal articles (not inclusive)
4610             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4611             * @return the ordered range of matching journal articles that the user has permission to view
4612             * @throws SystemException if a system exception occurred
4613             */
4614            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
4615                    int start, int end, OrderByComparator orderByComparator)
4616                    throws SystemException {
4617                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4618                            return findByG_A(groupId, articleId, start, end, orderByComparator);
4619                    }
4620    
4621                    StringBundler query = null;
4622    
4623                    if (orderByComparator != null) {
4624                            query = new StringBundler(4 +
4625                                            (orderByComparator.getOrderByFields().length * 3));
4626                    }
4627                    else {
4628                            query = new StringBundler(4);
4629                    }
4630    
4631                    if (getDB().isSupportsInlineDistinct()) {
4632                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
4633                    }
4634                    else {
4635                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
4636                    }
4637    
4638                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
4639    
4640                    if (articleId == null) {
4641                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
4642                    }
4643                    else {
4644                            if (articleId.equals(StringPool.BLANK)) {
4645                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
4646                            }
4647                            else {
4648                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
4649                            }
4650                    }
4651    
4652                    if (!getDB().isSupportsInlineDistinct()) {
4653                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
4654                    }
4655    
4656                    if (orderByComparator != null) {
4657                            if (getDB().isSupportsInlineDistinct()) {
4658                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4659                                            orderByComparator);
4660                            }
4661                            else {
4662                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4663                                            orderByComparator);
4664                            }
4665                    }
4666    
4667                    else {
4668                            if (getDB().isSupportsInlineDistinct()) {
4669                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4670                            }
4671                            else {
4672                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
4673                            }
4674                    }
4675    
4676                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4677                                    JournalArticle.class.getName(),
4678                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4679    
4680                    Session session = null;
4681    
4682                    try {
4683                            session = openSession();
4684    
4685                            SQLQuery q = session.createSQLQuery(sql);
4686    
4687                            if (getDB().isSupportsInlineDistinct()) {
4688                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
4689                            }
4690                            else {
4691                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
4692                            }
4693    
4694                            QueryPos qPos = QueryPos.getInstance(q);
4695    
4696                            qPos.add(groupId);
4697    
4698                            if (articleId != null) {
4699                                    qPos.add(articleId);
4700                            }
4701    
4702                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
4703                                    end);
4704                    }
4705                    catch (Exception e) {
4706                            throw processException(e);
4707                    }
4708                    finally {
4709                            closeSession(session);
4710                    }
4711            }
4712    
4713            /**
4714             * 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;.
4715             *
4716             * @param id the primary key of the current journal article
4717             * @param groupId the group ID
4718             * @param articleId the article ID
4719             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4720             * @return the previous, current, and next journal article
4721             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4722             * @throws SystemException if a system exception occurred
4723             */
4724            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
4725                    String articleId, OrderByComparator orderByComparator)
4726                    throws NoSuchArticleException, SystemException {
4727                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4728                            return findByG_A_PrevAndNext(id, groupId, articleId,
4729                                    orderByComparator);
4730                    }
4731    
4732                    JournalArticle journalArticle = findByPrimaryKey(id);
4733    
4734                    Session session = null;
4735    
4736                    try {
4737                            session = openSession();
4738    
4739                            JournalArticle[] array = new JournalArticleImpl[3];
4740    
4741                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
4742                                            groupId, articleId, orderByComparator, true);
4743    
4744                            array[1] = journalArticle;
4745    
4746                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
4747                                            groupId, articleId, orderByComparator, false);
4748    
4749                            return array;
4750                    }
4751                    catch (Exception e) {
4752                            throw processException(e);
4753                    }
4754                    finally {
4755                            closeSession(session);
4756                    }
4757            }
4758    
4759            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
4760                    JournalArticle journalArticle, long groupId, String articleId,
4761                    OrderByComparator orderByComparator, boolean previous) {
4762                    StringBundler query = null;
4763    
4764                    if (orderByComparator != null) {
4765                            query = new StringBundler(6 +
4766                                            (orderByComparator.getOrderByFields().length * 6));
4767                    }
4768                    else {
4769                            query = new StringBundler(3);
4770                    }
4771    
4772                    if (getDB().isSupportsInlineDistinct()) {
4773                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
4774                    }
4775                    else {
4776                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
4777                    }
4778    
4779                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
4780    
4781                    if (articleId == null) {
4782                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
4783                    }
4784                    else {
4785                            if (articleId.equals(StringPool.BLANK)) {
4786                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
4787                            }
4788                            else {
4789                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
4790                            }
4791                    }
4792    
4793                    if (!getDB().isSupportsInlineDistinct()) {
4794                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
4795                    }
4796    
4797                    if (orderByComparator != null) {
4798                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4799    
4800                            if (orderByConditionFields.length > 0) {
4801                                    query.append(WHERE_AND);
4802                            }
4803    
4804                            for (int i = 0; i < orderByConditionFields.length; i++) {
4805                                    if (getDB().isSupportsInlineDistinct()) {
4806                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4807                                    }
4808                                    else {
4809                                            query.append(_ORDER_BY_ENTITY_TABLE);
4810                                    }
4811    
4812                                    query.append(orderByConditionFields[i]);
4813    
4814                                    if ((i + 1) < orderByConditionFields.length) {
4815                                            if (orderByComparator.isAscending() ^ previous) {
4816                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4817                                            }
4818                                            else {
4819                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4820                                            }
4821                                    }
4822                                    else {
4823                                            if (orderByComparator.isAscending() ^ previous) {
4824                                                    query.append(WHERE_GREATER_THAN);
4825                                            }
4826                                            else {
4827                                                    query.append(WHERE_LESSER_THAN);
4828                                            }
4829                                    }
4830                            }
4831    
4832                            query.append(ORDER_BY_CLAUSE);
4833    
4834                            String[] orderByFields = orderByComparator.getOrderByFields();
4835    
4836                            for (int i = 0; i < orderByFields.length; i++) {
4837                                    if (getDB().isSupportsInlineDistinct()) {
4838                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4839                                    }
4840                                    else {
4841                                            query.append(_ORDER_BY_ENTITY_TABLE);
4842                                    }
4843    
4844                                    query.append(orderByFields[i]);
4845    
4846                                    if ((i + 1) < orderByFields.length) {
4847                                            if (orderByComparator.isAscending() ^ previous) {
4848                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4849                                            }
4850                                            else {
4851                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4852                                            }
4853                                    }
4854                                    else {
4855                                            if (orderByComparator.isAscending() ^ previous) {
4856                                                    query.append(ORDER_BY_ASC);
4857                                            }
4858                                            else {
4859                                                    query.append(ORDER_BY_DESC);
4860                                            }
4861                                    }
4862                            }
4863                    }
4864    
4865                    else {
4866                            if (getDB().isSupportsInlineDistinct()) {
4867                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4868                            }
4869                            else {
4870                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
4871                            }
4872                    }
4873    
4874                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4875                                    JournalArticle.class.getName(),
4876                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4877    
4878                    SQLQuery q = session.createSQLQuery(sql);
4879    
4880                    q.setFirstResult(0);
4881                    q.setMaxResults(2);
4882    
4883                    if (getDB().isSupportsInlineDistinct()) {
4884                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
4885                    }
4886                    else {
4887                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
4888                    }
4889    
4890                    QueryPos qPos = QueryPos.getInstance(q);
4891    
4892                    qPos.add(groupId);
4893    
4894                    if (articleId != null) {
4895                            qPos.add(articleId);
4896                    }
4897    
4898                    if (orderByComparator != null) {
4899                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4900    
4901                            for (Object value : values) {
4902                                    qPos.add(value);
4903                            }
4904                    }
4905    
4906                    List<JournalArticle> list = q.list();
4907    
4908                    if (list.size() == 2) {
4909                            return list.get(1);
4910                    }
4911                    else {
4912                            return null;
4913                    }
4914            }
4915    
4916            /**
4917             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
4918             *
4919             * @param groupId the group ID
4920             * @param urlTitle the url title
4921             * @return the matching journal articles
4922             * @throws SystemException if a system exception occurred
4923             */
4924            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
4925                    throws SystemException {
4926                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
4927                            QueryUtil.ALL_POS, null);
4928            }
4929    
4930            /**
4931             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
4932             *
4933             * <p>
4934             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4935             * </p>
4936             *
4937             * @param groupId the group ID
4938             * @param urlTitle the url title
4939             * @param start the lower bound of the range of journal articles
4940             * @param end the upper bound of the range of journal articles (not inclusive)
4941             * @return the range of matching journal articles
4942             * @throws SystemException if a system exception occurred
4943             */
4944            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
4945                    int start, int end) throws SystemException {
4946                    return findByG_UT(groupId, urlTitle, start, end, null);
4947            }
4948    
4949            /**
4950             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
4951             *
4952             * <p>
4953             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4954             * </p>
4955             *
4956             * @param groupId the group ID
4957             * @param urlTitle the url title
4958             * @param start the lower bound of the range of journal articles
4959             * @param end the upper bound of the range of journal articles (not inclusive)
4960             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4961             * @return the ordered range of matching journal articles
4962             * @throws SystemException if a system exception occurred
4963             */
4964            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
4965                    int start, int end, OrderByComparator orderByComparator)
4966                    throws SystemException {
4967                    FinderPath finderPath = null;
4968                    Object[] finderArgs = null;
4969    
4970                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4971                                    (orderByComparator == null)) {
4972                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
4973                            finderArgs = new Object[] { groupId, urlTitle };
4974                    }
4975                    else {
4976                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
4977                            finderArgs = new Object[] {
4978                                            groupId, urlTitle,
4979                                            
4980                                            start, end, orderByComparator
4981                                    };
4982                    }
4983    
4984                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4985                                    finderArgs, this);
4986    
4987                    if (list == null) {
4988                            StringBundler query = null;
4989    
4990                            if (orderByComparator != null) {
4991                                    query = new StringBundler(4 +
4992                                                    (orderByComparator.getOrderByFields().length * 3));
4993                            }
4994                            else {
4995                                    query = new StringBundler(4);
4996                            }
4997    
4998                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4999    
5000                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5001    
5002                            if (urlTitle == null) {
5003                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5004                            }
5005                            else {
5006                                    if (urlTitle.equals(StringPool.BLANK)) {
5007                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5008                                    }
5009                                    else {
5010                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5011                                    }
5012                            }
5013    
5014                            if (orderByComparator != null) {
5015                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5016                                            orderByComparator);
5017                            }
5018    
5019                            else {
5020                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5021                            }
5022    
5023                            String sql = query.toString();
5024    
5025                            Session session = null;
5026    
5027                            try {
5028                                    session = openSession();
5029    
5030                                    Query q = session.createQuery(sql);
5031    
5032                                    QueryPos qPos = QueryPos.getInstance(q);
5033    
5034                                    qPos.add(groupId);
5035    
5036                                    if (urlTitle != null) {
5037                                            qPos.add(urlTitle);
5038                                    }
5039    
5040                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5041                                                    start, end);
5042                            }
5043                            catch (Exception e) {
5044                                    throw processException(e);
5045                            }
5046                            finally {
5047                                    if (list == null) {
5048                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5049                                    }
5050                                    else {
5051                                            cacheResult(list);
5052    
5053                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5054                                    }
5055    
5056                                    closeSession(session);
5057                            }
5058                    }
5059    
5060                    return list;
5061            }
5062    
5063            /**
5064             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
5065             *
5066             * <p>
5067             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5068             * </p>
5069             *
5070             * @param groupId the group ID
5071             * @param urlTitle the url title
5072             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5073             * @return the first matching journal article
5074             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5075             * @throws SystemException if a system exception occurred
5076             */
5077            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
5078                    OrderByComparator orderByComparator)
5079                    throws NoSuchArticleException, SystemException {
5080                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
5081                                    orderByComparator);
5082    
5083                    if (list.isEmpty()) {
5084                            StringBundler msg = new StringBundler(6);
5085    
5086                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5087    
5088                            msg.append("groupId=");
5089                            msg.append(groupId);
5090    
5091                            msg.append(", urlTitle=");
5092                            msg.append(urlTitle);
5093    
5094                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5095    
5096                            throw new NoSuchArticleException(msg.toString());
5097                    }
5098                    else {
5099                            return list.get(0);
5100                    }
5101            }
5102    
5103            /**
5104             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
5105             *
5106             * <p>
5107             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5108             * </p>
5109             *
5110             * @param groupId the group ID
5111             * @param urlTitle the url title
5112             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5113             * @return the last matching journal article
5114             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5115             * @throws SystemException if a system exception occurred
5116             */
5117            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
5118                    OrderByComparator orderByComparator)
5119                    throws NoSuchArticleException, SystemException {
5120                    int count = countByG_UT(groupId, urlTitle);
5121    
5122                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
5123                                    count, orderByComparator);
5124    
5125                    if (list.isEmpty()) {
5126                            StringBundler msg = new StringBundler(6);
5127    
5128                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5129    
5130                            msg.append("groupId=");
5131                            msg.append(groupId);
5132    
5133                            msg.append(", urlTitle=");
5134                            msg.append(urlTitle);
5135    
5136                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5137    
5138                            throw new NoSuchArticleException(msg.toString());
5139                    }
5140                    else {
5141                            return list.get(0);
5142                    }
5143            }
5144    
5145            /**
5146             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
5147             *
5148             * <p>
5149             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5150             * </p>
5151             *
5152             * @param id the primary key of the current journal article
5153             * @param groupId the group ID
5154             * @param urlTitle the url title
5155             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5156             * @return the previous, current, and next journal article
5157             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5158             * @throws SystemException if a system exception occurred
5159             */
5160            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
5161                    String urlTitle, OrderByComparator orderByComparator)
5162                    throws NoSuchArticleException, SystemException {
5163                    JournalArticle journalArticle = findByPrimaryKey(id);
5164    
5165                    Session session = null;
5166    
5167                    try {
5168                            session = openSession();
5169    
5170                            JournalArticle[] array = new JournalArticleImpl[3];
5171    
5172                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
5173                                            urlTitle, orderByComparator, true);
5174    
5175                            array[1] = journalArticle;
5176    
5177                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
5178                                            urlTitle, orderByComparator, false);
5179    
5180                            return array;
5181                    }
5182                    catch (Exception e) {
5183                            throw processException(e);
5184                    }
5185                    finally {
5186                            closeSession(session);
5187                    }
5188            }
5189    
5190            protected JournalArticle getByG_UT_PrevAndNext(Session session,
5191                    JournalArticle journalArticle, long groupId, String urlTitle,
5192                    OrderByComparator orderByComparator, boolean previous) {
5193                    StringBundler query = null;
5194    
5195                    if (orderByComparator != null) {
5196                            query = new StringBundler(6 +
5197                                            (orderByComparator.getOrderByFields().length * 6));
5198                    }
5199                    else {
5200                            query = new StringBundler(3);
5201                    }
5202    
5203                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5204    
5205                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5206    
5207                    if (urlTitle == null) {
5208                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5209                    }
5210                    else {
5211                            if (urlTitle.equals(StringPool.BLANK)) {
5212                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5213                            }
5214                            else {
5215                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5216                            }
5217                    }
5218    
5219                    if (orderByComparator != null) {
5220                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5221    
5222                            if (orderByConditionFields.length > 0) {
5223                                    query.append(WHERE_AND);
5224                            }
5225    
5226                            for (int i = 0; i < orderByConditionFields.length; i++) {
5227                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5228                                    query.append(orderByConditionFields[i]);
5229    
5230                                    if ((i + 1) < orderByConditionFields.length) {
5231                                            if (orderByComparator.isAscending() ^ previous) {
5232                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5233                                            }
5234                                            else {
5235                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5236                                            }
5237                                    }
5238                                    else {
5239                                            if (orderByComparator.isAscending() ^ previous) {
5240                                                    query.append(WHERE_GREATER_THAN);
5241                                            }
5242                                            else {
5243                                                    query.append(WHERE_LESSER_THAN);
5244                                            }
5245                                    }
5246                            }
5247    
5248                            query.append(ORDER_BY_CLAUSE);
5249    
5250                            String[] orderByFields = orderByComparator.getOrderByFields();
5251    
5252                            for (int i = 0; i < orderByFields.length; i++) {
5253                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5254                                    query.append(orderByFields[i]);
5255    
5256                                    if ((i + 1) < orderByFields.length) {
5257                                            if (orderByComparator.isAscending() ^ previous) {
5258                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5259                                            }
5260                                            else {
5261                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5262                                            }
5263                                    }
5264                                    else {
5265                                            if (orderByComparator.isAscending() ^ previous) {
5266                                                    query.append(ORDER_BY_ASC);
5267                                            }
5268                                            else {
5269                                                    query.append(ORDER_BY_DESC);
5270                                            }
5271                                    }
5272                            }
5273                    }
5274    
5275                    else {
5276                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5277                    }
5278    
5279                    String sql = query.toString();
5280    
5281                    Query q = session.createQuery(sql);
5282    
5283                    q.setFirstResult(0);
5284                    q.setMaxResults(2);
5285    
5286                    QueryPos qPos = QueryPos.getInstance(q);
5287    
5288                    qPos.add(groupId);
5289    
5290                    if (urlTitle != null) {
5291                            qPos.add(urlTitle);
5292                    }
5293    
5294                    if (orderByComparator != null) {
5295                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5296    
5297                            for (Object value : values) {
5298                                    qPos.add(value);
5299                            }
5300                    }
5301    
5302                    List<JournalArticle> list = q.list();
5303    
5304                    if (list.size() == 2) {
5305                            return list.get(1);
5306                    }
5307                    else {
5308                            return null;
5309                    }
5310            }
5311    
5312            /**
5313             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
5314             *
5315             * @param groupId the group ID
5316             * @param urlTitle the url title
5317             * @return the matching journal articles that the user has permission to view
5318             * @throws SystemException if a system exception occurred
5319             */
5320            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
5321                    throws SystemException {
5322                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
5323                            QueryUtil.ALL_POS, null);
5324            }
5325    
5326            /**
5327             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
5328             *
5329             * <p>
5330             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5331             * </p>
5332             *
5333             * @param groupId the group ID
5334             * @param urlTitle the url title
5335             * @param start the lower bound of the range of journal articles
5336             * @param end the upper bound of the range of journal articles (not inclusive)
5337             * @return the range of matching journal articles that the user has permission to view
5338             * @throws SystemException if a system exception occurred
5339             */
5340            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
5341                    int start, int end) throws SystemException {
5342                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
5343            }
5344    
5345            /**
5346             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
5347             *
5348             * <p>
5349             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5350             * </p>
5351             *
5352             * @param groupId the group ID
5353             * @param urlTitle the url title
5354             * @param start the lower bound of the range of journal articles
5355             * @param end the upper bound of the range of journal articles (not inclusive)
5356             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5357             * @return the ordered range of matching journal articles that the user has permission to view
5358             * @throws SystemException if a system exception occurred
5359             */
5360            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
5361                    int start, int end, OrderByComparator orderByComparator)
5362                    throws SystemException {
5363                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5364                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
5365                    }
5366    
5367                    StringBundler query = null;
5368    
5369                    if (orderByComparator != null) {
5370                            query = new StringBundler(4 +
5371                                            (orderByComparator.getOrderByFields().length * 3));
5372                    }
5373                    else {
5374                            query = new StringBundler(4);
5375                    }
5376    
5377                    if (getDB().isSupportsInlineDistinct()) {
5378                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
5379                    }
5380                    else {
5381                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
5382                    }
5383    
5384                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5385    
5386                    if (urlTitle == null) {
5387                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5388                    }
5389                    else {
5390                            if (urlTitle.equals(StringPool.BLANK)) {
5391                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5392                            }
5393                            else {
5394                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5395                            }
5396                    }
5397    
5398                    if (!getDB().isSupportsInlineDistinct()) {
5399                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
5400                    }
5401    
5402                    if (orderByComparator != null) {
5403                            if (getDB().isSupportsInlineDistinct()) {
5404                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5405                                            orderByComparator);
5406                            }
5407                            else {
5408                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5409                                            orderByComparator);
5410                            }
5411                    }
5412    
5413                    else {
5414                            if (getDB().isSupportsInlineDistinct()) {
5415                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5416                            }
5417                            else {
5418                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
5419                            }
5420                    }
5421    
5422                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5423                                    JournalArticle.class.getName(),
5424                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5425    
5426                    Session session = null;
5427    
5428                    try {
5429                            session = openSession();
5430    
5431                            SQLQuery q = session.createSQLQuery(sql);
5432    
5433                            if (getDB().isSupportsInlineDistinct()) {
5434                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
5435                            }
5436                            else {
5437                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
5438                            }
5439    
5440                            QueryPos qPos = QueryPos.getInstance(q);
5441    
5442                            qPos.add(groupId);
5443    
5444                            if (urlTitle != null) {
5445                                    qPos.add(urlTitle);
5446                            }
5447    
5448                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
5449                                    end);
5450                    }
5451                    catch (Exception e) {
5452                            throw processException(e);
5453                    }
5454                    finally {
5455                            closeSession(session);
5456                    }
5457            }
5458    
5459            /**
5460             * 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;.
5461             *
5462             * @param id the primary key of the current journal article
5463             * @param groupId the group ID
5464             * @param urlTitle the url title
5465             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5466             * @return the previous, current, and next journal article
5467             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5468             * @throws SystemException if a system exception occurred
5469             */
5470            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
5471                    String urlTitle, OrderByComparator orderByComparator)
5472                    throws NoSuchArticleException, SystemException {
5473                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5474                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
5475                                    orderByComparator);
5476                    }
5477    
5478                    JournalArticle journalArticle = findByPrimaryKey(id);
5479    
5480                    Session session = null;
5481    
5482                    try {
5483                            session = openSession();
5484    
5485                            JournalArticle[] array = new JournalArticleImpl[3];
5486    
5487                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
5488                                            groupId, urlTitle, orderByComparator, true);
5489    
5490                            array[1] = journalArticle;
5491    
5492                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
5493                                            groupId, urlTitle, orderByComparator, false);
5494    
5495                            return array;
5496                    }
5497                    catch (Exception e) {
5498                            throw processException(e);
5499                    }
5500                    finally {
5501                            closeSession(session);
5502                    }
5503            }
5504    
5505            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
5506                    JournalArticle journalArticle, long groupId, String urlTitle,
5507                    OrderByComparator orderByComparator, boolean previous) {
5508                    StringBundler query = null;
5509    
5510                    if (orderByComparator != null) {
5511                            query = new StringBundler(6 +
5512                                            (orderByComparator.getOrderByFields().length * 6));
5513                    }
5514                    else {
5515                            query = new StringBundler(3);
5516                    }
5517    
5518                    if (getDB().isSupportsInlineDistinct()) {
5519                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
5520                    }
5521                    else {
5522                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
5523                    }
5524    
5525                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5526    
5527                    if (urlTitle == null) {
5528                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5529                    }
5530                    else {
5531                            if (urlTitle.equals(StringPool.BLANK)) {
5532                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5533                            }
5534                            else {
5535                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5536                            }
5537                    }
5538    
5539                    if (!getDB().isSupportsInlineDistinct()) {
5540                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
5541                    }
5542    
5543                    if (orderByComparator != null) {
5544                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5545    
5546                            if (orderByConditionFields.length > 0) {
5547                                    query.append(WHERE_AND);
5548                            }
5549    
5550                            for (int i = 0; i < orderByConditionFields.length; i++) {
5551                                    if (getDB().isSupportsInlineDistinct()) {
5552                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5553                                    }
5554                                    else {
5555                                            query.append(_ORDER_BY_ENTITY_TABLE);
5556                                    }
5557    
5558                                    query.append(orderByConditionFields[i]);
5559    
5560                                    if ((i + 1) < orderByConditionFields.length) {
5561                                            if (orderByComparator.isAscending() ^ previous) {
5562                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5563                                            }
5564                                            else {
5565                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5566                                            }
5567                                    }
5568                                    else {
5569                                            if (orderByComparator.isAscending() ^ previous) {
5570                                                    query.append(WHERE_GREATER_THAN);
5571                                            }
5572                                            else {
5573                                                    query.append(WHERE_LESSER_THAN);
5574                                            }
5575                                    }
5576                            }
5577    
5578                            query.append(ORDER_BY_CLAUSE);
5579    
5580                            String[] orderByFields = orderByComparator.getOrderByFields();
5581    
5582                            for (int i = 0; i < orderByFields.length; i++) {
5583                                    if (getDB().isSupportsInlineDistinct()) {
5584                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5585                                    }
5586                                    else {
5587                                            query.append(_ORDER_BY_ENTITY_TABLE);
5588                                    }
5589    
5590                                    query.append(orderByFields[i]);
5591    
5592                                    if ((i + 1) < orderByFields.length) {
5593                                            if (orderByComparator.isAscending() ^ previous) {
5594                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5595                                            }
5596                                            else {
5597                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5598                                            }
5599                                    }
5600                                    else {
5601                                            if (orderByComparator.isAscending() ^ previous) {
5602                                                    query.append(ORDER_BY_ASC);
5603                                            }
5604                                            else {
5605                                                    query.append(ORDER_BY_DESC);
5606                                            }
5607                                    }
5608                            }
5609                    }
5610    
5611                    else {
5612                            if (getDB().isSupportsInlineDistinct()) {
5613                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5614                            }
5615                            else {
5616                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
5617                            }
5618                    }
5619    
5620                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5621                                    JournalArticle.class.getName(),
5622                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5623    
5624                    SQLQuery q = session.createSQLQuery(sql);
5625    
5626                    q.setFirstResult(0);
5627                    q.setMaxResults(2);
5628    
5629                    if (getDB().isSupportsInlineDistinct()) {
5630                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
5631                    }
5632                    else {
5633                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
5634                    }
5635    
5636                    QueryPos qPos = QueryPos.getInstance(q);
5637    
5638                    qPos.add(groupId);
5639    
5640                    if (urlTitle != null) {
5641                            qPos.add(urlTitle);
5642                    }
5643    
5644                    if (orderByComparator != null) {
5645                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5646    
5647                            for (Object value : values) {
5648                                    qPos.add(value);
5649                            }
5650                    }
5651    
5652                    List<JournalArticle> list = q.list();
5653    
5654                    if (list.size() == 2) {
5655                            return list.get(1);
5656                    }
5657                    else {
5658                            return null;
5659                    }
5660            }
5661    
5662            /**
5663             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
5664             *
5665             * @param groupId the group ID
5666             * @param structureId the structure ID
5667             * @return the matching journal articles
5668             * @throws SystemException if a system exception occurred
5669             */
5670            public List<JournalArticle> findByG_S(long groupId, String structureId)
5671                    throws SystemException {
5672                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
5673                            QueryUtil.ALL_POS, null);
5674            }
5675    
5676            /**
5677             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
5678             *
5679             * <p>
5680             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5681             * </p>
5682             *
5683             * @param groupId the group ID
5684             * @param structureId the structure ID
5685             * @param start the lower bound of the range of journal articles
5686             * @param end the upper bound of the range of journal articles (not inclusive)
5687             * @return the range of matching journal articles
5688             * @throws SystemException if a system exception occurred
5689             */
5690            public List<JournalArticle> findByG_S(long groupId, String structureId,
5691                    int start, int end) throws SystemException {
5692                    return findByG_S(groupId, structureId, start, end, null);
5693            }
5694    
5695            /**
5696             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
5697             *
5698             * <p>
5699             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5700             * </p>
5701             *
5702             * @param groupId the group ID
5703             * @param structureId the structure ID
5704             * @param start the lower bound of the range of journal articles
5705             * @param end the upper bound of the range of journal articles (not inclusive)
5706             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5707             * @return the ordered range of matching journal articles
5708             * @throws SystemException if a system exception occurred
5709             */
5710            public List<JournalArticle> findByG_S(long groupId, String structureId,
5711                    int start, int end, OrderByComparator orderByComparator)
5712                    throws SystemException {
5713                    FinderPath finderPath = null;
5714                    Object[] finderArgs = null;
5715    
5716                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5717                                    (orderByComparator == null)) {
5718                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
5719                            finderArgs = new Object[] { groupId, structureId };
5720                    }
5721                    else {
5722                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
5723                            finderArgs = new Object[] {
5724                                            groupId, structureId,
5725                                            
5726                                            start, end, orderByComparator
5727                                    };
5728                    }
5729    
5730                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5731                                    finderArgs, this);
5732    
5733                    if (list == null) {
5734                            StringBundler query = null;
5735    
5736                            if (orderByComparator != null) {
5737                                    query = new StringBundler(4 +
5738                                                    (orderByComparator.getOrderByFields().length * 3));
5739                            }
5740                            else {
5741                                    query = new StringBundler(4);
5742                            }
5743    
5744                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5745    
5746                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5747    
5748                            if (structureId == null) {
5749                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
5750                            }
5751                            else {
5752                                    if (structureId.equals(StringPool.BLANK)) {
5753                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
5754                                    }
5755                                    else {
5756                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
5757                                    }
5758                            }
5759    
5760                            if (orderByComparator != null) {
5761                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5762                                            orderByComparator);
5763                            }
5764    
5765                            else {
5766                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5767                            }
5768    
5769                            String sql = query.toString();
5770    
5771                            Session session = null;
5772    
5773                            try {
5774                                    session = openSession();
5775    
5776                                    Query q = session.createQuery(sql);
5777    
5778                                    QueryPos qPos = QueryPos.getInstance(q);
5779    
5780                                    qPos.add(groupId);
5781    
5782                                    if (structureId != null) {
5783                                            qPos.add(structureId);
5784                                    }
5785    
5786                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5787                                                    start, end);
5788                            }
5789                            catch (Exception e) {
5790                                    throw processException(e);
5791                            }
5792                            finally {
5793                                    if (list == null) {
5794                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5795                                    }
5796                                    else {
5797                                            cacheResult(list);
5798    
5799                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5800                                    }
5801    
5802                                    closeSession(session);
5803                            }
5804                    }
5805    
5806                    return list;
5807            }
5808    
5809            /**
5810             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
5811             *
5812             * <p>
5813             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5814             * </p>
5815             *
5816             * @param groupId the group ID
5817             * @param structureId the structure ID
5818             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5819             * @return the first matching journal article
5820             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5821             * @throws SystemException if a system exception occurred
5822             */
5823            public JournalArticle findByG_S_First(long groupId, String structureId,
5824                    OrderByComparator orderByComparator)
5825                    throws NoSuchArticleException, SystemException {
5826                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
5827                                    orderByComparator);
5828    
5829                    if (list.isEmpty()) {
5830                            StringBundler msg = new StringBundler(6);
5831    
5832                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5833    
5834                            msg.append("groupId=");
5835                            msg.append(groupId);
5836    
5837                            msg.append(", structureId=");
5838                            msg.append(structureId);
5839    
5840                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5841    
5842                            throw new NoSuchArticleException(msg.toString());
5843                    }
5844                    else {
5845                            return list.get(0);
5846                    }
5847            }
5848    
5849            /**
5850             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
5851             *
5852             * <p>
5853             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5854             * </p>
5855             *
5856             * @param groupId the group ID
5857             * @param structureId the structure ID
5858             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5859             * @return the last matching journal article
5860             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5861             * @throws SystemException if a system exception occurred
5862             */
5863            public JournalArticle findByG_S_Last(long groupId, String structureId,
5864                    OrderByComparator orderByComparator)
5865                    throws NoSuchArticleException, SystemException {
5866                    int count = countByG_S(groupId, structureId);
5867    
5868                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
5869                                    count, orderByComparator);
5870    
5871                    if (list.isEmpty()) {
5872                            StringBundler msg = new StringBundler(6);
5873    
5874                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5875    
5876                            msg.append("groupId=");
5877                            msg.append(groupId);
5878    
5879                            msg.append(", structureId=");
5880                            msg.append(structureId);
5881    
5882                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5883    
5884                            throw new NoSuchArticleException(msg.toString());
5885                    }
5886                    else {
5887                            return list.get(0);
5888                    }
5889            }
5890    
5891            /**
5892             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
5893             *
5894             * <p>
5895             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5896             * </p>
5897             *
5898             * @param id the primary key of the current journal article
5899             * @param groupId the group ID
5900             * @param structureId the structure ID
5901             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5902             * @return the previous, current, and next journal article
5903             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5904             * @throws SystemException if a system exception occurred
5905             */
5906            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
5907                    String structureId, OrderByComparator orderByComparator)
5908                    throws NoSuchArticleException, SystemException {
5909                    JournalArticle journalArticle = findByPrimaryKey(id);
5910    
5911                    Session session = null;
5912    
5913                    try {
5914                            session = openSession();
5915    
5916                            JournalArticle[] array = new JournalArticleImpl[3];
5917    
5918                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
5919                                            structureId, orderByComparator, true);
5920    
5921                            array[1] = journalArticle;
5922    
5923                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
5924                                            structureId, orderByComparator, false);
5925    
5926                            return array;
5927                    }
5928                    catch (Exception e) {
5929                            throw processException(e);
5930                    }
5931                    finally {
5932                            closeSession(session);
5933                    }
5934            }
5935    
5936            protected JournalArticle getByG_S_PrevAndNext(Session session,
5937                    JournalArticle journalArticle, long groupId, String structureId,
5938                    OrderByComparator orderByComparator, boolean previous) {
5939                    StringBundler query = null;
5940    
5941                    if (orderByComparator != null) {
5942                            query = new StringBundler(6 +
5943                                            (orderByComparator.getOrderByFields().length * 6));
5944                    }
5945                    else {
5946                            query = new StringBundler(3);
5947                    }
5948    
5949                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5950    
5951                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5952    
5953                    if (structureId == null) {
5954                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
5955                    }
5956                    else {
5957                            if (structureId.equals(StringPool.BLANK)) {
5958                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
5959                            }
5960                            else {
5961                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
5962                            }
5963                    }
5964    
5965                    if (orderByComparator != null) {
5966                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5967    
5968                            if (orderByConditionFields.length > 0) {
5969                                    query.append(WHERE_AND);
5970                            }
5971    
5972                            for (int i = 0; i < orderByConditionFields.length; i++) {
5973                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5974                                    query.append(orderByConditionFields[i]);
5975    
5976                                    if ((i + 1) < orderByConditionFields.length) {
5977                                            if (orderByComparator.isAscending() ^ previous) {
5978                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5979                                            }
5980                                            else {
5981                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5982                                            }
5983                                    }
5984                                    else {
5985                                            if (orderByComparator.isAscending() ^ previous) {
5986                                                    query.append(WHERE_GREATER_THAN);
5987                                            }
5988                                            else {
5989                                                    query.append(WHERE_LESSER_THAN);
5990                                            }
5991                                    }
5992                            }
5993    
5994                            query.append(ORDER_BY_CLAUSE);
5995    
5996                            String[] orderByFields = orderByComparator.getOrderByFields();
5997    
5998                            for (int i = 0; i < orderByFields.length; i++) {
5999                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6000                                    query.append(orderByFields[i]);
6001    
6002                                    if ((i + 1) < orderByFields.length) {
6003                                            if (orderByComparator.isAscending() ^ previous) {
6004                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6005                                            }
6006                                            else {
6007                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6008                                            }
6009                                    }
6010                                    else {
6011                                            if (orderByComparator.isAscending() ^ previous) {
6012                                                    query.append(ORDER_BY_ASC);
6013                                            }
6014                                            else {
6015                                                    query.append(ORDER_BY_DESC);
6016                                            }
6017                                    }
6018                            }
6019                    }
6020    
6021                    else {
6022                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6023                    }
6024    
6025                    String sql = query.toString();
6026    
6027                    Query q = session.createQuery(sql);
6028    
6029                    q.setFirstResult(0);
6030                    q.setMaxResults(2);
6031    
6032                    QueryPos qPos = QueryPos.getInstance(q);
6033    
6034                    qPos.add(groupId);
6035    
6036                    if (structureId != null) {
6037                            qPos.add(structureId);
6038                    }
6039    
6040                    if (orderByComparator != null) {
6041                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6042    
6043                            for (Object value : values) {
6044                                    qPos.add(value);
6045                            }
6046                    }
6047    
6048                    List<JournalArticle> list = q.list();
6049    
6050                    if (list.size() == 2) {
6051                            return list.get(1);
6052                    }
6053                    else {
6054                            return null;
6055                    }
6056            }
6057    
6058            /**
6059             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
6060             *
6061             * @param groupId the group ID
6062             * @param structureId the structure ID
6063             * @return the matching journal articles that the user has permission to view
6064             * @throws SystemException if a system exception occurred
6065             */
6066            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
6067                    throws SystemException {
6068                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
6069                            QueryUtil.ALL_POS, null);
6070            }
6071    
6072            /**
6073             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
6074             *
6075             * <p>
6076             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6077             * </p>
6078             *
6079             * @param groupId the group ID
6080             * @param structureId the structure ID
6081             * @param start the lower bound of the range of journal articles
6082             * @param end the upper bound of the range of journal articles (not inclusive)
6083             * @return the range of matching journal articles that the user has permission to view
6084             * @throws SystemException if a system exception occurred
6085             */
6086            public List<JournalArticle> filterFindByG_S(long groupId,
6087                    String structureId, int start, int end) throws SystemException {
6088                    return filterFindByG_S(groupId, structureId, start, end, null);
6089            }
6090    
6091            /**
6092             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
6093             *
6094             * <p>
6095             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6096             * </p>
6097             *
6098             * @param groupId the group ID
6099             * @param structureId the structure ID
6100             * @param start the lower bound of the range of journal articles
6101             * @param end the upper bound of the range of journal articles (not inclusive)
6102             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6103             * @return the ordered range of matching journal articles that the user has permission to view
6104             * @throws SystemException if a system exception occurred
6105             */
6106            public List<JournalArticle> filterFindByG_S(long groupId,
6107                    String structureId, int start, int end,
6108                    OrderByComparator orderByComparator) throws SystemException {
6109                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6110                            return findByG_S(groupId, structureId, start, end, orderByComparator);
6111                    }
6112    
6113                    StringBundler query = null;
6114    
6115                    if (orderByComparator != null) {
6116                            query = new StringBundler(4 +
6117                                            (orderByComparator.getOrderByFields().length * 3));
6118                    }
6119                    else {
6120                            query = new StringBundler(4);
6121                    }
6122    
6123                    if (getDB().isSupportsInlineDistinct()) {
6124                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6125                    }
6126                    else {
6127                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6128                    }
6129    
6130                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6131    
6132                    if (structureId == null) {
6133                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
6134                    }
6135                    else {
6136                            if (structureId.equals(StringPool.BLANK)) {
6137                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
6138                            }
6139                            else {
6140                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
6141                            }
6142                    }
6143    
6144                    if (!getDB().isSupportsInlineDistinct()) {
6145                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6146                    }
6147    
6148                    if (orderByComparator != null) {
6149                            if (getDB().isSupportsInlineDistinct()) {
6150                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6151                                            orderByComparator);
6152                            }
6153                            else {
6154                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6155                                            orderByComparator);
6156                            }
6157                    }
6158    
6159                    else {
6160                            if (getDB().isSupportsInlineDistinct()) {
6161                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6162                            }
6163                            else {
6164                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6165                            }
6166                    }
6167    
6168                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6169                                    JournalArticle.class.getName(),
6170                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6171    
6172                    Session session = null;
6173    
6174                    try {
6175                            session = openSession();
6176    
6177                            SQLQuery q = session.createSQLQuery(sql);
6178    
6179                            if (getDB().isSupportsInlineDistinct()) {
6180                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6181                            }
6182                            else {
6183                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6184                            }
6185    
6186                            QueryPos qPos = QueryPos.getInstance(q);
6187    
6188                            qPos.add(groupId);
6189    
6190                            if (structureId != null) {
6191                                    qPos.add(structureId);
6192                            }
6193    
6194                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6195                                    end);
6196                    }
6197                    catch (Exception e) {
6198                            throw processException(e);
6199                    }
6200                    finally {
6201                            closeSession(session);
6202                    }
6203            }
6204    
6205            /**
6206             * 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;.
6207             *
6208             * @param id the primary key of the current journal article
6209             * @param groupId the group ID
6210             * @param structureId the structure ID
6211             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6212             * @return the previous, current, and next journal article
6213             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6214             * @throws SystemException if a system exception occurred
6215             */
6216            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
6217                    String structureId, OrderByComparator orderByComparator)
6218                    throws NoSuchArticleException, SystemException {
6219                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6220                            return findByG_S_PrevAndNext(id, groupId, structureId,
6221                                    orderByComparator);
6222                    }
6223    
6224                    JournalArticle journalArticle = findByPrimaryKey(id);
6225    
6226                    Session session = null;
6227    
6228                    try {
6229                            session = openSession();
6230    
6231                            JournalArticle[] array = new JournalArticleImpl[3];
6232    
6233                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
6234                                            groupId, structureId, orderByComparator, true);
6235    
6236                            array[1] = journalArticle;
6237    
6238                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
6239                                            groupId, structureId, orderByComparator, false);
6240    
6241                            return array;
6242                    }
6243                    catch (Exception e) {
6244                            throw processException(e);
6245                    }
6246                    finally {
6247                            closeSession(session);
6248                    }
6249            }
6250    
6251            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
6252                    JournalArticle journalArticle, long groupId, String structureId,
6253                    OrderByComparator orderByComparator, boolean previous) {
6254                    StringBundler query = null;
6255    
6256                    if (orderByComparator != null) {
6257                            query = new StringBundler(6 +
6258                                            (orderByComparator.getOrderByFields().length * 6));
6259                    }
6260                    else {
6261                            query = new StringBundler(3);
6262                    }
6263    
6264                    if (getDB().isSupportsInlineDistinct()) {
6265                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6266                    }
6267                    else {
6268                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6269                    }
6270    
6271                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6272    
6273                    if (structureId == null) {
6274                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
6275                    }
6276                    else {
6277                            if (structureId.equals(StringPool.BLANK)) {
6278                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
6279                            }
6280                            else {
6281                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
6282                            }
6283                    }
6284    
6285                    if (!getDB().isSupportsInlineDistinct()) {
6286                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6287                    }
6288    
6289                    if (orderByComparator != null) {
6290                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6291    
6292                            if (orderByConditionFields.length > 0) {
6293                                    query.append(WHERE_AND);
6294                            }
6295    
6296                            for (int i = 0; i < orderByConditionFields.length; i++) {
6297                                    if (getDB().isSupportsInlineDistinct()) {
6298                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6299                                    }
6300                                    else {
6301                                            query.append(_ORDER_BY_ENTITY_TABLE);
6302                                    }
6303    
6304                                    query.append(orderByConditionFields[i]);
6305    
6306                                    if ((i + 1) < orderByConditionFields.length) {
6307                                            if (orderByComparator.isAscending() ^ previous) {
6308                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6309                                            }
6310                                            else {
6311                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6312                                            }
6313                                    }
6314                                    else {
6315                                            if (orderByComparator.isAscending() ^ previous) {
6316                                                    query.append(WHERE_GREATER_THAN);
6317                                            }
6318                                            else {
6319                                                    query.append(WHERE_LESSER_THAN);
6320                                            }
6321                                    }
6322                            }
6323    
6324                            query.append(ORDER_BY_CLAUSE);
6325    
6326                            String[] orderByFields = orderByComparator.getOrderByFields();
6327    
6328                            for (int i = 0; i < orderByFields.length; i++) {
6329                                    if (getDB().isSupportsInlineDistinct()) {
6330                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6331                                    }
6332                                    else {
6333                                            query.append(_ORDER_BY_ENTITY_TABLE);
6334                                    }
6335    
6336                                    query.append(orderByFields[i]);
6337    
6338                                    if ((i + 1) < orderByFields.length) {
6339                                            if (orderByComparator.isAscending() ^ previous) {
6340                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6341                                            }
6342                                            else {
6343                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6344                                            }
6345                                    }
6346                                    else {
6347                                            if (orderByComparator.isAscending() ^ previous) {
6348                                                    query.append(ORDER_BY_ASC);
6349                                            }
6350                                            else {
6351                                                    query.append(ORDER_BY_DESC);
6352                                            }
6353                                    }
6354                            }
6355                    }
6356    
6357                    else {
6358                            if (getDB().isSupportsInlineDistinct()) {
6359                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6360                            }
6361                            else {
6362                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6363                            }
6364                    }
6365    
6366                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6367                                    JournalArticle.class.getName(),
6368                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6369    
6370                    SQLQuery q = session.createSQLQuery(sql);
6371    
6372                    q.setFirstResult(0);
6373                    q.setMaxResults(2);
6374    
6375                    if (getDB().isSupportsInlineDistinct()) {
6376                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6377                    }
6378                    else {
6379                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6380                    }
6381    
6382                    QueryPos qPos = QueryPos.getInstance(q);
6383    
6384                    qPos.add(groupId);
6385    
6386                    if (structureId != null) {
6387                            qPos.add(structureId);
6388                    }
6389    
6390                    if (orderByComparator != null) {
6391                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6392    
6393                            for (Object value : values) {
6394                                    qPos.add(value);
6395                            }
6396                    }
6397    
6398                    List<JournalArticle> list = q.list();
6399    
6400                    if (list.size() == 2) {
6401                            return list.get(1);
6402                    }
6403                    else {
6404                            return null;
6405                    }
6406            }
6407    
6408            /**
6409             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
6410             *
6411             * @param groupId the group ID
6412             * @param templateId the template ID
6413             * @return the matching journal articles
6414             * @throws SystemException if a system exception occurred
6415             */
6416            public List<JournalArticle> findByG_T(long groupId, String templateId)
6417                    throws SystemException {
6418                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
6419                            QueryUtil.ALL_POS, null);
6420            }
6421    
6422            /**
6423             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
6424             *
6425             * <p>
6426             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6427             * </p>
6428             *
6429             * @param groupId the group ID
6430             * @param templateId the template ID
6431             * @param start the lower bound of the range of journal articles
6432             * @param end the upper bound of the range of journal articles (not inclusive)
6433             * @return the range of matching journal articles
6434             * @throws SystemException if a system exception occurred
6435             */
6436            public List<JournalArticle> findByG_T(long groupId, String templateId,
6437                    int start, int end) throws SystemException {
6438                    return findByG_T(groupId, templateId, start, end, null);
6439            }
6440    
6441            /**
6442             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
6443             *
6444             * <p>
6445             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6446             * </p>
6447             *
6448             * @param groupId the group ID
6449             * @param templateId the template ID
6450             * @param start the lower bound of the range of journal articles
6451             * @param end the upper bound of the range of journal articles (not inclusive)
6452             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6453             * @return the ordered range of matching journal articles
6454             * @throws SystemException if a system exception occurred
6455             */
6456            public List<JournalArticle> findByG_T(long groupId, String templateId,
6457                    int start, int end, OrderByComparator orderByComparator)
6458                    throws SystemException {
6459                    FinderPath finderPath = null;
6460                    Object[] finderArgs = null;
6461    
6462                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6463                                    (orderByComparator == null)) {
6464                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
6465                            finderArgs = new Object[] { groupId, templateId };
6466                    }
6467                    else {
6468                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
6469                            finderArgs = new Object[] {
6470                                            groupId, templateId,
6471                                            
6472                                            start, end, orderByComparator
6473                                    };
6474                    }
6475    
6476                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6477                                    finderArgs, this);
6478    
6479                    if (list == null) {
6480                            StringBundler query = null;
6481    
6482                            if (orderByComparator != null) {
6483                                    query = new StringBundler(4 +
6484                                                    (orderByComparator.getOrderByFields().length * 3));
6485                            }
6486                            else {
6487                                    query = new StringBundler(4);
6488                            }
6489    
6490                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6491    
6492                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
6493    
6494                            if (templateId == null) {
6495                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
6496                            }
6497                            else {
6498                                    if (templateId.equals(StringPool.BLANK)) {
6499                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
6500                                    }
6501                                    else {
6502                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
6503                                    }
6504                            }
6505    
6506                            if (orderByComparator != null) {
6507                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6508                                            orderByComparator);
6509                            }
6510    
6511                            else {
6512                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6513                            }
6514    
6515                            String sql = query.toString();
6516    
6517                            Session session = null;
6518    
6519                            try {
6520                                    session = openSession();
6521    
6522                                    Query q = session.createQuery(sql);
6523    
6524                                    QueryPos qPos = QueryPos.getInstance(q);
6525    
6526                                    qPos.add(groupId);
6527    
6528                                    if (templateId != null) {
6529                                            qPos.add(templateId);
6530                                    }
6531    
6532                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
6533                                                    start, end);
6534                            }
6535                            catch (Exception e) {
6536                                    throw processException(e);
6537                            }
6538                            finally {
6539                                    if (list == null) {
6540                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6541                                    }
6542                                    else {
6543                                            cacheResult(list);
6544    
6545                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6546                                    }
6547    
6548                                    closeSession(session);
6549                            }
6550                    }
6551    
6552                    return list;
6553            }
6554    
6555            /**
6556             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
6557             *
6558             * <p>
6559             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6560             * </p>
6561             *
6562             * @param groupId the group ID
6563             * @param templateId the template ID
6564             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6565             * @return the first matching journal article
6566             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6567             * @throws SystemException if a system exception occurred
6568             */
6569            public JournalArticle findByG_T_First(long groupId, String templateId,
6570                    OrderByComparator orderByComparator)
6571                    throws NoSuchArticleException, SystemException {
6572                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
6573                                    orderByComparator);
6574    
6575                    if (list.isEmpty()) {
6576                            StringBundler msg = new StringBundler(6);
6577    
6578                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6579    
6580                            msg.append("groupId=");
6581                            msg.append(groupId);
6582    
6583                            msg.append(", templateId=");
6584                            msg.append(templateId);
6585    
6586                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6587    
6588                            throw new NoSuchArticleException(msg.toString());
6589                    }
6590                    else {
6591                            return list.get(0);
6592                    }
6593            }
6594    
6595            /**
6596             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
6597             *
6598             * <p>
6599             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6600             * </p>
6601             *
6602             * @param groupId the group ID
6603             * @param templateId the template ID
6604             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6605             * @return the last matching journal article
6606             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6607             * @throws SystemException if a system exception occurred
6608             */
6609            public JournalArticle findByG_T_Last(long groupId, String templateId,
6610                    OrderByComparator orderByComparator)
6611                    throws NoSuchArticleException, SystemException {
6612                    int count = countByG_T(groupId, templateId);
6613    
6614                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
6615                                    count, orderByComparator);
6616    
6617                    if (list.isEmpty()) {
6618                            StringBundler msg = new StringBundler(6);
6619    
6620                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6621    
6622                            msg.append("groupId=");
6623                            msg.append(groupId);
6624    
6625                            msg.append(", templateId=");
6626                            msg.append(templateId);
6627    
6628                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6629    
6630                            throw new NoSuchArticleException(msg.toString());
6631                    }
6632                    else {
6633                            return list.get(0);
6634                    }
6635            }
6636    
6637            /**
6638             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
6639             *
6640             * <p>
6641             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6642             * </p>
6643             *
6644             * @param id the primary key of the current journal article
6645             * @param groupId the group ID
6646             * @param templateId the template ID
6647             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6648             * @return the previous, current, and next journal article
6649             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6650             * @throws SystemException if a system exception occurred
6651             */
6652            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
6653                    String templateId, OrderByComparator orderByComparator)
6654                    throws NoSuchArticleException, SystemException {
6655                    JournalArticle journalArticle = findByPrimaryKey(id);
6656    
6657                    Session session = null;
6658    
6659                    try {
6660                            session = openSession();
6661    
6662                            JournalArticle[] array = new JournalArticleImpl[3];
6663    
6664                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
6665                                            templateId, orderByComparator, true);
6666    
6667                            array[1] = journalArticle;
6668    
6669                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
6670                                            templateId, orderByComparator, false);
6671    
6672                            return array;
6673                    }
6674                    catch (Exception e) {
6675                            throw processException(e);
6676                    }
6677                    finally {
6678                            closeSession(session);
6679                    }
6680            }
6681    
6682            protected JournalArticle getByG_T_PrevAndNext(Session session,
6683                    JournalArticle journalArticle, long groupId, String templateId,
6684                    OrderByComparator orderByComparator, boolean previous) {
6685                    StringBundler query = null;
6686    
6687                    if (orderByComparator != null) {
6688                            query = new StringBundler(6 +
6689                                            (orderByComparator.getOrderByFields().length * 6));
6690                    }
6691                    else {
6692                            query = new StringBundler(3);
6693                    }
6694    
6695                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6696    
6697                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
6698    
6699                    if (templateId == null) {
6700                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
6701                    }
6702                    else {
6703                            if (templateId.equals(StringPool.BLANK)) {
6704                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
6705                            }
6706                            else {
6707                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
6708                            }
6709                    }
6710    
6711                    if (orderByComparator != null) {
6712                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6713    
6714                            if (orderByConditionFields.length > 0) {
6715                                    query.append(WHERE_AND);
6716                            }
6717    
6718                            for (int i = 0; i < orderByConditionFields.length; i++) {
6719                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6720                                    query.append(orderByConditionFields[i]);
6721    
6722                                    if ((i + 1) < orderByConditionFields.length) {
6723                                            if (orderByComparator.isAscending() ^ previous) {
6724                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6725                                            }
6726                                            else {
6727                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6728                                            }
6729                                    }
6730                                    else {
6731                                            if (orderByComparator.isAscending() ^ previous) {
6732                                                    query.append(WHERE_GREATER_THAN);
6733                                            }
6734                                            else {
6735                                                    query.append(WHERE_LESSER_THAN);
6736                                            }
6737                                    }
6738                            }
6739    
6740                            query.append(ORDER_BY_CLAUSE);
6741    
6742                            String[] orderByFields = orderByComparator.getOrderByFields();
6743    
6744                            for (int i = 0; i < orderByFields.length; i++) {
6745                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6746                                    query.append(orderByFields[i]);
6747    
6748                                    if ((i + 1) < orderByFields.length) {
6749                                            if (orderByComparator.isAscending() ^ previous) {
6750                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6751                                            }
6752                                            else {
6753                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6754                                            }
6755                                    }
6756                                    else {
6757                                            if (orderByComparator.isAscending() ^ previous) {
6758                                                    query.append(ORDER_BY_ASC);
6759                                            }
6760                                            else {
6761                                                    query.append(ORDER_BY_DESC);
6762                                            }
6763                                    }
6764                            }
6765                    }
6766    
6767                    else {
6768                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6769                    }
6770    
6771                    String sql = query.toString();
6772    
6773                    Query q = session.createQuery(sql);
6774    
6775                    q.setFirstResult(0);
6776                    q.setMaxResults(2);
6777    
6778                    QueryPos qPos = QueryPos.getInstance(q);
6779    
6780                    qPos.add(groupId);
6781    
6782                    if (templateId != null) {
6783                            qPos.add(templateId);
6784                    }
6785    
6786                    if (orderByComparator != null) {
6787                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6788    
6789                            for (Object value : values) {
6790                                    qPos.add(value);
6791                            }
6792                    }
6793    
6794                    List<JournalArticle> list = q.list();
6795    
6796                    if (list.size() == 2) {
6797                            return list.get(1);
6798                    }
6799                    else {
6800                            return null;
6801                    }
6802            }
6803    
6804            /**
6805             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
6806             *
6807             * @param groupId the group ID
6808             * @param templateId the template ID
6809             * @return the matching journal articles that the user has permission to view
6810             * @throws SystemException if a system exception occurred
6811             */
6812            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
6813                    throws SystemException {
6814                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
6815                            QueryUtil.ALL_POS, null);
6816            }
6817    
6818            /**
6819             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
6820             *
6821             * <p>
6822             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6823             * </p>
6824             *
6825             * @param groupId the group ID
6826             * @param templateId the template ID
6827             * @param start the lower bound of the range of journal articles
6828             * @param end the upper bound of the range of journal articles (not inclusive)
6829             * @return the range of matching journal articles that the user has permission to view
6830             * @throws SystemException if a system exception occurred
6831             */
6832            public List<JournalArticle> filterFindByG_T(long groupId,
6833                    String templateId, int start, int end) throws SystemException {
6834                    return filterFindByG_T(groupId, templateId, start, end, null);
6835            }
6836    
6837            /**
6838             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
6839             *
6840             * <p>
6841             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6842             * </p>
6843             *
6844             * @param groupId the group ID
6845             * @param templateId the template ID
6846             * @param start the lower bound of the range of journal articles
6847             * @param end the upper bound of the range of journal articles (not inclusive)
6848             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6849             * @return the ordered range of matching journal articles that the user has permission to view
6850             * @throws SystemException if a system exception occurred
6851             */
6852            public List<JournalArticle> filterFindByG_T(long groupId,
6853                    String templateId, int start, int end,
6854                    OrderByComparator orderByComparator) throws SystemException {
6855                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6856                            return findByG_T(groupId, templateId, start, end, orderByComparator);
6857                    }
6858    
6859                    StringBundler query = null;
6860    
6861                    if (orderByComparator != null) {
6862                            query = new StringBundler(4 +
6863                                            (orderByComparator.getOrderByFields().length * 3));
6864                    }
6865                    else {
6866                            query = new StringBundler(4);
6867                    }
6868    
6869                    if (getDB().isSupportsInlineDistinct()) {
6870                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6871                    }
6872                    else {
6873                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6874                    }
6875    
6876                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
6877    
6878                    if (templateId == null) {
6879                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
6880                    }
6881                    else {
6882                            if (templateId.equals(StringPool.BLANK)) {
6883                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
6884                            }
6885                            else {
6886                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
6887                            }
6888                    }
6889    
6890                    if (!getDB().isSupportsInlineDistinct()) {
6891                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6892                    }
6893    
6894                    if (orderByComparator != null) {
6895                            if (getDB().isSupportsInlineDistinct()) {
6896                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6897                                            orderByComparator);
6898                            }
6899                            else {
6900                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6901                                            orderByComparator);
6902                            }
6903                    }
6904    
6905                    else {
6906                            if (getDB().isSupportsInlineDistinct()) {
6907                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6908                            }
6909                            else {
6910                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6911                            }
6912                    }
6913    
6914                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6915                                    JournalArticle.class.getName(),
6916                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6917    
6918                    Session session = null;
6919    
6920                    try {
6921                            session = openSession();
6922    
6923                            SQLQuery q = session.createSQLQuery(sql);
6924    
6925                            if (getDB().isSupportsInlineDistinct()) {
6926                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6927                            }
6928                            else {
6929                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6930                            }
6931    
6932                            QueryPos qPos = QueryPos.getInstance(q);
6933    
6934                            qPos.add(groupId);
6935    
6936                            if (templateId != null) {
6937                                    qPos.add(templateId);
6938                            }
6939    
6940                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6941                                    end);
6942                    }
6943                    catch (Exception e) {
6944                            throw processException(e);
6945                    }
6946                    finally {
6947                            closeSession(session);
6948                    }
6949            }
6950    
6951            /**
6952             * 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;.
6953             *
6954             * @param id the primary key of the current journal article
6955             * @param groupId the group ID
6956             * @param templateId the template ID
6957             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6958             * @return the previous, current, and next journal article
6959             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6960             * @throws SystemException if a system exception occurred
6961             */
6962            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
6963                    String templateId, OrderByComparator orderByComparator)
6964                    throws NoSuchArticleException, SystemException {
6965                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6966                            return findByG_T_PrevAndNext(id, groupId, templateId,
6967                                    orderByComparator);
6968                    }
6969    
6970                    JournalArticle journalArticle = findByPrimaryKey(id);
6971    
6972                    Session session = null;
6973    
6974                    try {
6975                            session = openSession();
6976    
6977                            JournalArticle[] array = new JournalArticleImpl[3];
6978    
6979                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
6980                                            groupId, templateId, orderByComparator, true);
6981    
6982                            array[1] = journalArticle;
6983    
6984                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
6985                                            groupId, templateId, orderByComparator, false);
6986    
6987                            return array;
6988                    }
6989                    catch (Exception e) {
6990                            throw processException(e);
6991                    }
6992                    finally {
6993                            closeSession(session);
6994                    }
6995            }
6996    
6997            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
6998                    JournalArticle journalArticle, long groupId, String templateId,
6999                    OrderByComparator orderByComparator, boolean previous) {
7000                    StringBundler query = null;
7001    
7002                    if (orderByComparator != null) {
7003                            query = new StringBundler(6 +
7004                                            (orderByComparator.getOrderByFields().length * 6));
7005                    }
7006                    else {
7007                            query = new StringBundler(3);
7008                    }
7009    
7010                    if (getDB().isSupportsInlineDistinct()) {
7011                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7012                    }
7013                    else {
7014                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7015                    }
7016    
7017                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
7018    
7019                    if (templateId == null) {
7020                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
7021                    }
7022                    else {
7023                            if (templateId.equals(StringPool.BLANK)) {
7024                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
7025                            }
7026                            else {
7027                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
7028                            }
7029                    }
7030    
7031                    if (!getDB().isSupportsInlineDistinct()) {
7032                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7033                    }
7034    
7035                    if (orderByComparator != null) {
7036                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7037    
7038                            if (orderByConditionFields.length > 0) {
7039                                    query.append(WHERE_AND);
7040                            }
7041    
7042                            for (int i = 0; i < orderByConditionFields.length; i++) {
7043                                    if (getDB().isSupportsInlineDistinct()) {
7044                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7045                                    }
7046                                    else {
7047                                            query.append(_ORDER_BY_ENTITY_TABLE);
7048                                    }
7049    
7050                                    query.append(orderByConditionFields[i]);
7051    
7052                                    if ((i + 1) < orderByConditionFields.length) {
7053                                            if (orderByComparator.isAscending() ^ previous) {
7054                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7055                                            }
7056                                            else {
7057                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7058                                            }
7059                                    }
7060                                    else {
7061                                            if (orderByComparator.isAscending() ^ previous) {
7062                                                    query.append(WHERE_GREATER_THAN);
7063                                            }
7064                                            else {
7065                                                    query.append(WHERE_LESSER_THAN);
7066                                            }
7067                                    }
7068                            }
7069    
7070                            query.append(ORDER_BY_CLAUSE);
7071    
7072                            String[] orderByFields = orderByComparator.getOrderByFields();
7073    
7074                            for (int i = 0; i < orderByFields.length; i++) {
7075                                    if (getDB().isSupportsInlineDistinct()) {
7076                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7077                                    }
7078                                    else {
7079                                            query.append(_ORDER_BY_ENTITY_TABLE);
7080                                    }
7081    
7082                                    query.append(orderByFields[i]);
7083    
7084                                    if ((i + 1) < orderByFields.length) {
7085                                            if (orderByComparator.isAscending() ^ previous) {
7086                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7087                                            }
7088                                            else {
7089                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7090                                            }
7091                                    }
7092                                    else {
7093                                            if (orderByComparator.isAscending() ^ previous) {
7094                                                    query.append(ORDER_BY_ASC);
7095                                            }
7096                                            else {
7097                                                    query.append(ORDER_BY_DESC);
7098                                            }
7099                                    }
7100                            }
7101                    }
7102    
7103                    else {
7104                            if (getDB().isSupportsInlineDistinct()) {
7105                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7106                            }
7107                            else {
7108                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7109                            }
7110                    }
7111    
7112                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7113                                    JournalArticle.class.getName(),
7114                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7115    
7116                    SQLQuery q = session.createSQLQuery(sql);
7117    
7118                    q.setFirstResult(0);
7119                    q.setMaxResults(2);
7120    
7121                    if (getDB().isSupportsInlineDistinct()) {
7122                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7123                    }
7124                    else {
7125                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7126                    }
7127    
7128                    QueryPos qPos = QueryPos.getInstance(q);
7129    
7130                    qPos.add(groupId);
7131    
7132                    if (templateId != null) {
7133                            qPos.add(templateId);
7134                    }
7135    
7136                    if (orderByComparator != null) {
7137                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7138    
7139                            for (Object value : values) {
7140                                    qPos.add(value);
7141                            }
7142                    }
7143    
7144                    List<JournalArticle> list = q.list();
7145    
7146                    if (list.size() == 2) {
7147                            return list.get(1);
7148                    }
7149                    else {
7150                            return null;
7151                    }
7152            }
7153    
7154            /**
7155             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
7156             *
7157             * @param groupId the group ID
7158             * @param layoutUuid the layout uuid
7159             * @return the matching journal articles
7160             * @throws SystemException if a system exception occurred
7161             */
7162            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
7163                    throws SystemException {
7164                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
7165                            QueryUtil.ALL_POS, null);
7166            }
7167    
7168            /**
7169             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
7170             *
7171             * <p>
7172             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7173             * </p>
7174             *
7175             * @param groupId the group ID
7176             * @param layoutUuid the layout uuid
7177             * @param start the lower bound of the range of journal articles
7178             * @param end the upper bound of the range of journal articles (not inclusive)
7179             * @return the range of matching journal articles
7180             * @throws SystemException if a system exception occurred
7181             */
7182            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
7183                    int start, int end) throws SystemException {
7184                    return findByG_L(groupId, layoutUuid, start, end, null);
7185            }
7186    
7187            /**
7188             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
7189             *
7190             * <p>
7191             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7192             * </p>
7193             *
7194             * @param groupId the group ID
7195             * @param layoutUuid the layout uuid
7196             * @param start the lower bound of the range of journal articles
7197             * @param end the upper bound of the range of journal articles (not inclusive)
7198             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7199             * @return the ordered range of matching journal articles
7200             * @throws SystemException if a system exception occurred
7201             */
7202            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
7203                    int start, int end, OrderByComparator orderByComparator)
7204                    throws SystemException {
7205                    FinderPath finderPath = null;
7206                    Object[] finderArgs = null;
7207    
7208                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7209                                    (orderByComparator == null)) {
7210                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
7211                            finderArgs = new Object[] { groupId, layoutUuid };
7212                    }
7213                    else {
7214                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
7215                            finderArgs = new Object[] {
7216                                            groupId, layoutUuid,
7217                                            
7218                                            start, end, orderByComparator
7219                                    };
7220                    }
7221    
7222                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7223                                    finderArgs, this);
7224    
7225                    if (list == null) {
7226                            StringBundler query = null;
7227    
7228                            if (orderByComparator != null) {
7229                                    query = new StringBundler(4 +
7230                                                    (orderByComparator.getOrderByFields().length * 3));
7231                            }
7232                            else {
7233                                    query = new StringBundler(4);
7234                            }
7235    
7236                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7237    
7238                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
7239    
7240                            if (layoutUuid == null) {
7241                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
7242                            }
7243                            else {
7244                                    if (layoutUuid.equals(StringPool.BLANK)) {
7245                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
7246                                    }
7247                                    else {
7248                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
7249                                    }
7250                            }
7251    
7252                            if (orderByComparator != null) {
7253                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7254                                            orderByComparator);
7255                            }
7256    
7257                            else {
7258                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7259                            }
7260    
7261                            String sql = query.toString();
7262    
7263                            Session session = null;
7264    
7265                            try {
7266                                    session = openSession();
7267    
7268                                    Query q = session.createQuery(sql);
7269    
7270                                    QueryPos qPos = QueryPos.getInstance(q);
7271    
7272                                    qPos.add(groupId);
7273    
7274                                    if (layoutUuid != null) {
7275                                            qPos.add(layoutUuid);
7276                                    }
7277    
7278                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
7279                                                    start, end);
7280                            }
7281                            catch (Exception e) {
7282                                    throw processException(e);
7283                            }
7284                            finally {
7285                                    if (list == null) {
7286                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7287                                    }
7288                                    else {
7289                                            cacheResult(list);
7290    
7291                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7292                                    }
7293    
7294                                    closeSession(session);
7295                            }
7296                    }
7297    
7298                    return list;
7299            }
7300    
7301            /**
7302             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
7303             *
7304             * <p>
7305             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7306             * </p>
7307             *
7308             * @param groupId the group ID
7309             * @param layoutUuid the layout uuid
7310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7311             * @return the first matching journal article
7312             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7313             * @throws SystemException if a system exception occurred
7314             */
7315            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
7316                    OrderByComparator orderByComparator)
7317                    throws NoSuchArticleException, SystemException {
7318                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
7319                                    orderByComparator);
7320    
7321                    if (list.isEmpty()) {
7322                            StringBundler msg = new StringBundler(6);
7323    
7324                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7325    
7326                            msg.append("groupId=");
7327                            msg.append(groupId);
7328    
7329                            msg.append(", layoutUuid=");
7330                            msg.append(layoutUuid);
7331    
7332                            msg.append(StringPool.CLOSE_CURLY_BRACE);
7333    
7334                            throw new NoSuchArticleException(msg.toString());
7335                    }
7336                    else {
7337                            return list.get(0);
7338                    }
7339            }
7340    
7341            /**
7342             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
7343             *
7344             * <p>
7345             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7346             * </p>
7347             *
7348             * @param groupId the group ID
7349             * @param layoutUuid the layout uuid
7350             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7351             * @return the last matching journal article
7352             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7353             * @throws SystemException if a system exception occurred
7354             */
7355            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
7356                    OrderByComparator orderByComparator)
7357                    throws NoSuchArticleException, SystemException {
7358                    int count = countByG_L(groupId, layoutUuid);
7359    
7360                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
7361                                    count, orderByComparator);
7362    
7363                    if (list.isEmpty()) {
7364                            StringBundler msg = new StringBundler(6);
7365    
7366                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7367    
7368                            msg.append("groupId=");
7369                            msg.append(groupId);
7370    
7371                            msg.append(", layoutUuid=");
7372                            msg.append(layoutUuid);
7373    
7374                            msg.append(StringPool.CLOSE_CURLY_BRACE);
7375    
7376                            throw new NoSuchArticleException(msg.toString());
7377                    }
7378                    else {
7379                            return list.get(0);
7380                    }
7381            }
7382    
7383            /**
7384             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
7385             *
7386             * <p>
7387             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7388             * </p>
7389             *
7390             * @param id the primary key of the current journal article
7391             * @param groupId the group ID
7392             * @param layoutUuid the layout uuid
7393             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7394             * @return the previous, current, and next journal article
7395             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7396             * @throws SystemException if a system exception occurred
7397             */
7398            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
7399                    String layoutUuid, OrderByComparator orderByComparator)
7400                    throws NoSuchArticleException, SystemException {
7401                    JournalArticle journalArticle = findByPrimaryKey(id);
7402    
7403                    Session session = null;
7404    
7405                    try {
7406                            session = openSession();
7407    
7408                            JournalArticle[] array = new JournalArticleImpl[3];
7409    
7410                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
7411                                            layoutUuid, orderByComparator, true);
7412    
7413                            array[1] = journalArticle;
7414    
7415                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
7416                                            layoutUuid, orderByComparator, false);
7417    
7418                            return array;
7419                    }
7420                    catch (Exception e) {
7421                            throw processException(e);
7422                    }
7423                    finally {
7424                            closeSession(session);
7425                    }
7426            }
7427    
7428            protected JournalArticle getByG_L_PrevAndNext(Session session,
7429                    JournalArticle journalArticle, long groupId, String layoutUuid,
7430                    OrderByComparator orderByComparator, boolean previous) {
7431                    StringBundler query = null;
7432    
7433                    if (orderByComparator != null) {
7434                            query = new StringBundler(6 +
7435                                            (orderByComparator.getOrderByFields().length * 6));
7436                    }
7437                    else {
7438                            query = new StringBundler(3);
7439                    }
7440    
7441                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7442    
7443                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
7444    
7445                    if (layoutUuid == null) {
7446                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
7447                    }
7448                    else {
7449                            if (layoutUuid.equals(StringPool.BLANK)) {
7450                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
7451                            }
7452                            else {
7453                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
7454                            }
7455                    }
7456    
7457                    if (orderByComparator != null) {
7458                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7459    
7460                            if (orderByConditionFields.length > 0) {
7461                                    query.append(WHERE_AND);
7462                            }
7463    
7464                            for (int i = 0; i < orderByConditionFields.length; i++) {
7465                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7466                                    query.append(orderByConditionFields[i]);
7467    
7468                                    if ((i + 1) < orderByConditionFields.length) {
7469                                            if (orderByComparator.isAscending() ^ previous) {
7470                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7471                                            }
7472                                            else {
7473                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7474                                            }
7475                                    }
7476                                    else {
7477                                            if (orderByComparator.isAscending() ^ previous) {
7478                                                    query.append(WHERE_GREATER_THAN);
7479                                            }
7480                                            else {
7481                                                    query.append(WHERE_LESSER_THAN);
7482                                            }
7483                                    }
7484                            }
7485    
7486                            query.append(ORDER_BY_CLAUSE);
7487    
7488                            String[] orderByFields = orderByComparator.getOrderByFields();
7489    
7490                            for (int i = 0; i < orderByFields.length; i++) {
7491                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7492                                    query.append(orderByFields[i]);
7493    
7494                                    if ((i + 1) < orderByFields.length) {
7495                                            if (orderByComparator.isAscending() ^ previous) {
7496                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7497                                            }
7498                                            else {
7499                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7500                                            }
7501                                    }
7502                                    else {
7503                                            if (orderByComparator.isAscending() ^ previous) {
7504                                                    query.append(ORDER_BY_ASC);
7505                                            }
7506                                            else {
7507                                                    query.append(ORDER_BY_DESC);
7508                                            }
7509                                    }
7510                            }
7511                    }
7512    
7513                    else {
7514                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7515                    }
7516    
7517                    String sql = query.toString();
7518    
7519                    Query q = session.createQuery(sql);
7520    
7521                    q.setFirstResult(0);
7522                    q.setMaxResults(2);
7523    
7524                    QueryPos qPos = QueryPos.getInstance(q);
7525    
7526                    qPos.add(groupId);
7527    
7528                    if (layoutUuid != null) {
7529                            qPos.add(layoutUuid);
7530                    }
7531    
7532                    if (orderByComparator != null) {
7533                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7534    
7535                            for (Object value : values) {
7536                                    qPos.add(value);
7537                            }
7538                    }
7539    
7540                    List<JournalArticle> list = q.list();
7541    
7542                    if (list.size() == 2) {
7543                            return list.get(1);
7544                    }
7545                    else {
7546                            return null;
7547                    }
7548            }
7549    
7550            /**
7551             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
7552             *
7553             * @param groupId the group ID
7554             * @param layoutUuid the layout uuid
7555             * @return the matching journal articles that the user has permission to view
7556             * @throws SystemException if a system exception occurred
7557             */
7558            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
7559                    throws SystemException {
7560                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
7561                            QueryUtil.ALL_POS, null);
7562            }
7563    
7564            /**
7565             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
7566             *
7567             * <p>
7568             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7569             * </p>
7570             *
7571             * @param groupId the group ID
7572             * @param layoutUuid the layout uuid
7573             * @param start the lower bound of the range of journal articles
7574             * @param end the upper bound of the range of journal articles (not inclusive)
7575             * @return the range of matching journal articles that the user has permission to view
7576             * @throws SystemException if a system exception occurred
7577             */
7578            public List<JournalArticle> filterFindByG_L(long groupId,
7579                    String layoutUuid, int start, int end) throws SystemException {
7580                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
7581            }
7582    
7583            /**
7584             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
7585             *
7586             * <p>
7587             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7588             * </p>
7589             *
7590             * @param groupId the group ID
7591             * @param layoutUuid the layout uuid
7592             * @param start the lower bound of the range of journal articles
7593             * @param end the upper bound of the range of journal articles (not inclusive)
7594             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7595             * @return the ordered range of matching journal articles that the user has permission to view
7596             * @throws SystemException if a system exception occurred
7597             */
7598            public List<JournalArticle> filterFindByG_L(long groupId,
7599                    String layoutUuid, int start, int end,
7600                    OrderByComparator orderByComparator) throws SystemException {
7601                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7602                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
7603                    }
7604    
7605                    StringBundler query = null;
7606    
7607                    if (orderByComparator != null) {
7608                            query = new StringBundler(4 +
7609                                            (orderByComparator.getOrderByFields().length * 3));
7610                    }
7611                    else {
7612                            query = new StringBundler(4);
7613                    }
7614    
7615                    if (getDB().isSupportsInlineDistinct()) {
7616                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7617                    }
7618                    else {
7619                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7620                    }
7621    
7622                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
7623    
7624                    if (layoutUuid == null) {
7625                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
7626                    }
7627                    else {
7628                            if (layoutUuid.equals(StringPool.BLANK)) {
7629                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
7630                            }
7631                            else {
7632                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
7633                            }
7634                    }
7635    
7636                    if (!getDB().isSupportsInlineDistinct()) {
7637                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7638                    }
7639    
7640                    if (orderByComparator != null) {
7641                            if (getDB().isSupportsInlineDistinct()) {
7642                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7643                                            orderByComparator);
7644                            }
7645                            else {
7646                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7647                                            orderByComparator);
7648                            }
7649                    }
7650    
7651                    else {
7652                            if (getDB().isSupportsInlineDistinct()) {
7653                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7654                            }
7655                            else {
7656                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7657                            }
7658                    }
7659    
7660                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7661                                    JournalArticle.class.getName(),
7662                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7663    
7664                    Session session = null;
7665    
7666                    try {
7667                            session = openSession();
7668    
7669                            SQLQuery q = session.createSQLQuery(sql);
7670    
7671                            if (getDB().isSupportsInlineDistinct()) {
7672                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7673                            }
7674                            else {
7675                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7676                            }
7677    
7678                            QueryPos qPos = QueryPos.getInstance(q);
7679    
7680                            qPos.add(groupId);
7681    
7682                            if (layoutUuid != null) {
7683                                    qPos.add(layoutUuid);
7684                            }
7685    
7686                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7687                                    end);
7688                    }
7689                    catch (Exception e) {
7690                            throw processException(e);
7691                    }
7692                    finally {
7693                            closeSession(session);
7694                    }
7695            }
7696    
7697            /**
7698             * 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;.
7699             *
7700             * @param id the primary key of the current journal article
7701             * @param groupId the group ID
7702             * @param layoutUuid the layout uuid
7703             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7704             * @return the previous, current, and next journal article
7705             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7706             * @throws SystemException if a system exception occurred
7707             */
7708            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
7709                    String layoutUuid, OrderByComparator orderByComparator)
7710                    throws NoSuchArticleException, SystemException {
7711                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7712                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
7713                                    orderByComparator);
7714                    }
7715    
7716                    JournalArticle journalArticle = findByPrimaryKey(id);
7717    
7718                    Session session = null;
7719    
7720                    try {
7721                            session = openSession();
7722    
7723                            JournalArticle[] array = new JournalArticleImpl[3];
7724    
7725                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
7726                                            groupId, layoutUuid, orderByComparator, true);
7727    
7728                            array[1] = journalArticle;
7729    
7730                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
7731                                            groupId, layoutUuid, orderByComparator, false);
7732    
7733                            return array;
7734                    }
7735                    catch (Exception e) {
7736                            throw processException(e);
7737                    }
7738                    finally {
7739                            closeSession(session);
7740                    }
7741            }
7742    
7743            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
7744                    JournalArticle journalArticle, long groupId, String layoutUuid,
7745                    OrderByComparator orderByComparator, boolean previous) {
7746                    StringBundler query = null;
7747    
7748                    if (orderByComparator != null) {
7749                            query = new StringBundler(6 +
7750                                            (orderByComparator.getOrderByFields().length * 6));
7751                    }
7752                    else {
7753                            query = new StringBundler(3);
7754                    }
7755    
7756                    if (getDB().isSupportsInlineDistinct()) {
7757                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7758                    }
7759                    else {
7760                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7761                    }
7762    
7763                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
7764    
7765                    if (layoutUuid == null) {
7766                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
7767                    }
7768                    else {
7769                            if (layoutUuid.equals(StringPool.BLANK)) {
7770                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
7771                            }
7772                            else {
7773                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
7774                            }
7775                    }
7776    
7777                    if (!getDB().isSupportsInlineDistinct()) {
7778                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7779                    }
7780    
7781                    if (orderByComparator != null) {
7782                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7783    
7784                            if (orderByConditionFields.length > 0) {
7785                                    query.append(WHERE_AND);
7786                            }
7787    
7788                            for (int i = 0; i < orderByConditionFields.length; i++) {
7789                                    if (getDB().isSupportsInlineDistinct()) {
7790                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7791                                    }
7792                                    else {
7793                                            query.append(_ORDER_BY_ENTITY_TABLE);
7794                                    }
7795    
7796                                    query.append(orderByConditionFields[i]);
7797    
7798                                    if ((i + 1) < orderByConditionFields.length) {
7799                                            if (orderByComparator.isAscending() ^ previous) {
7800                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7801                                            }
7802                                            else {
7803                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7804                                            }
7805                                    }
7806                                    else {
7807                                            if (orderByComparator.isAscending() ^ previous) {
7808                                                    query.append(WHERE_GREATER_THAN);
7809                                            }
7810                                            else {
7811                                                    query.append(WHERE_LESSER_THAN);
7812                                            }
7813                                    }
7814                            }
7815    
7816                            query.append(ORDER_BY_CLAUSE);
7817    
7818                            String[] orderByFields = orderByComparator.getOrderByFields();
7819    
7820                            for (int i = 0; i < orderByFields.length; i++) {
7821                                    if (getDB().isSupportsInlineDistinct()) {
7822                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7823                                    }
7824                                    else {
7825                                            query.append(_ORDER_BY_ENTITY_TABLE);
7826                                    }
7827    
7828                                    query.append(orderByFields[i]);
7829    
7830                                    if ((i + 1) < orderByFields.length) {
7831                                            if (orderByComparator.isAscending() ^ previous) {
7832                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7833                                            }
7834                                            else {
7835                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7836                                            }
7837                                    }
7838                                    else {
7839                                            if (orderByComparator.isAscending() ^ previous) {
7840                                                    query.append(ORDER_BY_ASC);
7841                                            }
7842                                            else {
7843                                                    query.append(ORDER_BY_DESC);
7844                                            }
7845                                    }
7846                            }
7847                    }
7848    
7849                    else {
7850                            if (getDB().isSupportsInlineDistinct()) {
7851                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7852                            }
7853                            else {
7854                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7855                            }
7856                    }
7857    
7858                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7859                                    JournalArticle.class.getName(),
7860                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7861    
7862                    SQLQuery q = session.createSQLQuery(sql);
7863    
7864                    q.setFirstResult(0);
7865                    q.setMaxResults(2);
7866    
7867                    if (getDB().isSupportsInlineDistinct()) {
7868                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7869                    }
7870                    else {
7871                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7872                    }
7873    
7874                    QueryPos qPos = QueryPos.getInstance(q);
7875    
7876                    qPos.add(groupId);
7877    
7878                    if (layoutUuid != null) {
7879                            qPos.add(layoutUuid);
7880                    }
7881    
7882                    if (orderByComparator != null) {
7883                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7884    
7885                            for (Object value : values) {
7886                                    qPos.add(value);
7887                            }
7888                    }
7889    
7890                    List<JournalArticle> list = q.list();
7891    
7892                    if (list.size() == 2) {
7893                            return list.get(1);
7894                    }
7895                    else {
7896                            return null;
7897                    }
7898            }
7899    
7900            /**
7901             * Returns all the journal articles where groupId = &#63; and status = &#63;.
7902             *
7903             * @param groupId the group ID
7904             * @param status the status
7905             * @return the matching journal articles
7906             * @throws SystemException if a system exception occurred
7907             */
7908            public List<JournalArticle> findByG_ST(long groupId, int status)
7909                    throws SystemException {
7910                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
7911                            QueryUtil.ALL_POS, null);
7912            }
7913    
7914            /**
7915             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
7916             *
7917             * <p>
7918             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7919             * </p>
7920             *
7921             * @param groupId the group ID
7922             * @param status the status
7923             * @param start the lower bound of the range of journal articles
7924             * @param end the upper bound of the range of journal articles (not inclusive)
7925             * @return the range of matching journal articles
7926             * @throws SystemException if a system exception occurred
7927             */
7928            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
7929                    int end) throws SystemException {
7930                    return findByG_ST(groupId, status, start, end, null);
7931            }
7932    
7933            /**
7934             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
7935             *
7936             * <p>
7937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7938             * </p>
7939             *
7940             * @param groupId the group ID
7941             * @param status the status
7942             * @param start the lower bound of the range of journal articles
7943             * @param end the upper bound of the range of journal articles (not inclusive)
7944             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7945             * @return the ordered range of matching journal articles
7946             * @throws SystemException if a system exception occurred
7947             */
7948            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
7949                    int end, OrderByComparator orderByComparator) throws SystemException {
7950                    FinderPath finderPath = null;
7951                    Object[] finderArgs = null;
7952    
7953                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7954                                    (orderByComparator == null)) {
7955                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
7956                            finderArgs = new Object[] { groupId, status };
7957                    }
7958                    else {
7959                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
7960                            finderArgs = new Object[] {
7961                                            groupId, status,
7962                                            
7963                                            start, end, orderByComparator
7964                                    };
7965                    }
7966    
7967                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7968                                    finderArgs, this);
7969    
7970                    if (list == null) {
7971                            StringBundler query = null;
7972    
7973                            if (orderByComparator != null) {
7974                                    query = new StringBundler(4 +
7975                                                    (orderByComparator.getOrderByFields().length * 3));
7976                            }
7977                            else {
7978                                    query = new StringBundler(4);
7979                            }
7980    
7981                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7982    
7983                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
7984    
7985                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
7986    
7987                            if (orderByComparator != null) {
7988                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7989                                            orderByComparator);
7990                            }
7991    
7992                            else {
7993                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7994                            }
7995    
7996                            String sql = query.toString();
7997    
7998                            Session session = null;
7999    
8000                            try {
8001                                    session = openSession();
8002    
8003                                    Query q = session.createQuery(sql);
8004    
8005                                    QueryPos qPos = QueryPos.getInstance(q);
8006    
8007                                    qPos.add(groupId);
8008    
8009                                    qPos.add(status);
8010    
8011                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
8012                                                    start, end);
8013                            }
8014                            catch (Exception e) {
8015                                    throw processException(e);
8016                            }
8017                            finally {
8018                                    if (list == null) {
8019                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8020                                    }
8021                                    else {
8022                                            cacheResult(list);
8023    
8024                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8025                                    }
8026    
8027                                    closeSession(session);
8028                            }
8029                    }
8030    
8031                    return list;
8032            }
8033    
8034            /**
8035             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
8036             *
8037             * <p>
8038             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8039             * </p>
8040             *
8041             * @param groupId the group ID
8042             * @param status the status
8043             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8044             * @return the first matching journal article
8045             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8046             * @throws SystemException if a system exception occurred
8047             */
8048            public JournalArticle findByG_ST_First(long groupId, int status,
8049                    OrderByComparator orderByComparator)
8050                    throws NoSuchArticleException, SystemException {
8051                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
8052                                    orderByComparator);
8053    
8054                    if (list.isEmpty()) {
8055                            StringBundler msg = new StringBundler(6);
8056    
8057                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8058    
8059                            msg.append("groupId=");
8060                            msg.append(groupId);
8061    
8062                            msg.append(", status=");
8063                            msg.append(status);
8064    
8065                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8066    
8067                            throw new NoSuchArticleException(msg.toString());
8068                    }
8069                    else {
8070                            return list.get(0);
8071                    }
8072            }
8073    
8074            /**
8075             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
8076             *
8077             * <p>
8078             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8079             * </p>
8080             *
8081             * @param groupId the group ID
8082             * @param status the status
8083             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8084             * @return the last matching journal article
8085             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8086             * @throws SystemException if a system exception occurred
8087             */
8088            public JournalArticle findByG_ST_Last(long groupId, int status,
8089                    OrderByComparator orderByComparator)
8090                    throws NoSuchArticleException, SystemException {
8091                    int count = countByG_ST(groupId, status);
8092    
8093                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
8094                                    count, orderByComparator);
8095    
8096                    if (list.isEmpty()) {
8097                            StringBundler msg = new StringBundler(6);
8098    
8099                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8100    
8101                            msg.append("groupId=");
8102                            msg.append(groupId);
8103    
8104                            msg.append(", status=");
8105                            msg.append(status);
8106    
8107                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8108    
8109                            throw new NoSuchArticleException(msg.toString());
8110                    }
8111                    else {
8112                            return list.get(0);
8113                    }
8114            }
8115    
8116            /**
8117             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
8118             *
8119             * <p>
8120             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8121             * </p>
8122             *
8123             * @param id the primary key of the current journal article
8124             * @param groupId the group ID
8125             * @param status the status
8126             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8127             * @return the previous, current, and next journal article
8128             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8129             * @throws SystemException if a system exception occurred
8130             */
8131            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
8132                    int status, OrderByComparator orderByComparator)
8133                    throws NoSuchArticleException, SystemException {
8134                    JournalArticle journalArticle = findByPrimaryKey(id);
8135    
8136                    Session session = null;
8137    
8138                    try {
8139                            session = openSession();
8140    
8141                            JournalArticle[] array = new JournalArticleImpl[3];
8142    
8143                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
8144                                            status, orderByComparator, true);
8145    
8146                            array[1] = journalArticle;
8147    
8148                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
8149                                            status, orderByComparator, false);
8150    
8151                            return array;
8152                    }
8153                    catch (Exception e) {
8154                            throw processException(e);
8155                    }
8156                    finally {
8157                            closeSession(session);
8158                    }
8159            }
8160    
8161            protected JournalArticle getByG_ST_PrevAndNext(Session session,
8162                    JournalArticle journalArticle, long groupId, int status,
8163                    OrderByComparator orderByComparator, boolean previous) {
8164                    StringBundler query = null;
8165    
8166                    if (orderByComparator != null) {
8167                            query = new StringBundler(6 +
8168                                            (orderByComparator.getOrderByFields().length * 6));
8169                    }
8170                    else {
8171                            query = new StringBundler(3);
8172                    }
8173    
8174                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8175    
8176                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
8177    
8178                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
8179    
8180                    if (orderByComparator != null) {
8181                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8182    
8183                            if (orderByConditionFields.length > 0) {
8184                                    query.append(WHERE_AND);
8185                            }
8186    
8187                            for (int i = 0; i < orderByConditionFields.length; i++) {
8188                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8189                                    query.append(orderByConditionFields[i]);
8190    
8191                                    if ((i + 1) < orderByConditionFields.length) {
8192                                            if (orderByComparator.isAscending() ^ previous) {
8193                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8194                                            }
8195                                            else {
8196                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8197                                            }
8198                                    }
8199                                    else {
8200                                            if (orderByComparator.isAscending() ^ previous) {
8201                                                    query.append(WHERE_GREATER_THAN);
8202                                            }
8203                                            else {
8204                                                    query.append(WHERE_LESSER_THAN);
8205                                            }
8206                                    }
8207                            }
8208    
8209                            query.append(ORDER_BY_CLAUSE);
8210    
8211                            String[] orderByFields = orderByComparator.getOrderByFields();
8212    
8213                            for (int i = 0; i < orderByFields.length; i++) {
8214                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8215                                    query.append(orderByFields[i]);
8216    
8217                                    if ((i + 1) < orderByFields.length) {
8218                                            if (orderByComparator.isAscending() ^ previous) {
8219                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8220                                            }
8221                                            else {
8222                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8223                                            }
8224                                    }
8225                                    else {
8226                                            if (orderByComparator.isAscending() ^ previous) {
8227                                                    query.append(ORDER_BY_ASC);
8228                                            }
8229                                            else {
8230                                                    query.append(ORDER_BY_DESC);
8231                                            }
8232                                    }
8233                            }
8234                    }
8235    
8236                    else {
8237                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8238                    }
8239    
8240                    String sql = query.toString();
8241    
8242                    Query q = session.createQuery(sql);
8243    
8244                    q.setFirstResult(0);
8245                    q.setMaxResults(2);
8246    
8247                    QueryPos qPos = QueryPos.getInstance(q);
8248    
8249                    qPos.add(groupId);
8250    
8251                    qPos.add(status);
8252    
8253                    if (orderByComparator != null) {
8254                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8255    
8256                            for (Object value : values) {
8257                                    qPos.add(value);
8258                            }
8259                    }
8260    
8261                    List<JournalArticle> list = q.list();
8262    
8263                    if (list.size() == 2) {
8264                            return list.get(1);
8265                    }
8266                    else {
8267                            return null;
8268                    }
8269            }
8270    
8271            /**
8272             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
8273             *
8274             * @param groupId the group ID
8275             * @param status the status
8276             * @return the matching journal articles that the user has permission to view
8277             * @throws SystemException if a system exception occurred
8278             */
8279            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
8280                    throws SystemException {
8281                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
8282                            QueryUtil.ALL_POS, null);
8283            }
8284    
8285            /**
8286             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
8287             *
8288             * <p>
8289             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8290             * </p>
8291             *
8292             * @param groupId the group ID
8293             * @param status the status
8294             * @param start the lower bound of the range of journal articles
8295             * @param end the upper bound of the range of journal articles (not inclusive)
8296             * @return the range of matching journal articles that the user has permission to view
8297             * @throws SystemException if a system exception occurred
8298             */
8299            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
8300                    int start, int end) throws SystemException {
8301                    return filterFindByG_ST(groupId, status, start, end, null);
8302            }
8303    
8304            /**
8305             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
8306             *
8307             * <p>
8308             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8309             * </p>
8310             *
8311             * @param groupId the group ID
8312             * @param status the status
8313             * @param start the lower bound of the range of journal articles
8314             * @param end the upper bound of the range of journal articles (not inclusive)
8315             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8316             * @return the ordered range of matching journal articles that the user has permission to view
8317             * @throws SystemException if a system exception occurred
8318             */
8319            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
8320                    int start, int end, OrderByComparator orderByComparator)
8321                    throws SystemException {
8322                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8323                            return findByG_ST(groupId, status, start, end, orderByComparator);
8324                    }
8325    
8326                    StringBundler query = null;
8327    
8328                    if (orderByComparator != null) {
8329                            query = new StringBundler(4 +
8330                                            (orderByComparator.getOrderByFields().length * 3));
8331                    }
8332                    else {
8333                            query = new StringBundler(4);
8334                    }
8335    
8336                    if (getDB().isSupportsInlineDistinct()) {
8337                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8338                    }
8339                    else {
8340                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8341                    }
8342    
8343                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
8344    
8345                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
8346    
8347                    if (!getDB().isSupportsInlineDistinct()) {
8348                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8349                    }
8350    
8351                    if (orderByComparator != null) {
8352                            if (getDB().isSupportsInlineDistinct()) {
8353                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8354                                            orderByComparator);
8355                            }
8356                            else {
8357                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8358                                            orderByComparator);
8359                            }
8360                    }
8361    
8362                    else {
8363                            if (getDB().isSupportsInlineDistinct()) {
8364                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8365                            }
8366                            else {
8367                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8368                            }
8369                    }
8370    
8371                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8372                                    JournalArticle.class.getName(),
8373                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8374    
8375                    Session session = null;
8376    
8377                    try {
8378                            session = openSession();
8379    
8380                            SQLQuery q = session.createSQLQuery(sql);
8381    
8382                            if (getDB().isSupportsInlineDistinct()) {
8383                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8384                            }
8385                            else {
8386                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8387                            }
8388    
8389                            QueryPos qPos = QueryPos.getInstance(q);
8390    
8391                            qPos.add(groupId);
8392    
8393                            qPos.add(status);
8394    
8395                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8396                                    end);
8397                    }
8398                    catch (Exception e) {
8399                            throw processException(e);
8400                    }
8401                    finally {
8402                            closeSession(session);
8403                    }
8404            }
8405    
8406            /**
8407             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
8408             *
8409             * @param id the primary key of the current journal article
8410             * @param groupId the group ID
8411             * @param status the status
8412             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8413             * @return the previous, current, and next journal article
8414             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8415             * @throws SystemException if a system exception occurred
8416             */
8417            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
8418                    int status, OrderByComparator orderByComparator)
8419                    throws NoSuchArticleException, SystemException {
8420                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8421                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
8422                    }
8423    
8424                    JournalArticle journalArticle = findByPrimaryKey(id);
8425    
8426                    Session session = null;
8427    
8428                    try {
8429                            session = openSession();
8430    
8431                            JournalArticle[] array = new JournalArticleImpl[3];
8432    
8433                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
8434                                            groupId, status, orderByComparator, true);
8435    
8436                            array[1] = journalArticle;
8437    
8438                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
8439                                            groupId, status, orderByComparator, false);
8440    
8441                            return array;
8442                    }
8443                    catch (Exception e) {
8444                            throw processException(e);
8445                    }
8446                    finally {
8447                            closeSession(session);
8448                    }
8449            }
8450    
8451            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
8452                    JournalArticle journalArticle, long groupId, int status,
8453                    OrderByComparator orderByComparator, boolean previous) {
8454                    StringBundler query = null;
8455    
8456                    if (orderByComparator != null) {
8457                            query = new StringBundler(6 +
8458                                            (orderByComparator.getOrderByFields().length * 6));
8459                    }
8460                    else {
8461                            query = new StringBundler(3);
8462                    }
8463    
8464                    if (getDB().isSupportsInlineDistinct()) {
8465                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8466                    }
8467                    else {
8468                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8469                    }
8470    
8471                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
8472    
8473                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
8474    
8475                    if (!getDB().isSupportsInlineDistinct()) {
8476                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8477                    }
8478    
8479                    if (orderByComparator != null) {
8480                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8481    
8482                            if (orderByConditionFields.length > 0) {
8483                                    query.append(WHERE_AND);
8484                            }
8485    
8486                            for (int i = 0; i < orderByConditionFields.length; i++) {
8487                                    if (getDB().isSupportsInlineDistinct()) {
8488                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8489                                    }
8490                                    else {
8491                                            query.append(_ORDER_BY_ENTITY_TABLE);
8492                                    }
8493    
8494                                    query.append(orderByConditionFields[i]);
8495    
8496                                    if ((i + 1) < orderByConditionFields.length) {
8497                                            if (orderByComparator.isAscending() ^ previous) {
8498                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8499                                            }
8500                                            else {
8501                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8502                                            }
8503                                    }
8504                                    else {
8505                                            if (orderByComparator.isAscending() ^ previous) {
8506                                                    query.append(WHERE_GREATER_THAN);
8507                                            }
8508                                            else {
8509                                                    query.append(WHERE_LESSER_THAN);
8510                                            }
8511                                    }
8512                            }
8513    
8514                            query.append(ORDER_BY_CLAUSE);
8515    
8516                            String[] orderByFields = orderByComparator.getOrderByFields();
8517    
8518                            for (int i = 0; i < orderByFields.length; i++) {
8519                                    if (getDB().isSupportsInlineDistinct()) {
8520                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8521                                    }
8522                                    else {
8523                                            query.append(_ORDER_BY_ENTITY_TABLE);
8524                                    }
8525    
8526                                    query.append(orderByFields[i]);
8527    
8528                                    if ((i + 1) < orderByFields.length) {
8529                                            if (orderByComparator.isAscending() ^ previous) {
8530                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8531                                            }
8532                                            else {
8533                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8534                                            }
8535                                    }
8536                                    else {
8537                                            if (orderByComparator.isAscending() ^ previous) {
8538                                                    query.append(ORDER_BY_ASC);
8539                                            }
8540                                            else {
8541                                                    query.append(ORDER_BY_DESC);
8542                                            }
8543                                    }
8544                            }
8545                    }
8546    
8547                    else {
8548                            if (getDB().isSupportsInlineDistinct()) {
8549                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8550                            }
8551                            else {
8552                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8553                            }
8554                    }
8555    
8556                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8557                                    JournalArticle.class.getName(),
8558                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8559    
8560                    SQLQuery q = session.createSQLQuery(sql);
8561    
8562                    q.setFirstResult(0);
8563                    q.setMaxResults(2);
8564    
8565                    if (getDB().isSupportsInlineDistinct()) {
8566                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8567                    }
8568                    else {
8569                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8570                    }
8571    
8572                    QueryPos qPos = QueryPos.getInstance(q);
8573    
8574                    qPos.add(groupId);
8575    
8576                    qPos.add(status);
8577    
8578                    if (orderByComparator != null) {
8579                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8580    
8581                            for (Object value : values) {
8582                                    qPos.add(value);
8583                            }
8584                    }
8585    
8586                    List<JournalArticle> list = q.list();
8587    
8588                    if (list.size() == 2) {
8589                            return list.get(1);
8590                    }
8591                    else {
8592                            return null;
8593                    }
8594            }
8595    
8596            /**
8597             * Returns all the journal articles where companyId = &#63; and version = &#63;.
8598             *
8599             * @param companyId the company ID
8600             * @param version the version
8601             * @return the matching journal articles
8602             * @throws SystemException if a system exception occurred
8603             */
8604            public List<JournalArticle> findByC_V(long companyId, double version)
8605                    throws SystemException {
8606                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
8607                            QueryUtil.ALL_POS, null);
8608            }
8609    
8610            /**
8611             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
8612             *
8613             * <p>
8614             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8615             * </p>
8616             *
8617             * @param companyId the company ID
8618             * @param version the version
8619             * @param start the lower bound of the range of journal articles
8620             * @param end the upper bound of the range of journal articles (not inclusive)
8621             * @return the range of matching journal articles
8622             * @throws SystemException if a system exception occurred
8623             */
8624            public List<JournalArticle> findByC_V(long companyId, double version,
8625                    int start, int end) throws SystemException {
8626                    return findByC_V(companyId, version, start, end, null);
8627            }
8628    
8629            /**
8630             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
8631             *
8632             * <p>
8633             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8634             * </p>
8635             *
8636             * @param companyId the company ID
8637             * @param version the version
8638             * @param start the lower bound of the range of journal articles
8639             * @param end the upper bound of the range of journal articles (not inclusive)
8640             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8641             * @return the ordered range of matching journal articles
8642             * @throws SystemException if a system exception occurred
8643             */
8644            public List<JournalArticle> findByC_V(long companyId, double version,
8645                    int start, int end, OrderByComparator orderByComparator)
8646                    throws SystemException {
8647                    FinderPath finderPath = null;
8648                    Object[] finderArgs = null;
8649    
8650                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8651                                    (orderByComparator == null)) {
8652                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
8653                            finderArgs = new Object[] { companyId, version };
8654                    }
8655                    else {
8656                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
8657                            finderArgs = new Object[] {
8658                                            companyId, version,
8659                                            
8660                                            start, end, orderByComparator
8661                                    };
8662                    }
8663    
8664                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8665                                    finderArgs, this);
8666    
8667                    if (list == null) {
8668                            StringBundler query = null;
8669    
8670                            if (orderByComparator != null) {
8671                                    query = new StringBundler(4 +
8672                                                    (orderByComparator.getOrderByFields().length * 3));
8673                            }
8674                            else {
8675                                    query = new StringBundler(4);
8676                            }
8677    
8678                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8679    
8680                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
8681    
8682                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
8683    
8684                            if (orderByComparator != null) {
8685                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8686                                            orderByComparator);
8687                            }
8688    
8689                            else {
8690                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8691                            }
8692    
8693                            String sql = query.toString();
8694    
8695                            Session session = null;
8696    
8697                            try {
8698                                    session = openSession();
8699    
8700                                    Query q = session.createQuery(sql);
8701    
8702                                    QueryPos qPos = QueryPos.getInstance(q);
8703    
8704                                    qPos.add(companyId);
8705    
8706                                    qPos.add(version);
8707    
8708                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
8709                                                    start, end);
8710                            }
8711                            catch (Exception e) {
8712                                    throw processException(e);
8713                            }
8714                            finally {
8715                                    if (list == null) {
8716                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8717                                    }
8718                                    else {
8719                                            cacheResult(list);
8720    
8721                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8722                                    }
8723    
8724                                    closeSession(session);
8725                            }
8726                    }
8727    
8728                    return list;
8729            }
8730    
8731            /**
8732             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
8733             *
8734             * <p>
8735             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8736             * </p>
8737             *
8738             * @param companyId the company ID
8739             * @param version the version
8740             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8741             * @return the first matching journal article
8742             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8743             * @throws SystemException if a system exception occurred
8744             */
8745            public JournalArticle findByC_V_First(long companyId, double version,
8746                    OrderByComparator orderByComparator)
8747                    throws NoSuchArticleException, SystemException {
8748                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
8749                                    orderByComparator);
8750    
8751                    if (list.isEmpty()) {
8752                            StringBundler msg = new StringBundler(6);
8753    
8754                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8755    
8756                            msg.append("companyId=");
8757                            msg.append(companyId);
8758    
8759                            msg.append(", version=");
8760                            msg.append(version);
8761    
8762                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8763    
8764                            throw new NoSuchArticleException(msg.toString());
8765                    }
8766                    else {
8767                            return list.get(0);
8768                    }
8769            }
8770    
8771            /**
8772             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
8773             *
8774             * <p>
8775             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8776             * </p>
8777             *
8778             * @param companyId the company ID
8779             * @param version the version
8780             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8781             * @return the last matching journal article
8782             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8783             * @throws SystemException if a system exception occurred
8784             */
8785            public JournalArticle findByC_V_Last(long companyId, double version,
8786                    OrderByComparator orderByComparator)
8787                    throws NoSuchArticleException, SystemException {
8788                    int count = countByC_V(companyId, version);
8789    
8790                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
8791                                    count, orderByComparator);
8792    
8793                    if (list.isEmpty()) {
8794                            StringBundler msg = new StringBundler(6);
8795    
8796                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8797    
8798                            msg.append("companyId=");
8799                            msg.append(companyId);
8800    
8801                            msg.append(", version=");
8802                            msg.append(version);
8803    
8804                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8805    
8806                            throw new NoSuchArticleException(msg.toString());
8807                    }
8808                    else {
8809                            return list.get(0);
8810                    }
8811            }
8812    
8813            /**
8814             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
8815             *
8816             * <p>
8817             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8818             * </p>
8819             *
8820             * @param id the primary key of the current journal article
8821             * @param companyId the company ID
8822             * @param version the version
8823             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8824             * @return the previous, current, and next journal article
8825             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8826             * @throws SystemException if a system exception occurred
8827             */
8828            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
8829                    double version, OrderByComparator orderByComparator)
8830                    throws NoSuchArticleException, SystemException {
8831                    JournalArticle journalArticle = findByPrimaryKey(id);
8832    
8833                    Session session = null;
8834    
8835                    try {
8836                            session = openSession();
8837    
8838                            JournalArticle[] array = new JournalArticleImpl[3];
8839    
8840                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
8841                                            version, orderByComparator, true);
8842    
8843                            array[1] = journalArticle;
8844    
8845                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
8846                                            version, orderByComparator, false);
8847    
8848                            return array;
8849                    }
8850                    catch (Exception e) {
8851                            throw processException(e);
8852                    }
8853                    finally {
8854                            closeSession(session);
8855                    }
8856            }
8857    
8858            protected JournalArticle getByC_V_PrevAndNext(Session session,
8859                    JournalArticle journalArticle, long companyId, double version,
8860                    OrderByComparator orderByComparator, boolean previous) {
8861                    StringBundler query = null;
8862    
8863                    if (orderByComparator != null) {
8864                            query = new StringBundler(6 +
8865                                            (orderByComparator.getOrderByFields().length * 6));
8866                    }
8867                    else {
8868                            query = new StringBundler(3);
8869                    }
8870    
8871                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8872    
8873                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
8874    
8875                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
8876    
8877                    if (orderByComparator != null) {
8878                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8879    
8880                            if (orderByConditionFields.length > 0) {
8881                                    query.append(WHERE_AND);
8882                            }
8883    
8884                            for (int i = 0; i < orderByConditionFields.length; i++) {
8885                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8886                                    query.append(orderByConditionFields[i]);
8887    
8888                                    if ((i + 1) < orderByConditionFields.length) {
8889                                            if (orderByComparator.isAscending() ^ previous) {
8890                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8891                                            }
8892                                            else {
8893                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8894                                            }
8895                                    }
8896                                    else {
8897                                            if (orderByComparator.isAscending() ^ previous) {
8898                                                    query.append(WHERE_GREATER_THAN);
8899                                            }
8900                                            else {
8901                                                    query.append(WHERE_LESSER_THAN);
8902                                            }
8903                                    }
8904                            }
8905    
8906                            query.append(ORDER_BY_CLAUSE);
8907    
8908                            String[] orderByFields = orderByComparator.getOrderByFields();
8909    
8910                            for (int i = 0; i < orderByFields.length; i++) {
8911                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8912                                    query.append(orderByFields[i]);
8913    
8914                                    if ((i + 1) < orderByFields.length) {
8915                                            if (orderByComparator.isAscending() ^ previous) {
8916                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8917                                            }
8918                                            else {
8919                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8920                                            }
8921                                    }
8922                                    else {
8923                                            if (orderByComparator.isAscending() ^ previous) {
8924                                                    query.append(ORDER_BY_ASC);
8925                                            }
8926                                            else {
8927                                                    query.append(ORDER_BY_DESC);
8928                                            }
8929                                    }
8930                            }
8931                    }
8932    
8933                    else {
8934                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8935                    }
8936    
8937                    String sql = query.toString();
8938    
8939                    Query q = session.createQuery(sql);
8940    
8941                    q.setFirstResult(0);
8942                    q.setMaxResults(2);
8943    
8944                    QueryPos qPos = QueryPos.getInstance(q);
8945    
8946                    qPos.add(companyId);
8947    
8948                    qPos.add(version);
8949    
8950                    if (orderByComparator != null) {
8951                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8952    
8953                            for (Object value : values) {
8954                                    qPos.add(value);
8955                            }
8956                    }
8957    
8958                    List<JournalArticle> list = q.list();
8959    
8960                    if (list.size() == 2) {
8961                            return list.get(1);
8962                    }
8963                    else {
8964                            return null;
8965                    }
8966            }
8967    
8968            /**
8969             * Returns all the journal articles where companyId = &#63; and status = &#63;.
8970             *
8971             * @param companyId the company ID
8972             * @param status the status
8973             * @return the matching journal articles
8974             * @throws SystemException if a system exception occurred
8975             */
8976            public List<JournalArticle> findByC_ST(long companyId, int status)
8977                    throws SystemException {
8978                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
8979                            QueryUtil.ALL_POS, null);
8980            }
8981    
8982            /**
8983             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
8984             *
8985             * <p>
8986             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8987             * </p>
8988             *
8989             * @param companyId the company ID
8990             * @param status the status
8991             * @param start the lower bound of the range of journal articles
8992             * @param end the upper bound of the range of journal articles (not inclusive)
8993             * @return the range of matching journal articles
8994             * @throws SystemException if a system exception occurred
8995             */
8996            public List<JournalArticle> findByC_ST(long companyId, int status,
8997                    int start, int end) throws SystemException {
8998                    return findByC_ST(companyId, status, start, end, null);
8999            }
9000    
9001            /**
9002             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
9003             *
9004             * <p>
9005             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9006             * </p>
9007             *
9008             * @param companyId the company ID
9009             * @param status the status
9010             * @param start the lower bound of the range of journal articles
9011             * @param end the upper bound of the range of journal articles (not inclusive)
9012             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9013             * @return the ordered range of matching journal articles
9014             * @throws SystemException if a system exception occurred
9015             */
9016            public List<JournalArticle> findByC_ST(long companyId, int status,
9017                    int start, int end, OrderByComparator orderByComparator)
9018                    throws SystemException {
9019                    FinderPath finderPath = null;
9020                    Object[] finderArgs = null;
9021    
9022                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9023                                    (orderByComparator == null)) {
9024                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
9025                            finderArgs = new Object[] { companyId, status };
9026                    }
9027                    else {
9028                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
9029                            finderArgs = new Object[] {
9030                                            companyId, status,
9031                                            
9032                                            start, end, orderByComparator
9033                                    };
9034                    }
9035    
9036                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9037                                    finderArgs, this);
9038    
9039                    if (list == null) {
9040                            StringBundler query = null;
9041    
9042                            if (orderByComparator != null) {
9043                                    query = new StringBundler(4 +
9044                                                    (orderByComparator.getOrderByFields().length * 3));
9045                            }
9046                            else {
9047                                    query = new StringBundler(4);
9048                            }
9049    
9050                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9051    
9052                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
9053    
9054                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
9055    
9056                            if (orderByComparator != null) {
9057                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9058                                            orderByComparator);
9059                            }
9060    
9061                            else {
9062                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9063                            }
9064    
9065                            String sql = query.toString();
9066    
9067                            Session session = null;
9068    
9069                            try {
9070                                    session = openSession();
9071    
9072                                    Query q = session.createQuery(sql);
9073    
9074                                    QueryPos qPos = QueryPos.getInstance(q);
9075    
9076                                    qPos.add(companyId);
9077    
9078                                    qPos.add(status);
9079    
9080                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
9081                                                    start, end);
9082                            }
9083                            catch (Exception e) {
9084                                    throw processException(e);
9085                            }
9086                            finally {
9087                                    if (list == null) {
9088                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9089                                    }
9090                                    else {
9091                                            cacheResult(list);
9092    
9093                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9094                                    }
9095    
9096                                    closeSession(session);
9097                            }
9098                    }
9099    
9100                    return list;
9101            }
9102    
9103            /**
9104             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
9105             *
9106             * <p>
9107             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9108             * </p>
9109             *
9110             * @param companyId the company ID
9111             * @param status the status
9112             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9113             * @return the first matching journal article
9114             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9115             * @throws SystemException if a system exception occurred
9116             */
9117            public JournalArticle findByC_ST_First(long companyId, int status,
9118                    OrderByComparator orderByComparator)
9119                    throws NoSuchArticleException, SystemException {
9120                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
9121                                    orderByComparator);
9122    
9123                    if (list.isEmpty()) {
9124                            StringBundler msg = new StringBundler(6);
9125    
9126                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9127    
9128                            msg.append("companyId=");
9129                            msg.append(companyId);
9130    
9131                            msg.append(", status=");
9132                            msg.append(status);
9133    
9134                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9135    
9136                            throw new NoSuchArticleException(msg.toString());
9137                    }
9138                    else {
9139                            return list.get(0);
9140                    }
9141            }
9142    
9143            /**
9144             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
9145             *
9146             * <p>
9147             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9148             * </p>
9149             *
9150             * @param companyId the company ID
9151             * @param status the status
9152             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9153             * @return the last matching journal article
9154             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9155             * @throws SystemException if a system exception occurred
9156             */
9157            public JournalArticle findByC_ST_Last(long companyId, int status,
9158                    OrderByComparator orderByComparator)
9159                    throws NoSuchArticleException, SystemException {
9160                    int count = countByC_ST(companyId, status);
9161    
9162                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
9163                                    count, orderByComparator);
9164    
9165                    if (list.isEmpty()) {
9166                            StringBundler msg = new StringBundler(6);
9167    
9168                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9169    
9170                            msg.append("companyId=");
9171                            msg.append(companyId);
9172    
9173                            msg.append(", status=");
9174                            msg.append(status);
9175    
9176                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9177    
9178                            throw new NoSuchArticleException(msg.toString());
9179                    }
9180                    else {
9181                            return list.get(0);
9182                    }
9183            }
9184    
9185            /**
9186             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
9187             *
9188             * <p>
9189             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9190             * </p>
9191             *
9192             * @param id the primary key of the current journal article
9193             * @param companyId the company ID
9194             * @param status the status
9195             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9196             * @return the previous, current, and next journal article
9197             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9198             * @throws SystemException if a system exception occurred
9199             */
9200            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
9201                    int status, OrderByComparator orderByComparator)
9202                    throws NoSuchArticleException, SystemException {
9203                    JournalArticle journalArticle = findByPrimaryKey(id);
9204    
9205                    Session session = null;
9206    
9207                    try {
9208                            session = openSession();
9209    
9210                            JournalArticle[] array = new JournalArticleImpl[3];
9211    
9212                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
9213                                            companyId, status, orderByComparator, true);
9214    
9215                            array[1] = journalArticle;
9216    
9217                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
9218                                            companyId, status, orderByComparator, false);
9219    
9220                            return array;
9221                    }
9222                    catch (Exception e) {
9223                            throw processException(e);
9224                    }
9225                    finally {
9226                            closeSession(session);
9227                    }
9228            }
9229    
9230            protected JournalArticle getByC_ST_PrevAndNext(Session session,
9231                    JournalArticle journalArticle, long companyId, int status,
9232                    OrderByComparator orderByComparator, boolean previous) {
9233                    StringBundler query = null;
9234    
9235                    if (orderByComparator != null) {
9236                            query = new StringBundler(6 +
9237                                            (orderByComparator.getOrderByFields().length * 6));
9238                    }
9239                    else {
9240                            query = new StringBundler(3);
9241                    }
9242    
9243                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9244    
9245                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
9246    
9247                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
9248    
9249                    if (orderByComparator != null) {
9250                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9251    
9252                            if (orderByConditionFields.length > 0) {
9253                                    query.append(WHERE_AND);
9254                            }
9255    
9256                            for (int i = 0; i < orderByConditionFields.length; i++) {
9257                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9258                                    query.append(orderByConditionFields[i]);
9259    
9260                                    if ((i + 1) < orderByConditionFields.length) {
9261                                            if (orderByComparator.isAscending() ^ previous) {
9262                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9263                                            }
9264                                            else {
9265                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9266                                            }
9267                                    }
9268                                    else {
9269                                            if (orderByComparator.isAscending() ^ previous) {
9270                                                    query.append(WHERE_GREATER_THAN);
9271                                            }
9272                                            else {
9273                                                    query.append(WHERE_LESSER_THAN);
9274                                            }
9275                                    }
9276                            }
9277    
9278                            query.append(ORDER_BY_CLAUSE);
9279    
9280                            String[] orderByFields = orderByComparator.getOrderByFields();
9281    
9282                            for (int i = 0; i < orderByFields.length; i++) {
9283                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9284                                    query.append(orderByFields[i]);
9285    
9286                                    if ((i + 1) < orderByFields.length) {
9287                                            if (orderByComparator.isAscending() ^ previous) {
9288                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9289                                            }
9290                                            else {
9291                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9292                                            }
9293                                    }
9294                                    else {
9295                                            if (orderByComparator.isAscending() ^ previous) {
9296                                                    query.append(ORDER_BY_ASC);
9297                                            }
9298                                            else {
9299                                                    query.append(ORDER_BY_DESC);
9300                                            }
9301                                    }
9302                            }
9303                    }
9304    
9305                    else {
9306                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9307                    }
9308    
9309                    String sql = query.toString();
9310    
9311                    Query q = session.createQuery(sql);
9312    
9313                    q.setFirstResult(0);
9314                    q.setMaxResults(2);
9315    
9316                    QueryPos qPos = QueryPos.getInstance(q);
9317    
9318                    qPos.add(companyId);
9319    
9320                    qPos.add(status);
9321    
9322                    if (orderByComparator != null) {
9323                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9324    
9325                            for (Object value : values) {
9326                                    qPos.add(value);
9327                            }
9328                    }
9329    
9330                    List<JournalArticle> list = q.list();
9331    
9332                    if (list.size() == 2) {
9333                            return list.get(1);
9334                    }
9335                    else {
9336                            return null;
9337                    }
9338            }
9339    
9340            /**
9341             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9342             *
9343             * @param groupId the group ID
9344             * @param classNameId the class name ID
9345             * @param classPK the class p k
9346             * @return the matching journal articles
9347             * @throws SystemException if a system exception occurred
9348             */
9349            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
9350                    long classPK) throws SystemException {
9351                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
9352                            QueryUtil.ALL_POS, null);
9353            }
9354    
9355            /**
9356             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9357             *
9358             * <p>
9359             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9360             * </p>
9361             *
9362             * @param groupId the group ID
9363             * @param classNameId the class name ID
9364             * @param classPK the class p k
9365             * @param start the lower bound of the range of journal articles
9366             * @param end the upper bound of the range of journal articles (not inclusive)
9367             * @return the range of matching journal articles
9368             * @throws SystemException if a system exception occurred
9369             */
9370            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
9371                    long classPK, int start, int end) throws SystemException {
9372                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
9373            }
9374    
9375            /**
9376             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9377             *
9378             * <p>
9379             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9380             * </p>
9381             *
9382             * @param groupId the group ID
9383             * @param classNameId the class name ID
9384             * @param classPK the class p k
9385             * @param start the lower bound of the range of journal articles
9386             * @param end the upper bound of the range of journal articles (not inclusive)
9387             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9388             * @return the ordered range of matching journal articles
9389             * @throws SystemException if a system exception occurred
9390             */
9391            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
9392                    long classPK, int start, int end, OrderByComparator orderByComparator)
9393                    throws SystemException {
9394                    FinderPath finderPath = null;
9395                    Object[] finderArgs = null;
9396    
9397                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9398                                    (orderByComparator == null)) {
9399                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
9400                            finderArgs = new Object[] { groupId, classNameId, classPK };
9401                    }
9402                    else {
9403                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
9404                            finderArgs = new Object[] {
9405                                            groupId, classNameId, classPK,
9406                                            
9407                                            start, end, orderByComparator
9408                                    };
9409                    }
9410    
9411                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9412                                    finderArgs, this);
9413    
9414                    if (list == null) {
9415                            StringBundler query = null;
9416    
9417                            if (orderByComparator != null) {
9418                                    query = new StringBundler(5 +
9419                                                    (orderByComparator.getOrderByFields().length * 3));
9420                            }
9421                            else {
9422                                    query = new StringBundler(5);
9423                            }
9424    
9425                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9426    
9427                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
9428    
9429                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
9430    
9431                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
9432    
9433                            if (orderByComparator != null) {
9434                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9435                                            orderByComparator);
9436                            }
9437    
9438                            else {
9439                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9440                            }
9441    
9442                            String sql = query.toString();
9443    
9444                            Session session = null;
9445    
9446                            try {
9447                                    session = openSession();
9448    
9449                                    Query q = session.createQuery(sql);
9450    
9451                                    QueryPos qPos = QueryPos.getInstance(q);
9452    
9453                                    qPos.add(groupId);
9454    
9455                                    qPos.add(classNameId);
9456    
9457                                    qPos.add(classPK);
9458    
9459                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
9460                                                    start, end);
9461                            }
9462                            catch (Exception e) {
9463                                    throw processException(e);
9464                            }
9465                            finally {
9466                                    if (list == null) {
9467                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9468                                    }
9469                                    else {
9470                                            cacheResult(list);
9471    
9472                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9473                                    }
9474    
9475                                    closeSession(session);
9476                            }
9477                    }
9478    
9479                    return list;
9480            }
9481    
9482            /**
9483             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9484             *
9485             * <p>
9486             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9487             * </p>
9488             *
9489             * @param groupId the group ID
9490             * @param classNameId the class name ID
9491             * @param classPK the class p k
9492             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9493             * @return the first matching journal article
9494             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9495             * @throws SystemException if a system exception occurred
9496             */
9497            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
9498                    long classPK, OrderByComparator orderByComparator)
9499                    throws NoSuchArticleException, SystemException {
9500                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
9501                                    0, 1, orderByComparator);
9502    
9503                    if (list.isEmpty()) {
9504                            StringBundler msg = new StringBundler(8);
9505    
9506                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9507    
9508                            msg.append("groupId=");
9509                            msg.append(groupId);
9510    
9511                            msg.append(", classNameId=");
9512                            msg.append(classNameId);
9513    
9514                            msg.append(", classPK=");
9515                            msg.append(classPK);
9516    
9517                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9518    
9519                            throw new NoSuchArticleException(msg.toString());
9520                    }
9521                    else {
9522                            return list.get(0);
9523                    }
9524            }
9525    
9526            /**
9527             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9528             *
9529             * <p>
9530             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9531             * </p>
9532             *
9533             * @param groupId the group ID
9534             * @param classNameId the class name ID
9535             * @param classPK the class p k
9536             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9537             * @return the last matching journal article
9538             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9539             * @throws SystemException if a system exception occurred
9540             */
9541            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
9542                    long classPK, OrderByComparator orderByComparator)
9543                    throws NoSuchArticleException, SystemException {
9544                    int count = countByG_C_C(groupId, classNameId, classPK);
9545    
9546                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
9547                                    count - 1, count, orderByComparator);
9548    
9549                    if (list.isEmpty()) {
9550                            StringBundler msg = new StringBundler(8);
9551    
9552                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9553    
9554                            msg.append("groupId=");
9555                            msg.append(groupId);
9556    
9557                            msg.append(", classNameId=");
9558                            msg.append(classNameId);
9559    
9560                            msg.append(", classPK=");
9561                            msg.append(classPK);
9562    
9563                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9564    
9565                            throw new NoSuchArticleException(msg.toString());
9566                    }
9567                    else {
9568                            return list.get(0);
9569                    }
9570            }
9571    
9572            /**
9573             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9574             *
9575             * <p>
9576             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9577             * </p>
9578             *
9579             * @param id the primary key of the current journal article
9580             * @param groupId the group ID
9581             * @param classNameId the class name ID
9582             * @param classPK the class p k
9583             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9584             * @return the previous, current, and next journal article
9585             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9586             * @throws SystemException if a system exception occurred
9587             */
9588            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
9589                    long classNameId, long classPK, OrderByComparator orderByComparator)
9590                    throws NoSuchArticleException, SystemException {
9591                    JournalArticle journalArticle = findByPrimaryKey(id);
9592    
9593                    Session session = null;
9594    
9595                    try {
9596                            session = openSession();
9597    
9598                            JournalArticle[] array = new JournalArticleImpl[3];
9599    
9600                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
9601                                            classNameId, classPK, orderByComparator, true);
9602    
9603                            array[1] = journalArticle;
9604    
9605                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
9606                                            classNameId, classPK, orderByComparator, false);
9607    
9608                            return array;
9609                    }
9610                    catch (Exception e) {
9611                            throw processException(e);
9612                    }
9613                    finally {
9614                            closeSession(session);
9615                    }
9616            }
9617    
9618            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
9619                    JournalArticle journalArticle, long groupId, long classNameId,
9620                    long classPK, OrderByComparator orderByComparator, boolean previous) {
9621                    StringBundler query = null;
9622    
9623                    if (orderByComparator != null) {
9624                            query = new StringBundler(6 +
9625                                            (orderByComparator.getOrderByFields().length * 6));
9626                    }
9627                    else {
9628                            query = new StringBundler(3);
9629                    }
9630    
9631                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9632    
9633                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
9634    
9635                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
9636    
9637                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
9638    
9639                    if (orderByComparator != null) {
9640                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9641    
9642                            if (orderByConditionFields.length > 0) {
9643                                    query.append(WHERE_AND);
9644                            }
9645    
9646                            for (int i = 0; i < orderByConditionFields.length; i++) {
9647                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9648                                    query.append(orderByConditionFields[i]);
9649    
9650                                    if ((i + 1) < orderByConditionFields.length) {
9651                                            if (orderByComparator.isAscending() ^ previous) {
9652                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9653                                            }
9654                                            else {
9655                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9656                                            }
9657                                    }
9658                                    else {
9659                                            if (orderByComparator.isAscending() ^ previous) {
9660                                                    query.append(WHERE_GREATER_THAN);
9661                                            }
9662                                            else {
9663                                                    query.append(WHERE_LESSER_THAN);
9664                                            }
9665                                    }
9666                            }
9667    
9668                            query.append(ORDER_BY_CLAUSE);
9669    
9670                            String[] orderByFields = orderByComparator.getOrderByFields();
9671    
9672                            for (int i = 0; i < orderByFields.length; i++) {
9673                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9674                                    query.append(orderByFields[i]);
9675    
9676                                    if ((i + 1) < orderByFields.length) {
9677                                            if (orderByComparator.isAscending() ^ previous) {
9678                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9679                                            }
9680                                            else {
9681                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9682                                            }
9683                                    }
9684                                    else {
9685                                            if (orderByComparator.isAscending() ^ previous) {
9686                                                    query.append(ORDER_BY_ASC);
9687                                            }
9688                                            else {
9689                                                    query.append(ORDER_BY_DESC);
9690                                            }
9691                                    }
9692                            }
9693                    }
9694    
9695                    else {
9696                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9697                    }
9698    
9699                    String sql = query.toString();
9700    
9701                    Query q = session.createQuery(sql);
9702    
9703                    q.setFirstResult(0);
9704                    q.setMaxResults(2);
9705    
9706                    QueryPos qPos = QueryPos.getInstance(q);
9707    
9708                    qPos.add(groupId);
9709    
9710                    qPos.add(classNameId);
9711    
9712                    qPos.add(classPK);
9713    
9714                    if (orderByComparator != null) {
9715                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9716    
9717                            for (Object value : values) {
9718                                    qPos.add(value);
9719                            }
9720                    }
9721    
9722                    List<JournalArticle> list = q.list();
9723    
9724                    if (list.size() == 2) {
9725                            return list.get(1);
9726                    }
9727                    else {
9728                            return null;
9729                    }
9730            }
9731    
9732            /**
9733             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9734             *
9735             * @param groupId the group ID
9736             * @param classNameId the class name ID
9737             * @param classPK the class p k
9738             * @return the matching journal articles that the user has permission to view
9739             * @throws SystemException if a system exception occurred
9740             */
9741            public List<JournalArticle> filterFindByG_C_C(long groupId,
9742                    long classNameId, long classPK) throws SystemException {
9743                    return filterFindByG_C_C(groupId, classNameId, classPK,
9744                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9745            }
9746    
9747            /**
9748             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9749             *
9750             * <p>
9751             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9752             * </p>
9753             *
9754             * @param groupId the group ID
9755             * @param classNameId the class name ID
9756             * @param classPK the class p k
9757             * @param start the lower bound of the range of journal articles
9758             * @param end the upper bound of the range of journal articles (not inclusive)
9759             * @return the range of matching journal articles that the user has permission to view
9760             * @throws SystemException if a system exception occurred
9761             */
9762            public List<JournalArticle> filterFindByG_C_C(long groupId,
9763                    long classNameId, long classPK, int start, int end)
9764                    throws SystemException {
9765                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
9766            }
9767    
9768            /**
9769             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9770             *
9771             * <p>
9772             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9773             * </p>
9774             *
9775             * @param groupId the group ID
9776             * @param classNameId the class name ID
9777             * @param classPK the class p k
9778             * @param start the lower bound of the range of journal articles
9779             * @param end the upper bound of the range of journal articles (not inclusive)
9780             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9781             * @return the ordered range of matching journal articles that the user has permission to view
9782             * @throws SystemException if a system exception occurred
9783             */
9784            public List<JournalArticle> filterFindByG_C_C(long groupId,
9785                    long classNameId, long classPK, int start, int end,
9786                    OrderByComparator orderByComparator) throws SystemException {
9787                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9788                            return findByG_C_C(groupId, classNameId, classPK, start, end,
9789                                    orderByComparator);
9790                    }
9791    
9792                    StringBundler query = null;
9793    
9794                    if (orderByComparator != null) {
9795                            query = new StringBundler(5 +
9796                                            (orderByComparator.getOrderByFields().length * 3));
9797                    }
9798                    else {
9799                            query = new StringBundler(5);
9800                    }
9801    
9802                    if (getDB().isSupportsInlineDistinct()) {
9803                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9804                    }
9805                    else {
9806                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9807                    }
9808    
9809                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
9810    
9811                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
9812    
9813                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
9814    
9815                    if (!getDB().isSupportsInlineDistinct()) {
9816                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9817                    }
9818    
9819                    if (orderByComparator != null) {
9820                            if (getDB().isSupportsInlineDistinct()) {
9821                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9822                                            orderByComparator);
9823                            }
9824                            else {
9825                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9826                                            orderByComparator);
9827                            }
9828                    }
9829    
9830                    else {
9831                            if (getDB().isSupportsInlineDistinct()) {
9832                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9833                            }
9834                            else {
9835                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9836                            }
9837                    }
9838    
9839                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9840                                    JournalArticle.class.getName(),
9841                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9842    
9843                    Session session = null;
9844    
9845                    try {
9846                            session = openSession();
9847    
9848                            SQLQuery q = session.createSQLQuery(sql);
9849    
9850                            if (getDB().isSupportsInlineDistinct()) {
9851                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9852                            }
9853                            else {
9854                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9855                            }
9856    
9857                            QueryPos qPos = QueryPos.getInstance(q);
9858    
9859                            qPos.add(groupId);
9860    
9861                            qPos.add(classNameId);
9862    
9863                            qPos.add(classPK);
9864    
9865                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9866                                    end);
9867                    }
9868                    catch (Exception e) {
9869                            throw processException(e);
9870                    }
9871                    finally {
9872                            closeSession(session);
9873                    }
9874            }
9875    
9876            /**
9877             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9878             *
9879             * @param id the primary key of the current journal article
9880             * @param groupId the group ID
9881             * @param classNameId the class name ID
9882             * @param classPK the class p k
9883             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9884             * @return the previous, current, and next journal article
9885             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9886             * @throws SystemException if a system exception occurred
9887             */
9888            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
9889                    long groupId, long classNameId, long classPK,
9890                    OrderByComparator orderByComparator)
9891                    throws NoSuchArticleException, SystemException {
9892                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9893                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
9894                                    orderByComparator);
9895                    }
9896    
9897                    JournalArticle journalArticle = findByPrimaryKey(id);
9898    
9899                    Session session = null;
9900    
9901                    try {
9902                            session = openSession();
9903    
9904                            JournalArticle[] array = new JournalArticleImpl[3];
9905    
9906                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
9907                                            groupId, classNameId, classPK, orderByComparator, true);
9908    
9909                            array[1] = journalArticle;
9910    
9911                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
9912                                            groupId, classNameId, classPK, orderByComparator, false);
9913    
9914                            return array;
9915                    }
9916                    catch (Exception e) {
9917                            throw processException(e);
9918                    }
9919                    finally {
9920                            closeSession(session);
9921                    }
9922            }
9923    
9924            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
9925                    JournalArticle journalArticle, long groupId, long classNameId,
9926                    long classPK, OrderByComparator orderByComparator, boolean previous) {
9927                    StringBundler query = null;
9928    
9929                    if (orderByComparator != null) {
9930                            query = new StringBundler(6 +
9931                                            (orderByComparator.getOrderByFields().length * 6));
9932                    }
9933                    else {
9934                            query = new StringBundler(3);
9935                    }
9936    
9937                    if (getDB().isSupportsInlineDistinct()) {
9938                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9939                    }
9940                    else {
9941                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9942                    }
9943    
9944                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
9945    
9946                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
9947    
9948                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
9949    
9950                    if (!getDB().isSupportsInlineDistinct()) {
9951                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9952                    }
9953    
9954                    if (orderByComparator != null) {
9955                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9956    
9957                            if (orderByConditionFields.length > 0) {
9958                                    query.append(WHERE_AND);
9959                            }
9960    
9961                            for (int i = 0; i < orderByConditionFields.length; i++) {
9962                                    if (getDB().isSupportsInlineDistinct()) {
9963                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9964                                    }
9965                                    else {
9966                                            query.append(_ORDER_BY_ENTITY_TABLE);
9967                                    }
9968    
9969                                    query.append(orderByConditionFields[i]);
9970    
9971                                    if ((i + 1) < orderByConditionFields.length) {
9972                                            if (orderByComparator.isAscending() ^ previous) {
9973                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9974                                            }
9975                                            else {
9976                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9977                                            }
9978                                    }
9979                                    else {
9980                                            if (orderByComparator.isAscending() ^ previous) {
9981                                                    query.append(WHERE_GREATER_THAN);
9982                                            }
9983                                            else {
9984                                                    query.append(WHERE_LESSER_THAN);
9985                                            }
9986                                    }
9987                            }
9988    
9989                            query.append(ORDER_BY_CLAUSE);
9990    
9991                            String[] orderByFields = orderByComparator.getOrderByFields();
9992    
9993                            for (int i = 0; i < orderByFields.length; i++) {
9994                                    if (getDB().isSupportsInlineDistinct()) {
9995                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9996                                    }
9997                                    else {
9998                                            query.append(_ORDER_BY_ENTITY_TABLE);
9999                                    }
10000    
10001                                    query.append(orderByFields[i]);
10002    
10003                                    if ((i + 1) < orderByFields.length) {
10004                                            if (orderByComparator.isAscending() ^ previous) {
10005                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10006                                            }
10007                                            else {
10008                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10009                                            }
10010                                    }
10011                                    else {
10012                                            if (orderByComparator.isAscending() ^ previous) {
10013                                                    query.append(ORDER_BY_ASC);
10014                                            }
10015                                            else {
10016                                                    query.append(ORDER_BY_DESC);
10017                                            }
10018                                    }
10019                            }
10020                    }
10021    
10022                    else {
10023                            if (getDB().isSupportsInlineDistinct()) {
10024                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10025                            }
10026                            else {
10027                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10028                            }
10029                    }
10030    
10031                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10032                                    JournalArticle.class.getName(),
10033                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10034    
10035                    SQLQuery q = session.createSQLQuery(sql);
10036    
10037                    q.setFirstResult(0);
10038                    q.setMaxResults(2);
10039    
10040                    if (getDB().isSupportsInlineDistinct()) {
10041                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10042                    }
10043                    else {
10044                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10045                    }
10046    
10047                    QueryPos qPos = QueryPos.getInstance(q);
10048    
10049                    qPos.add(groupId);
10050    
10051                    qPos.add(classNameId);
10052    
10053                    qPos.add(classPK);
10054    
10055                    if (orderByComparator != null) {
10056                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10057    
10058                            for (Object value : values) {
10059                                    qPos.add(value);
10060                            }
10061                    }
10062    
10063                    List<JournalArticle> list = q.list();
10064    
10065                    if (list.size() == 2) {
10066                            return list.get(1);
10067                    }
10068                    else {
10069                            return null;
10070                    }
10071            }
10072    
10073            /**
10074             * Returns the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
10075             *
10076             * @param groupId the group ID
10077             * @param classNameId the class name ID
10078             * @param structureId the structure ID
10079             * @return the matching journal article
10080             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10081             * @throws SystemException if a system exception occurred
10082             */
10083            public JournalArticle findByG_C_S(long groupId, long classNameId,
10084                    String structureId) throws NoSuchArticleException, SystemException {
10085                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
10086                                    structureId);
10087    
10088                    if (journalArticle == null) {
10089                            StringBundler msg = new StringBundler(8);
10090    
10091                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10092    
10093                            msg.append("groupId=");
10094                            msg.append(groupId);
10095    
10096                            msg.append(", classNameId=");
10097                            msg.append(classNameId);
10098    
10099                            msg.append(", structureId=");
10100                            msg.append(structureId);
10101    
10102                            msg.append(StringPool.CLOSE_CURLY_BRACE);
10103    
10104                            if (_log.isWarnEnabled()) {
10105                                    _log.warn(msg.toString());
10106                            }
10107    
10108                            throw new NoSuchArticleException(msg.toString());
10109                    }
10110    
10111                    return journalArticle;
10112            }
10113    
10114            /**
10115             * Returns the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
10116             *
10117             * @param groupId the group ID
10118             * @param classNameId the class name ID
10119             * @param structureId the structure ID
10120             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
10121             * @throws SystemException if a system exception occurred
10122             */
10123            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
10124                    String structureId) throws SystemException {
10125                    return fetchByG_C_S(groupId, classNameId, structureId, true);
10126            }
10127    
10128            /**
10129             * Returns the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
10130             *
10131             * @param groupId the group ID
10132             * @param classNameId the class name ID
10133             * @param structureId the structure ID
10134             * @param retrieveFromCache whether to use the finder cache
10135             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
10136             * @throws SystemException if a system exception occurred
10137             */
10138            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
10139                    String structureId, boolean retrieveFromCache)
10140                    throws SystemException {
10141                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
10142    
10143                    Object result = null;
10144    
10145                    if (retrieveFromCache) {
10146                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
10147                                            finderArgs, this);
10148                    }
10149    
10150                    if (result == null) {
10151                            StringBundler query = new StringBundler(5);
10152    
10153                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10154    
10155                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
10156    
10157                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
10158    
10159                            if (structureId == null) {
10160                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
10161                            }
10162                            else {
10163                                    if (structureId.equals(StringPool.BLANK)) {
10164                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
10165                                    }
10166                                    else {
10167                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
10168                                    }
10169                            }
10170    
10171                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10172    
10173                            String sql = query.toString();
10174    
10175                            Session session = null;
10176    
10177                            try {
10178                                    session = openSession();
10179    
10180                                    Query q = session.createQuery(sql);
10181    
10182                                    QueryPos qPos = QueryPos.getInstance(q);
10183    
10184                                    qPos.add(groupId);
10185    
10186                                    qPos.add(classNameId);
10187    
10188                                    if (structureId != null) {
10189                                            qPos.add(structureId);
10190                                    }
10191    
10192                                    List<JournalArticle> list = q.list();
10193    
10194                                    result = list;
10195    
10196                                    JournalArticle journalArticle = null;
10197    
10198                                    if (list.isEmpty()) {
10199                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
10200                                                    finderArgs, list);
10201                                    }
10202                                    else {
10203                                            journalArticle = list.get(0);
10204    
10205                                            cacheResult(journalArticle);
10206    
10207                                            if ((journalArticle.getGroupId() != groupId) ||
10208                                                            (journalArticle.getClassNameId() != classNameId) ||
10209                                                            (journalArticle.getStructureId() == null) ||
10210                                                            !journalArticle.getStructureId().equals(structureId)) {
10211                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
10212                                                            finderArgs, journalArticle);
10213                                            }
10214                                    }
10215    
10216                                    return journalArticle;
10217                            }
10218                            catch (Exception e) {
10219                                    throw processException(e);
10220                            }
10221                            finally {
10222                                    if (result == null) {
10223                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
10224                                                    finderArgs);
10225                                    }
10226    
10227                                    closeSession(session);
10228                            }
10229                    }
10230                    else {
10231                            if (result instanceof List<?>) {
10232                                    return null;
10233                            }
10234                            else {
10235                                    return (JournalArticle)result;
10236                            }
10237                    }
10238            }
10239    
10240            /**
10241             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10242             *
10243             * @param groupId the group ID
10244             * @param classNameId the class name ID
10245             * @param templateId the template ID
10246             * @return the matching journal articles
10247             * @throws SystemException if a system exception occurred
10248             */
10249            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
10250                    String templateId) throws SystemException {
10251                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
10252                            QueryUtil.ALL_POS, null);
10253            }
10254    
10255            /**
10256             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10257             *
10258             * <p>
10259             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10260             * </p>
10261             *
10262             * @param groupId the group ID
10263             * @param classNameId the class name ID
10264             * @param templateId the template ID
10265             * @param start the lower bound of the range of journal articles
10266             * @param end the upper bound of the range of journal articles (not inclusive)
10267             * @return the range of matching journal articles
10268             * @throws SystemException if a system exception occurred
10269             */
10270            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
10271                    String templateId, int start, int end) throws SystemException {
10272                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
10273            }
10274    
10275            /**
10276             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10277             *
10278             * <p>
10279             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10280             * </p>
10281             *
10282             * @param groupId the group ID
10283             * @param classNameId the class name ID
10284             * @param templateId the template ID
10285             * @param start the lower bound of the range of journal articles
10286             * @param end the upper bound of the range of journal articles (not inclusive)
10287             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10288             * @return the ordered range of matching journal articles
10289             * @throws SystemException if a system exception occurred
10290             */
10291            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
10292                    String templateId, int start, int end,
10293                    OrderByComparator orderByComparator) throws SystemException {
10294                    FinderPath finderPath = null;
10295                    Object[] finderArgs = null;
10296    
10297                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10298                                    (orderByComparator == null)) {
10299                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
10300                            finderArgs = new Object[] { groupId, classNameId, templateId };
10301                    }
10302                    else {
10303                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
10304                            finderArgs = new Object[] {
10305                                            groupId, classNameId, templateId,
10306                                            
10307                                            start, end, orderByComparator
10308                                    };
10309                    }
10310    
10311                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10312                                    finderArgs, this);
10313    
10314                    if (list == null) {
10315                            StringBundler query = null;
10316    
10317                            if (orderByComparator != null) {
10318                                    query = new StringBundler(5 +
10319                                                    (orderByComparator.getOrderByFields().length * 3));
10320                            }
10321                            else {
10322                                    query = new StringBundler(5);
10323                            }
10324    
10325                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10326    
10327                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
10328    
10329                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
10330    
10331                            if (templateId == null) {
10332                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
10333                            }
10334                            else {
10335                                    if (templateId.equals(StringPool.BLANK)) {
10336                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
10337                                    }
10338                                    else {
10339                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
10340                                    }
10341                            }
10342    
10343                            if (orderByComparator != null) {
10344                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10345                                            orderByComparator);
10346                            }
10347    
10348                            else {
10349                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10350                            }
10351    
10352                            String sql = query.toString();
10353    
10354                            Session session = null;
10355    
10356                            try {
10357                                    session = openSession();
10358    
10359                                    Query q = session.createQuery(sql);
10360    
10361                                    QueryPos qPos = QueryPos.getInstance(q);
10362    
10363                                    qPos.add(groupId);
10364    
10365                                    qPos.add(classNameId);
10366    
10367                                    if (templateId != null) {
10368                                            qPos.add(templateId);
10369                                    }
10370    
10371                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
10372                                                    start, end);
10373                            }
10374                            catch (Exception e) {
10375                                    throw processException(e);
10376                            }
10377                            finally {
10378                                    if (list == null) {
10379                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
10380                                    }
10381                                    else {
10382                                            cacheResult(list);
10383    
10384                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
10385                                    }
10386    
10387                                    closeSession(session);
10388                            }
10389                    }
10390    
10391                    return list;
10392            }
10393    
10394            /**
10395             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10396             *
10397             * <p>
10398             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10399             * </p>
10400             *
10401             * @param groupId the group ID
10402             * @param classNameId the class name ID
10403             * @param templateId the template ID
10404             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10405             * @return the first matching journal article
10406             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10407             * @throws SystemException if a system exception occurred
10408             */
10409            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
10410                    String templateId, OrderByComparator orderByComparator)
10411                    throws NoSuchArticleException, SystemException {
10412                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
10413                                    templateId, 0, 1, orderByComparator);
10414    
10415                    if (list.isEmpty()) {
10416                            StringBundler msg = new StringBundler(8);
10417    
10418                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10419    
10420                            msg.append("groupId=");
10421                            msg.append(groupId);
10422    
10423                            msg.append(", classNameId=");
10424                            msg.append(classNameId);
10425    
10426                            msg.append(", templateId=");
10427                            msg.append(templateId);
10428    
10429                            msg.append(StringPool.CLOSE_CURLY_BRACE);
10430    
10431                            throw new NoSuchArticleException(msg.toString());
10432                    }
10433                    else {
10434                            return list.get(0);
10435                    }
10436            }
10437    
10438            /**
10439             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10440             *
10441             * <p>
10442             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10443             * </p>
10444             *
10445             * @param groupId the group ID
10446             * @param classNameId the class name ID
10447             * @param templateId the template ID
10448             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10449             * @return the last matching journal article
10450             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10451             * @throws SystemException if a system exception occurred
10452             */
10453            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
10454                    String templateId, OrderByComparator orderByComparator)
10455                    throws NoSuchArticleException, SystemException {
10456                    int count = countByG_C_T(groupId, classNameId, templateId);
10457    
10458                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
10459                                    templateId, count - 1, count, orderByComparator);
10460    
10461                    if (list.isEmpty()) {
10462                            StringBundler msg = new StringBundler(8);
10463    
10464                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10465    
10466                            msg.append("groupId=");
10467                            msg.append(groupId);
10468    
10469                            msg.append(", classNameId=");
10470                            msg.append(classNameId);
10471    
10472                            msg.append(", templateId=");
10473                            msg.append(templateId);
10474    
10475                            msg.append(StringPool.CLOSE_CURLY_BRACE);
10476    
10477                            throw new NoSuchArticleException(msg.toString());
10478                    }
10479                    else {
10480                            return list.get(0);
10481                    }
10482            }
10483    
10484            /**
10485             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10486             *
10487             * <p>
10488             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10489             * </p>
10490             *
10491             * @param id the primary key of the current journal article
10492             * @param groupId the group ID
10493             * @param classNameId the class name ID
10494             * @param templateId the template ID
10495             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10496             * @return the previous, current, and next journal article
10497             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10498             * @throws SystemException if a system exception occurred
10499             */
10500            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
10501                    long classNameId, String templateId, OrderByComparator orderByComparator)
10502                    throws NoSuchArticleException, SystemException {
10503                    JournalArticle journalArticle = findByPrimaryKey(id);
10504    
10505                    Session session = null;
10506    
10507                    try {
10508                            session = openSession();
10509    
10510                            JournalArticle[] array = new JournalArticleImpl[3];
10511    
10512                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
10513                                            classNameId, templateId, orderByComparator, true);
10514    
10515                            array[1] = journalArticle;
10516    
10517                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
10518                                            classNameId, templateId, orderByComparator, false);
10519    
10520                            return array;
10521                    }
10522                    catch (Exception e) {
10523                            throw processException(e);
10524                    }
10525                    finally {
10526                            closeSession(session);
10527                    }
10528            }
10529    
10530            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
10531                    JournalArticle journalArticle, long groupId, long classNameId,
10532                    String templateId, OrderByComparator orderByComparator, boolean previous) {
10533                    StringBundler query = null;
10534    
10535                    if (orderByComparator != null) {
10536                            query = new StringBundler(6 +
10537                                            (orderByComparator.getOrderByFields().length * 6));
10538                    }
10539                    else {
10540                            query = new StringBundler(3);
10541                    }
10542    
10543                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10544    
10545                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
10546    
10547                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
10548    
10549                    if (templateId == null) {
10550                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
10551                    }
10552                    else {
10553                            if (templateId.equals(StringPool.BLANK)) {
10554                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
10555                            }
10556                            else {
10557                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
10558                            }
10559                    }
10560    
10561                    if (orderByComparator != null) {
10562                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10563    
10564                            if (orderByConditionFields.length > 0) {
10565                                    query.append(WHERE_AND);
10566                            }
10567    
10568                            for (int i = 0; i < orderByConditionFields.length; i++) {
10569                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10570                                    query.append(orderByConditionFields[i]);
10571    
10572                                    if ((i + 1) < orderByConditionFields.length) {
10573                                            if (orderByComparator.isAscending() ^ previous) {
10574                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10575                                            }
10576                                            else {
10577                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10578                                            }
10579                                    }
10580                                    else {
10581                                            if (orderByComparator.isAscending() ^ previous) {
10582                                                    query.append(WHERE_GREATER_THAN);
10583                                            }
10584                                            else {
10585                                                    query.append(WHERE_LESSER_THAN);
10586                                            }
10587                                    }
10588                            }
10589    
10590                            query.append(ORDER_BY_CLAUSE);
10591    
10592                            String[] orderByFields = orderByComparator.getOrderByFields();
10593    
10594                            for (int i = 0; i < orderByFields.length; i++) {
10595                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10596                                    query.append(orderByFields[i]);
10597    
10598                                    if ((i + 1) < orderByFields.length) {
10599                                            if (orderByComparator.isAscending() ^ previous) {
10600                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10601                                            }
10602                                            else {
10603                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10604                                            }
10605                                    }
10606                                    else {
10607                                            if (orderByComparator.isAscending() ^ previous) {
10608                                                    query.append(ORDER_BY_ASC);
10609                                            }
10610                                            else {
10611                                                    query.append(ORDER_BY_DESC);
10612                                            }
10613                                    }
10614                            }
10615                    }
10616    
10617                    else {
10618                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10619                    }
10620    
10621                    String sql = query.toString();
10622    
10623                    Query q = session.createQuery(sql);
10624    
10625                    q.setFirstResult(0);
10626                    q.setMaxResults(2);
10627    
10628                    QueryPos qPos = QueryPos.getInstance(q);
10629    
10630                    qPos.add(groupId);
10631    
10632                    qPos.add(classNameId);
10633    
10634                    if (templateId != null) {
10635                            qPos.add(templateId);
10636                    }
10637    
10638                    if (orderByComparator != null) {
10639                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10640    
10641                            for (Object value : values) {
10642                                    qPos.add(value);
10643                            }
10644                    }
10645    
10646                    List<JournalArticle> list = q.list();
10647    
10648                    if (list.size() == 2) {
10649                            return list.get(1);
10650                    }
10651                    else {
10652                            return null;
10653                    }
10654            }
10655    
10656            /**
10657             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10658             *
10659             * @param groupId the group ID
10660             * @param classNameId the class name ID
10661             * @param templateId the template ID
10662             * @return the matching journal articles that the user has permission to view
10663             * @throws SystemException if a system exception occurred
10664             */
10665            public List<JournalArticle> filterFindByG_C_T(long groupId,
10666                    long classNameId, String templateId) throws SystemException {
10667                    return filterFindByG_C_T(groupId, classNameId, templateId,
10668                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10669            }
10670    
10671            /**
10672             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10673             *
10674             * <p>
10675             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10676             * </p>
10677             *
10678             * @param groupId the group ID
10679             * @param classNameId the class name ID
10680             * @param templateId the template ID
10681             * @param start the lower bound of the range of journal articles
10682             * @param end the upper bound of the range of journal articles (not inclusive)
10683             * @return the range of matching journal articles that the user has permission to view
10684             * @throws SystemException if a system exception occurred
10685             */
10686            public List<JournalArticle> filterFindByG_C_T(long groupId,
10687                    long classNameId, String templateId, int start, int end)
10688                    throws SystemException {
10689                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
10690                            null);
10691            }
10692    
10693            /**
10694             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10695             *
10696             * <p>
10697             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10698             * </p>
10699             *
10700             * @param groupId the group ID
10701             * @param classNameId the class name ID
10702             * @param templateId the template ID
10703             * @param start the lower bound of the range of journal articles
10704             * @param end the upper bound of the range of journal articles (not inclusive)
10705             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10706             * @return the ordered range of matching journal articles that the user has permission to view
10707             * @throws SystemException if a system exception occurred
10708             */
10709            public List<JournalArticle> filterFindByG_C_T(long groupId,
10710                    long classNameId, String templateId, int start, int end,
10711                    OrderByComparator orderByComparator) throws SystemException {
10712                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10713                            return findByG_C_T(groupId, classNameId, templateId, start, end,
10714                                    orderByComparator);
10715                    }
10716    
10717                    StringBundler query = null;
10718    
10719                    if (orderByComparator != null) {
10720                            query = new StringBundler(5 +
10721                                            (orderByComparator.getOrderByFields().length * 3));
10722                    }
10723                    else {
10724                            query = new StringBundler(5);
10725                    }
10726    
10727                    if (getDB().isSupportsInlineDistinct()) {
10728                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10729                    }
10730                    else {
10731                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10732                    }
10733    
10734                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
10735    
10736                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
10737    
10738                    if (templateId == null) {
10739                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
10740                    }
10741                    else {
10742                            if (templateId.equals(StringPool.BLANK)) {
10743                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
10744                            }
10745                            else {
10746                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
10747                            }
10748                    }
10749    
10750                    if (!getDB().isSupportsInlineDistinct()) {
10751                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10752                    }
10753    
10754                    if (orderByComparator != null) {
10755                            if (getDB().isSupportsInlineDistinct()) {
10756                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10757                                            orderByComparator);
10758                            }
10759                            else {
10760                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10761                                            orderByComparator);
10762                            }
10763                    }
10764    
10765                    else {
10766                            if (getDB().isSupportsInlineDistinct()) {
10767                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10768                            }
10769                            else {
10770                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10771                            }
10772                    }
10773    
10774                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10775                                    JournalArticle.class.getName(),
10776                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10777    
10778                    Session session = null;
10779    
10780                    try {
10781                            session = openSession();
10782    
10783                            SQLQuery q = session.createSQLQuery(sql);
10784    
10785                            if (getDB().isSupportsInlineDistinct()) {
10786                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10787                            }
10788                            else {
10789                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10790                            }
10791    
10792                            QueryPos qPos = QueryPos.getInstance(q);
10793    
10794                            qPos.add(groupId);
10795    
10796                            qPos.add(classNameId);
10797    
10798                            if (templateId != null) {
10799                                    qPos.add(templateId);
10800                            }
10801    
10802                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10803                                    end);
10804                    }
10805                    catch (Exception e) {
10806                            throw processException(e);
10807                    }
10808                    finally {
10809                            closeSession(session);
10810                    }
10811            }
10812    
10813            /**
10814             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10815             *
10816             * @param id the primary key of the current journal article
10817             * @param groupId the group ID
10818             * @param classNameId the class name ID
10819             * @param templateId the template ID
10820             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10821             * @return the previous, current, and next journal article
10822             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10823             * @throws SystemException if a system exception occurred
10824             */
10825            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
10826                    long groupId, long classNameId, String templateId,
10827                    OrderByComparator orderByComparator)
10828                    throws NoSuchArticleException, SystemException {
10829                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10830                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
10831                                    templateId, orderByComparator);
10832                    }
10833    
10834                    JournalArticle journalArticle = findByPrimaryKey(id);
10835    
10836                    Session session = null;
10837    
10838                    try {
10839                            session = openSession();
10840    
10841                            JournalArticle[] array = new JournalArticleImpl[3];
10842    
10843                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
10844                                            groupId, classNameId, templateId, orderByComparator, true);
10845    
10846                            array[1] = journalArticle;
10847    
10848                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
10849                                            groupId, classNameId, templateId, orderByComparator, false);
10850    
10851                            return array;
10852                    }
10853                    catch (Exception e) {
10854                            throw processException(e);
10855                    }
10856                    finally {
10857                            closeSession(session);
10858                    }
10859            }
10860    
10861            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
10862                    JournalArticle journalArticle, long groupId, long classNameId,
10863                    String templateId, OrderByComparator orderByComparator, boolean previous) {
10864                    StringBundler query = null;
10865    
10866                    if (orderByComparator != null) {
10867                            query = new StringBundler(6 +
10868                                            (orderByComparator.getOrderByFields().length * 6));
10869                    }
10870                    else {
10871                            query = new StringBundler(3);
10872                    }
10873    
10874                    if (getDB().isSupportsInlineDistinct()) {
10875                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10876                    }
10877                    else {
10878                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10879                    }
10880    
10881                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
10882    
10883                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
10884    
10885                    if (templateId == null) {
10886                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
10887                    }
10888                    else {
10889                            if (templateId.equals(StringPool.BLANK)) {
10890                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
10891                            }
10892                            else {
10893                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
10894                            }
10895                    }
10896    
10897                    if (!getDB().isSupportsInlineDistinct()) {
10898                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10899                    }
10900    
10901                    if (orderByComparator != null) {
10902                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10903    
10904                            if (orderByConditionFields.length > 0) {
10905                                    query.append(WHERE_AND);
10906                            }
10907    
10908                            for (int i = 0; i < orderByConditionFields.length; i++) {
10909                                    if (getDB().isSupportsInlineDistinct()) {
10910                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10911                                    }
10912                                    else {
10913                                            query.append(_ORDER_BY_ENTITY_TABLE);
10914                                    }
10915    
10916                                    query.append(orderByConditionFields[i]);
10917    
10918                                    if ((i + 1) < orderByConditionFields.length) {
10919                                            if (orderByComparator.isAscending() ^ previous) {
10920                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10921                                            }
10922                                            else {
10923                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10924                                            }
10925                                    }
10926                                    else {
10927                                            if (orderByComparator.isAscending() ^ previous) {
10928                                                    query.append(WHERE_GREATER_THAN);
10929                                            }
10930                                            else {
10931                                                    query.append(WHERE_LESSER_THAN);
10932                                            }
10933                                    }
10934                            }
10935    
10936                            query.append(ORDER_BY_CLAUSE);
10937    
10938                            String[] orderByFields = orderByComparator.getOrderByFields();
10939    
10940                            for (int i = 0; i < orderByFields.length; i++) {
10941                                    if (getDB().isSupportsInlineDistinct()) {
10942                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10943                                    }
10944                                    else {
10945                                            query.append(_ORDER_BY_ENTITY_TABLE);
10946                                    }
10947    
10948                                    query.append(orderByFields[i]);
10949    
10950                                    if ((i + 1) < orderByFields.length) {
10951                                            if (orderByComparator.isAscending() ^ previous) {
10952                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10953                                            }
10954                                            else {
10955                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10956                                            }
10957                                    }
10958                                    else {
10959                                            if (orderByComparator.isAscending() ^ previous) {
10960                                                    query.append(ORDER_BY_ASC);
10961                                            }
10962                                            else {
10963                                                    query.append(ORDER_BY_DESC);
10964                                            }
10965                                    }
10966                            }
10967                    }
10968    
10969                    else {
10970                            if (getDB().isSupportsInlineDistinct()) {
10971                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10972                            }
10973                            else {
10974                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10975                            }
10976                    }
10977    
10978                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10979                                    JournalArticle.class.getName(),
10980                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10981    
10982                    SQLQuery q = session.createSQLQuery(sql);
10983    
10984                    q.setFirstResult(0);
10985                    q.setMaxResults(2);
10986    
10987                    if (getDB().isSupportsInlineDistinct()) {
10988                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10989                    }
10990                    else {
10991                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10992                    }
10993    
10994                    QueryPos qPos = QueryPos.getInstance(q);
10995    
10996                    qPos.add(groupId);
10997    
10998                    qPos.add(classNameId);
10999    
11000                    if (templateId != null) {
11001                            qPos.add(templateId);
11002                    }
11003    
11004                    if (orderByComparator != null) {
11005                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11006    
11007                            for (Object value : values) {
11008                                    qPos.add(value);
11009                            }
11010                    }
11011    
11012                    List<JournalArticle> list = q.list();
11013    
11014                    if (list.size() == 2) {
11015                            return list.get(1);
11016                    }
11017                    else {
11018                            return null;
11019                    }
11020            }
11021    
11022            /**
11023             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11024             *
11025             * @param groupId the group ID
11026             * @param classNameId the class name ID
11027             * @param layoutUuid the layout uuid
11028             * @return the matching journal articles
11029             * @throws SystemException if a system exception occurred
11030             */
11031            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
11032                    String layoutUuid) throws SystemException {
11033                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
11034                            QueryUtil.ALL_POS, null);
11035            }
11036    
11037            /**
11038             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11039             *
11040             * <p>
11041             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11042             * </p>
11043             *
11044             * @param groupId the group ID
11045             * @param classNameId the class name ID
11046             * @param layoutUuid the layout uuid
11047             * @param start the lower bound of the range of journal articles
11048             * @param end the upper bound of the range of journal articles (not inclusive)
11049             * @return the range of matching journal articles
11050             * @throws SystemException if a system exception occurred
11051             */
11052            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
11053                    String layoutUuid, int start, int end) throws SystemException {
11054                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
11055            }
11056    
11057            /**
11058             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11059             *
11060             * <p>
11061             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11062             * </p>
11063             *
11064             * @param groupId the group ID
11065             * @param classNameId the class name ID
11066             * @param layoutUuid the layout uuid
11067             * @param start the lower bound of the range of journal articles
11068             * @param end the upper bound of the range of journal articles (not inclusive)
11069             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11070             * @return the ordered range of matching journal articles
11071             * @throws SystemException if a system exception occurred
11072             */
11073            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
11074                    String layoutUuid, int start, int end,
11075                    OrderByComparator orderByComparator) throws SystemException {
11076                    FinderPath finderPath = null;
11077                    Object[] finderArgs = null;
11078    
11079                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11080                                    (orderByComparator == null)) {
11081                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
11082                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
11083                    }
11084                    else {
11085                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
11086                            finderArgs = new Object[] {
11087                                            groupId, classNameId, layoutUuid,
11088                                            
11089                                            start, end, orderByComparator
11090                                    };
11091                    }
11092    
11093                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11094                                    finderArgs, this);
11095    
11096                    if (list == null) {
11097                            StringBundler query = null;
11098    
11099                            if (orderByComparator != null) {
11100                                    query = new StringBundler(5 +
11101                                                    (orderByComparator.getOrderByFields().length * 3));
11102                            }
11103                            else {
11104                                    query = new StringBundler(5);
11105                            }
11106    
11107                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11108    
11109                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
11110    
11111                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
11112    
11113                            if (layoutUuid == null) {
11114                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
11115                            }
11116                            else {
11117                                    if (layoutUuid.equals(StringPool.BLANK)) {
11118                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
11119                                    }
11120                                    else {
11121                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
11122                                    }
11123                            }
11124    
11125                            if (orderByComparator != null) {
11126                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11127                                            orderByComparator);
11128                            }
11129    
11130                            else {
11131                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11132                            }
11133    
11134                            String sql = query.toString();
11135    
11136                            Session session = null;
11137    
11138                            try {
11139                                    session = openSession();
11140    
11141                                    Query q = session.createQuery(sql);
11142    
11143                                    QueryPos qPos = QueryPos.getInstance(q);
11144    
11145                                    qPos.add(groupId);
11146    
11147                                    qPos.add(classNameId);
11148    
11149                                    if (layoutUuid != null) {
11150                                            qPos.add(layoutUuid);
11151                                    }
11152    
11153                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
11154                                                    start, end);
11155                            }
11156                            catch (Exception e) {
11157                                    throw processException(e);
11158                            }
11159                            finally {
11160                                    if (list == null) {
11161                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
11162                                    }
11163                                    else {
11164                                            cacheResult(list);
11165    
11166                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
11167                                    }
11168    
11169                                    closeSession(session);
11170                            }
11171                    }
11172    
11173                    return list;
11174            }
11175    
11176            /**
11177             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11178             *
11179             * <p>
11180             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11181             * </p>
11182             *
11183             * @param groupId the group ID
11184             * @param classNameId the class name ID
11185             * @param layoutUuid the layout uuid
11186             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11187             * @return the first matching journal article
11188             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11189             * @throws SystemException if a system exception occurred
11190             */
11191            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
11192                    String layoutUuid, OrderByComparator orderByComparator)
11193                    throws NoSuchArticleException, SystemException {
11194                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
11195                                    layoutUuid, 0, 1, orderByComparator);
11196    
11197                    if (list.isEmpty()) {
11198                            StringBundler msg = new StringBundler(8);
11199    
11200                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11201    
11202                            msg.append("groupId=");
11203                            msg.append(groupId);
11204    
11205                            msg.append(", classNameId=");
11206                            msg.append(classNameId);
11207    
11208                            msg.append(", layoutUuid=");
11209                            msg.append(layoutUuid);
11210    
11211                            msg.append(StringPool.CLOSE_CURLY_BRACE);
11212    
11213                            throw new NoSuchArticleException(msg.toString());
11214                    }
11215                    else {
11216                            return list.get(0);
11217                    }
11218            }
11219    
11220            /**
11221             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11222             *
11223             * <p>
11224             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11225             * </p>
11226             *
11227             * @param groupId the group ID
11228             * @param classNameId the class name ID
11229             * @param layoutUuid the layout uuid
11230             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11231             * @return the last matching journal article
11232             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11233             * @throws SystemException if a system exception occurred
11234             */
11235            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
11236                    String layoutUuid, OrderByComparator orderByComparator)
11237                    throws NoSuchArticleException, SystemException {
11238                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
11239    
11240                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
11241                                    layoutUuid, count - 1, count, orderByComparator);
11242    
11243                    if (list.isEmpty()) {
11244                            StringBundler msg = new StringBundler(8);
11245    
11246                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11247    
11248                            msg.append("groupId=");
11249                            msg.append(groupId);
11250    
11251                            msg.append(", classNameId=");
11252                            msg.append(classNameId);
11253    
11254                            msg.append(", layoutUuid=");
11255                            msg.append(layoutUuid);
11256    
11257                            msg.append(StringPool.CLOSE_CURLY_BRACE);
11258    
11259                            throw new NoSuchArticleException(msg.toString());
11260                    }
11261                    else {
11262                            return list.get(0);
11263                    }
11264            }
11265    
11266            /**
11267             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11268             *
11269             * <p>
11270             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11271             * </p>
11272             *
11273             * @param id the primary key of the current journal article
11274             * @param groupId the group ID
11275             * @param classNameId the class name ID
11276             * @param layoutUuid the layout uuid
11277             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11278             * @return the previous, current, and next journal article
11279             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11280             * @throws SystemException if a system exception occurred
11281             */
11282            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
11283                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
11284                    throws NoSuchArticleException, SystemException {
11285                    JournalArticle journalArticle = findByPrimaryKey(id);
11286    
11287                    Session session = null;
11288    
11289                    try {
11290                            session = openSession();
11291    
11292                            JournalArticle[] array = new JournalArticleImpl[3];
11293    
11294                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
11295                                            classNameId, layoutUuid, orderByComparator, true);
11296    
11297                            array[1] = journalArticle;
11298    
11299                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
11300                                            classNameId, layoutUuid, orderByComparator, false);
11301    
11302                            return array;
11303                    }
11304                    catch (Exception e) {
11305                            throw processException(e);
11306                    }
11307                    finally {
11308                            closeSession(session);
11309                    }
11310            }
11311    
11312            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
11313                    JournalArticle journalArticle, long groupId, long classNameId,
11314                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
11315                    StringBundler query = null;
11316    
11317                    if (orderByComparator != null) {
11318                            query = new StringBundler(6 +
11319                                            (orderByComparator.getOrderByFields().length * 6));
11320                    }
11321                    else {
11322                            query = new StringBundler(3);
11323                    }
11324    
11325                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11326    
11327                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
11328    
11329                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
11330    
11331                    if (layoutUuid == null) {
11332                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
11333                    }
11334                    else {
11335                            if (layoutUuid.equals(StringPool.BLANK)) {
11336                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
11337                            }
11338                            else {
11339                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
11340                            }
11341                    }
11342    
11343                    if (orderByComparator != null) {
11344                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11345    
11346                            if (orderByConditionFields.length > 0) {
11347                                    query.append(WHERE_AND);
11348                            }
11349    
11350                            for (int i = 0; i < orderByConditionFields.length; i++) {
11351                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11352                                    query.append(orderByConditionFields[i]);
11353    
11354                                    if ((i + 1) < orderByConditionFields.length) {
11355                                            if (orderByComparator.isAscending() ^ previous) {
11356                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11357                                            }
11358                                            else {
11359                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11360                                            }
11361                                    }
11362                                    else {
11363                                            if (orderByComparator.isAscending() ^ previous) {
11364                                                    query.append(WHERE_GREATER_THAN);
11365                                            }
11366                                            else {
11367                                                    query.append(WHERE_LESSER_THAN);
11368                                            }
11369                                    }
11370                            }
11371    
11372                            query.append(ORDER_BY_CLAUSE);
11373    
11374                            String[] orderByFields = orderByComparator.getOrderByFields();
11375    
11376                            for (int i = 0; i < orderByFields.length; i++) {
11377                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11378                                    query.append(orderByFields[i]);
11379    
11380                                    if ((i + 1) < orderByFields.length) {
11381                                            if (orderByComparator.isAscending() ^ previous) {
11382                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11383                                            }
11384                                            else {
11385                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11386                                            }
11387                                    }
11388                                    else {
11389                                            if (orderByComparator.isAscending() ^ previous) {
11390                                                    query.append(ORDER_BY_ASC);
11391                                            }
11392                                            else {
11393                                                    query.append(ORDER_BY_DESC);
11394                                            }
11395                                    }
11396                            }
11397                    }
11398    
11399                    else {
11400                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11401                    }
11402    
11403                    String sql = query.toString();
11404    
11405                    Query q = session.createQuery(sql);
11406    
11407                    q.setFirstResult(0);
11408                    q.setMaxResults(2);
11409    
11410                    QueryPos qPos = QueryPos.getInstance(q);
11411    
11412                    qPos.add(groupId);
11413    
11414                    qPos.add(classNameId);
11415    
11416                    if (layoutUuid != null) {
11417                            qPos.add(layoutUuid);
11418                    }
11419    
11420                    if (orderByComparator != null) {
11421                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11422    
11423                            for (Object value : values) {
11424                                    qPos.add(value);
11425                            }
11426                    }
11427    
11428                    List<JournalArticle> list = q.list();
11429    
11430                    if (list.size() == 2) {
11431                            return list.get(1);
11432                    }
11433                    else {
11434                            return null;
11435                    }
11436            }
11437    
11438            /**
11439             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11440             *
11441             * @param groupId the group ID
11442             * @param classNameId the class name ID
11443             * @param layoutUuid the layout uuid
11444             * @return the matching journal articles that the user has permission to view
11445             * @throws SystemException if a system exception occurred
11446             */
11447            public List<JournalArticle> filterFindByG_C_L(long groupId,
11448                    long classNameId, String layoutUuid) throws SystemException {
11449                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
11450                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11451            }
11452    
11453            /**
11454             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11455             *
11456             * <p>
11457             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11458             * </p>
11459             *
11460             * @param groupId the group ID
11461             * @param classNameId the class name ID
11462             * @param layoutUuid the layout uuid
11463             * @param start the lower bound of the range of journal articles
11464             * @param end the upper bound of the range of journal articles (not inclusive)
11465             * @return the range of matching journal articles that the user has permission to view
11466             * @throws SystemException if a system exception occurred
11467             */
11468            public List<JournalArticle> filterFindByG_C_L(long groupId,
11469                    long classNameId, String layoutUuid, int start, int end)
11470                    throws SystemException {
11471                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
11472                            null);
11473            }
11474    
11475            /**
11476             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11477             *
11478             * <p>
11479             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11480             * </p>
11481             *
11482             * @param groupId the group ID
11483             * @param classNameId the class name ID
11484             * @param layoutUuid the layout uuid
11485             * @param start the lower bound of the range of journal articles
11486             * @param end the upper bound of the range of journal articles (not inclusive)
11487             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11488             * @return the ordered range of matching journal articles that the user has permission to view
11489             * @throws SystemException if a system exception occurred
11490             */
11491            public List<JournalArticle> filterFindByG_C_L(long groupId,
11492                    long classNameId, String layoutUuid, int start, int end,
11493                    OrderByComparator orderByComparator) throws SystemException {
11494                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11495                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
11496                                    orderByComparator);
11497                    }
11498    
11499                    StringBundler query = null;
11500    
11501                    if (orderByComparator != null) {
11502                            query = new StringBundler(5 +
11503                                            (orderByComparator.getOrderByFields().length * 3));
11504                    }
11505                    else {
11506                            query = new StringBundler(5);
11507                    }
11508    
11509                    if (getDB().isSupportsInlineDistinct()) {
11510                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11511                    }
11512                    else {
11513                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11514                    }
11515    
11516                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
11517    
11518                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
11519    
11520                    if (layoutUuid == null) {
11521                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
11522                    }
11523                    else {
11524                            if (layoutUuid.equals(StringPool.BLANK)) {
11525                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
11526                            }
11527                            else {
11528                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
11529                            }
11530                    }
11531    
11532                    if (!getDB().isSupportsInlineDistinct()) {
11533                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11534                    }
11535    
11536                    if (orderByComparator != null) {
11537                            if (getDB().isSupportsInlineDistinct()) {
11538                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11539                                            orderByComparator);
11540                            }
11541                            else {
11542                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11543                                            orderByComparator);
11544                            }
11545                    }
11546    
11547                    else {
11548                            if (getDB().isSupportsInlineDistinct()) {
11549                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11550                            }
11551                            else {
11552                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11553                            }
11554                    }
11555    
11556                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11557                                    JournalArticle.class.getName(),
11558                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11559    
11560                    Session session = null;
11561    
11562                    try {
11563                            session = openSession();
11564    
11565                            SQLQuery q = session.createSQLQuery(sql);
11566    
11567                            if (getDB().isSupportsInlineDistinct()) {
11568                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11569                            }
11570                            else {
11571                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11572                            }
11573    
11574                            QueryPos qPos = QueryPos.getInstance(q);
11575    
11576                            qPos.add(groupId);
11577    
11578                            qPos.add(classNameId);
11579    
11580                            if (layoutUuid != null) {
11581                                    qPos.add(layoutUuid);
11582                            }
11583    
11584                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11585                                    end);
11586                    }
11587                    catch (Exception e) {
11588                            throw processException(e);
11589                    }
11590                    finally {
11591                            closeSession(session);
11592                    }
11593            }
11594    
11595            /**
11596             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11597             *
11598             * @param id the primary key of the current journal article
11599             * @param groupId the group ID
11600             * @param classNameId the class name ID
11601             * @param layoutUuid the layout uuid
11602             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11603             * @return the previous, current, and next journal article
11604             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11605             * @throws SystemException if a system exception occurred
11606             */
11607            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
11608                    long groupId, long classNameId, String layoutUuid,
11609                    OrderByComparator orderByComparator)
11610                    throws NoSuchArticleException, SystemException {
11611                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11612                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
11613                                    layoutUuid, orderByComparator);
11614                    }
11615    
11616                    JournalArticle journalArticle = findByPrimaryKey(id);
11617    
11618                    Session session = null;
11619    
11620                    try {
11621                            session = openSession();
11622    
11623                            JournalArticle[] array = new JournalArticleImpl[3];
11624    
11625                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
11626                                            groupId, classNameId, layoutUuid, orderByComparator, true);
11627    
11628                            array[1] = journalArticle;
11629    
11630                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
11631                                            groupId, classNameId, layoutUuid, orderByComparator, false);
11632    
11633                            return array;
11634                    }
11635                    catch (Exception e) {
11636                            throw processException(e);
11637                    }
11638                    finally {
11639                            closeSession(session);
11640                    }
11641            }
11642    
11643            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
11644                    JournalArticle journalArticle, long groupId, long classNameId,
11645                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
11646                    StringBundler query = null;
11647    
11648                    if (orderByComparator != null) {
11649                            query = new StringBundler(6 +
11650                                            (orderByComparator.getOrderByFields().length * 6));
11651                    }
11652                    else {
11653                            query = new StringBundler(3);
11654                    }
11655    
11656                    if (getDB().isSupportsInlineDistinct()) {
11657                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11658                    }
11659                    else {
11660                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11661                    }
11662    
11663                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
11664    
11665                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
11666    
11667                    if (layoutUuid == null) {
11668                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
11669                    }
11670                    else {
11671                            if (layoutUuid.equals(StringPool.BLANK)) {
11672                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
11673                            }
11674                            else {
11675                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
11676                            }
11677                    }
11678    
11679                    if (!getDB().isSupportsInlineDistinct()) {
11680                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11681                    }
11682    
11683                    if (orderByComparator != null) {
11684                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11685    
11686                            if (orderByConditionFields.length > 0) {
11687                                    query.append(WHERE_AND);
11688                            }
11689    
11690                            for (int i = 0; i < orderByConditionFields.length; i++) {
11691                                    if (getDB().isSupportsInlineDistinct()) {
11692                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11693                                    }
11694                                    else {
11695                                            query.append(_ORDER_BY_ENTITY_TABLE);
11696                                    }
11697    
11698                                    query.append(orderByConditionFields[i]);
11699    
11700                                    if ((i + 1) < orderByConditionFields.length) {
11701                                            if (orderByComparator.isAscending() ^ previous) {
11702                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11703                                            }
11704                                            else {
11705                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11706                                            }
11707                                    }
11708                                    else {
11709                                            if (orderByComparator.isAscending() ^ previous) {
11710                                                    query.append(WHERE_GREATER_THAN);
11711                                            }
11712                                            else {
11713                                                    query.append(WHERE_LESSER_THAN);
11714                                            }
11715                                    }
11716                            }
11717    
11718                            query.append(ORDER_BY_CLAUSE);
11719    
11720                            String[] orderByFields = orderByComparator.getOrderByFields();
11721    
11722                            for (int i = 0; i < orderByFields.length; i++) {
11723                                    if (getDB().isSupportsInlineDistinct()) {
11724                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11725                                    }
11726                                    else {
11727                                            query.append(_ORDER_BY_ENTITY_TABLE);
11728                                    }
11729    
11730                                    query.append(orderByFields[i]);
11731    
11732                                    if ((i + 1) < orderByFields.length) {
11733                                            if (orderByComparator.isAscending() ^ previous) {
11734                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11735                                            }
11736                                            else {
11737                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11738                                            }
11739                                    }
11740                                    else {
11741                                            if (orderByComparator.isAscending() ^ previous) {
11742                                                    query.append(ORDER_BY_ASC);
11743                                            }
11744                                            else {
11745                                                    query.append(ORDER_BY_DESC);
11746                                            }
11747                                    }
11748                            }
11749                    }
11750    
11751                    else {
11752                            if (getDB().isSupportsInlineDistinct()) {
11753                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11754                            }
11755                            else {
11756                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11757                            }
11758                    }
11759    
11760                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11761                                    JournalArticle.class.getName(),
11762                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11763    
11764                    SQLQuery q = session.createSQLQuery(sql);
11765    
11766                    q.setFirstResult(0);
11767                    q.setMaxResults(2);
11768    
11769                    if (getDB().isSupportsInlineDistinct()) {
11770                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11771                    }
11772                    else {
11773                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11774                    }
11775    
11776                    QueryPos qPos = QueryPos.getInstance(q);
11777    
11778                    qPos.add(groupId);
11779    
11780                    qPos.add(classNameId);
11781    
11782                    if (layoutUuid != null) {
11783                            qPos.add(layoutUuid);
11784                    }
11785    
11786                    if (orderByComparator != null) {
11787                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11788    
11789                            for (Object value : values) {
11790                                    qPos.add(value);
11791                            }
11792                    }
11793    
11794                    List<JournalArticle> list = q.list();
11795    
11796                    if (list.size() == 2) {
11797                            return list.get(1);
11798                    }
11799                    else {
11800                            return null;
11801                    }
11802            }
11803    
11804            /**
11805             * Returns the journal article where groupId = &#63; and articleId = &#63; and version = &#63; or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
11806             *
11807             * @param groupId the group ID
11808             * @param articleId the article ID
11809             * @param version the version
11810             * @return the matching journal article
11811             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11812             * @throws SystemException if a system exception occurred
11813             */
11814            public JournalArticle findByG_A_V(long groupId, String articleId,
11815                    double version) throws NoSuchArticleException, SystemException {
11816                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
11817    
11818                    if (journalArticle == null) {
11819                            StringBundler msg = new StringBundler(8);
11820    
11821                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11822    
11823                            msg.append("groupId=");
11824                            msg.append(groupId);
11825    
11826                            msg.append(", articleId=");
11827                            msg.append(articleId);
11828    
11829                            msg.append(", version=");
11830                            msg.append(version);
11831    
11832                            msg.append(StringPool.CLOSE_CURLY_BRACE);
11833    
11834                            if (_log.isWarnEnabled()) {
11835                                    _log.warn(msg.toString());
11836                            }
11837    
11838                            throw new NoSuchArticleException(msg.toString());
11839                    }
11840    
11841                    return journalArticle;
11842            }
11843    
11844            /**
11845             * Returns the journal article where groupId = &#63; and articleId = &#63; and version = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
11846             *
11847             * @param groupId the group ID
11848             * @param articleId the article ID
11849             * @param version the version
11850             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
11851             * @throws SystemException if a system exception occurred
11852             */
11853            public JournalArticle fetchByG_A_V(long groupId, String articleId,
11854                    double version) throws SystemException {
11855                    return fetchByG_A_V(groupId, articleId, version, true);
11856            }
11857    
11858            /**
11859             * Returns the journal article where groupId = &#63; and articleId = &#63; and version = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
11860             *
11861             * @param groupId the group ID
11862             * @param articleId the article ID
11863             * @param version the version
11864             * @param retrieveFromCache whether to use the finder cache
11865             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
11866             * @throws SystemException if a system exception occurred
11867             */
11868            public JournalArticle fetchByG_A_V(long groupId, String articleId,
11869                    double version, boolean retrieveFromCache) throws SystemException {
11870                    Object[] finderArgs = new Object[] { groupId, articleId, version };
11871    
11872                    Object result = null;
11873    
11874                    if (retrieveFromCache) {
11875                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
11876                                            finderArgs, this);
11877                    }
11878    
11879                    if (result == null) {
11880                            StringBundler query = new StringBundler(5);
11881    
11882                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11883    
11884                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
11885    
11886                            if (articleId == null) {
11887                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
11888                            }
11889                            else {
11890                                    if (articleId.equals(StringPool.BLANK)) {
11891                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
11892                                    }
11893                                    else {
11894                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
11895                                    }
11896                            }
11897    
11898                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
11899    
11900                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11901    
11902                            String sql = query.toString();
11903    
11904                            Session session = null;
11905    
11906                            try {
11907                                    session = openSession();
11908    
11909                                    Query q = session.createQuery(sql);
11910    
11911                                    QueryPos qPos = QueryPos.getInstance(q);
11912    
11913                                    qPos.add(groupId);
11914    
11915                                    if (articleId != null) {
11916                                            qPos.add(articleId);
11917                                    }
11918    
11919                                    qPos.add(version);
11920    
11921                                    List<JournalArticle> list = q.list();
11922    
11923                                    result = list;
11924    
11925                                    JournalArticle journalArticle = null;
11926    
11927                                    if (list.isEmpty()) {
11928                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
11929                                                    finderArgs, list);
11930                                    }
11931                                    else {
11932                                            journalArticle = list.get(0);
11933    
11934                                            cacheResult(journalArticle);
11935    
11936                                            if ((journalArticle.getGroupId() != groupId) ||
11937                                                            (journalArticle.getArticleId() == null) ||
11938                                                            !journalArticle.getArticleId().equals(articleId) ||
11939                                                            (journalArticle.getVersion() != version)) {
11940                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
11941                                                            finderArgs, journalArticle);
11942                                            }
11943                                    }
11944    
11945                                    return journalArticle;
11946                            }
11947                            catch (Exception e) {
11948                                    throw processException(e);
11949                            }
11950                            finally {
11951                                    if (result == null) {
11952                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
11953                                                    finderArgs);
11954                                    }
11955    
11956                                    closeSession(session);
11957                            }
11958                    }
11959                    else {
11960                            if (result instanceof List<?>) {
11961                                    return null;
11962                            }
11963                            else {
11964                                    return (JournalArticle)result;
11965                            }
11966                    }
11967            }
11968    
11969            /**
11970             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
11971             *
11972             * @param groupId the group ID
11973             * @param articleId the article ID
11974             * @param status the status
11975             * @return the matching journal articles
11976             * @throws SystemException if a system exception occurred
11977             */
11978            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
11979                    int status) throws SystemException {
11980                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
11981                            QueryUtil.ALL_POS, null);
11982            }
11983    
11984            /**
11985             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
11986             *
11987             * <p>
11988             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11989             * </p>
11990             *
11991             * @param groupId the group ID
11992             * @param articleId the article ID
11993             * @param status the status
11994             * @param start the lower bound of the range of journal articles
11995             * @param end the upper bound of the range of journal articles (not inclusive)
11996             * @return the range of matching journal articles
11997             * @throws SystemException if a system exception occurred
11998             */
11999            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
12000                    int status, int start, int end) throws SystemException {
12001                    return findByG_A_ST(groupId, articleId, status, start, end, null);
12002            }
12003    
12004            /**
12005             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
12006             *
12007             * <p>
12008             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12009             * </p>
12010             *
12011             * @param groupId the group ID
12012             * @param articleId the article ID
12013             * @param status the status
12014             * @param start the lower bound of the range of journal articles
12015             * @param end the upper bound of the range of journal articles (not inclusive)
12016             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12017             * @return the ordered range of matching journal articles
12018             * @throws SystemException if a system exception occurred
12019             */
12020            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
12021                    int status, int start, int end, OrderByComparator orderByComparator)
12022                    throws SystemException {
12023                    FinderPath finderPath = null;
12024                    Object[] finderArgs = null;
12025    
12026                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12027                                    (orderByComparator == null)) {
12028                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
12029                            finderArgs = new Object[] { groupId, articleId, status };
12030                    }
12031                    else {
12032                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
12033                            finderArgs = new Object[] {
12034                                            groupId, articleId, status,
12035                                            
12036                                            start, end, orderByComparator
12037                                    };
12038                    }
12039    
12040                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12041                                    finderArgs, this);
12042    
12043                    if (list == null) {
12044                            StringBundler query = null;
12045    
12046                            if (orderByComparator != null) {
12047                                    query = new StringBundler(5 +
12048                                                    (orderByComparator.getOrderByFields().length * 3));
12049                            }
12050                            else {
12051                                    query = new StringBundler(5);
12052                            }
12053    
12054                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12055    
12056                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
12057    
12058                            if (articleId == null) {
12059                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
12060                            }
12061                            else {
12062                                    if (articleId.equals(StringPool.BLANK)) {
12063                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
12064                                    }
12065                                    else {
12066                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
12067                                    }
12068                            }
12069    
12070                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
12071    
12072                            if (orderByComparator != null) {
12073                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12074                                            orderByComparator);
12075                            }
12076    
12077                            else {
12078                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12079                            }
12080    
12081                            String sql = query.toString();
12082    
12083                            Session session = null;
12084    
12085                            try {
12086                                    session = openSession();
12087    
12088                                    Query q = session.createQuery(sql);
12089    
12090                                    QueryPos qPos = QueryPos.getInstance(q);
12091    
12092                                    qPos.add(groupId);
12093    
12094                                    if (articleId != null) {
12095                                            qPos.add(articleId);
12096                                    }
12097    
12098                                    qPos.add(status);
12099    
12100                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
12101                                                    start, end);
12102                            }
12103                            catch (Exception e) {
12104                                    throw processException(e);
12105                            }
12106                            finally {
12107                                    if (list == null) {
12108                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
12109                                    }
12110                                    else {
12111                                            cacheResult(list);
12112    
12113                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12114                                    }
12115    
12116                                    closeSession(session);
12117                            }
12118                    }
12119    
12120                    return list;
12121            }
12122    
12123            /**
12124             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
12125             *
12126             * <p>
12127             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12128             * </p>
12129             *
12130             * @param groupId the group ID
12131             * @param articleId the article ID
12132             * @param status the status
12133             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12134             * @return the first matching journal article
12135             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12136             * @throws SystemException if a system exception occurred
12137             */
12138            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
12139                    int status, OrderByComparator orderByComparator)
12140                    throws NoSuchArticleException, SystemException {
12141                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
12142                                    1, orderByComparator);
12143    
12144                    if (list.isEmpty()) {
12145                            StringBundler msg = new StringBundler(8);
12146    
12147                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12148    
12149                            msg.append("groupId=");
12150                            msg.append(groupId);
12151    
12152                            msg.append(", articleId=");
12153                            msg.append(articleId);
12154    
12155                            msg.append(", status=");
12156                            msg.append(status);
12157    
12158                            msg.append(StringPool.CLOSE_CURLY_BRACE);
12159    
12160                            throw new NoSuchArticleException(msg.toString());
12161                    }
12162                    else {
12163                            return list.get(0);
12164                    }
12165            }
12166    
12167            /**
12168             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
12169             *
12170             * <p>
12171             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12172             * </p>
12173             *
12174             * @param groupId the group ID
12175             * @param articleId the article ID
12176             * @param status the status
12177             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12178             * @return the last matching journal article
12179             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12180             * @throws SystemException if a system exception occurred
12181             */
12182            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
12183                    int status, OrderByComparator orderByComparator)
12184                    throws NoSuchArticleException, SystemException {
12185                    int count = countByG_A_ST(groupId, articleId, status);
12186    
12187                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
12188                                    count - 1, count, orderByComparator);
12189    
12190                    if (list.isEmpty()) {
12191                            StringBundler msg = new StringBundler(8);
12192    
12193                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12194    
12195                            msg.append("groupId=");
12196                            msg.append(groupId);
12197    
12198                            msg.append(", articleId=");
12199                            msg.append(articleId);
12200    
12201                            msg.append(", status=");
12202                            msg.append(status);
12203    
12204                            msg.append(StringPool.CLOSE_CURLY_BRACE);
12205    
12206                            throw new NoSuchArticleException(msg.toString());
12207                    }
12208                    else {
12209                            return list.get(0);
12210                    }
12211            }
12212    
12213            /**
12214             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
12215             *
12216             * <p>
12217             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12218             * </p>
12219             *
12220             * @param id the primary key of the current journal article
12221             * @param groupId the group ID
12222             * @param articleId the article ID
12223             * @param status the status
12224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12225             * @return the previous, current, and next journal article
12226             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12227             * @throws SystemException if a system exception occurred
12228             */
12229            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
12230                    String articleId, int status, OrderByComparator orderByComparator)
12231                    throws NoSuchArticleException, SystemException {
12232                    JournalArticle journalArticle = findByPrimaryKey(id);
12233    
12234                    Session session = null;
12235    
12236                    try {
12237                            session = openSession();
12238    
12239                            JournalArticle[] array = new JournalArticleImpl[3];
12240    
12241                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
12242                                            groupId, articleId, status, orderByComparator, true);
12243    
12244                            array[1] = journalArticle;
12245    
12246                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
12247                                            groupId, articleId, status, orderByComparator, false);
12248    
12249                            return array;
12250                    }
12251                    catch (Exception e) {
12252                            throw processException(e);
12253                    }
12254                    finally {
12255                            closeSession(session);
12256                    }
12257            }
12258    
12259            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
12260                    JournalArticle journalArticle, long groupId, String articleId,
12261                    int status, OrderByComparator orderByComparator, boolean previous) {
12262                    StringBundler query = null;
12263    
12264                    if (orderByComparator != null) {
12265                            query = new StringBundler(6 +
12266                                            (orderByComparator.getOrderByFields().length * 6));
12267                    }
12268                    else {
12269                            query = new StringBundler(3);
12270                    }
12271    
12272                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12273    
12274                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
12275    
12276                    if (articleId == null) {
12277                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
12278                    }
12279                    else {
12280                            if (articleId.equals(StringPool.BLANK)) {
12281                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
12282                            }
12283                            else {
12284                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
12285                            }
12286                    }
12287    
12288                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
12289    
12290                    if (orderByComparator != null) {
12291                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12292    
12293                            if (orderByConditionFields.length > 0) {
12294                                    query.append(WHERE_AND);
12295                            }
12296    
12297                            for (int i = 0; i < orderByConditionFields.length; i++) {
12298                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12299                                    query.append(orderByConditionFields[i]);
12300    
12301                                    if ((i + 1) < orderByConditionFields.length) {
12302                                            if (orderByComparator.isAscending() ^ previous) {
12303                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12304                                            }
12305                                            else {
12306                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12307                                            }
12308                                    }
12309                                    else {
12310                                            if (orderByComparator.isAscending() ^ previous) {
12311                                                    query.append(WHERE_GREATER_THAN);
12312                                            }
12313                                            else {
12314                                                    query.append(WHERE_LESSER_THAN);
12315                                            }
12316                                    }
12317                            }
12318    
12319                            query.append(ORDER_BY_CLAUSE);
12320    
12321                            String[] orderByFields = orderByComparator.getOrderByFields();
12322    
12323                            for (int i = 0; i < orderByFields.length; i++) {
12324                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12325                                    query.append(orderByFields[i]);
12326    
12327                                    if ((i + 1) < orderByFields.length) {
12328                                            if (orderByComparator.isAscending() ^ previous) {
12329                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12330                                            }
12331                                            else {
12332                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12333                                            }
12334                                    }
12335                                    else {
12336                                            if (orderByComparator.isAscending() ^ previous) {
12337                                                    query.append(ORDER_BY_ASC);
12338                                            }
12339                                            else {
12340                                                    query.append(ORDER_BY_DESC);
12341                                            }
12342                                    }
12343                            }
12344                    }
12345    
12346                    else {
12347                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12348                    }
12349    
12350                    String sql = query.toString();
12351    
12352                    Query q = session.createQuery(sql);
12353    
12354                    q.setFirstResult(0);
12355                    q.setMaxResults(2);
12356    
12357                    QueryPos qPos = QueryPos.getInstance(q);
12358    
12359                    qPos.add(groupId);
12360    
12361                    if (articleId != null) {
12362                            qPos.add(articleId);
12363                    }
12364    
12365                    qPos.add(status);
12366    
12367                    if (orderByComparator != null) {
12368                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12369    
12370                            for (Object value : values) {
12371                                    qPos.add(value);
12372                            }
12373                    }
12374    
12375                    List<JournalArticle> list = q.list();
12376    
12377                    if (list.size() == 2) {
12378                            return list.get(1);
12379                    }
12380                    else {
12381                            return null;
12382                    }
12383            }
12384    
12385            /**
12386             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
12387             *
12388             * @param groupId the group ID
12389             * @param articleId the article ID
12390             * @param status the status
12391             * @return the matching journal articles that the user has permission to view
12392             * @throws SystemException if a system exception occurred
12393             */
12394            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12395                    String articleId, int status) throws SystemException {
12396                    return filterFindByG_A_ST(groupId, articleId, status,
12397                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12398            }
12399    
12400            /**
12401             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
12402             *
12403             * <p>
12404             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12405             * </p>
12406             *
12407             * @param groupId the group ID
12408             * @param articleId the article ID
12409             * @param status the status
12410             * @param start the lower bound of the range of journal articles
12411             * @param end the upper bound of the range of journal articles (not inclusive)
12412             * @return the range of matching journal articles that the user has permission to view
12413             * @throws SystemException if a system exception occurred
12414             */
12415            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12416                    String articleId, int status, int start, int end)
12417                    throws SystemException {
12418                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
12419            }
12420    
12421            /**
12422             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63; and status = &#63;.
12423             *
12424             * <p>
12425             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12426             * </p>
12427             *
12428             * @param groupId the group ID
12429             * @param articleId the article ID
12430             * @param status the status
12431             * @param start the lower bound of the range of journal articles
12432             * @param end the upper bound of the range of journal articles (not inclusive)
12433             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12434             * @return the ordered range of matching journal articles that the user has permission to view
12435             * @throws SystemException if a system exception occurred
12436             */
12437            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12438                    String articleId, int status, int start, int end,
12439                    OrderByComparator orderByComparator) throws SystemException {
12440                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12441                            return findByG_A_ST(groupId, articleId, status, start, end,
12442                                    orderByComparator);
12443                    }
12444    
12445                    StringBundler query = null;
12446    
12447                    if (orderByComparator != null) {
12448                            query = new StringBundler(5 +
12449                                            (orderByComparator.getOrderByFields().length * 3));
12450                    }
12451                    else {
12452                            query = new StringBundler(5);
12453                    }
12454    
12455                    if (getDB().isSupportsInlineDistinct()) {
12456                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12457                    }
12458                    else {
12459                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12460                    }
12461    
12462                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
12463    
12464                    if (articleId == null) {
12465                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
12466                    }
12467                    else {
12468                            if (articleId.equals(StringPool.BLANK)) {
12469                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
12470                            }
12471                            else {
12472                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
12473                            }
12474                    }
12475    
12476                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
12477    
12478                    if (!getDB().isSupportsInlineDistinct()) {
12479                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12480                    }
12481    
12482                    if (orderByComparator != null) {
12483                            if (getDB().isSupportsInlineDistinct()) {
12484                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12485                                            orderByComparator);
12486                            }
12487                            else {
12488                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12489                                            orderByComparator);
12490                            }
12491                    }
12492    
12493                    else {
12494                            if (getDB().isSupportsInlineDistinct()) {
12495                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12496                            }
12497                            else {
12498                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12499                            }
12500                    }
12501    
12502                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12503                                    JournalArticle.class.getName(),
12504                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12505    
12506                    Session session = null;
12507    
12508                    try {
12509                            session = openSession();
12510    
12511                            SQLQuery q = session.createSQLQuery(sql);
12512    
12513                            if (getDB().isSupportsInlineDistinct()) {
12514                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12515                            }
12516                            else {
12517                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12518                            }
12519    
12520                            QueryPos qPos = QueryPos.getInstance(q);
12521    
12522                            qPos.add(groupId);
12523    
12524                            if (articleId != null) {
12525                                    qPos.add(articleId);
12526                            }
12527    
12528                            qPos.add(status);
12529    
12530                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12531                                    end);
12532                    }
12533                    catch (Exception e) {
12534                            throw processException(e);
12535                    }
12536                    finally {
12537                            closeSession(session);
12538                    }
12539            }
12540    
12541            /**
12542             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
12543             *
12544             * @param id the primary key of the current journal article
12545             * @param groupId the group ID
12546             * @param articleId the article ID
12547             * @param status the status
12548             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12549             * @return the previous, current, and next journal article
12550             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12551             * @throws SystemException if a system exception occurred
12552             */
12553            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
12554                    long groupId, String articleId, int status,
12555                    OrderByComparator orderByComparator)
12556                    throws NoSuchArticleException, SystemException {
12557                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12558                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
12559                                    orderByComparator);
12560                    }
12561    
12562                    JournalArticle journalArticle = findByPrimaryKey(id);
12563    
12564                    Session session = null;
12565    
12566                    try {
12567                            session = openSession();
12568    
12569                            JournalArticle[] array = new JournalArticleImpl[3];
12570    
12571                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
12572                                            groupId, articleId, status, orderByComparator, true);
12573    
12574                            array[1] = journalArticle;
12575    
12576                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
12577                                            groupId, articleId, status, orderByComparator, false);
12578    
12579                            return array;
12580                    }
12581                    catch (Exception e) {
12582                            throw processException(e);
12583                    }
12584                    finally {
12585                            closeSession(session);
12586                    }
12587            }
12588    
12589            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
12590                    JournalArticle journalArticle, long groupId, String articleId,
12591                    int status, OrderByComparator orderByComparator, boolean previous) {
12592                    StringBundler query = null;
12593    
12594                    if (orderByComparator != null) {
12595                            query = new StringBundler(6 +
12596                                            (orderByComparator.getOrderByFields().length * 6));
12597                    }
12598                    else {
12599                            query = new StringBundler(3);
12600                    }
12601    
12602                    if (getDB().isSupportsInlineDistinct()) {
12603                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12604                    }
12605                    else {
12606                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12607                    }
12608    
12609                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
12610    
12611                    if (articleId == null) {
12612                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
12613                    }
12614                    else {
12615                            if (articleId.equals(StringPool.BLANK)) {
12616                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
12617                            }
12618                            else {
12619                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
12620                            }
12621                    }
12622    
12623                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
12624    
12625                    if (!getDB().isSupportsInlineDistinct()) {
12626                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12627                    }
12628    
12629                    if (orderByComparator != null) {
12630                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12631    
12632                            if (orderByConditionFields.length > 0) {
12633                                    query.append(WHERE_AND);
12634                            }
12635    
12636                            for (int i = 0; i < orderByConditionFields.length; i++) {
12637                                    if (getDB().isSupportsInlineDistinct()) {
12638                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12639                                    }
12640                                    else {
12641                                            query.append(_ORDER_BY_ENTITY_TABLE);
12642                                    }
12643    
12644                                    query.append(orderByConditionFields[i]);
12645    
12646                                    if ((i + 1) < orderByConditionFields.length) {
12647                                            if (orderByComparator.isAscending() ^ previous) {
12648                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12649                                            }
12650                                            else {
12651                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12652                                            }
12653                                    }
12654                                    else {
12655                                            if (orderByComparator.isAscending() ^ previous) {
12656                                                    query.append(WHERE_GREATER_THAN);
12657                                            }
12658                                            else {
12659                                                    query.append(WHERE_LESSER_THAN);
12660                                            }
12661                                    }
12662                            }
12663    
12664                            query.append(ORDER_BY_CLAUSE);
12665    
12666                            String[] orderByFields = orderByComparator.getOrderByFields();
12667    
12668                            for (int i = 0; i < orderByFields.length; i++) {
12669                                    if (getDB().isSupportsInlineDistinct()) {
12670                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12671                                    }
12672                                    else {
12673                                            query.append(_ORDER_BY_ENTITY_TABLE);
12674                                    }
12675    
12676                                    query.append(orderByFields[i]);
12677    
12678                                    if ((i + 1) < orderByFields.length) {
12679                                            if (orderByComparator.isAscending() ^ previous) {
12680                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12681                                            }
12682                                            else {
12683                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12684                                            }
12685                                    }
12686                                    else {
12687                                            if (orderByComparator.isAscending() ^ previous) {
12688                                                    query.append(ORDER_BY_ASC);
12689                                            }
12690                                            else {
12691                                                    query.append(ORDER_BY_DESC);
12692                                            }
12693                                    }
12694                            }
12695                    }
12696    
12697                    else {
12698                            if (getDB().isSupportsInlineDistinct()) {
12699                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12700                            }
12701                            else {
12702                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12703                            }
12704                    }
12705    
12706                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12707                                    JournalArticle.class.getName(),
12708                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12709    
12710                    SQLQuery q = session.createSQLQuery(sql);
12711    
12712                    q.setFirstResult(0);
12713                    q.setMaxResults(2);
12714    
12715                    if (getDB().isSupportsInlineDistinct()) {
12716                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12717                    }
12718                    else {
12719                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12720                    }
12721    
12722                    QueryPos qPos = QueryPos.getInstance(q);
12723    
12724                    qPos.add(groupId);
12725    
12726                    if (articleId != null) {
12727                            qPos.add(articleId);
12728                    }
12729    
12730                    qPos.add(status);
12731    
12732                    if (orderByComparator != null) {
12733                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12734    
12735                            for (Object value : values) {
12736                                    qPos.add(value);
12737                            }
12738                    }
12739    
12740                    List<JournalArticle> list = q.list();
12741    
12742                    if (list.size() == 2) {
12743                            return list.get(1);
12744                    }
12745                    else {
12746                            return null;
12747                    }
12748            }
12749    
12750            /**
12751             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
12752             *
12753             * @param groupId the group ID
12754             * @param urlTitle the url title
12755             * @param status the status
12756             * @return the matching journal articles
12757             * @throws SystemException if a system exception occurred
12758             */
12759            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
12760                    int status) throws SystemException {
12761                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
12762                            QueryUtil.ALL_POS, null);
12763            }
12764    
12765            /**
12766             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
12767             *
12768             * <p>
12769             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12770             * </p>
12771             *
12772             * @param groupId the group ID
12773             * @param urlTitle the url title
12774             * @param status the status
12775             * @param start the lower bound of the range of journal articles
12776             * @param end the upper bound of the range of journal articles (not inclusive)
12777             * @return the range of matching journal articles
12778             * @throws SystemException if a system exception occurred
12779             */
12780            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
12781                    int status, int start, int end) throws SystemException {
12782                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
12783            }
12784    
12785            /**
12786             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
12787             *
12788             * <p>
12789             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12790             * </p>
12791             *
12792             * @param groupId the group ID
12793             * @param urlTitle the url title
12794             * @param status the status
12795             * @param start the lower bound of the range of journal articles
12796             * @param end the upper bound of the range of journal articles (not inclusive)
12797             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12798             * @return the ordered range of matching journal articles
12799             * @throws SystemException if a system exception occurred
12800             */
12801            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
12802                    int status, int start, int end, OrderByComparator orderByComparator)
12803                    throws SystemException {
12804                    FinderPath finderPath = null;
12805                    Object[] finderArgs = null;
12806    
12807                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12808                                    (orderByComparator == null)) {
12809                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
12810                            finderArgs = new Object[] { groupId, urlTitle, status };
12811                    }
12812                    else {
12813                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
12814                            finderArgs = new Object[] {
12815                                            groupId, urlTitle, status,
12816                                            
12817                                            start, end, orderByComparator
12818                                    };
12819                    }
12820    
12821                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12822                                    finderArgs, this);
12823    
12824                    if (list == null) {
12825                            StringBundler query = null;
12826    
12827                            if (orderByComparator != null) {
12828                                    query = new StringBundler(5 +
12829                                                    (orderByComparator.getOrderByFields().length * 3));
12830                            }
12831                            else {
12832                                    query = new StringBundler(5);
12833                            }
12834    
12835                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12836    
12837                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
12838    
12839                            if (urlTitle == null) {
12840                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
12841                            }
12842                            else {
12843                                    if (urlTitle.equals(StringPool.BLANK)) {
12844                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
12845                                    }
12846                                    else {
12847                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
12848                                    }
12849                            }
12850    
12851                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
12852    
12853                            if (orderByComparator != null) {
12854                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12855                                            orderByComparator);
12856                            }
12857    
12858                            else {
12859                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12860                            }
12861    
12862                            String sql = query.toString();
12863    
12864                            Session session = null;
12865    
12866                            try {
12867                                    session = openSession();
12868    
12869                                    Query q = session.createQuery(sql);
12870    
12871                                    QueryPos qPos = QueryPos.getInstance(q);
12872    
12873                                    qPos.add(groupId);
12874    
12875                                    if (urlTitle != null) {
12876                                            qPos.add(urlTitle);
12877                                    }
12878    
12879                                    qPos.add(status);
12880    
12881                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
12882                                                    start, end);
12883                            }
12884                            catch (Exception e) {
12885                                    throw processException(e);
12886                            }
12887                            finally {
12888                                    if (list == null) {
12889                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
12890                                    }
12891                                    else {
12892                                            cacheResult(list);
12893    
12894                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12895                                    }
12896    
12897                                    closeSession(session);
12898                            }
12899                    }
12900    
12901                    return list;
12902            }
12903    
12904            /**
12905             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
12906             *
12907             * <p>
12908             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12909             * </p>
12910             *
12911             * @param groupId the group ID
12912             * @param urlTitle the url title
12913             * @param status the status
12914             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12915             * @return the first matching journal article
12916             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12917             * @throws SystemException if a system exception occurred
12918             */
12919            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
12920                    int status, OrderByComparator orderByComparator)
12921                    throws NoSuchArticleException, SystemException {
12922                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
12923                                    1, orderByComparator);
12924    
12925                    if (list.isEmpty()) {
12926                            StringBundler msg = new StringBundler(8);
12927    
12928                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12929    
12930                            msg.append("groupId=");
12931                            msg.append(groupId);
12932    
12933                            msg.append(", urlTitle=");
12934                            msg.append(urlTitle);
12935    
12936                            msg.append(", status=");
12937                            msg.append(status);
12938    
12939                            msg.append(StringPool.CLOSE_CURLY_BRACE);
12940    
12941                            throw new NoSuchArticleException(msg.toString());
12942                    }
12943                    else {
12944                            return list.get(0);
12945                    }
12946            }
12947    
12948            /**
12949             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
12950             *
12951             * <p>
12952             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12953             * </p>
12954             *
12955             * @param groupId the group ID
12956             * @param urlTitle the url title
12957             * @param status the status
12958             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12959             * @return the last matching journal article
12960             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12961             * @throws SystemException if a system exception occurred
12962             */
12963            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
12964                    int status, OrderByComparator orderByComparator)
12965                    throws NoSuchArticleException, SystemException {
12966                    int count = countByG_UT_ST(groupId, urlTitle, status);
12967    
12968                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
12969                                    count - 1, count, orderByComparator);
12970    
12971                    if (list.isEmpty()) {
12972                            StringBundler msg = new StringBundler(8);
12973    
12974                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12975    
12976                            msg.append("groupId=");
12977                            msg.append(groupId);
12978    
12979                            msg.append(", urlTitle=");
12980                            msg.append(urlTitle);
12981    
12982                            msg.append(", status=");
12983                            msg.append(status);
12984    
12985                            msg.append(StringPool.CLOSE_CURLY_BRACE);
12986    
12987                            throw new NoSuchArticleException(msg.toString());
12988                    }
12989                    else {
12990                            return list.get(0);
12991                    }
12992            }
12993    
12994            /**
12995             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
12996             *
12997             * <p>
12998             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12999             * </p>
13000             *
13001             * @param id the primary key of the current journal article
13002             * @param groupId the group ID
13003             * @param urlTitle the url title
13004             * @param status the status
13005             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13006             * @return the previous, current, and next journal article
13007             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13008             * @throws SystemException if a system exception occurred
13009             */
13010            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
13011                    String urlTitle, int status, OrderByComparator orderByComparator)
13012                    throws NoSuchArticleException, SystemException {
13013                    JournalArticle journalArticle = findByPrimaryKey(id);
13014    
13015                    Session session = null;
13016    
13017                    try {
13018                            session = openSession();
13019    
13020                            JournalArticle[] array = new JournalArticleImpl[3];
13021    
13022                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
13023                                            groupId, urlTitle, status, orderByComparator, true);
13024    
13025                            array[1] = journalArticle;
13026    
13027                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
13028                                            groupId, urlTitle, status, orderByComparator, false);
13029    
13030                            return array;
13031                    }
13032                    catch (Exception e) {
13033                            throw processException(e);
13034                    }
13035                    finally {
13036                            closeSession(session);
13037                    }
13038            }
13039    
13040            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
13041                    JournalArticle journalArticle, long groupId, String urlTitle,
13042                    int status, OrderByComparator orderByComparator, boolean previous) {
13043                    StringBundler query = null;
13044    
13045                    if (orderByComparator != null) {
13046                            query = new StringBundler(6 +
13047                                            (orderByComparator.getOrderByFields().length * 6));
13048                    }
13049                    else {
13050                            query = new StringBundler(3);
13051                    }
13052    
13053                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13054    
13055                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
13056    
13057                    if (urlTitle == null) {
13058                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
13059                    }
13060                    else {
13061                            if (urlTitle.equals(StringPool.BLANK)) {
13062                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
13063                            }
13064                            else {
13065                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
13066                            }
13067                    }
13068    
13069                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
13070    
13071                    if (orderByComparator != null) {
13072                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13073    
13074                            if (orderByConditionFields.length > 0) {
13075                                    query.append(WHERE_AND);
13076                            }
13077    
13078                            for (int i = 0; i < orderByConditionFields.length; i++) {
13079                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13080                                    query.append(orderByConditionFields[i]);
13081    
13082                                    if ((i + 1) < orderByConditionFields.length) {
13083                                            if (orderByComparator.isAscending() ^ previous) {
13084                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13085                                            }
13086                                            else {
13087                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13088                                            }
13089                                    }
13090                                    else {
13091                                            if (orderByComparator.isAscending() ^ previous) {
13092                                                    query.append(WHERE_GREATER_THAN);
13093                                            }
13094                                            else {
13095                                                    query.append(WHERE_LESSER_THAN);
13096                                            }
13097                                    }
13098                            }
13099    
13100                            query.append(ORDER_BY_CLAUSE);
13101    
13102                            String[] orderByFields = orderByComparator.getOrderByFields();
13103    
13104                            for (int i = 0; i < orderByFields.length; i++) {
13105                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13106                                    query.append(orderByFields[i]);
13107    
13108                                    if ((i + 1) < orderByFields.length) {
13109                                            if (orderByComparator.isAscending() ^ previous) {
13110                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13111                                            }
13112                                            else {
13113                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13114                                            }
13115                                    }
13116                                    else {
13117                                            if (orderByComparator.isAscending() ^ previous) {
13118                                                    query.append(ORDER_BY_ASC);
13119                                            }
13120                                            else {
13121                                                    query.append(ORDER_BY_DESC);
13122                                            }
13123                                    }
13124                            }
13125                    }
13126    
13127                    else {
13128                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13129                    }
13130    
13131                    String sql = query.toString();
13132    
13133                    Query q = session.createQuery(sql);
13134    
13135                    q.setFirstResult(0);
13136                    q.setMaxResults(2);
13137    
13138                    QueryPos qPos = QueryPos.getInstance(q);
13139    
13140                    qPos.add(groupId);
13141    
13142                    if (urlTitle != null) {
13143                            qPos.add(urlTitle);
13144                    }
13145    
13146                    qPos.add(status);
13147    
13148                    if (orderByComparator != null) {
13149                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13150    
13151                            for (Object value : values) {
13152                                    qPos.add(value);
13153                            }
13154                    }
13155    
13156                    List<JournalArticle> list = q.list();
13157    
13158                    if (list.size() == 2) {
13159                            return list.get(1);
13160                    }
13161                    else {
13162                            return null;
13163                    }
13164            }
13165    
13166            /**
13167             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13168             *
13169             * @param groupId the group ID
13170             * @param urlTitle the url title
13171             * @param status the status
13172             * @return the matching journal articles that the user has permission to view
13173             * @throws SystemException if a system exception occurred
13174             */
13175            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
13176                    String urlTitle, int status) throws SystemException {
13177                    return filterFindByG_UT_ST(groupId, urlTitle, status,
13178                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13179            }
13180    
13181            /**
13182             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13183             *
13184             * <p>
13185             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13186             * </p>
13187             *
13188             * @param groupId the group ID
13189             * @param urlTitle the url title
13190             * @param status the status
13191             * @param start the lower bound of the range of journal articles
13192             * @param end the upper bound of the range of journal articles (not inclusive)
13193             * @return the range of matching journal articles that the user has permission to view
13194             * @throws SystemException if a system exception occurred
13195             */
13196            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
13197                    String urlTitle, int status, int start, int end)
13198                    throws SystemException {
13199                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
13200            }
13201    
13202            /**
13203             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13204             *
13205             * <p>
13206             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13207             * </p>
13208             *
13209             * @param groupId the group ID
13210             * @param urlTitle the url title
13211             * @param status the status
13212             * @param start the lower bound of the range of journal articles
13213             * @param end the upper bound of the range of journal articles (not inclusive)
13214             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13215             * @return the ordered range of matching journal articles that the user has permission to view
13216             * @throws SystemException if a system exception occurred
13217             */
13218            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
13219                    String urlTitle, int status, int start, int end,
13220                    OrderByComparator orderByComparator) throws SystemException {
13221                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13222                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
13223                                    orderByComparator);
13224                    }
13225    
13226                    StringBundler query = null;
13227    
13228                    if (orderByComparator != null) {
13229                            query = new StringBundler(5 +
13230                                            (orderByComparator.getOrderByFields().length * 3));
13231                    }
13232                    else {
13233                            query = new StringBundler(5);
13234                    }
13235    
13236                    if (getDB().isSupportsInlineDistinct()) {
13237                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13238                    }
13239                    else {
13240                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13241                    }
13242    
13243                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
13244    
13245                    if (urlTitle == null) {
13246                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
13247                    }
13248                    else {
13249                            if (urlTitle.equals(StringPool.BLANK)) {
13250                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
13251                            }
13252                            else {
13253                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
13254                            }
13255                    }
13256    
13257                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
13258    
13259                    if (!getDB().isSupportsInlineDistinct()) {
13260                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13261                    }
13262    
13263                    if (orderByComparator != null) {
13264                            if (getDB().isSupportsInlineDistinct()) {
13265                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13266                                            orderByComparator);
13267                            }
13268                            else {
13269                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13270                                            orderByComparator);
13271                            }
13272                    }
13273    
13274                    else {
13275                            if (getDB().isSupportsInlineDistinct()) {
13276                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13277                            }
13278                            else {
13279                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13280                            }
13281                    }
13282    
13283                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13284                                    JournalArticle.class.getName(),
13285                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13286    
13287                    Session session = null;
13288    
13289                    try {
13290                            session = openSession();
13291    
13292                            SQLQuery q = session.createSQLQuery(sql);
13293    
13294                            if (getDB().isSupportsInlineDistinct()) {
13295                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13296                            }
13297                            else {
13298                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13299                            }
13300    
13301                            QueryPos qPos = QueryPos.getInstance(q);
13302    
13303                            qPos.add(groupId);
13304    
13305                            if (urlTitle != null) {
13306                                    qPos.add(urlTitle);
13307                            }
13308    
13309                            qPos.add(status);
13310    
13311                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13312                                    end);
13313                    }
13314                    catch (Exception e) {
13315                            throw processException(e);
13316                    }
13317                    finally {
13318                            closeSession(session);
13319                    }
13320            }
13321    
13322            /**
13323             * Returns the journal articles before and after the current journal article in the ordered set of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13324             *
13325             * @param id the primary key of the current journal article
13326             * @param groupId the group ID
13327             * @param urlTitle the url title
13328             * @param status the status
13329             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13330             * @return the previous, current, and next journal article
13331             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13332             * @throws SystemException if a system exception occurred
13333             */
13334            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
13335                    long groupId, String urlTitle, int status,
13336                    OrderByComparator orderByComparator)
13337                    throws NoSuchArticleException, SystemException {
13338                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13339                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
13340                                    orderByComparator);
13341                    }
13342    
13343                    JournalArticle journalArticle = findByPrimaryKey(id);
13344    
13345                    Session session = null;
13346    
13347                    try {
13348                            session = openSession();
13349    
13350                            JournalArticle[] array = new JournalArticleImpl[3];
13351    
13352                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
13353                                            groupId, urlTitle, status, orderByComparator, true);
13354    
13355                            array[1] = journalArticle;
13356    
13357                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
13358                                            groupId, urlTitle, status, orderByComparator, false);
13359    
13360                            return array;
13361                    }
13362                    catch (Exception e) {
13363                            throw processException(e);
13364                    }
13365                    finally {
13366                            closeSession(session);
13367                    }
13368            }
13369    
13370            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
13371                    JournalArticle journalArticle, long groupId, String urlTitle,
13372                    int status, OrderByComparator orderByComparator, boolean previous) {
13373                    StringBundler query = null;
13374    
13375                    if (orderByComparator != null) {
13376                            query = new StringBundler(6 +
13377                                            (orderByComparator.getOrderByFields().length * 6));
13378                    }
13379                    else {
13380                            query = new StringBundler(3);
13381                    }
13382    
13383                    if (getDB().isSupportsInlineDistinct()) {
13384                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13385                    }
13386                    else {
13387                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13388                    }
13389    
13390                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
13391    
13392                    if (urlTitle == null) {
13393                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
13394                    }
13395                    else {
13396                            if (urlTitle.equals(StringPool.BLANK)) {
13397                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
13398                            }
13399                            else {
13400                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
13401                            }
13402                    }
13403    
13404                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
13405    
13406                    if (!getDB().isSupportsInlineDistinct()) {
13407                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13408                    }
13409    
13410                    if (orderByComparator != null) {
13411                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13412    
13413                            if (orderByConditionFields.length > 0) {
13414                                    query.append(WHERE_AND);
13415                            }
13416    
13417                            for (int i = 0; i < orderByConditionFields.length; i++) {
13418                                    if (getDB().isSupportsInlineDistinct()) {
13419                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13420                                    }
13421                                    else {
13422                                            query.append(_ORDER_BY_ENTITY_TABLE);
13423                                    }
13424    
13425                                    query.append(orderByConditionFields[i]);
13426    
13427                                    if ((i + 1) < orderByConditionFields.length) {
13428                                            if (orderByComparator.isAscending() ^ previous) {
13429                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13430                                            }
13431                                            else {
13432                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13433                                            }
13434                                    }
13435                                    else {
13436                                            if (orderByComparator.isAscending() ^ previous) {
13437                                                    query.append(WHERE_GREATER_THAN);
13438                                            }
13439                                            else {
13440                                                    query.append(WHERE_LESSER_THAN);
13441                                            }
13442                                    }
13443                            }
13444    
13445                            query.append(ORDER_BY_CLAUSE);
13446    
13447                            String[] orderByFields = orderByComparator.getOrderByFields();
13448    
13449                            for (int i = 0; i < orderByFields.length; i++) {
13450                                    if (getDB().isSupportsInlineDistinct()) {
13451                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13452                                    }
13453                                    else {
13454                                            query.append(_ORDER_BY_ENTITY_TABLE);
13455                                    }
13456    
13457                                    query.append(orderByFields[i]);
13458    
13459                                    if ((i + 1) < orderByFields.length) {
13460                                            if (orderByComparator.isAscending() ^ previous) {
13461                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13462                                            }
13463                                            else {
13464                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13465                                            }
13466                                    }
13467                                    else {
13468                                            if (orderByComparator.isAscending() ^ previous) {
13469                                                    query.append(ORDER_BY_ASC);
13470                                            }
13471                                            else {
13472                                                    query.append(ORDER_BY_DESC);
13473                                            }
13474                                    }
13475                            }
13476                    }
13477    
13478                    else {
13479                            if (getDB().isSupportsInlineDistinct()) {
13480                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13481                            }
13482                            else {
13483                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13484                            }
13485                    }
13486    
13487                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13488                                    JournalArticle.class.getName(),
13489                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13490    
13491                    SQLQuery q = session.createSQLQuery(sql);
13492    
13493                    q.setFirstResult(0);
13494                    q.setMaxResults(2);
13495    
13496                    if (getDB().isSupportsInlineDistinct()) {
13497                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13498                    }
13499                    else {
13500                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13501                    }
13502    
13503                    QueryPos qPos = QueryPos.getInstance(q);
13504    
13505                    qPos.add(groupId);
13506    
13507                    if (urlTitle != null) {
13508                            qPos.add(urlTitle);
13509                    }
13510    
13511                    qPos.add(status);
13512    
13513                    if (orderByComparator != null) {
13514                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13515    
13516                            for (Object value : values) {
13517                                    qPos.add(value);
13518                            }
13519                    }
13520    
13521                    List<JournalArticle> list = q.list();
13522    
13523                    if (list.size() == 2) {
13524                            return list.get(1);
13525                    }
13526                    else {
13527                            return null;
13528                    }
13529            }
13530    
13531            /**
13532             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
13533             *
13534             * @param companyId the company ID
13535             * @param version the version
13536             * @param status the status
13537             * @return the matching journal articles
13538             * @throws SystemException if a system exception occurred
13539             */
13540            public List<JournalArticle> findByC_V_ST(long companyId, double version,
13541                    int status) throws SystemException {
13542                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
13543                            QueryUtil.ALL_POS, null);
13544            }
13545    
13546            /**
13547             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
13548             *
13549             * <p>
13550             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13551             * </p>
13552             *
13553             * @param companyId the company ID
13554             * @param version the version
13555             * @param status the status
13556             * @param start the lower bound of the range of journal articles
13557             * @param end the upper bound of the range of journal articles (not inclusive)
13558             * @return the range of matching journal articles
13559             * @throws SystemException if a system exception occurred
13560             */
13561            public List<JournalArticle> findByC_V_ST(long companyId, double version,
13562                    int status, int start, int end) throws SystemException {
13563                    return findByC_V_ST(companyId, version, status, start, end, null);
13564            }
13565    
13566            /**
13567             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
13568             *
13569             * <p>
13570             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13571             * </p>
13572             *
13573             * @param companyId the company ID
13574             * @param version the version
13575             * @param status the status
13576             * @param start the lower bound of the range of journal articles
13577             * @param end the upper bound of the range of journal articles (not inclusive)
13578             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13579             * @return the ordered range of matching journal articles
13580             * @throws SystemException if a system exception occurred
13581             */
13582            public List<JournalArticle> findByC_V_ST(long companyId, double version,
13583                    int status, int start, int end, OrderByComparator orderByComparator)
13584                    throws SystemException {
13585                    FinderPath finderPath = null;
13586                    Object[] finderArgs = null;
13587    
13588                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13589                                    (orderByComparator == null)) {
13590                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
13591                            finderArgs = new Object[] { companyId, version, status };
13592                    }
13593                    else {
13594                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
13595                            finderArgs = new Object[] {
13596                                            companyId, version, status,
13597                                            
13598                                            start, end, orderByComparator
13599                                    };
13600                    }
13601    
13602                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13603                                    finderArgs, this);
13604    
13605                    if (list == null) {
13606                            StringBundler query = null;
13607    
13608                            if (orderByComparator != null) {
13609                                    query = new StringBundler(5 +
13610                                                    (orderByComparator.getOrderByFields().length * 3));
13611                            }
13612                            else {
13613                                    query = new StringBundler(5);
13614                            }
13615    
13616                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13617    
13618                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
13619    
13620                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
13621    
13622                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
13623    
13624                            if (orderByComparator != null) {
13625                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13626                                            orderByComparator);
13627                            }
13628    
13629                            else {
13630                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13631                            }
13632    
13633                            String sql = query.toString();
13634    
13635                            Session session = null;
13636    
13637                            try {
13638                                    session = openSession();
13639    
13640                                    Query q = session.createQuery(sql);
13641    
13642                                    QueryPos qPos = QueryPos.getInstance(q);
13643    
13644                                    qPos.add(companyId);
13645    
13646                                    qPos.add(version);
13647    
13648                                    qPos.add(status);
13649    
13650                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
13651                                                    start, end);
13652                            }
13653                            catch (Exception e) {
13654                                    throw processException(e);
13655                            }
13656                            finally {
13657                                    if (list == null) {
13658                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
13659                                    }
13660                                    else {
13661                                            cacheResult(list);
13662    
13663                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
13664                                    }
13665    
13666                                    closeSession(session);
13667                            }
13668                    }
13669    
13670                    return list;
13671            }
13672    
13673            /**
13674             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
13675             *
13676             * <p>
13677             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13678             * </p>
13679             *
13680             * @param companyId the company ID
13681             * @param version the version
13682             * @param status the status
13683             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13684             * @return the first matching journal article
13685             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13686             * @throws SystemException if a system exception occurred
13687             */
13688            public JournalArticle findByC_V_ST_First(long companyId, double version,
13689                    int status, OrderByComparator orderByComparator)
13690                    throws NoSuchArticleException, SystemException {
13691                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
13692                                    1, orderByComparator);
13693    
13694                    if (list.isEmpty()) {
13695                            StringBundler msg = new StringBundler(8);
13696    
13697                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13698    
13699                            msg.append("companyId=");
13700                            msg.append(companyId);
13701    
13702                            msg.append(", version=");
13703                            msg.append(version);
13704    
13705                            msg.append(", status=");
13706                            msg.append(status);
13707    
13708                            msg.append(StringPool.CLOSE_CURLY_BRACE);
13709    
13710                            throw new NoSuchArticleException(msg.toString());
13711                    }
13712                    else {
13713                            return list.get(0);
13714                    }
13715            }
13716    
13717            /**
13718             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
13719             *
13720             * <p>
13721             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13722             * </p>
13723             *
13724             * @param companyId the company ID
13725             * @param version the version
13726             * @param status the status
13727             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13728             * @return the last matching journal article
13729             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13730             * @throws SystemException if a system exception occurred
13731             */
13732            public JournalArticle findByC_V_ST_Last(long companyId, double version,
13733                    int status, OrderByComparator orderByComparator)
13734                    throws NoSuchArticleException, SystemException {
13735                    int count = countByC_V_ST(companyId, version, status);
13736    
13737                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
13738                                    count - 1, count, orderByComparator);
13739    
13740                    if (list.isEmpty()) {
13741                            StringBundler msg = new StringBundler(8);
13742    
13743                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13744    
13745                            msg.append("companyId=");
13746                            msg.append(companyId);
13747    
13748                            msg.append(", version=");
13749                            msg.append(version);
13750    
13751                            msg.append(", status=");
13752                            msg.append(status);
13753    
13754                            msg.append(StringPool.CLOSE_CURLY_BRACE);
13755    
13756                            throw new NoSuchArticleException(msg.toString());
13757                    }
13758                    else {
13759                            return list.get(0);
13760                    }
13761            }
13762    
13763            /**
13764             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
13765             *
13766             * <p>
13767             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13768             * </p>
13769             *
13770             * @param id the primary key of the current journal article
13771             * @param companyId the company ID
13772             * @param version the version
13773             * @param status the status
13774             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13775             * @return the previous, current, and next journal article
13776             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13777             * @throws SystemException if a system exception occurred
13778             */
13779            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
13780                    double version, int status, OrderByComparator orderByComparator)
13781                    throws NoSuchArticleException, SystemException {
13782                    JournalArticle journalArticle = findByPrimaryKey(id);
13783    
13784                    Session session = null;
13785    
13786                    try {
13787                            session = openSession();
13788    
13789                            JournalArticle[] array = new JournalArticleImpl[3];
13790    
13791                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
13792                                            companyId, version, status, orderByComparator, true);
13793    
13794                            array[1] = journalArticle;
13795    
13796                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
13797                                            companyId, version, status, orderByComparator, false);
13798    
13799                            return array;
13800                    }
13801                    catch (Exception e) {
13802                            throw processException(e);
13803                    }
13804                    finally {
13805                            closeSession(session);
13806                    }
13807            }
13808    
13809            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
13810                    JournalArticle journalArticle, long companyId, double version,
13811                    int status, OrderByComparator orderByComparator, boolean previous) {
13812                    StringBundler query = null;
13813    
13814                    if (orderByComparator != null) {
13815                            query = new StringBundler(6 +
13816                                            (orderByComparator.getOrderByFields().length * 6));
13817                    }
13818                    else {
13819                            query = new StringBundler(3);
13820                    }
13821    
13822                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13823    
13824                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
13825    
13826                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
13827    
13828                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
13829    
13830                    if (orderByComparator != null) {
13831                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13832    
13833                            if (orderByConditionFields.length > 0) {
13834                                    query.append(WHERE_AND);
13835                            }
13836    
13837                            for (int i = 0; i < orderByConditionFields.length; i++) {
13838                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13839                                    query.append(orderByConditionFields[i]);
13840    
13841                                    if ((i + 1) < orderByConditionFields.length) {
13842                                            if (orderByComparator.isAscending() ^ previous) {
13843                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13844                                            }
13845                                            else {
13846                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13847                                            }
13848                                    }
13849                                    else {
13850                                            if (orderByComparator.isAscending() ^ previous) {
13851                                                    query.append(WHERE_GREATER_THAN);
13852                                            }
13853                                            else {
13854                                                    query.append(WHERE_LESSER_THAN);
13855                                            }
13856                                    }
13857                            }
13858    
13859                            query.append(ORDER_BY_CLAUSE);
13860    
13861                            String[] orderByFields = orderByComparator.getOrderByFields();
13862    
13863                            for (int i = 0; i < orderByFields.length; i++) {
13864                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13865                                    query.append(orderByFields[i]);
13866    
13867                                    if ((i + 1) < orderByFields.length) {
13868                                            if (orderByComparator.isAscending() ^ previous) {
13869                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13870                                            }
13871                                            else {
13872                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13873                                            }
13874                                    }
13875                                    else {
13876                                            if (orderByComparator.isAscending() ^ previous) {
13877                                                    query.append(ORDER_BY_ASC);
13878                                            }
13879                                            else {
13880                                                    query.append(ORDER_BY_DESC);
13881                                            }
13882                                    }
13883                            }
13884                    }
13885    
13886                    else {
13887                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13888                    }
13889    
13890                    String sql = query.toString();
13891    
13892                    Query q = session.createQuery(sql);
13893    
13894                    q.setFirstResult(0);
13895                    q.setMaxResults(2);
13896    
13897                    QueryPos qPos = QueryPos.getInstance(q);
13898    
13899                    qPos.add(companyId);
13900    
13901                    qPos.add(version);
13902    
13903                    qPos.add(status);
13904    
13905                    if (orderByComparator != null) {
13906                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13907    
13908                            for (Object value : values) {
13909                                    qPos.add(value);
13910                            }
13911                    }
13912    
13913                    List<JournalArticle> list = q.list();
13914    
13915                    if (list.size() == 2) {
13916                            return list.get(1);
13917                    }
13918                    else {
13919                            return null;
13920                    }
13921            }
13922    
13923            /**
13924             * Returns all the journal articles.
13925             *
13926             * @return the journal articles
13927             * @throws SystemException if a system exception occurred
13928             */
13929            public List<JournalArticle> findAll() throws SystemException {
13930                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13931            }
13932    
13933            /**
13934             * Returns a range of all the journal articles.
13935             *
13936             * <p>
13937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13938             * </p>
13939             *
13940             * @param start the lower bound of the range of journal articles
13941             * @param end the upper bound of the range of journal articles (not inclusive)
13942             * @return the range of journal articles
13943             * @throws SystemException if a system exception occurred
13944             */
13945            public List<JournalArticle> findAll(int start, int end)
13946                    throws SystemException {
13947                    return findAll(start, end, null);
13948            }
13949    
13950            /**
13951             * Returns an ordered range of all the journal articles.
13952             *
13953             * <p>
13954             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13955             * </p>
13956             *
13957             * @param start the lower bound of the range of journal articles
13958             * @param end the upper bound of the range of journal articles (not inclusive)
13959             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13960             * @return the ordered range of journal articles
13961             * @throws SystemException if a system exception occurred
13962             */
13963            public List<JournalArticle> findAll(int start, int end,
13964                    OrderByComparator orderByComparator) throws SystemException {
13965                    FinderPath finderPath = null;
13966                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
13967    
13968                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13969                                    (orderByComparator == null)) {
13970                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
13971                            finderArgs = FINDER_ARGS_EMPTY;
13972                    }
13973                    else {
13974                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
13975                            finderArgs = new Object[] { start, end, orderByComparator };
13976                    }
13977    
13978                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13979                                    finderArgs, this);
13980    
13981                    if (list == null) {
13982                            StringBundler query = null;
13983                            String sql = null;
13984    
13985                            if (orderByComparator != null) {
13986                                    query = new StringBundler(2 +
13987                                                    (orderByComparator.getOrderByFields().length * 3));
13988    
13989                                    query.append(_SQL_SELECT_JOURNALARTICLE);
13990    
13991                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13992                                            orderByComparator);
13993    
13994                                    sql = query.toString();
13995                            }
13996                            else {
13997                                    sql = _SQL_SELECT_JOURNALARTICLE.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
13998                            }
13999    
14000                            Session session = null;
14001    
14002                            try {
14003                                    session = openSession();
14004    
14005                                    Query q = session.createQuery(sql);
14006    
14007                                    if (orderByComparator == null) {
14008                                            list = (List<JournalArticle>)QueryUtil.list(q,
14009                                                            getDialect(), start, end, false);
14010    
14011                                            Collections.sort(list);
14012                                    }
14013                                    else {
14014                                            list = (List<JournalArticle>)QueryUtil.list(q,
14015                                                            getDialect(), start, end);
14016                                    }
14017                            }
14018                            catch (Exception e) {
14019                                    throw processException(e);
14020                            }
14021                            finally {
14022                                    if (list == null) {
14023                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
14024                                    }
14025                                    else {
14026                                            cacheResult(list);
14027    
14028                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
14029                                    }
14030    
14031                                    closeSession(session);
14032                            }
14033                    }
14034    
14035                    return list;
14036            }
14037    
14038            /**
14039             * Removes all the journal articles where uuid = &#63; from the database.
14040             *
14041             * @param uuid the uuid
14042             * @throws SystemException if a system exception occurred
14043             */
14044            public void removeByUuid(String uuid) throws SystemException {
14045                    for (JournalArticle journalArticle : findByUuid(uuid)) {
14046                            remove(journalArticle);
14047                    }
14048            }
14049    
14050            /**
14051             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
14052             *
14053             * @param uuid the uuid
14054             * @param groupId the group ID
14055             * @throws SystemException if a system exception occurred
14056             */
14057            public void removeByUUID_G(String uuid, long groupId)
14058                    throws NoSuchArticleException, SystemException {
14059                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
14060    
14061                    remove(journalArticle);
14062            }
14063    
14064            /**
14065             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
14066             *
14067             * @param resourcePrimKey the resource prim key
14068             * @throws SystemException if a system exception occurred
14069             */
14070            public void removeByResourcePrimKey(long resourcePrimKey)
14071                    throws SystemException {
14072                    for (JournalArticle journalArticle : findByResourcePrimKey(
14073                                    resourcePrimKey)) {
14074                            remove(journalArticle);
14075                    }
14076            }
14077    
14078            /**
14079             * Removes all the journal articles where groupId = &#63; from the database.
14080             *
14081             * @param groupId the group ID
14082             * @throws SystemException if a system exception occurred
14083             */
14084            public void removeByGroupId(long groupId) throws SystemException {
14085                    for (JournalArticle journalArticle : findByGroupId(groupId)) {
14086                            remove(journalArticle);
14087                    }
14088            }
14089    
14090            /**
14091             * Removes all the journal articles where companyId = &#63; from the database.
14092             *
14093             * @param companyId the company ID
14094             * @throws SystemException if a system exception occurred
14095             */
14096            public void removeByCompanyId(long companyId) throws SystemException {
14097                    for (JournalArticle journalArticle : findByCompanyId(companyId)) {
14098                            remove(journalArticle);
14099                    }
14100            }
14101    
14102            /**
14103             * Removes all the journal articles where smallImageId = &#63; from the database.
14104             *
14105             * @param smallImageId the small image ID
14106             * @throws SystemException if a system exception occurred
14107             */
14108            public void removeBySmallImageId(long smallImageId)
14109                    throws SystemException {
14110                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId)) {
14111                            remove(journalArticle);
14112                    }
14113            }
14114    
14115            /**
14116             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
14117             *
14118             * @param resourcePrimKey the resource prim key
14119             * @param status the status
14120             * @throws SystemException if a system exception occurred
14121             */
14122            public void removeByR_ST(long resourcePrimKey, int status)
14123                    throws SystemException {
14124                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey, status)) {
14125                            remove(journalArticle);
14126                    }
14127            }
14128    
14129            /**
14130             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
14131             *
14132             * @param groupId the group ID
14133             * @param articleId the article ID
14134             * @throws SystemException if a system exception occurred
14135             */
14136            public void removeByG_A(long groupId, String articleId)
14137                    throws SystemException {
14138                    for (JournalArticle journalArticle : findByG_A(groupId, articleId)) {
14139                            remove(journalArticle);
14140                    }
14141            }
14142    
14143            /**
14144             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
14145             *
14146             * @param groupId the group ID
14147             * @param urlTitle the url title
14148             * @throws SystemException if a system exception occurred
14149             */
14150            public void removeByG_UT(long groupId, String urlTitle)
14151                    throws SystemException {
14152                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle)) {
14153                            remove(journalArticle);
14154                    }
14155            }
14156    
14157            /**
14158             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
14159             *
14160             * @param groupId the group ID
14161             * @param structureId the structure ID
14162             * @throws SystemException if a system exception occurred
14163             */
14164            public void removeByG_S(long groupId, String structureId)
14165                    throws SystemException {
14166                    for (JournalArticle journalArticle : findByG_S(groupId, structureId)) {
14167                            remove(journalArticle);
14168                    }
14169            }
14170    
14171            /**
14172             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
14173             *
14174             * @param groupId the group ID
14175             * @param templateId the template ID
14176             * @throws SystemException if a system exception occurred
14177             */
14178            public void removeByG_T(long groupId, String templateId)
14179                    throws SystemException {
14180                    for (JournalArticle journalArticle : findByG_T(groupId, templateId)) {
14181                            remove(journalArticle);
14182                    }
14183            }
14184    
14185            /**
14186             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
14187             *
14188             * @param groupId the group ID
14189             * @param layoutUuid the layout uuid
14190             * @throws SystemException if a system exception occurred
14191             */
14192            public void removeByG_L(long groupId, String layoutUuid)
14193                    throws SystemException {
14194                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid)) {
14195                            remove(journalArticle);
14196                    }
14197            }
14198    
14199            /**
14200             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
14201             *
14202             * @param groupId the group ID
14203             * @param status the status
14204             * @throws SystemException if a system exception occurred
14205             */
14206            public void removeByG_ST(long groupId, int status)
14207                    throws SystemException {
14208                    for (JournalArticle journalArticle : findByG_ST(groupId, status)) {
14209                            remove(journalArticle);
14210                    }
14211            }
14212    
14213            /**
14214             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
14215             *
14216             * @param companyId the company ID
14217             * @param version the version
14218             * @throws SystemException if a system exception occurred
14219             */
14220            public void removeByC_V(long companyId, double version)
14221                    throws SystemException {
14222                    for (JournalArticle journalArticle : findByC_V(companyId, version)) {
14223                            remove(journalArticle);
14224                    }
14225            }
14226    
14227            /**
14228             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
14229             *
14230             * @param companyId the company ID
14231             * @param status the status
14232             * @throws SystemException if a system exception occurred
14233             */
14234            public void removeByC_ST(long companyId, int status)
14235                    throws SystemException {
14236                    for (JournalArticle journalArticle : findByC_ST(companyId, status)) {
14237                            remove(journalArticle);
14238                    }
14239            }
14240    
14241            /**
14242             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
14243             *
14244             * @param groupId the group ID
14245             * @param classNameId the class name ID
14246             * @param classPK the class p k
14247             * @throws SystemException if a system exception occurred
14248             */
14249            public void removeByG_C_C(long groupId, long classNameId, long classPK)
14250                    throws SystemException {
14251                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
14252                                    classPK)) {
14253                            remove(journalArticle);
14254                    }
14255            }
14256    
14257            /**
14258             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
14259             *
14260             * @param groupId the group ID
14261             * @param classNameId the class name ID
14262             * @param structureId the structure ID
14263             * @throws SystemException if a system exception occurred
14264             */
14265            public void removeByG_C_S(long groupId, long classNameId, String structureId)
14266                    throws NoSuchArticleException, SystemException {
14267                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
14268                                    structureId);
14269    
14270                    remove(journalArticle);
14271            }
14272    
14273            /**
14274             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
14275             *
14276             * @param groupId the group ID
14277             * @param classNameId the class name ID
14278             * @param templateId the template ID
14279             * @throws SystemException if a system exception occurred
14280             */
14281            public void removeByG_C_T(long groupId, long classNameId, String templateId)
14282                    throws SystemException {
14283                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
14284                                    templateId)) {
14285                            remove(journalArticle);
14286                    }
14287            }
14288    
14289            /**
14290             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
14291             *
14292             * @param groupId the group ID
14293             * @param classNameId the class name ID
14294             * @param layoutUuid the layout uuid
14295             * @throws SystemException if a system exception occurred
14296             */
14297            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
14298                    throws SystemException {
14299                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
14300                                    layoutUuid)) {
14301                            remove(journalArticle);
14302                    }
14303            }
14304    
14305            /**
14306             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
14307             *
14308             * @param groupId the group ID
14309             * @param articleId the article ID
14310             * @param version the version
14311             * @throws SystemException if a system exception occurred
14312             */
14313            public void removeByG_A_V(long groupId, String articleId, double version)
14314                    throws NoSuchArticleException, SystemException {
14315                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
14316    
14317                    remove(journalArticle);
14318            }
14319    
14320            /**
14321             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
14322             *
14323             * @param groupId the group ID
14324             * @param articleId the article ID
14325             * @param status the status
14326             * @throws SystemException if a system exception occurred
14327             */
14328            public void removeByG_A_ST(long groupId, String articleId, int status)
14329                    throws SystemException {
14330                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
14331                                    status)) {
14332                            remove(journalArticle);
14333                    }
14334            }
14335    
14336            /**
14337             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
14338             *
14339             * @param groupId the group ID
14340             * @param urlTitle the url title
14341             * @param status the status
14342             * @throws SystemException if a system exception occurred
14343             */
14344            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
14345                    throws SystemException {
14346                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
14347                                    status)) {
14348                            remove(journalArticle);
14349                    }
14350            }
14351    
14352            /**
14353             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
14354             *
14355             * @param companyId the company ID
14356             * @param version the version
14357             * @param status the status
14358             * @throws SystemException if a system exception occurred
14359             */
14360            public void removeByC_V_ST(long companyId, double version, int status)
14361                    throws SystemException {
14362                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
14363                                    status)) {
14364                            remove(journalArticle);
14365                    }
14366            }
14367    
14368            /**
14369             * Removes all the journal articles from the database.
14370             *
14371             * @throws SystemException if a system exception occurred
14372             */
14373            public void removeAll() throws SystemException {
14374                    for (JournalArticle journalArticle : findAll()) {
14375                            remove(journalArticle);
14376                    }
14377            }
14378    
14379            /**
14380             * Returns the number of journal articles where uuid = &#63;.
14381             *
14382             * @param uuid the uuid
14383             * @return the number of matching journal articles
14384             * @throws SystemException if a system exception occurred
14385             */
14386            public int countByUuid(String uuid) throws SystemException {
14387                    Object[] finderArgs = new Object[] { uuid };
14388    
14389                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
14390                                    finderArgs, this);
14391    
14392                    if (count == null) {
14393                            StringBundler query = new StringBundler(2);
14394    
14395                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14396    
14397                            if (uuid == null) {
14398                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
14399                            }
14400                            else {
14401                                    if (uuid.equals(StringPool.BLANK)) {
14402                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
14403                                    }
14404                                    else {
14405                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
14406                                    }
14407                            }
14408    
14409                            String sql = query.toString();
14410    
14411                            Session session = null;
14412    
14413                            try {
14414                                    session = openSession();
14415    
14416                                    Query q = session.createQuery(sql);
14417    
14418                                    QueryPos qPos = QueryPos.getInstance(q);
14419    
14420                                    if (uuid != null) {
14421                                            qPos.add(uuid);
14422                                    }
14423    
14424                                    count = (Long)q.uniqueResult();
14425                            }
14426                            catch (Exception e) {
14427                                    throw processException(e);
14428                            }
14429                            finally {
14430                                    if (count == null) {
14431                                            count = Long.valueOf(0);
14432                                    }
14433    
14434                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
14435                                            finderArgs, count);
14436    
14437                                    closeSession(session);
14438                            }
14439                    }
14440    
14441                    return count.intValue();
14442            }
14443    
14444            /**
14445             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
14446             *
14447             * @param uuid the uuid
14448             * @param groupId the group ID
14449             * @return the number of matching journal articles
14450             * @throws SystemException if a system exception occurred
14451             */
14452            public int countByUUID_G(String uuid, long groupId)
14453                    throws SystemException {
14454                    Object[] finderArgs = new Object[] { uuid, groupId };
14455    
14456                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
14457                                    finderArgs, this);
14458    
14459                    if (count == null) {
14460                            StringBundler query = new StringBundler(3);
14461    
14462                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14463    
14464                            if (uuid == null) {
14465                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
14466                            }
14467                            else {
14468                                    if (uuid.equals(StringPool.BLANK)) {
14469                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
14470                                    }
14471                                    else {
14472                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
14473                                    }
14474                            }
14475    
14476                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
14477    
14478                            String sql = query.toString();
14479    
14480                            Session session = null;
14481    
14482                            try {
14483                                    session = openSession();
14484    
14485                                    Query q = session.createQuery(sql);
14486    
14487                                    QueryPos qPos = QueryPos.getInstance(q);
14488    
14489                                    if (uuid != null) {
14490                                            qPos.add(uuid);
14491                                    }
14492    
14493                                    qPos.add(groupId);
14494    
14495                                    count = (Long)q.uniqueResult();
14496                            }
14497                            catch (Exception e) {
14498                                    throw processException(e);
14499                            }
14500                            finally {
14501                                    if (count == null) {
14502                                            count = Long.valueOf(0);
14503                                    }
14504    
14505                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
14506                                            finderArgs, count);
14507    
14508                                    closeSession(session);
14509                            }
14510                    }
14511    
14512                    return count.intValue();
14513            }
14514    
14515            /**
14516             * Returns the number of journal articles where resourcePrimKey = &#63;.
14517             *
14518             * @param resourcePrimKey the resource prim key
14519             * @return the number of matching journal articles
14520             * @throws SystemException if a system exception occurred
14521             */
14522            public int countByResourcePrimKey(long resourcePrimKey)
14523                    throws SystemException {
14524                    Object[] finderArgs = new Object[] { resourcePrimKey };
14525    
14526                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
14527                                    finderArgs, this);
14528    
14529                    if (count == null) {
14530                            StringBundler query = new StringBundler(2);
14531    
14532                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14533    
14534                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
14535    
14536                            String sql = query.toString();
14537    
14538                            Session session = null;
14539    
14540                            try {
14541                                    session = openSession();
14542    
14543                                    Query q = session.createQuery(sql);
14544    
14545                                    QueryPos qPos = QueryPos.getInstance(q);
14546    
14547                                    qPos.add(resourcePrimKey);
14548    
14549                                    count = (Long)q.uniqueResult();
14550                            }
14551                            catch (Exception e) {
14552                                    throw processException(e);
14553                            }
14554                            finally {
14555                                    if (count == null) {
14556                                            count = Long.valueOf(0);
14557                                    }
14558    
14559                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
14560                                            finderArgs, count);
14561    
14562                                    closeSession(session);
14563                            }
14564                    }
14565    
14566                    return count.intValue();
14567            }
14568    
14569            /**
14570             * Returns the number of journal articles where groupId = &#63;.
14571             *
14572             * @param groupId the group ID
14573             * @return the number of matching journal articles
14574             * @throws SystemException if a system exception occurred
14575             */
14576            public int countByGroupId(long groupId) throws SystemException {
14577                    Object[] finderArgs = new Object[] { groupId };
14578    
14579                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
14580                                    finderArgs, this);
14581    
14582                    if (count == null) {
14583                            StringBundler query = new StringBundler(2);
14584    
14585                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14586    
14587                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
14588    
14589                            String sql = query.toString();
14590    
14591                            Session session = null;
14592    
14593                            try {
14594                                    session = openSession();
14595    
14596                                    Query q = session.createQuery(sql);
14597    
14598                                    QueryPos qPos = QueryPos.getInstance(q);
14599    
14600                                    qPos.add(groupId);
14601    
14602                                    count = (Long)q.uniqueResult();
14603                            }
14604                            catch (Exception e) {
14605                                    throw processException(e);
14606                            }
14607                            finally {
14608                                    if (count == null) {
14609                                            count = Long.valueOf(0);
14610                                    }
14611    
14612                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
14613                                            finderArgs, count);
14614    
14615                                    closeSession(session);
14616                            }
14617                    }
14618    
14619                    return count.intValue();
14620            }
14621    
14622            /**
14623             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
14624             *
14625             * @param groupId the group ID
14626             * @return the number of matching journal articles that the user has permission to view
14627             * @throws SystemException if a system exception occurred
14628             */
14629            public int filterCountByGroupId(long groupId) throws SystemException {
14630                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14631                            return countByGroupId(groupId);
14632                    }
14633    
14634                    StringBundler query = new StringBundler(2);
14635    
14636                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14637    
14638                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
14639    
14640                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14641                                    JournalArticle.class.getName(),
14642                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14643    
14644                    Session session = null;
14645    
14646                    try {
14647                            session = openSession();
14648    
14649                            SQLQuery q = session.createSQLQuery(sql);
14650    
14651                            q.addScalar(COUNT_COLUMN_NAME,
14652                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14653    
14654                            QueryPos qPos = QueryPos.getInstance(q);
14655    
14656                            qPos.add(groupId);
14657    
14658                            Long count = (Long)q.uniqueResult();
14659    
14660                            return count.intValue();
14661                    }
14662                    catch (Exception e) {
14663                            throw processException(e);
14664                    }
14665                    finally {
14666                            closeSession(session);
14667                    }
14668            }
14669    
14670            /**
14671             * Returns the number of journal articles where companyId = &#63;.
14672             *
14673             * @param companyId the company ID
14674             * @return the number of matching journal articles
14675             * @throws SystemException if a system exception occurred
14676             */
14677            public int countByCompanyId(long companyId) throws SystemException {
14678                    Object[] finderArgs = new Object[] { companyId };
14679    
14680                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
14681                                    finderArgs, this);
14682    
14683                    if (count == null) {
14684                            StringBundler query = new StringBundler(2);
14685    
14686                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14687    
14688                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
14689    
14690                            String sql = query.toString();
14691    
14692                            Session session = null;
14693    
14694                            try {
14695                                    session = openSession();
14696    
14697                                    Query q = session.createQuery(sql);
14698    
14699                                    QueryPos qPos = QueryPos.getInstance(q);
14700    
14701                                    qPos.add(companyId);
14702    
14703                                    count = (Long)q.uniqueResult();
14704                            }
14705                            catch (Exception e) {
14706                                    throw processException(e);
14707                            }
14708                            finally {
14709                                    if (count == null) {
14710                                            count = Long.valueOf(0);
14711                                    }
14712    
14713                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
14714                                            finderArgs, count);
14715    
14716                                    closeSession(session);
14717                            }
14718                    }
14719    
14720                    return count.intValue();
14721            }
14722    
14723            /**
14724             * Returns the number of journal articles where smallImageId = &#63;.
14725             *
14726             * @param smallImageId the small image ID
14727             * @return the number of matching journal articles
14728             * @throws SystemException if a system exception occurred
14729             */
14730            public int countBySmallImageId(long smallImageId) throws SystemException {
14731                    Object[] finderArgs = new Object[] { smallImageId };
14732    
14733                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
14734                                    finderArgs, this);
14735    
14736                    if (count == null) {
14737                            StringBundler query = new StringBundler(2);
14738    
14739                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14740    
14741                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
14742    
14743                            String sql = query.toString();
14744    
14745                            Session session = null;
14746    
14747                            try {
14748                                    session = openSession();
14749    
14750                                    Query q = session.createQuery(sql);
14751    
14752                                    QueryPos qPos = QueryPos.getInstance(q);
14753    
14754                                    qPos.add(smallImageId);
14755    
14756                                    count = (Long)q.uniqueResult();
14757                            }
14758                            catch (Exception e) {
14759                                    throw processException(e);
14760                            }
14761                            finally {
14762                                    if (count == null) {
14763                                            count = Long.valueOf(0);
14764                                    }
14765    
14766                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
14767                                            finderArgs, count);
14768    
14769                                    closeSession(session);
14770                            }
14771                    }
14772    
14773                    return count.intValue();
14774            }
14775    
14776            /**
14777             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
14778             *
14779             * @param resourcePrimKey the resource prim key
14780             * @param status the status
14781             * @return the number of matching journal articles
14782             * @throws SystemException if a system exception occurred
14783             */
14784            public int countByR_ST(long resourcePrimKey, int status)
14785                    throws SystemException {
14786                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
14787    
14788                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_ST,
14789                                    finderArgs, this);
14790    
14791                    if (count == null) {
14792                            StringBundler query = new StringBundler(3);
14793    
14794                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14795    
14796                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
14797    
14798                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
14799    
14800                            String sql = query.toString();
14801    
14802                            Session session = null;
14803    
14804                            try {
14805                                    session = openSession();
14806    
14807                                    Query q = session.createQuery(sql);
14808    
14809                                    QueryPos qPos = QueryPos.getInstance(q);
14810    
14811                                    qPos.add(resourcePrimKey);
14812    
14813                                    qPos.add(status);
14814    
14815                                    count = (Long)q.uniqueResult();
14816                            }
14817                            catch (Exception e) {
14818                                    throw processException(e);
14819                            }
14820                            finally {
14821                                    if (count == null) {
14822                                            count = Long.valueOf(0);
14823                                    }
14824    
14825                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_ST,
14826                                            finderArgs, count);
14827    
14828                                    closeSession(session);
14829                            }
14830                    }
14831    
14832                    return count.intValue();
14833            }
14834    
14835            /**
14836             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
14837             *
14838             * @param groupId the group ID
14839             * @param articleId the article ID
14840             * @return the number of matching journal articles
14841             * @throws SystemException if a system exception occurred
14842             */
14843            public int countByG_A(long groupId, String articleId)
14844                    throws SystemException {
14845                    Object[] finderArgs = new Object[] { groupId, articleId };
14846    
14847                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
14848                                    finderArgs, this);
14849    
14850                    if (count == null) {
14851                            StringBundler query = new StringBundler(3);
14852    
14853                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14854    
14855                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
14856    
14857                            if (articleId == null) {
14858                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
14859                            }
14860                            else {
14861                                    if (articleId.equals(StringPool.BLANK)) {
14862                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
14863                                    }
14864                                    else {
14865                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
14866                                    }
14867                            }
14868    
14869                            String sql = query.toString();
14870    
14871                            Session session = null;
14872    
14873                            try {
14874                                    session = openSession();
14875    
14876                                    Query q = session.createQuery(sql);
14877    
14878                                    QueryPos qPos = QueryPos.getInstance(q);
14879    
14880                                    qPos.add(groupId);
14881    
14882                                    if (articleId != null) {
14883                                            qPos.add(articleId);
14884                                    }
14885    
14886                                    count = (Long)q.uniqueResult();
14887                            }
14888                            catch (Exception e) {
14889                                    throw processException(e);
14890                            }
14891                            finally {
14892                                    if (count == null) {
14893                                            count = Long.valueOf(0);
14894                                    }
14895    
14896                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
14897                                            count);
14898    
14899                                    closeSession(session);
14900                            }
14901                    }
14902    
14903                    return count.intValue();
14904            }
14905    
14906            /**
14907             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
14908             *
14909             * @param groupId the group ID
14910             * @param articleId the article ID
14911             * @return the number of matching journal articles that the user has permission to view
14912             * @throws SystemException if a system exception occurred
14913             */
14914            public int filterCountByG_A(long groupId, String articleId)
14915                    throws SystemException {
14916                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14917                            return countByG_A(groupId, articleId);
14918                    }
14919    
14920                    StringBundler query = new StringBundler(3);
14921    
14922                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14923    
14924                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
14925    
14926                    if (articleId == null) {
14927                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
14928                    }
14929                    else {
14930                            if (articleId.equals(StringPool.BLANK)) {
14931                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
14932                            }
14933                            else {
14934                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
14935                            }
14936                    }
14937    
14938                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14939                                    JournalArticle.class.getName(),
14940                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14941    
14942                    Session session = null;
14943    
14944                    try {
14945                            session = openSession();
14946    
14947                            SQLQuery q = session.createSQLQuery(sql);
14948    
14949                            q.addScalar(COUNT_COLUMN_NAME,
14950                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14951    
14952                            QueryPos qPos = QueryPos.getInstance(q);
14953    
14954                            qPos.add(groupId);
14955    
14956                            if (articleId != null) {
14957                                    qPos.add(articleId);
14958                            }
14959    
14960                            Long count = (Long)q.uniqueResult();
14961    
14962                            return count.intValue();
14963                    }
14964                    catch (Exception e) {
14965                            throw processException(e);
14966                    }
14967                    finally {
14968                            closeSession(session);
14969                    }
14970            }
14971    
14972            /**
14973             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
14974             *
14975             * @param groupId the group ID
14976             * @param urlTitle the url title
14977             * @return the number of matching journal articles
14978             * @throws SystemException if a system exception occurred
14979             */
14980            public int countByG_UT(long groupId, String urlTitle)
14981                    throws SystemException {
14982                    Object[] finderArgs = new Object[] { groupId, urlTitle };
14983    
14984                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT,
14985                                    finderArgs, this);
14986    
14987                    if (count == null) {
14988                            StringBundler query = new StringBundler(3);
14989    
14990                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14991    
14992                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
14993    
14994                            if (urlTitle == null) {
14995                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
14996                            }
14997                            else {
14998                                    if (urlTitle.equals(StringPool.BLANK)) {
14999                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
15000                                    }
15001                                    else {
15002                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
15003                                    }
15004                            }
15005    
15006                            String sql = query.toString();
15007    
15008                            Session session = null;
15009    
15010                            try {
15011                                    session = openSession();
15012    
15013                                    Query q = session.createQuery(sql);
15014    
15015                                    QueryPos qPos = QueryPos.getInstance(q);
15016    
15017                                    qPos.add(groupId);
15018    
15019                                    if (urlTitle != null) {
15020                                            qPos.add(urlTitle);
15021                                    }
15022    
15023                                    count = (Long)q.uniqueResult();
15024                            }
15025                            catch (Exception e) {
15026                                    throw processException(e);
15027                            }
15028                            finally {
15029                                    if (count == null) {
15030                                            count = Long.valueOf(0);
15031                                    }
15032    
15033                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT,
15034                                            finderArgs, count);
15035    
15036                                    closeSession(session);
15037                            }
15038                    }
15039    
15040                    return count.intValue();
15041            }
15042    
15043            /**
15044             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
15045             *
15046             * @param groupId the group ID
15047             * @param urlTitle the url title
15048             * @return the number of matching journal articles that the user has permission to view
15049             * @throws SystemException if a system exception occurred
15050             */
15051            public int filterCountByG_UT(long groupId, String urlTitle)
15052                    throws SystemException {
15053                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15054                            return countByG_UT(groupId, urlTitle);
15055                    }
15056    
15057                    StringBundler query = new StringBundler(3);
15058    
15059                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15060    
15061                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
15062    
15063                    if (urlTitle == null) {
15064                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
15065                    }
15066                    else {
15067                            if (urlTitle.equals(StringPool.BLANK)) {
15068                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
15069                            }
15070                            else {
15071                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
15072                            }
15073                    }
15074    
15075                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15076                                    JournalArticle.class.getName(),
15077                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15078    
15079                    Session session = null;
15080    
15081                    try {
15082                            session = openSession();
15083    
15084                            SQLQuery q = session.createSQLQuery(sql);
15085    
15086                            q.addScalar(COUNT_COLUMN_NAME,
15087                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15088    
15089                            QueryPos qPos = QueryPos.getInstance(q);
15090    
15091                            qPos.add(groupId);
15092    
15093                            if (urlTitle != null) {
15094                                    qPos.add(urlTitle);
15095                            }
15096    
15097                            Long count = (Long)q.uniqueResult();
15098    
15099                            return count.intValue();
15100                    }
15101                    catch (Exception e) {
15102                            throw processException(e);
15103                    }
15104                    finally {
15105                            closeSession(session);
15106                    }
15107            }
15108    
15109            /**
15110             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
15111             *
15112             * @param groupId the group ID
15113             * @param structureId the structure ID
15114             * @return the number of matching journal articles
15115             * @throws SystemException if a system exception occurred
15116             */
15117            public int countByG_S(long groupId, String structureId)
15118                    throws SystemException {
15119                    Object[] finderArgs = new Object[] { groupId, structureId };
15120    
15121                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
15122                                    finderArgs, this);
15123    
15124                    if (count == null) {
15125                            StringBundler query = new StringBundler(3);
15126    
15127                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15128    
15129                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
15130    
15131                            if (structureId == null) {
15132                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
15133                            }
15134                            else {
15135                                    if (structureId.equals(StringPool.BLANK)) {
15136                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
15137                                    }
15138                                    else {
15139                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
15140                                    }
15141                            }
15142    
15143                            String sql = query.toString();
15144    
15145                            Session session = null;
15146    
15147                            try {
15148                                    session = openSession();
15149    
15150                                    Query q = session.createQuery(sql);
15151    
15152                                    QueryPos qPos = QueryPos.getInstance(q);
15153    
15154                                    qPos.add(groupId);
15155    
15156                                    if (structureId != null) {
15157                                            qPos.add(structureId);
15158                                    }
15159    
15160                                    count = (Long)q.uniqueResult();
15161                            }
15162                            catch (Exception e) {
15163                                    throw processException(e);
15164                            }
15165                            finally {
15166                                    if (count == null) {
15167                                            count = Long.valueOf(0);
15168                                    }
15169    
15170                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
15171                                            count);
15172    
15173                                    closeSession(session);
15174                            }
15175                    }
15176    
15177                    return count.intValue();
15178            }
15179    
15180            /**
15181             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
15182             *
15183             * @param groupId the group ID
15184             * @param structureId the structure ID
15185             * @return the number of matching journal articles that the user has permission to view
15186             * @throws SystemException if a system exception occurred
15187             */
15188            public int filterCountByG_S(long groupId, String structureId)
15189                    throws SystemException {
15190                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15191                            return countByG_S(groupId, structureId);
15192                    }
15193    
15194                    StringBundler query = new StringBundler(3);
15195    
15196                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15197    
15198                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
15199    
15200                    if (structureId == null) {
15201                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
15202                    }
15203                    else {
15204                            if (structureId.equals(StringPool.BLANK)) {
15205                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
15206                            }
15207                            else {
15208                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
15209                            }
15210                    }
15211    
15212                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15213                                    JournalArticle.class.getName(),
15214                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15215    
15216                    Session session = null;
15217    
15218                    try {
15219                            session = openSession();
15220    
15221                            SQLQuery q = session.createSQLQuery(sql);
15222    
15223                            q.addScalar(COUNT_COLUMN_NAME,
15224                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15225    
15226                            QueryPos qPos = QueryPos.getInstance(q);
15227    
15228                            qPos.add(groupId);
15229    
15230                            if (structureId != null) {
15231                                    qPos.add(structureId);
15232                            }
15233    
15234                            Long count = (Long)q.uniqueResult();
15235    
15236                            return count.intValue();
15237                    }
15238                    catch (Exception e) {
15239                            throw processException(e);
15240                    }
15241                    finally {
15242                            closeSession(session);
15243                    }
15244            }
15245    
15246            /**
15247             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
15248             *
15249             * @param groupId the group ID
15250             * @param templateId the template ID
15251             * @return the number of matching journal articles
15252             * @throws SystemException if a system exception occurred
15253             */
15254            public int countByG_T(long groupId, String templateId)
15255                    throws SystemException {
15256                    Object[] finderArgs = new Object[] { groupId, templateId };
15257    
15258                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T,
15259                                    finderArgs, this);
15260    
15261                    if (count == null) {
15262                            StringBundler query = new StringBundler(3);
15263    
15264                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15265    
15266                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
15267    
15268                            if (templateId == null) {
15269                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
15270                            }
15271                            else {
15272                                    if (templateId.equals(StringPool.BLANK)) {
15273                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
15274                                    }
15275                                    else {
15276                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
15277                                    }
15278                            }
15279    
15280                            String sql = query.toString();
15281    
15282                            Session session = null;
15283    
15284                            try {
15285                                    session = openSession();
15286    
15287                                    Query q = session.createQuery(sql);
15288    
15289                                    QueryPos qPos = QueryPos.getInstance(q);
15290    
15291                                    qPos.add(groupId);
15292    
15293                                    if (templateId != null) {
15294                                            qPos.add(templateId);
15295                                    }
15296    
15297                                    count = (Long)q.uniqueResult();
15298                            }
15299                            catch (Exception e) {
15300                                    throw processException(e);
15301                            }
15302                            finally {
15303                                    if (count == null) {
15304                                            count = Long.valueOf(0);
15305                                    }
15306    
15307                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_T, finderArgs,
15308                                            count);
15309    
15310                                    closeSession(session);
15311                            }
15312                    }
15313    
15314                    return count.intValue();
15315            }
15316    
15317            /**
15318             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
15319             *
15320             * @param groupId the group ID
15321             * @param templateId the template ID
15322             * @return the number of matching journal articles that the user has permission to view
15323             * @throws SystemException if a system exception occurred
15324             */
15325            public int filterCountByG_T(long groupId, String templateId)
15326                    throws SystemException {
15327                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15328                            return countByG_T(groupId, templateId);
15329                    }
15330    
15331                    StringBundler query = new StringBundler(3);
15332    
15333                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15334    
15335                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
15336    
15337                    if (templateId == null) {
15338                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
15339                    }
15340                    else {
15341                            if (templateId.equals(StringPool.BLANK)) {
15342                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
15343                            }
15344                            else {
15345                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
15346                            }
15347                    }
15348    
15349                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15350                                    JournalArticle.class.getName(),
15351                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15352    
15353                    Session session = null;
15354    
15355                    try {
15356                            session = openSession();
15357    
15358                            SQLQuery q = session.createSQLQuery(sql);
15359    
15360                            q.addScalar(COUNT_COLUMN_NAME,
15361                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15362    
15363                            QueryPos qPos = QueryPos.getInstance(q);
15364    
15365                            qPos.add(groupId);
15366    
15367                            if (templateId != null) {
15368                                    qPos.add(templateId);
15369                            }
15370    
15371                            Long count = (Long)q.uniqueResult();
15372    
15373                            return count.intValue();
15374                    }
15375                    catch (Exception e) {
15376                            throw processException(e);
15377                    }
15378                    finally {
15379                            closeSession(session);
15380                    }
15381            }
15382    
15383            /**
15384             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
15385             *
15386             * @param groupId the group ID
15387             * @param layoutUuid the layout uuid
15388             * @return the number of matching journal articles
15389             * @throws SystemException if a system exception occurred
15390             */
15391            public int countByG_L(long groupId, String layoutUuid)
15392                    throws SystemException {
15393                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
15394    
15395                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_L,
15396                                    finderArgs, this);
15397    
15398                    if (count == null) {
15399                            StringBundler query = new StringBundler(3);
15400    
15401                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15402    
15403                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
15404    
15405                            if (layoutUuid == null) {
15406                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
15407                            }
15408                            else {
15409                                    if (layoutUuid.equals(StringPool.BLANK)) {
15410                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
15411                                    }
15412                                    else {
15413                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
15414                                    }
15415                            }
15416    
15417                            String sql = query.toString();
15418    
15419                            Session session = null;
15420    
15421                            try {
15422                                    session = openSession();
15423    
15424                                    Query q = session.createQuery(sql);
15425    
15426                                    QueryPos qPos = QueryPos.getInstance(q);
15427    
15428                                    qPos.add(groupId);
15429    
15430                                    if (layoutUuid != null) {
15431                                            qPos.add(layoutUuid);
15432                                    }
15433    
15434                                    count = (Long)q.uniqueResult();
15435                            }
15436                            catch (Exception e) {
15437                                    throw processException(e);
15438                            }
15439                            finally {
15440                                    if (count == null) {
15441                                            count = Long.valueOf(0);
15442                                    }
15443    
15444                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_L, finderArgs,
15445                                            count);
15446    
15447                                    closeSession(session);
15448                            }
15449                    }
15450    
15451                    return count.intValue();
15452            }
15453    
15454            /**
15455             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
15456             *
15457             * @param groupId the group ID
15458             * @param layoutUuid the layout uuid
15459             * @return the number of matching journal articles that the user has permission to view
15460             * @throws SystemException if a system exception occurred
15461             */
15462            public int filterCountByG_L(long groupId, String layoutUuid)
15463                    throws SystemException {
15464                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15465                            return countByG_L(groupId, layoutUuid);
15466                    }
15467    
15468                    StringBundler query = new StringBundler(3);
15469    
15470                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15471    
15472                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
15473    
15474                    if (layoutUuid == null) {
15475                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
15476                    }
15477                    else {
15478                            if (layoutUuid.equals(StringPool.BLANK)) {
15479                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
15480                            }
15481                            else {
15482                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
15483                            }
15484                    }
15485    
15486                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15487                                    JournalArticle.class.getName(),
15488                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15489    
15490                    Session session = null;
15491    
15492                    try {
15493                            session = openSession();
15494    
15495                            SQLQuery q = session.createSQLQuery(sql);
15496    
15497                            q.addScalar(COUNT_COLUMN_NAME,
15498                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15499    
15500                            QueryPos qPos = QueryPos.getInstance(q);
15501    
15502                            qPos.add(groupId);
15503    
15504                            if (layoutUuid != null) {
15505                                    qPos.add(layoutUuid);
15506                            }
15507    
15508                            Long count = (Long)q.uniqueResult();
15509    
15510                            return count.intValue();
15511                    }
15512                    catch (Exception e) {
15513                            throw processException(e);
15514                    }
15515                    finally {
15516                            closeSession(session);
15517                    }
15518            }
15519    
15520            /**
15521             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
15522             *
15523             * @param groupId the group ID
15524             * @param status the status
15525             * @return the number of matching journal articles
15526             * @throws SystemException if a system exception occurred
15527             */
15528            public int countByG_ST(long groupId, int status) throws SystemException {
15529                    Object[] finderArgs = new Object[] { groupId, status };
15530    
15531                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_ST,
15532                                    finderArgs, this);
15533    
15534                    if (count == null) {
15535                            StringBundler query = new StringBundler(3);
15536    
15537                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15538    
15539                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15540    
15541                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15542    
15543                            String sql = query.toString();
15544    
15545                            Session session = null;
15546    
15547                            try {
15548                                    session = openSession();
15549    
15550                                    Query q = session.createQuery(sql);
15551    
15552                                    QueryPos qPos = QueryPos.getInstance(q);
15553    
15554                                    qPos.add(groupId);
15555    
15556                                    qPos.add(status);
15557    
15558                                    count = (Long)q.uniqueResult();
15559                            }
15560                            catch (Exception e) {
15561                                    throw processException(e);
15562                            }
15563                            finally {
15564                                    if (count == null) {
15565                                            count = Long.valueOf(0);
15566                                    }
15567    
15568                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_ST,
15569                                            finderArgs, count);
15570    
15571                                    closeSession(session);
15572                            }
15573                    }
15574    
15575                    return count.intValue();
15576            }
15577    
15578            /**
15579             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
15580             *
15581             * @param groupId the group ID
15582             * @param status the status
15583             * @return the number of matching journal articles that the user has permission to view
15584             * @throws SystemException if a system exception occurred
15585             */
15586            public int filterCountByG_ST(long groupId, int status)
15587                    throws SystemException {
15588                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15589                            return countByG_ST(groupId, status);
15590                    }
15591    
15592                    StringBundler query = new StringBundler(3);
15593    
15594                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15595    
15596                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15597    
15598                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15599    
15600                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15601                                    JournalArticle.class.getName(),
15602                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15603    
15604                    Session session = null;
15605    
15606                    try {
15607                            session = openSession();
15608    
15609                            SQLQuery q = session.createSQLQuery(sql);
15610    
15611                            q.addScalar(COUNT_COLUMN_NAME,
15612                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15613    
15614                            QueryPos qPos = QueryPos.getInstance(q);
15615    
15616                            qPos.add(groupId);
15617    
15618                            qPos.add(status);
15619    
15620                            Long count = (Long)q.uniqueResult();
15621    
15622                            return count.intValue();
15623                    }
15624                    catch (Exception e) {
15625                            throw processException(e);
15626                    }
15627                    finally {
15628                            closeSession(session);
15629                    }
15630            }
15631    
15632            /**
15633             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
15634             *
15635             * @param companyId the company ID
15636             * @param version the version
15637             * @return the number of matching journal articles
15638             * @throws SystemException if a system exception occurred
15639             */
15640            public int countByC_V(long companyId, double version)
15641                    throws SystemException {
15642                    Object[] finderArgs = new Object[] { companyId, version };
15643    
15644                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V,
15645                                    finderArgs, this);
15646    
15647                    if (count == null) {
15648                            StringBundler query = new StringBundler(3);
15649    
15650                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15651    
15652                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15653    
15654                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15655    
15656                            String sql = query.toString();
15657    
15658                            Session session = null;
15659    
15660                            try {
15661                                    session = openSession();
15662    
15663                                    Query q = session.createQuery(sql);
15664    
15665                                    QueryPos qPos = QueryPos.getInstance(q);
15666    
15667                                    qPos.add(companyId);
15668    
15669                                    qPos.add(version);
15670    
15671                                    count = (Long)q.uniqueResult();
15672                            }
15673                            catch (Exception e) {
15674                                    throw processException(e);
15675                            }
15676                            finally {
15677                                    if (count == null) {
15678                                            count = Long.valueOf(0);
15679                                    }
15680    
15681                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V, finderArgs,
15682                                            count);
15683    
15684                                    closeSession(session);
15685                            }
15686                    }
15687    
15688                    return count.intValue();
15689            }
15690    
15691            /**
15692             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
15693             *
15694             * @param companyId the company ID
15695             * @param status the status
15696             * @return the number of matching journal articles
15697             * @throws SystemException if a system exception occurred
15698             */
15699            public int countByC_ST(long companyId, int status)
15700                    throws SystemException {
15701                    Object[] finderArgs = new Object[] { companyId, status };
15702    
15703                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_ST,
15704                                    finderArgs, this);
15705    
15706                    if (count == null) {
15707                            StringBundler query = new StringBundler(3);
15708    
15709                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15710    
15711                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15712    
15713                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15714    
15715                            String sql = query.toString();
15716    
15717                            Session session = null;
15718    
15719                            try {
15720                                    session = openSession();
15721    
15722                                    Query q = session.createQuery(sql);
15723    
15724                                    QueryPos qPos = QueryPos.getInstance(q);
15725    
15726                                    qPos.add(companyId);
15727    
15728                                    qPos.add(status);
15729    
15730                                    count = (Long)q.uniqueResult();
15731                            }
15732                            catch (Exception e) {
15733                                    throw processException(e);
15734                            }
15735                            finally {
15736                                    if (count == null) {
15737                                            count = Long.valueOf(0);
15738                                    }
15739    
15740                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_ST,
15741                                            finderArgs, count);
15742    
15743                                    closeSession(session);
15744                            }
15745                    }
15746    
15747                    return count.intValue();
15748            }
15749    
15750            /**
15751             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
15752             *
15753             * @param groupId the group ID
15754             * @param classNameId the class name ID
15755             * @param classPK the class p k
15756             * @return the number of matching journal articles
15757             * @throws SystemException if a system exception occurred
15758             */
15759            public int countByG_C_C(long groupId, long classNameId, long classPK)
15760                    throws SystemException {
15761                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
15762    
15763                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C,
15764                                    finderArgs, this);
15765    
15766                    if (count == null) {
15767                            StringBundler query = new StringBundler(4);
15768    
15769                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15770    
15771                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
15772    
15773                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
15774    
15775                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
15776    
15777                            String sql = query.toString();
15778    
15779                            Session session = null;
15780    
15781                            try {
15782                                    session = openSession();
15783    
15784                                    Query q = session.createQuery(sql);
15785    
15786                                    QueryPos qPos = QueryPos.getInstance(q);
15787    
15788                                    qPos.add(groupId);
15789    
15790                                    qPos.add(classNameId);
15791    
15792                                    qPos.add(classPK);
15793    
15794                                    count = (Long)q.uniqueResult();
15795                            }
15796                            catch (Exception e) {
15797                                    throw processException(e);
15798                            }
15799                            finally {
15800                                    if (count == null) {
15801                                            count = Long.valueOf(0);
15802                                    }
15803    
15804                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C,
15805                                            finderArgs, count);
15806    
15807                                    closeSession(session);
15808                            }
15809                    }
15810    
15811                    return count.intValue();
15812            }
15813    
15814            /**
15815             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
15816             *
15817             * @param groupId the group ID
15818             * @param classNameId the class name ID
15819             * @param classPK the class p k
15820             * @return the number of matching journal articles that the user has permission to view
15821             * @throws SystemException if a system exception occurred
15822             */
15823            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
15824                    throws SystemException {
15825                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15826                            return countByG_C_C(groupId, classNameId, classPK);
15827                    }
15828    
15829                    StringBundler query = new StringBundler(4);
15830    
15831                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15832    
15833                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
15834    
15835                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
15836    
15837                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
15838    
15839                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15840                                    JournalArticle.class.getName(),
15841                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15842    
15843                    Session session = null;
15844    
15845                    try {
15846                            session = openSession();
15847    
15848                            SQLQuery q = session.createSQLQuery(sql);
15849    
15850                            q.addScalar(COUNT_COLUMN_NAME,
15851                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15852    
15853                            QueryPos qPos = QueryPos.getInstance(q);
15854    
15855                            qPos.add(groupId);
15856    
15857                            qPos.add(classNameId);
15858    
15859                            qPos.add(classPK);
15860    
15861                            Long count = (Long)q.uniqueResult();
15862    
15863                            return count.intValue();
15864                    }
15865                    catch (Exception e) {
15866                            throw processException(e);
15867                    }
15868                    finally {
15869                            closeSession(session);
15870                    }
15871            }
15872    
15873            /**
15874             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
15875             *
15876             * @param groupId the group ID
15877             * @param classNameId the class name ID
15878             * @param structureId the structure ID
15879             * @return the number of matching journal articles
15880             * @throws SystemException if a system exception occurred
15881             */
15882            public int countByG_C_S(long groupId, long classNameId, String structureId)
15883                    throws SystemException {
15884                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
15885    
15886                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
15887                                    finderArgs, this);
15888    
15889                    if (count == null) {
15890                            StringBundler query = new StringBundler(4);
15891    
15892                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15893    
15894                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
15895    
15896                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
15897    
15898                            if (structureId == null) {
15899                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
15900                            }
15901                            else {
15902                                    if (structureId.equals(StringPool.BLANK)) {
15903                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
15904                                    }
15905                                    else {
15906                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
15907                                    }
15908                            }
15909    
15910                            String sql = query.toString();
15911    
15912                            Session session = null;
15913    
15914                            try {
15915                                    session = openSession();
15916    
15917                                    Query q = session.createQuery(sql);
15918    
15919                                    QueryPos qPos = QueryPos.getInstance(q);
15920    
15921                                    qPos.add(groupId);
15922    
15923                                    qPos.add(classNameId);
15924    
15925                                    if (structureId != null) {
15926                                            qPos.add(structureId);
15927                                    }
15928    
15929                                    count = (Long)q.uniqueResult();
15930                            }
15931                            catch (Exception e) {
15932                                    throw processException(e);
15933                            }
15934                            finally {
15935                                    if (count == null) {
15936                                            count = Long.valueOf(0);
15937                                    }
15938    
15939                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
15940                                            finderArgs, count);
15941    
15942                                    closeSession(session);
15943                            }
15944                    }
15945    
15946                    return count.intValue();
15947            }
15948    
15949            /**
15950             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
15951             *
15952             * @param groupId the group ID
15953             * @param classNameId the class name ID
15954             * @param templateId the template ID
15955             * @return the number of matching journal articles
15956             * @throws SystemException if a system exception occurred
15957             */
15958            public int countByG_C_T(long groupId, long classNameId, String templateId)
15959                    throws SystemException {
15960                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
15961    
15962                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_T,
15963                                    finderArgs, this);
15964    
15965                    if (count == null) {
15966                            StringBundler query = new StringBundler(4);
15967    
15968                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15969    
15970                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
15971    
15972                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
15973    
15974                            if (templateId == null) {
15975                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
15976                            }
15977                            else {
15978                                    if (templateId.equals(StringPool.BLANK)) {
15979                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
15980                                    }
15981                                    else {
15982                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
15983                                    }
15984                            }
15985    
15986                            String sql = query.toString();
15987    
15988                            Session session = null;
15989    
15990                            try {
15991                                    session = openSession();
15992    
15993                                    Query q = session.createQuery(sql);
15994    
15995                                    QueryPos qPos = QueryPos.getInstance(q);
15996    
15997                                    qPos.add(groupId);
15998    
15999                                    qPos.add(classNameId);
16000    
16001                                    if (templateId != null) {
16002                                            qPos.add(templateId);
16003                                    }
16004    
16005                                    count = (Long)q.uniqueResult();
16006                            }
16007                            catch (Exception e) {
16008                                    throw processException(e);
16009                            }
16010                            finally {
16011                                    if (count == null) {
16012                                            count = Long.valueOf(0);
16013                                    }
16014    
16015                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_T,
16016                                            finderArgs, count);
16017    
16018                                    closeSession(session);
16019                            }
16020                    }
16021    
16022                    return count.intValue();
16023            }
16024    
16025            /**
16026             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
16027             *
16028             * @param groupId the group ID
16029             * @param classNameId the class name ID
16030             * @param templateId the template ID
16031             * @return the number of matching journal articles that the user has permission to view
16032             * @throws SystemException if a system exception occurred
16033             */
16034            public int filterCountByG_C_T(long groupId, long classNameId,
16035                    String templateId) throws SystemException {
16036                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16037                            return countByG_C_T(groupId, classNameId, templateId);
16038                    }
16039    
16040                    StringBundler query = new StringBundler(4);
16041    
16042                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16043    
16044                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
16045    
16046                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
16047    
16048                    if (templateId == null) {
16049                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
16050                    }
16051                    else {
16052                            if (templateId.equals(StringPool.BLANK)) {
16053                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
16054                            }
16055                            else {
16056                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
16057                            }
16058                    }
16059    
16060                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16061                                    JournalArticle.class.getName(),
16062                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16063    
16064                    Session session = null;
16065    
16066                    try {
16067                            session = openSession();
16068    
16069                            SQLQuery q = session.createSQLQuery(sql);
16070    
16071                            q.addScalar(COUNT_COLUMN_NAME,
16072                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16073    
16074                            QueryPos qPos = QueryPos.getInstance(q);
16075    
16076                            qPos.add(groupId);
16077    
16078                            qPos.add(classNameId);
16079    
16080                            if (templateId != null) {
16081                                    qPos.add(templateId);
16082                            }
16083    
16084                            Long count = (Long)q.uniqueResult();
16085    
16086                            return count.intValue();
16087                    }
16088                    catch (Exception e) {
16089                            throw processException(e);
16090                    }
16091                    finally {
16092                            closeSession(session);
16093                    }
16094            }
16095    
16096            /**
16097             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16098             *
16099             * @param groupId the group ID
16100             * @param classNameId the class name ID
16101             * @param layoutUuid the layout uuid
16102             * @return the number of matching journal articles
16103             * @throws SystemException if a system exception occurred
16104             */
16105            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
16106                    throws SystemException {
16107                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
16108    
16109                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_L,
16110                                    finderArgs, this);
16111    
16112                    if (count == null) {
16113                            StringBundler query = new StringBundler(4);
16114    
16115                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16116    
16117                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
16118    
16119                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
16120    
16121                            if (layoutUuid == null) {
16122                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
16123                            }
16124                            else {
16125                                    if (layoutUuid.equals(StringPool.BLANK)) {
16126                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
16127                                    }
16128                                    else {
16129                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
16130                                    }
16131                            }
16132    
16133                            String sql = query.toString();
16134    
16135                            Session session = null;
16136    
16137                            try {
16138                                    session = openSession();
16139    
16140                                    Query q = session.createQuery(sql);
16141    
16142                                    QueryPos qPos = QueryPos.getInstance(q);
16143    
16144                                    qPos.add(groupId);
16145    
16146                                    qPos.add(classNameId);
16147    
16148                                    if (layoutUuid != null) {
16149                                            qPos.add(layoutUuid);
16150                                    }
16151    
16152                                    count = (Long)q.uniqueResult();
16153                            }
16154                            catch (Exception e) {
16155                                    throw processException(e);
16156                            }
16157                            finally {
16158                                    if (count == null) {
16159                                            count = Long.valueOf(0);
16160                                    }
16161    
16162                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_L,
16163                                            finderArgs, count);
16164    
16165                                    closeSession(session);
16166                            }
16167                    }
16168    
16169                    return count.intValue();
16170            }
16171    
16172            /**
16173             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16174             *
16175             * @param groupId the group ID
16176             * @param classNameId the class name ID
16177             * @param layoutUuid the layout uuid
16178             * @return the number of matching journal articles that the user has permission to view
16179             * @throws SystemException if a system exception occurred
16180             */
16181            public int filterCountByG_C_L(long groupId, long classNameId,
16182                    String layoutUuid) throws SystemException {
16183                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16184                            return countByG_C_L(groupId, classNameId, layoutUuid);
16185                    }
16186    
16187                    StringBundler query = new StringBundler(4);
16188    
16189                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16190    
16191                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
16192    
16193                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
16194    
16195                    if (layoutUuid == null) {
16196                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
16197                    }
16198                    else {
16199                            if (layoutUuid.equals(StringPool.BLANK)) {
16200                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
16201                            }
16202                            else {
16203                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
16204                            }
16205                    }
16206    
16207                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16208                                    JournalArticle.class.getName(),
16209                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16210    
16211                    Session session = null;
16212    
16213                    try {
16214                            session = openSession();
16215    
16216                            SQLQuery q = session.createSQLQuery(sql);
16217    
16218                            q.addScalar(COUNT_COLUMN_NAME,
16219                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16220    
16221                            QueryPos qPos = QueryPos.getInstance(q);
16222    
16223                            qPos.add(groupId);
16224    
16225                            qPos.add(classNameId);
16226    
16227                            if (layoutUuid != null) {
16228                                    qPos.add(layoutUuid);
16229                            }
16230    
16231                            Long count = (Long)q.uniqueResult();
16232    
16233                            return count.intValue();
16234                    }
16235                    catch (Exception e) {
16236                            throw processException(e);
16237                    }
16238                    finally {
16239                            closeSession(session);
16240                    }
16241            }
16242    
16243            /**
16244             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
16245             *
16246             * @param groupId the group ID
16247             * @param articleId the article ID
16248             * @param version the version
16249             * @return the number of matching journal articles
16250             * @throws SystemException if a system exception occurred
16251             */
16252            public int countByG_A_V(long groupId, String articleId, double version)
16253                    throws SystemException {
16254                    Object[] finderArgs = new Object[] { groupId, articleId, version };
16255    
16256                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_V,
16257                                    finderArgs, this);
16258    
16259                    if (count == null) {
16260                            StringBundler query = new StringBundler(4);
16261    
16262                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16263    
16264                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
16265    
16266                            if (articleId == null) {
16267                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
16268                            }
16269                            else {
16270                                    if (articleId.equals(StringPool.BLANK)) {
16271                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
16272                                    }
16273                                    else {
16274                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
16275                                    }
16276                            }
16277    
16278                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
16279    
16280                            String sql = query.toString();
16281    
16282                            Session session = null;
16283    
16284                            try {
16285                                    session = openSession();
16286    
16287                                    Query q = session.createQuery(sql);
16288    
16289                                    QueryPos qPos = QueryPos.getInstance(q);
16290    
16291                                    qPos.add(groupId);
16292    
16293                                    if (articleId != null) {
16294                                            qPos.add(articleId);
16295                                    }
16296    
16297                                    qPos.add(version);
16298    
16299                                    count = (Long)q.uniqueResult();
16300                            }
16301                            catch (Exception e) {
16302                                    throw processException(e);
16303                            }
16304                            finally {
16305                                    if (count == null) {
16306                                            count = Long.valueOf(0);
16307                                    }
16308    
16309                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V,
16310                                            finderArgs, count);
16311    
16312                                    closeSession(session);
16313                            }
16314                    }
16315    
16316                    return count.intValue();
16317            }
16318    
16319            /**
16320             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
16321             *
16322             * @param groupId the group ID
16323             * @param articleId the article ID
16324             * @param status the status
16325             * @return the number of matching journal articles
16326             * @throws SystemException if a system exception occurred
16327             */
16328            public int countByG_A_ST(long groupId, String articleId, int status)
16329                    throws SystemException {
16330                    Object[] finderArgs = new Object[] { groupId, articleId, status };
16331    
16332                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_ST,
16333                                    finderArgs, this);
16334    
16335                    if (count == null) {
16336                            StringBundler query = new StringBundler(4);
16337    
16338                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16339    
16340                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
16341    
16342                            if (articleId == null) {
16343                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
16344                            }
16345                            else {
16346                                    if (articleId.equals(StringPool.BLANK)) {
16347                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
16348                                    }
16349                                    else {
16350                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
16351                                    }
16352                            }
16353    
16354                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
16355    
16356                            String sql = query.toString();
16357    
16358                            Session session = null;
16359    
16360                            try {
16361                                    session = openSession();
16362    
16363                                    Query q = session.createQuery(sql);
16364    
16365                                    QueryPos qPos = QueryPos.getInstance(q);
16366    
16367                                    qPos.add(groupId);
16368    
16369                                    if (articleId != null) {
16370                                            qPos.add(articleId);
16371                                    }
16372    
16373                                    qPos.add(status);
16374    
16375                                    count = (Long)q.uniqueResult();
16376                            }
16377                            catch (Exception e) {
16378                                    throw processException(e);
16379                            }
16380                            finally {
16381                                    if (count == null) {
16382                                            count = Long.valueOf(0);
16383                                    }
16384    
16385                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_ST,
16386                                            finderArgs, count);
16387    
16388                                    closeSession(session);
16389                            }
16390                    }
16391    
16392                    return count.intValue();
16393            }
16394    
16395            /**
16396             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
16397             *
16398             * @param groupId the group ID
16399             * @param articleId the article ID
16400             * @param status the status
16401             * @return the number of matching journal articles that the user has permission to view
16402             * @throws SystemException if a system exception occurred
16403             */
16404            public int filterCountByG_A_ST(long groupId, String articleId, int status)
16405                    throws SystemException {
16406                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16407                            return countByG_A_ST(groupId, articleId, status);
16408                    }
16409    
16410                    StringBundler query = new StringBundler(4);
16411    
16412                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16413    
16414                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
16415    
16416                    if (articleId == null) {
16417                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
16418                    }
16419                    else {
16420                            if (articleId.equals(StringPool.BLANK)) {
16421                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
16422                            }
16423                            else {
16424                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
16425                            }
16426                    }
16427    
16428                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
16429    
16430                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16431                                    JournalArticle.class.getName(),
16432                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16433    
16434                    Session session = null;
16435    
16436                    try {
16437                            session = openSession();
16438    
16439                            SQLQuery q = session.createSQLQuery(sql);
16440    
16441                            q.addScalar(COUNT_COLUMN_NAME,
16442                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16443    
16444                            QueryPos qPos = QueryPos.getInstance(q);
16445    
16446                            qPos.add(groupId);
16447    
16448                            if (articleId != null) {
16449                                    qPos.add(articleId);
16450                            }
16451    
16452                            qPos.add(status);
16453    
16454                            Long count = (Long)q.uniqueResult();
16455    
16456                            return count.intValue();
16457                    }
16458                    catch (Exception e) {
16459                            throw processException(e);
16460                    }
16461                    finally {
16462                            closeSession(session);
16463                    }
16464            }
16465    
16466            /**
16467             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
16468             *
16469             * @param groupId the group ID
16470             * @param urlTitle the url title
16471             * @param status the status
16472             * @return the number of matching journal articles
16473             * @throws SystemException if a system exception occurred
16474             */
16475            public int countByG_UT_ST(long groupId, String urlTitle, int status)
16476                    throws SystemException {
16477                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
16478    
16479                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT_ST,
16480                                    finderArgs, this);
16481    
16482                    if (count == null) {
16483                            StringBundler query = new StringBundler(4);
16484    
16485                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16486    
16487                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
16488    
16489                            if (urlTitle == null) {
16490                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
16491                            }
16492                            else {
16493                                    if (urlTitle.equals(StringPool.BLANK)) {
16494                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
16495                                    }
16496                                    else {
16497                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
16498                                    }
16499                            }
16500    
16501                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
16502    
16503                            String sql = query.toString();
16504    
16505                            Session session = null;
16506    
16507                            try {
16508                                    session = openSession();
16509    
16510                                    Query q = session.createQuery(sql);
16511    
16512                                    QueryPos qPos = QueryPos.getInstance(q);
16513    
16514                                    qPos.add(groupId);
16515    
16516                                    if (urlTitle != null) {
16517                                            qPos.add(urlTitle);
16518                                    }
16519    
16520                                    qPos.add(status);
16521    
16522                                    count = (Long)q.uniqueResult();
16523                            }
16524                            catch (Exception e) {
16525                                    throw processException(e);
16526                            }
16527                            finally {
16528                                    if (count == null) {
16529                                            count = Long.valueOf(0);
16530                                    }
16531    
16532                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT_ST,
16533                                            finderArgs, count);
16534    
16535                                    closeSession(session);
16536                            }
16537                    }
16538    
16539                    return count.intValue();
16540            }
16541    
16542            /**
16543             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
16544             *
16545             * @param groupId the group ID
16546             * @param urlTitle the url title
16547             * @param status the status
16548             * @return the number of matching journal articles that the user has permission to view
16549             * @throws SystemException if a system exception occurred
16550             */
16551            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
16552                    throws SystemException {
16553                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16554                            return countByG_UT_ST(groupId, urlTitle, status);
16555                    }
16556    
16557                    StringBundler query = new StringBundler(4);
16558    
16559                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16560    
16561                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
16562    
16563                    if (urlTitle == null) {
16564                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
16565                    }
16566                    else {
16567                            if (urlTitle.equals(StringPool.BLANK)) {
16568                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
16569                            }
16570                            else {
16571                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
16572                            }
16573                    }
16574    
16575                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
16576    
16577                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16578                                    JournalArticle.class.getName(),
16579                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16580    
16581                    Session session = null;
16582    
16583                    try {
16584                            session = openSession();
16585    
16586                            SQLQuery q = session.createSQLQuery(sql);
16587    
16588                            q.addScalar(COUNT_COLUMN_NAME,
16589                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16590    
16591                            QueryPos qPos = QueryPos.getInstance(q);
16592    
16593                            qPos.add(groupId);
16594    
16595                            if (urlTitle != null) {
16596                                    qPos.add(urlTitle);
16597                            }
16598    
16599                            qPos.add(status);
16600    
16601                            Long count = (Long)q.uniqueResult();
16602    
16603                            return count.intValue();
16604                    }
16605                    catch (Exception e) {
16606                            throw processException(e);
16607                    }
16608                    finally {
16609                            closeSession(session);
16610                    }
16611            }
16612    
16613            /**
16614             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
16615             *
16616             * @param companyId the company ID
16617             * @param version the version
16618             * @param status the status
16619             * @return the number of matching journal articles
16620             * @throws SystemException if a system exception occurred
16621             */
16622            public int countByC_V_ST(long companyId, double version, int status)
16623                    throws SystemException {
16624                    Object[] finderArgs = new Object[] { companyId, version, status };
16625    
16626                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V_ST,
16627                                    finderArgs, this);
16628    
16629                    if (count == null) {
16630                            StringBundler query = new StringBundler(4);
16631    
16632                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16633    
16634                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
16635    
16636                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
16637    
16638                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
16639    
16640                            String sql = query.toString();
16641    
16642                            Session session = null;
16643    
16644                            try {
16645                                    session = openSession();
16646    
16647                                    Query q = session.createQuery(sql);
16648    
16649                                    QueryPos qPos = QueryPos.getInstance(q);
16650    
16651                                    qPos.add(companyId);
16652    
16653                                    qPos.add(version);
16654    
16655                                    qPos.add(status);
16656    
16657                                    count = (Long)q.uniqueResult();
16658                            }
16659                            catch (Exception e) {
16660                                    throw processException(e);
16661                            }
16662                            finally {
16663                                    if (count == null) {
16664                                            count = Long.valueOf(0);
16665                                    }
16666    
16667                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V_ST,
16668                                            finderArgs, count);
16669    
16670                                    closeSession(session);
16671                            }
16672                    }
16673    
16674                    return count.intValue();
16675            }
16676    
16677            /**
16678             * Returns the number of journal articles.
16679             *
16680             * @return the number of journal articles
16681             * @throws SystemException if a system exception occurred
16682             */
16683            public int countAll() throws SystemException {
16684                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
16685                                    FINDER_ARGS_EMPTY, this);
16686    
16687                    if (count == null) {
16688                            Session session = null;
16689    
16690                            try {
16691                                    session = openSession();
16692    
16693                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
16694    
16695                                    count = (Long)q.uniqueResult();
16696                            }
16697                            catch (Exception e) {
16698                                    throw processException(e);
16699                            }
16700                            finally {
16701                                    if (count == null) {
16702                                            count = Long.valueOf(0);
16703                                    }
16704    
16705                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
16706                                            FINDER_ARGS_EMPTY, count);
16707    
16708                                    closeSession(session);
16709                            }
16710                    }
16711    
16712                    return count.intValue();
16713            }
16714    
16715            /**
16716             * Initializes the journal article persistence.
16717             */
16718            public void afterPropertiesSet() {
16719                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
16720                                            com.liferay.portal.util.PropsUtil.get(
16721                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
16722    
16723                    if (listenerClassNames.length > 0) {
16724                            try {
16725                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
16726    
16727                                    for (String listenerClassName : listenerClassNames) {
16728                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
16729                                                            listenerClassName));
16730                                    }
16731    
16732                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
16733                            }
16734                            catch (Exception e) {
16735                                    _log.error(e);
16736                            }
16737                    }
16738            }
16739    
16740            public void destroy() {
16741                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
16742                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
16743                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
16744            }
16745    
16746            @BeanReference(type = JournalArticlePersistence.class)
16747            protected JournalArticlePersistence journalArticlePersistence;
16748            @BeanReference(type = JournalArticleImagePersistence.class)
16749            protected JournalArticleImagePersistence journalArticleImagePersistence;
16750            @BeanReference(type = JournalArticleResourcePersistence.class)
16751            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
16752            @BeanReference(type = JournalContentSearchPersistence.class)
16753            protected JournalContentSearchPersistence journalContentSearchPersistence;
16754            @BeanReference(type = JournalFeedPersistence.class)
16755            protected JournalFeedPersistence journalFeedPersistence;
16756            @BeanReference(type = JournalStructurePersistence.class)
16757            protected JournalStructurePersistence journalStructurePersistence;
16758            @BeanReference(type = JournalTemplatePersistence.class)
16759            protected JournalTemplatePersistence journalTemplatePersistence;
16760            @BeanReference(type = CompanyPersistence.class)
16761            protected CompanyPersistence companyPersistence;
16762            @BeanReference(type = GroupPersistence.class)
16763            protected GroupPersistence groupPersistence;
16764            @BeanReference(type = ImagePersistence.class)
16765            protected ImagePersistence imagePersistence;
16766            @BeanReference(type = PortletPreferencesPersistence.class)
16767            protected PortletPreferencesPersistence portletPreferencesPersistence;
16768            @BeanReference(type = ResourcePersistence.class)
16769            protected ResourcePersistence resourcePersistence;
16770            @BeanReference(type = SubscriptionPersistence.class)
16771            protected SubscriptionPersistence subscriptionPersistence;
16772            @BeanReference(type = UserPersistence.class)
16773            protected UserPersistence userPersistence;
16774            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
16775            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
16776            @BeanReference(type = AssetCategoryPersistence.class)
16777            protected AssetCategoryPersistence assetCategoryPersistence;
16778            @BeanReference(type = AssetEntryPersistence.class)
16779            protected AssetEntryPersistence assetEntryPersistence;
16780            @BeanReference(type = AssetLinkPersistence.class)
16781            protected AssetLinkPersistence assetLinkPersistence;
16782            @BeanReference(type = AssetTagPersistence.class)
16783            protected AssetTagPersistence assetTagPersistence;
16784            @BeanReference(type = ExpandoValuePersistence.class)
16785            protected ExpandoValuePersistence expandoValuePersistence;
16786            @BeanReference(type = MBMessagePersistence.class)
16787            protected MBMessagePersistence mbMessagePersistence;
16788            @BeanReference(type = RatingsStatsPersistence.class)
16789            protected RatingsStatsPersistence ratingsStatsPersistence;
16790            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
16791            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
16792            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
16793            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
16794            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
16795            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
16796            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?)";
16797            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
16798            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
16799            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?) AND ";
16800            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
16801            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
16802                    "journalArticle.resourcePrimKey = ?";
16803            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
16804            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
16805            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
16806            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
16807            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
16808            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
16809            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
16810            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
16811            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?)";
16812            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
16813            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
16814            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
16815            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?)";
16816            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
16817            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
16818            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
16819            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
16820            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
16821            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
16822            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
16823            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
16824            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
16825            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
16826            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
16827            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
16828            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
16829            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
16830            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16831            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
16832            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16833            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
16834            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
16835            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
16836            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
16837            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
16838            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
16839            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
16840            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
16841            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
16842            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
16843            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
16844            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
16845            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
16846            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
16847            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
16848            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
16849            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
16850            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
16851            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
16852            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
16853            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
16854            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
16855            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
16856            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
16857            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
16858            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
16859            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
16860            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
16861            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
16862            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
16863            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
16864            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
16865            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?) AND ";
16866            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
16867            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16868            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
16869            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
16870            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.id_";
16871            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
16872            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
16873                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
16874            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
16875                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
16876            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
16877            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
16878            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
16879            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
16880            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
16881            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
16882            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
16883            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
16884            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
16885            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
16886                            @Override
16887                            public Object clone() {
16888                                    return this;
16889                            }
16890    
16891                            @Override
16892                            public CacheModel<JournalArticle> toCacheModel() {
16893                                    return _nullJournalArticleCacheModel;
16894                            }
16895                    };
16896    
16897            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
16898                            public JournalArticle toEntityModel() {
16899                                    return _nullJournalArticle;
16900                            }
16901                    };
16902    }