001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.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 where groupId = &#63; and articleId = &#63; and status = any &#63;.
12387             *
12388             * <p>
12389             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12390             * </p>
12391             *
12392             * @param groupId the group ID
12393             * @param articleId the article ID
12394             * @param statuses the statuses
12395             * @return the matching journal articles
12396             * @throws SystemException if a system exception occurred
12397             */
12398            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
12399                    int[] statuses) throws SystemException {
12400                    return findByG_A_ST(groupId, articleId, statuses, QueryUtil.ALL_POS,
12401                            QueryUtil.ALL_POS, null);
12402            }
12403    
12404            /**
12405             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
12406             *
12407             * <p>
12408             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12409             * </p>
12410             *
12411             * @param groupId the group ID
12412             * @param articleId the article ID
12413             * @param statuses the statuses
12414             * @param start the lower bound of the range of journal articles
12415             * @param end the upper bound of the range of journal articles (not inclusive)
12416             * @return the range of matching journal articles
12417             * @throws SystemException if a system exception occurred
12418             */
12419            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
12420                    int[] statuses, int start, int end) throws SystemException {
12421                    return findByG_A_ST(groupId, articleId, statuses, start, end, null);
12422            }
12423    
12424            /**
12425             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
12426             *
12427             * <p>
12428             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12429             * </p>
12430             *
12431             * @param groupId the group ID
12432             * @param articleId the article ID
12433             * @param statuses the statuses
12434             * @param start the lower bound of the range of journal articles
12435             * @param end the upper bound of the range of journal articles (not inclusive)
12436             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12437             * @return the ordered range of matching journal articles
12438             * @throws SystemException if a system exception occurred
12439             */
12440            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
12441                    int[] statuses, int start, int end, OrderByComparator orderByComparator)
12442                    throws SystemException {
12443                    FinderPath finderPath = null;
12444                    Object[] finderArgs = null;
12445    
12446                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12447                                    (orderByComparator == null)) {
12448                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
12449                            finderArgs = new Object[] {
12450                                            groupId, articleId, StringUtil.merge(statuses)
12451                                    };
12452                    }
12453                    else {
12454                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
12455                            finderArgs = new Object[] {
12456                                            groupId, articleId, StringUtil.merge(statuses),
12457    
12458                                            start, end, orderByComparator
12459                                    };
12460                    }
12461    
12462                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12463                                    finderArgs, this);
12464    
12465                    if (list == null) {
12466                            StringBundler query = new StringBundler();
12467    
12468                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12469    
12470                            boolean conjunctionable = false;
12471    
12472                            if (conjunctionable) {
12473                                    query.append(WHERE_AND);
12474                            }
12475    
12476                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
12477    
12478                            conjunctionable = true;
12479    
12480                            if (conjunctionable) {
12481                                    query.append(WHERE_AND);
12482                            }
12483    
12484                            if (articleId == null) {
12485                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
12486                            }
12487                            else {
12488                                    if (articleId.equals(StringPool.BLANK)) {
12489                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
12490                                    }
12491                                    else {
12492                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
12493                                    }
12494                            }
12495    
12496                            conjunctionable = true;
12497    
12498                            if ((statuses == null) || (statuses.length > 0)) {
12499                                    if (conjunctionable) {
12500                                            query.append(WHERE_AND);
12501                                    }
12502    
12503                                    query.append(StringPool.OPEN_PARENTHESIS);
12504    
12505                                    for (int i = 0; i < statuses.length; i++) {
12506                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
12507    
12508                                            if ((i + 1) < statuses.length) {
12509                                                    query.append(WHERE_OR);
12510                                            }
12511                                    }
12512    
12513                                    query.append(StringPool.CLOSE_PARENTHESIS);
12514    
12515                                    conjunctionable = true;
12516                            }
12517    
12518                            if (orderByComparator != null) {
12519                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12520                                            orderByComparator);
12521                            }
12522    
12523                            else {
12524                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12525                            }
12526    
12527                            String sql = query.toString();
12528    
12529                            Session session = null;
12530    
12531                            try {
12532                                    session = openSession();
12533    
12534                                    Query q = session.createQuery(sql);
12535    
12536                                    QueryPos qPos = QueryPos.getInstance(q);
12537    
12538                                    qPos.add(groupId);
12539    
12540                                    if (articleId != null) {
12541                                            qPos.add(articleId);
12542                                    }
12543    
12544                                    if (statuses != null) {
12545                                            qPos.add(statuses);
12546                                    }
12547    
12548                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
12549                                                    start, end);
12550                            }
12551                            catch (Exception e) {
12552                                    throw processException(e);
12553                            }
12554                            finally {
12555                                    if (list == null) {
12556                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
12557                                    }
12558                                    else {
12559                                            cacheResult(list);
12560    
12561                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12562                                    }
12563    
12564                                    closeSession(session);
12565                            }
12566                    }
12567    
12568                    return list;
12569            }
12570    
12571            /**
12572             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
12573             *
12574             * @param groupId the group ID
12575             * @param articleId the article ID
12576             * @param status the status
12577             * @return the matching journal articles that the user has permission to view
12578             * @throws SystemException if a system exception occurred
12579             */
12580            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12581                    String articleId, int status) throws SystemException {
12582                    return filterFindByG_A_ST(groupId, articleId, status,
12583                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12584            }
12585    
12586            /**
12587             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
12588             *
12589             * <p>
12590             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12591             * </p>
12592             *
12593             * @param groupId the group ID
12594             * @param articleId the article ID
12595             * @param status the status
12596             * @param start the lower bound of the range of journal articles
12597             * @param end the upper bound of the range of journal articles (not inclusive)
12598             * @return the range of matching journal articles that the user has permission to view
12599             * @throws SystemException if a system exception occurred
12600             */
12601            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12602                    String articleId, int status, int start, int end)
12603                    throws SystemException {
12604                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
12605            }
12606    
12607            /**
12608             * 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;.
12609             *
12610             * <p>
12611             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12612             * </p>
12613             *
12614             * @param groupId the group ID
12615             * @param articleId the article ID
12616             * @param status the status
12617             * @param start the lower bound of the range of journal articles
12618             * @param end the upper bound of the range of journal articles (not inclusive)
12619             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12620             * @return the ordered range of matching journal articles that the user has permission to view
12621             * @throws SystemException if a system exception occurred
12622             */
12623            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12624                    String articleId, int status, int start, int end,
12625                    OrderByComparator orderByComparator) throws SystemException {
12626                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12627                            return findByG_A_ST(groupId, articleId, status, start, end,
12628                                    orderByComparator);
12629                    }
12630    
12631                    StringBundler query = null;
12632    
12633                    if (orderByComparator != null) {
12634                            query = new StringBundler(5 +
12635                                            (orderByComparator.getOrderByFields().length * 3));
12636                    }
12637                    else {
12638                            query = new StringBundler(5);
12639                    }
12640    
12641                    if (getDB().isSupportsInlineDistinct()) {
12642                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12643                    }
12644                    else {
12645                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12646                    }
12647    
12648                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
12649    
12650                    if (articleId == null) {
12651                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
12652                    }
12653                    else {
12654                            if (articleId.equals(StringPool.BLANK)) {
12655                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
12656                            }
12657                            else {
12658                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
12659                            }
12660                    }
12661    
12662                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
12663    
12664                    if (!getDB().isSupportsInlineDistinct()) {
12665                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12666                    }
12667    
12668                    if (orderByComparator != null) {
12669                            if (getDB().isSupportsInlineDistinct()) {
12670                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12671                                            orderByComparator);
12672                            }
12673                            else {
12674                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12675                                            orderByComparator);
12676                            }
12677                    }
12678    
12679                    else {
12680                            if (getDB().isSupportsInlineDistinct()) {
12681                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12682                            }
12683                            else {
12684                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12685                            }
12686                    }
12687    
12688                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12689                                    JournalArticle.class.getName(),
12690                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12691    
12692                    Session session = null;
12693    
12694                    try {
12695                            session = openSession();
12696    
12697                            SQLQuery q = session.createSQLQuery(sql);
12698    
12699                            if (getDB().isSupportsInlineDistinct()) {
12700                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12701                            }
12702                            else {
12703                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12704                            }
12705    
12706                            QueryPos qPos = QueryPos.getInstance(q);
12707    
12708                            qPos.add(groupId);
12709    
12710                            if (articleId != null) {
12711                                    qPos.add(articleId);
12712                            }
12713    
12714                            qPos.add(status);
12715    
12716                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12717                                    end);
12718                    }
12719                    catch (Exception e) {
12720                            throw processException(e);
12721                    }
12722                    finally {
12723                            closeSession(session);
12724                    }
12725            }
12726    
12727            /**
12728             * 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;.
12729             *
12730             * @param id the primary key of the current journal article
12731             * @param groupId the group ID
12732             * @param articleId the article ID
12733             * @param status the status
12734             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12735             * @return the previous, current, and next journal article
12736             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12737             * @throws SystemException if a system exception occurred
12738             */
12739            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
12740                    long groupId, String articleId, int status,
12741                    OrderByComparator orderByComparator)
12742                    throws NoSuchArticleException, SystemException {
12743                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12744                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
12745                                    orderByComparator);
12746                    }
12747    
12748                    JournalArticle journalArticle = findByPrimaryKey(id);
12749    
12750                    Session session = null;
12751    
12752                    try {
12753                            session = openSession();
12754    
12755                            JournalArticle[] array = new JournalArticleImpl[3];
12756    
12757                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
12758                                            groupId, articleId, status, orderByComparator, true);
12759    
12760                            array[1] = journalArticle;
12761    
12762                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
12763                                            groupId, articleId, status, orderByComparator, false);
12764    
12765                            return array;
12766                    }
12767                    catch (Exception e) {
12768                            throw processException(e);
12769                    }
12770                    finally {
12771                            closeSession(session);
12772                    }
12773            }
12774    
12775            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
12776                    JournalArticle journalArticle, long groupId, String articleId,
12777                    int status, OrderByComparator orderByComparator, boolean previous) {
12778                    StringBundler query = null;
12779    
12780                    if (orderByComparator != null) {
12781                            query = new StringBundler(6 +
12782                                            (orderByComparator.getOrderByFields().length * 6));
12783                    }
12784                    else {
12785                            query = new StringBundler(3);
12786                    }
12787    
12788                    if (getDB().isSupportsInlineDistinct()) {
12789                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12790                    }
12791                    else {
12792                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12793                    }
12794    
12795                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
12796    
12797                    if (articleId == null) {
12798                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
12799                    }
12800                    else {
12801                            if (articleId.equals(StringPool.BLANK)) {
12802                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
12803                            }
12804                            else {
12805                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
12806                            }
12807                    }
12808    
12809                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
12810    
12811                    if (!getDB().isSupportsInlineDistinct()) {
12812                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12813                    }
12814    
12815                    if (orderByComparator != null) {
12816                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12817    
12818                            if (orderByConditionFields.length > 0) {
12819                                    query.append(WHERE_AND);
12820                            }
12821    
12822                            for (int i = 0; i < orderByConditionFields.length; i++) {
12823                                    if (getDB().isSupportsInlineDistinct()) {
12824                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12825                                    }
12826                                    else {
12827                                            query.append(_ORDER_BY_ENTITY_TABLE);
12828                                    }
12829    
12830                                    query.append(orderByConditionFields[i]);
12831    
12832                                    if ((i + 1) < orderByConditionFields.length) {
12833                                            if (orderByComparator.isAscending() ^ previous) {
12834                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12835                                            }
12836                                            else {
12837                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12838                                            }
12839                                    }
12840                                    else {
12841                                            if (orderByComparator.isAscending() ^ previous) {
12842                                                    query.append(WHERE_GREATER_THAN);
12843                                            }
12844                                            else {
12845                                                    query.append(WHERE_LESSER_THAN);
12846                                            }
12847                                    }
12848                            }
12849    
12850                            query.append(ORDER_BY_CLAUSE);
12851    
12852                            String[] orderByFields = orderByComparator.getOrderByFields();
12853    
12854                            for (int i = 0; i < orderByFields.length; i++) {
12855                                    if (getDB().isSupportsInlineDistinct()) {
12856                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12857                                    }
12858                                    else {
12859                                            query.append(_ORDER_BY_ENTITY_TABLE);
12860                                    }
12861    
12862                                    query.append(orderByFields[i]);
12863    
12864                                    if ((i + 1) < orderByFields.length) {
12865                                            if (orderByComparator.isAscending() ^ previous) {
12866                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12867                                            }
12868                                            else {
12869                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12870                                            }
12871                                    }
12872                                    else {
12873                                            if (orderByComparator.isAscending() ^ previous) {
12874                                                    query.append(ORDER_BY_ASC);
12875                                            }
12876                                            else {
12877                                                    query.append(ORDER_BY_DESC);
12878                                            }
12879                                    }
12880                            }
12881                    }
12882    
12883                    else {
12884                            if (getDB().isSupportsInlineDistinct()) {
12885                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12886                            }
12887                            else {
12888                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12889                            }
12890                    }
12891    
12892                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12893                                    JournalArticle.class.getName(),
12894                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12895    
12896                    SQLQuery q = session.createSQLQuery(sql);
12897    
12898                    q.setFirstResult(0);
12899                    q.setMaxResults(2);
12900    
12901                    if (getDB().isSupportsInlineDistinct()) {
12902                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12903                    }
12904                    else {
12905                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12906                    }
12907    
12908                    QueryPos qPos = QueryPos.getInstance(q);
12909    
12910                    qPos.add(groupId);
12911    
12912                    if (articleId != null) {
12913                            qPos.add(articleId);
12914                    }
12915    
12916                    qPos.add(status);
12917    
12918                    if (orderByComparator != null) {
12919                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12920    
12921                            for (Object value : values) {
12922                                    qPos.add(value);
12923                            }
12924                    }
12925    
12926                    List<JournalArticle> list = q.list();
12927    
12928                    if (list.size() == 2) {
12929                            return list.get(1);
12930                    }
12931                    else {
12932                            return null;
12933                    }
12934            }
12935    
12936            /**
12937             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
12938             *
12939             * @param groupId the group ID
12940             * @param articleId the article ID
12941             * @param statuses the statuses
12942             * @return the matching journal articles that the user has permission to view
12943             * @throws SystemException if a system exception occurred
12944             */
12945            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12946                    String articleId, int[] statuses) throws SystemException {
12947                    return filterFindByG_A_ST(groupId, articleId, statuses,
12948                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12949            }
12950    
12951            /**
12952             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
12953             *
12954             * <p>
12955             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12956             * </p>
12957             *
12958             * @param groupId the group ID
12959             * @param articleId the article ID
12960             * @param statuses the statuses
12961             * @param start the lower bound of the range of journal articles
12962             * @param end the upper bound of the range of journal articles (not inclusive)
12963             * @return the range of matching journal articles that the user has permission to view
12964             * @throws SystemException if a system exception occurred
12965             */
12966            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12967                    String articleId, int[] statuses, int start, int end)
12968                    throws SystemException {
12969                    return filterFindByG_A_ST(groupId, articleId, statuses, start, end, null);
12970            }
12971    
12972            /**
12973             * Returns an ordered range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
12974             *
12975             * <p>
12976             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12977             * </p>
12978             *
12979             * @param groupId the group ID
12980             * @param articleId the article ID
12981             * @param statuses the statuses
12982             * @param start the lower bound of the range of journal articles
12983             * @param end the upper bound of the range of journal articles (not inclusive)
12984             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12985             * @return the ordered range of matching journal articles that the user has permission to view
12986             * @throws SystemException if a system exception occurred
12987             */
12988            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12989                    String articleId, int[] statuses, int start, int end,
12990                    OrderByComparator orderByComparator) throws SystemException {
12991                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12992                            return findByG_A_ST(groupId, articleId, statuses, start, end,
12993                                    orderByComparator);
12994                    }
12995    
12996                    StringBundler query = new StringBundler();
12997    
12998                    if (getDB().isSupportsInlineDistinct()) {
12999                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13000                    }
13001                    else {
13002                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13003                    }
13004    
13005                    boolean conjunctionable = false;
13006    
13007                    if (conjunctionable) {
13008                            query.append(WHERE_AND);
13009                    }
13010    
13011                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
13012    
13013                    conjunctionable = true;
13014    
13015                    if (conjunctionable) {
13016                            query.append(WHERE_AND);
13017                    }
13018    
13019                    if (articleId == null) {
13020                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
13021                    }
13022                    else {
13023                            if (articleId.equals(StringPool.BLANK)) {
13024                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
13025                            }
13026                            else {
13027                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
13028                            }
13029                    }
13030    
13031                    conjunctionable = true;
13032    
13033                    if ((statuses == null) || (statuses.length > 0)) {
13034                            if (conjunctionable) {
13035                                    query.append(WHERE_AND);
13036                            }
13037    
13038                            query.append(StringPool.OPEN_PARENTHESIS);
13039    
13040                            for (int i = 0; i < statuses.length; i++) {
13041                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
13042    
13043                                    if ((i + 1) < statuses.length) {
13044                                            query.append(WHERE_OR);
13045                                    }
13046                            }
13047    
13048                            query.append(StringPool.CLOSE_PARENTHESIS);
13049    
13050                            conjunctionable = true;
13051                    }
13052    
13053                    if (!getDB().isSupportsInlineDistinct()) {
13054                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13055                    }
13056    
13057                    if (orderByComparator != null) {
13058                            if (getDB().isSupportsInlineDistinct()) {
13059                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13060                                            orderByComparator);
13061                            }
13062                            else {
13063                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13064                                            orderByComparator);
13065                            }
13066                    }
13067    
13068                    else {
13069                            if (getDB().isSupportsInlineDistinct()) {
13070                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13071                            }
13072                            else {
13073                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13074                            }
13075                    }
13076    
13077                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13078                                    JournalArticle.class.getName(),
13079                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13080    
13081                    Session session = null;
13082    
13083                    try {
13084                            session = openSession();
13085    
13086                            SQLQuery q = session.createSQLQuery(sql);
13087    
13088                            if (getDB().isSupportsInlineDistinct()) {
13089                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13090                            }
13091                            else {
13092                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13093                            }
13094    
13095                            QueryPos qPos = QueryPos.getInstance(q);
13096    
13097                            qPos.add(groupId);
13098    
13099                            if (articleId != null) {
13100                                    qPos.add(articleId);
13101                            }
13102    
13103                            if (statuses != null) {
13104                                    qPos.add(statuses);
13105                            }
13106    
13107                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13108                                    end);
13109                    }
13110                    catch (Exception e) {
13111                            throw processException(e);
13112                    }
13113                    finally {
13114                            closeSession(session);
13115                    }
13116            }
13117    
13118            /**
13119             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13120             *
13121             * @param groupId the group ID
13122             * @param urlTitle the url title
13123             * @param status the status
13124             * @return the matching journal articles
13125             * @throws SystemException if a system exception occurred
13126             */
13127            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
13128                    int status) throws SystemException {
13129                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
13130                            QueryUtil.ALL_POS, null);
13131            }
13132    
13133            /**
13134             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13135             *
13136             * <p>
13137             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13138             * </p>
13139             *
13140             * @param groupId the group ID
13141             * @param urlTitle the url title
13142             * @param status the status
13143             * @param start the lower bound of the range of journal articles
13144             * @param end the upper bound of the range of journal articles (not inclusive)
13145             * @return the range of matching journal articles
13146             * @throws SystemException if a system exception occurred
13147             */
13148            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
13149                    int status, int start, int end) throws SystemException {
13150                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
13151            }
13152    
13153            /**
13154             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13155             *
13156             * <p>
13157             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13158             * </p>
13159             *
13160             * @param groupId the group ID
13161             * @param urlTitle the url title
13162             * @param status the status
13163             * @param start the lower bound of the range of journal articles
13164             * @param end the upper bound of the range of journal articles (not inclusive)
13165             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13166             * @return the ordered range of matching journal articles
13167             * @throws SystemException if a system exception occurred
13168             */
13169            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
13170                    int status, int start, int end, OrderByComparator orderByComparator)
13171                    throws SystemException {
13172                    FinderPath finderPath = null;
13173                    Object[] finderArgs = null;
13174    
13175                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13176                                    (orderByComparator == null)) {
13177                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
13178                            finderArgs = new Object[] { groupId, urlTitle, status };
13179                    }
13180                    else {
13181                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
13182                            finderArgs = new Object[] {
13183                                            groupId, urlTitle, status,
13184                                            
13185                                            start, end, orderByComparator
13186                                    };
13187                    }
13188    
13189                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13190                                    finderArgs, this);
13191    
13192                    if (list == null) {
13193                            StringBundler query = null;
13194    
13195                            if (orderByComparator != null) {
13196                                    query = new StringBundler(5 +
13197                                                    (orderByComparator.getOrderByFields().length * 3));
13198                            }
13199                            else {
13200                                    query = new StringBundler(5);
13201                            }
13202    
13203                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13204    
13205                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
13206    
13207                            if (urlTitle == null) {
13208                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
13209                            }
13210                            else {
13211                                    if (urlTitle.equals(StringPool.BLANK)) {
13212                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
13213                                    }
13214                                    else {
13215                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
13216                                    }
13217                            }
13218    
13219                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
13220    
13221                            if (orderByComparator != null) {
13222                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13223                                            orderByComparator);
13224                            }
13225    
13226                            else {
13227                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13228                            }
13229    
13230                            String sql = query.toString();
13231    
13232                            Session session = null;
13233    
13234                            try {
13235                                    session = openSession();
13236    
13237                                    Query q = session.createQuery(sql);
13238    
13239                                    QueryPos qPos = QueryPos.getInstance(q);
13240    
13241                                    qPos.add(groupId);
13242    
13243                                    if (urlTitle != null) {
13244                                            qPos.add(urlTitle);
13245                                    }
13246    
13247                                    qPos.add(status);
13248    
13249                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
13250                                                    start, end);
13251                            }
13252                            catch (Exception e) {
13253                                    throw processException(e);
13254                            }
13255                            finally {
13256                                    if (list == null) {
13257                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
13258                                    }
13259                                    else {
13260                                            cacheResult(list);
13261    
13262                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
13263                                    }
13264    
13265                                    closeSession(session);
13266                            }
13267                    }
13268    
13269                    return list;
13270            }
13271    
13272            /**
13273             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13274             *
13275             * <p>
13276             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13277             * </p>
13278             *
13279             * @param groupId the group ID
13280             * @param urlTitle the url title
13281             * @param status the status
13282             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13283             * @return the first matching journal article
13284             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13285             * @throws SystemException if a system exception occurred
13286             */
13287            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
13288                    int status, OrderByComparator orderByComparator)
13289                    throws NoSuchArticleException, SystemException {
13290                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
13291                                    1, orderByComparator);
13292    
13293                    if (list.isEmpty()) {
13294                            StringBundler msg = new StringBundler(8);
13295    
13296                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13297    
13298                            msg.append("groupId=");
13299                            msg.append(groupId);
13300    
13301                            msg.append(", urlTitle=");
13302                            msg.append(urlTitle);
13303    
13304                            msg.append(", status=");
13305                            msg.append(status);
13306    
13307                            msg.append(StringPool.CLOSE_CURLY_BRACE);
13308    
13309                            throw new NoSuchArticleException(msg.toString());
13310                    }
13311                    else {
13312                            return list.get(0);
13313                    }
13314            }
13315    
13316            /**
13317             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13318             *
13319             * <p>
13320             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13321             * </p>
13322             *
13323             * @param groupId the group ID
13324             * @param urlTitle the url title
13325             * @param status the status
13326             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13327             * @return the last matching journal article
13328             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13329             * @throws SystemException if a system exception occurred
13330             */
13331            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
13332                    int status, OrderByComparator orderByComparator)
13333                    throws NoSuchArticleException, SystemException {
13334                    int count = countByG_UT_ST(groupId, urlTitle, status);
13335    
13336                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
13337                                    count - 1, count, orderByComparator);
13338    
13339                    if (list.isEmpty()) {
13340                            StringBundler msg = new StringBundler(8);
13341    
13342                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13343    
13344                            msg.append("groupId=");
13345                            msg.append(groupId);
13346    
13347                            msg.append(", urlTitle=");
13348                            msg.append(urlTitle);
13349    
13350                            msg.append(", status=");
13351                            msg.append(status);
13352    
13353                            msg.append(StringPool.CLOSE_CURLY_BRACE);
13354    
13355                            throw new NoSuchArticleException(msg.toString());
13356                    }
13357                    else {
13358                            return list.get(0);
13359                    }
13360            }
13361    
13362            /**
13363             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13364             *
13365             * <p>
13366             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13367             * </p>
13368             *
13369             * @param id the primary key of the current journal article
13370             * @param groupId the group ID
13371             * @param urlTitle the url title
13372             * @param status the status
13373             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13374             * @return the previous, current, and next journal article
13375             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13376             * @throws SystemException if a system exception occurred
13377             */
13378            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
13379                    String urlTitle, int status, OrderByComparator orderByComparator)
13380                    throws NoSuchArticleException, SystemException {
13381                    JournalArticle journalArticle = findByPrimaryKey(id);
13382    
13383                    Session session = null;
13384    
13385                    try {
13386                            session = openSession();
13387    
13388                            JournalArticle[] array = new JournalArticleImpl[3];
13389    
13390                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
13391                                            groupId, urlTitle, status, orderByComparator, true);
13392    
13393                            array[1] = journalArticle;
13394    
13395                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
13396                                            groupId, urlTitle, status, orderByComparator, false);
13397    
13398                            return array;
13399                    }
13400                    catch (Exception e) {
13401                            throw processException(e);
13402                    }
13403                    finally {
13404                            closeSession(session);
13405                    }
13406            }
13407    
13408            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
13409                    JournalArticle journalArticle, long groupId, String urlTitle,
13410                    int status, OrderByComparator orderByComparator, boolean previous) {
13411                    StringBundler query = null;
13412    
13413                    if (orderByComparator != null) {
13414                            query = new StringBundler(6 +
13415                                            (orderByComparator.getOrderByFields().length * 6));
13416                    }
13417                    else {
13418                            query = new StringBundler(3);
13419                    }
13420    
13421                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13422    
13423                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
13424    
13425                    if (urlTitle == null) {
13426                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
13427                    }
13428                    else {
13429                            if (urlTitle.equals(StringPool.BLANK)) {
13430                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
13431                            }
13432                            else {
13433                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
13434                            }
13435                    }
13436    
13437                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
13438    
13439                    if (orderByComparator != null) {
13440                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13441    
13442                            if (orderByConditionFields.length > 0) {
13443                                    query.append(WHERE_AND);
13444                            }
13445    
13446                            for (int i = 0; i < orderByConditionFields.length; i++) {
13447                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13448                                    query.append(orderByConditionFields[i]);
13449    
13450                                    if ((i + 1) < orderByConditionFields.length) {
13451                                            if (orderByComparator.isAscending() ^ previous) {
13452                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13453                                            }
13454                                            else {
13455                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13456                                            }
13457                                    }
13458                                    else {
13459                                            if (orderByComparator.isAscending() ^ previous) {
13460                                                    query.append(WHERE_GREATER_THAN);
13461                                            }
13462                                            else {
13463                                                    query.append(WHERE_LESSER_THAN);
13464                                            }
13465                                    }
13466                            }
13467    
13468                            query.append(ORDER_BY_CLAUSE);
13469    
13470                            String[] orderByFields = orderByComparator.getOrderByFields();
13471    
13472                            for (int i = 0; i < orderByFields.length; i++) {
13473                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13474                                    query.append(orderByFields[i]);
13475    
13476                                    if ((i + 1) < orderByFields.length) {
13477                                            if (orderByComparator.isAscending() ^ previous) {
13478                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13479                                            }
13480                                            else {
13481                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13482                                            }
13483                                    }
13484                                    else {
13485                                            if (orderByComparator.isAscending() ^ previous) {
13486                                                    query.append(ORDER_BY_ASC);
13487                                            }
13488                                            else {
13489                                                    query.append(ORDER_BY_DESC);
13490                                            }
13491                                    }
13492                            }
13493                    }
13494    
13495                    else {
13496                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13497                    }
13498    
13499                    String sql = query.toString();
13500    
13501                    Query q = session.createQuery(sql);
13502    
13503                    q.setFirstResult(0);
13504                    q.setMaxResults(2);
13505    
13506                    QueryPos qPos = QueryPos.getInstance(q);
13507    
13508                    qPos.add(groupId);
13509    
13510                    if (urlTitle != null) {
13511                            qPos.add(urlTitle);
13512                    }
13513    
13514                    qPos.add(status);
13515    
13516                    if (orderByComparator != null) {
13517                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13518    
13519                            for (Object value : values) {
13520                                    qPos.add(value);
13521                            }
13522                    }
13523    
13524                    List<JournalArticle> list = q.list();
13525    
13526                    if (list.size() == 2) {
13527                            return list.get(1);
13528                    }
13529                    else {
13530                            return null;
13531                    }
13532            }
13533    
13534            /**
13535             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13536             *
13537             * @param groupId the group ID
13538             * @param urlTitle the url title
13539             * @param status the status
13540             * @return the matching journal articles that the user has permission to view
13541             * @throws SystemException if a system exception occurred
13542             */
13543            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
13544                    String urlTitle, int status) throws SystemException {
13545                    return filterFindByG_UT_ST(groupId, urlTitle, status,
13546                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13547            }
13548    
13549            /**
13550             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13551             *
13552             * <p>
13553             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13554             * </p>
13555             *
13556             * @param groupId the group ID
13557             * @param urlTitle the url title
13558             * @param status the status
13559             * @param start the lower bound of the range of journal articles
13560             * @param end the upper bound of the range of journal articles (not inclusive)
13561             * @return the range of matching journal articles that the user has permission to view
13562             * @throws SystemException if a system exception occurred
13563             */
13564            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
13565                    String urlTitle, int status, int start, int end)
13566                    throws SystemException {
13567                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
13568            }
13569    
13570            /**
13571             * 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;.
13572             *
13573             * <p>
13574             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13575             * </p>
13576             *
13577             * @param groupId the group ID
13578             * @param urlTitle the url title
13579             * @param status the status
13580             * @param start the lower bound of the range of journal articles
13581             * @param end the upper bound of the range of journal articles (not inclusive)
13582             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13583             * @return the ordered range of matching journal articles that the user has permission to view
13584             * @throws SystemException if a system exception occurred
13585             */
13586            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
13587                    String urlTitle, int status, int start, int end,
13588                    OrderByComparator orderByComparator) throws SystemException {
13589                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13590                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
13591                                    orderByComparator);
13592                    }
13593    
13594                    StringBundler query = null;
13595    
13596                    if (orderByComparator != null) {
13597                            query = new StringBundler(5 +
13598                                            (orderByComparator.getOrderByFields().length * 3));
13599                    }
13600                    else {
13601                            query = new StringBundler(5);
13602                    }
13603    
13604                    if (getDB().isSupportsInlineDistinct()) {
13605                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13606                    }
13607                    else {
13608                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13609                    }
13610    
13611                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
13612    
13613                    if (urlTitle == null) {
13614                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
13615                    }
13616                    else {
13617                            if (urlTitle.equals(StringPool.BLANK)) {
13618                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
13619                            }
13620                            else {
13621                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
13622                            }
13623                    }
13624    
13625                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
13626    
13627                    if (!getDB().isSupportsInlineDistinct()) {
13628                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13629                    }
13630    
13631                    if (orderByComparator != null) {
13632                            if (getDB().isSupportsInlineDistinct()) {
13633                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13634                                            orderByComparator);
13635                            }
13636                            else {
13637                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13638                                            orderByComparator);
13639                            }
13640                    }
13641    
13642                    else {
13643                            if (getDB().isSupportsInlineDistinct()) {
13644                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13645                            }
13646                            else {
13647                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13648                            }
13649                    }
13650    
13651                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13652                                    JournalArticle.class.getName(),
13653                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13654    
13655                    Session session = null;
13656    
13657                    try {
13658                            session = openSession();
13659    
13660                            SQLQuery q = session.createSQLQuery(sql);
13661    
13662                            if (getDB().isSupportsInlineDistinct()) {
13663                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13664                            }
13665                            else {
13666                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13667                            }
13668    
13669                            QueryPos qPos = QueryPos.getInstance(q);
13670    
13671                            qPos.add(groupId);
13672    
13673                            if (urlTitle != null) {
13674                                    qPos.add(urlTitle);
13675                            }
13676    
13677                            qPos.add(status);
13678    
13679                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13680                                    end);
13681                    }
13682                    catch (Exception e) {
13683                            throw processException(e);
13684                    }
13685                    finally {
13686                            closeSession(session);
13687                    }
13688            }
13689    
13690            /**
13691             * 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;.
13692             *
13693             * @param id the primary key of the current journal article
13694             * @param groupId the group ID
13695             * @param urlTitle the url title
13696             * @param status the status
13697             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13698             * @return the previous, current, and next journal article
13699             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13700             * @throws SystemException if a system exception occurred
13701             */
13702            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
13703                    long groupId, String urlTitle, int status,
13704                    OrderByComparator orderByComparator)
13705                    throws NoSuchArticleException, SystemException {
13706                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13707                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
13708                                    orderByComparator);
13709                    }
13710    
13711                    JournalArticle journalArticle = findByPrimaryKey(id);
13712    
13713                    Session session = null;
13714    
13715                    try {
13716                            session = openSession();
13717    
13718                            JournalArticle[] array = new JournalArticleImpl[3];
13719    
13720                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
13721                                            groupId, urlTitle, status, orderByComparator, true);
13722    
13723                            array[1] = journalArticle;
13724    
13725                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
13726                                            groupId, urlTitle, status, orderByComparator, false);
13727    
13728                            return array;
13729                    }
13730                    catch (Exception e) {
13731                            throw processException(e);
13732                    }
13733                    finally {
13734                            closeSession(session);
13735                    }
13736            }
13737    
13738            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
13739                    JournalArticle journalArticle, long groupId, String urlTitle,
13740                    int status, OrderByComparator orderByComparator, boolean previous) {
13741                    StringBundler query = null;
13742    
13743                    if (orderByComparator != null) {
13744                            query = new StringBundler(6 +
13745                                            (orderByComparator.getOrderByFields().length * 6));
13746                    }
13747                    else {
13748                            query = new StringBundler(3);
13749                    }
13750    
13751                    if (getDB().isSupportsInlineDistinct()) {
13752                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13753                    }
13754                    else {
13755                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13756                    }
13757    
13758                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
13759    
13760                    if (urlTitle == null) {
13761                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
13762                    }
13763                    else {
13764                            if (urlTitle.equals(StringPool.BLANK)) {
13765                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
13766                            }
13767                            else {
13768                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
13769                            }
13770                    }
13771    
13772                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
13773    
13774                    if (!getDB().isSupportsInlineDistinct()) {
13775                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13776                    }
13777    
13778                    if (orderByComparator != null) {
13779                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13780    
13781                            if (orderByConditionFields.length > 0) {
13782                                    query.append(WHERE_AND);
13783                            }
13784    
13785                            for (int i = 0; i < orderByConditionFields.length; i++) {
13786                                    if (getDB().isSupportsInlineDistinct()) {
13787                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13788                                    }
13789                                    else {
13790                                            query.append(_ORDER_BY_ENTITY_TABLE);
13791                                    }
13792    
13793                                    query.append(orderByConditionFields[i]);
13794    
13795                                    if ((i + 1) < orderByConditionFields.length) {
13796                                            if (orderByComparator.isAscending() ^ previous) {
13797                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13798                                            }
13799                                            else {
13800                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13801                                            }
13802                                    }
13803                                    else {
13804                                            if (orderByComparator.isAscending() ^ previous) {
13805                                                    query.append(WHERE_GREATER_THAN);
13806                                            }
13807                                            else {
13808                                                    query.append(WHERE_LESSER_THAN);
13809                                            }
13810                                    }
13811                            }
13812    
13813                            query.append(ORDER_BY_CLAUSE);
13814    
13815                            String[] orderByFields = orderByComparator.getOrderByFields();
13816    
13817                            for (int i = 0; i < orderByFields.length; i++) {
13818                                    if (getDB().isSupportsInlineDistinct()) {
13819                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13820                                    }
13821                                    else {
13822                                            query.append(_ORDER_BY_ENTITY_TABLE);
13823                                    }
13824    
13825                                    query.append(orderByFields[i]);
13826    
13827                                    if ((i + 1) < orderByFields.length) {
13828                                            if (orderByComparator.isAscending() ^ previous) {
13829                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13830                                            }
13831                                            else {
13832                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13833                                            }
13834                                    }
13835                                    else {
13836                                            if (orderByComparator.isAscending() ^ previous) {
13837                                                    query.append(ORDER_BY_ASC);
13838                                            }
13839                                            else {
13840                                                    query.append(ORDER_BY_DESC);
13841                                            }
13842                                    }
13843                            }
13844                    }
13845    
13846                    else {
13847                            if (getDB().isSupportsInlineDistinct()) {
13848                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13849                            }
13850                            else {
13851                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13852                            }
13853                    }
13854    
13855                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13856                                    JournalArticle.class.getName(),
13857                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13858    
13859                    SQLQuery q = session.createSQLQuery(sql);
13860    
13861                    q.setFirstResult(0);
13862                    q.setMaxResults(2);
13863    
13864                    if (getDB().isSupportsInlineDistinct()) {
13865                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13866                    }
13867                    else {
13868                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13869                    }
13870    
13871                    QueryPos qPos = QueryPos.getInstance(q);
13872    
13873                    qPos.add(groupId);
13874    
13875                    if (urlTitle != null) {
13876                            qPos.add(urlTitle);
13877                    }
13878    
13879                    qPos.add(status);
13880    
13881                    if (orderByComparator != null) {
13882                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13883    
13884                            for (Object value : values) {
13885                                    qPos.add(value);
13886                            }
13887                    }
13888    
13889                    List<JournalArticle> list = q.list();
13890    
13891                    if (list.size() == 2) {
13892                            return list.get(1);
13893                    }
13894                    else {
13895                            return null;
13896                    }
13897            }
13898    
13899            /**
13900             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
13901             *
13902             * @param companyId the company ID
13903             * @param version the version
13904             * @param status the status
13905             * @return the matching journal articles
13906             * @throws SystemException if a system exception occurred
13907             */
13908            public List<JournalArticle> findByC_V_ST(long companyId, double version,
13909                    int status) throws SystemException {
13910                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
13911                            QueryUtil.ALL_POS, null);
13912            }
13913    
13914            /**
13915             * Returns a range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
13916             *
13917             * <p>
13918             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13919             * </p>
13920             *
13921             * @param companyId the company ID
13922             * @param version the version
13923             * @param status the status
13924             * @param start the lower bound of the range of journal articles
13925             * @param end the upper bound of the range of journal articles (not inclusive)
13926             * @return the range of matching journal articles
13927             * @throws SystemException if a system exception occurred
13928             */
13929            public List<JournalArticle> findByC_V_ST(long companyId, double version,
13930                    int status, int start, int end) throws SystemException {
13931                    return findByC_V_ST(companyId, version, status, start, end, null);
13932            }
13933    
13934            /**
13935             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
13936             *
13937             * <p>
13938             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13939             * </p>
13940             *
13941             * @param companyId the company ID
13942             * @param version the version
13943             * @param status the status
13944             * @param start the lower bound of the range of journal articles
13945             * @param end the upper bound of the range of journal articles (not inclusive)
13946             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13947             * @return the ordered range of matching journal articles
13948             * @throws SystemException if a system exception occurred
13949             */
13950            public List<JournalArticle> findByC_V_ST(long companyId, double version,
13951                    int status, int start, int end, OrderByComparator orderByComparator)
13952                    throws SystemException {
13953                    FinderPath finderPath = null;
13954                    Object[] finderArgs = null;
13955    
13956                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13957                                    (orderByComparator == null)) {
13958                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
13959                            finderArgs = new Object[] { companyId, version, status };
13960                    }
13961                    else {
13962                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
13963                            finderArgs = new Object[] {
13964                                            companyId, version, status,
13965                                            
13966                                            start, end, orderByComparator
13967                                    };
13968                    }
13969    
13970                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13971                                    finderArgs, this);
13972    
13973                    if (list == null) {
13974                            StringBundler query = null;
13975    
13976                            if (orderByComparator != null) {
13977                                    query = new StringBundler(5 +
13978                                                    (orderByComparator.getOrderByFields().length * 3));
13979                            }
13980                            else {
13981                                    query = new StringBundler(5);
13982                            }
13983    
13984                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13985    
13986                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
13987    
13988                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
13989    
13990                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
13991    
13992                            if (orderByComparator != null) {
13993                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13994                                            orderByComparator);
13995                            }
13996    
13997                            else {
13998                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13999                            }
14000    
14001                            String sql = query.toString();
14002    
14003                            Session session = null;
14004    
14005                            try {
14006                                    session = openSession();
14007    
14008                                    Query q = session.createQuery(sql);
14009    
14010                                    QueryPos qPos = QueryPos.getInstance(q);
14011    
14012                                    qPos.add(companyId);
14013    
14014                                    qPos.add(version);
14015    
14016                                    qPos.add(status);
14017    
14018                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
14019                                                    start, end);
14020                            }
14021                            catch (Exception e) {
14022                                    throw processException(e);
14023                            }
14024                            finally {
14025                                    if (list == null) {
14026                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
14027                                    }
14028                                    else {
14029                                            cacheResult(list);
14030    
14031                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
14032                                    }
14033    
14034                                    closeSession(session);
14035                            }
14036                    }
14037    
14038                    return list;
14039            }
14040    
14041            /**
14042             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
14043             *
14044             * <p>
14045             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14046             * </p>
14047             *
14048             * @param companyId the company ID
14049             * @param version the version
14050             * @param status the status
14051             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14052             * @return the first matching journal article
14053             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14054             * @throws SystemException if a system exception occurred
14055             */
14056            public JournalArticle findByC_V_ST_First(long companyId, double version,
14057                    int status, OrderByComparator orderByComparator)
14058                    throws NoSuchArticleException, SystemException {
14059                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
14060                                    1, orderByComparator);
14061    
14062                    if (list.isEmpty()) {
14063                            StringBundler msg = new StringBundler(8);
14064    
14065                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14066    
14067                            msg.append("companyId=");
14068                            msg.append(companyId);
14069    
14070                            msg.append(", version=");
14071                            msg.append(version);
14072    
14073                            msg.append(", status=");
14074                            msg.append(status);
14075    
14076                            msg.append(StringPool.CLOSE_CURLY_BRACE);
14077    
14078                            throw new NoSuchArticleException(msg.toString());
14079                    }
14080                    else {
14081                            return list.get(0);
14082                    }
14083            }
14084    
14085            /**
14086             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
14087             *
14088             * <p>
14089             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14090             * </p>
14091             *
14092             * @param companyId the company ID
14093             * @param version the version
14094             * @param status the status
14095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14096             * @return the last matching journal article
14097             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
14098             * @throws SystemException if a system exception occurred
14099             */
14100            public JournalArticle findByC_V_ST_Last(long companyId, double version,
14101                    int status, OrderByComparator orderByComparator)
14102                    throws NoSuchArticleException, SystemException {
14103                    int count = countByC_V_ST(companyId, version, status);
14104    
14105                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
14106                                    count - 1, count, orderByComparator);
14107    
14108                    if (list.isEmpty()) {
14109                            StringBundler msg = new StringBundler(8);
14110    
14111                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14112    
14113                            msg.append("companyId=");
14114                            msg.append(companyId);
14115    
14116                            msg.append(", version=");
14117                            msg.append(version);
14118    
14119                            msg.append(", status=");
14120                            msg.append(status);
14121    
14122                            msg.append(StringPool.CLOSE_CURLY_BRACE);
14123    
14124                            throw new NoSuchArticleException(msg.toString());
14125                    }
14126                    else {
14127                            return list.get(0);
14128                    }
14129            }
14130    
14131            /**
14132             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
14133             *
14134             * <p>
14135             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14136             * </p>
14137             *
14138             * @param id the primary key of the current journal article
14139             * @param companyId the company ID
14140             * @param version the version
14141             * @param status the status
14142             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14143             * @return the previous, current, and next journal article
14144             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
14145             * @throws SystemException if a system exception occurred
14146             */
14147            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
14148                    double version, int status, OrderByComparator orderByComparator)
14149                    throws NoSuchArticleException, SystemException {
14150                    JournalArticle journalArticle = findByPrimaryKey(id);
14151    
14152                    Session session = null;
14153    
14154                    try {
14155                            session = openSession();
14156    
14157                            JournalArticle[] array = new JournalArticleImpl[3];
14158    
14159                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
14160                                            companyId, version, status, orderByComparator, true);
14161    
14162                            array[1] = journalArticle;
14163    
14164                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
14165                                            companyId, version, status, orderByComparator, false);
14166    
14167                            return array;
14168                    }
14169                    catch (Exception e) {
14170                            throw processException(e);
14171                    }
14172                    finally {
14173                            closeSession(session);
14174                    }
14175            }
14176    
14177            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
14178                    JournalArticle journalArticle, long companyId, double version,
14179                    int status, OrderByComparator orderByComparator, boolean previous) {
14180                    StringBundler query = null;
14181    
14182                    if (orderByComparator != null) {
14183                            query = new StringBundler(6 +
14184                                            (orderByComparator.getOrderByFields().length * 6));
14185                    }
14186                    else {
14187                            query = new StringBundler(3);
14188                    }
14189    
14190                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
14191    
14192                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
14193    
14194                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
14195    
14196                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
14197    
14198                    if (orderByComparator != null) {
14199                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14200    
14201                            if (orderByConditionFields.length > 0) {
14202                                    query.append(WHERE_AND);
14203                            }
14204    
14205                            for (int i = 0; i < orderByConditionFields.length; i++) {
14206                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14207                                    query.append(orderByConditionFields[i]);
14208    
14209                                    if ((i + 1) < orderByConditionFields.length) {
14210                                            if (orderByComparator.isAscending() ^ previous) {
14211                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14212                                            }
14213                                            else {
14214                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14215                                            }
14216                                    }
14217                                    else {
14218                                            if (orderByComparator.isAscending() ^ previous) {
14219                                                    query.append(WHERE_GREATER_THAN);
14220                                            }
14221                                            else {
14222                                                    query.append(WHERE_LESSER_THAN);
14223                                            }
14224                                    }
14225                            }
14226    
14227                            query.append(ORDER_BY_CLAUSE);
14228    
14229                            String[] orderByFields = orderByComparator.getOrderByFields();
14230    
14231                            for (int i = 0; i < orderByFields.length; i++) {
14232                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14233                                    query.append(orderByFields[i]);
14234    
14235                                    if ((i + 1) < orderByFields.length) {
14236                                            if (orderByComparator.isAscending() ^ previous) {
14237                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14238                                            }
14239                                            else {
14240                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14241                                            }
14242                                    }
14243                                    else {
14244                                            if (orderByComparator.isAscending() ^ previous) {
14245                                                    query.append(ORDER_BY_ASC);
14246                                            }
14247                                            else {
14248                                                    query.append(ORDER_BY_DESC);
14249                                            }
14250                                    }
14251                            }
14252                    }
14253    
14254                    else {
14255                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
14256                    }
14257    
14258                    String sql = query.toString();
14259    
14260                    Query q = session.createQuery(sql);
14261    
14262                    q.setFirstResult(0);
14263                    q.setMaxResults(2);
14264    
14265                    QueryPos qPos = QueryPos.getInstance(q);
14266    
14267                    qPos.add(companyId);
14268    
14269                    qPos.add(version);
14270    
14271                    qPos.add(status);
14272    
14273                    if (orderByComparator != null) {
14274                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
14275    
14276                            for (Object value : values) {
14277                                    qPos.add(value);
14278                            }
14279                    }
14280    
14281                    List<JournalArticle> list = q.list();
14282    
14283                    if (list.size() == 2) {
14284                            return list.get(1);
14285                    }
14286                    else {
14287                            return null;
14288                    }
14289            }
14290    
14291            /**
14292             * Returns all the journal articles.
14293             *
14294             * @return the journal articles
14295             * @throws SystemException if a system exception occurred
14296             */
14297            public List<JournalArticle> findAll() throws SystemException {
14298                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14299            }
14300    
14301            /**
14302             * Returns a range of all the journal articles.
14303             *
14304             * <p>
14305             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14306             * </p>
14307             *
14308             * @param start the lower bound of the range of journal articles
14309             * @param end the upper bound of the range of journal articles (not inclusive)
14310             * @return the range of journal articles
14311             * @throws SystemException if a system exception occurred
14312             */
14313            public List<JournalArticle> findAll(int start, int end)
14314                    throws SystemException {
14315                    return findAll(start, end, null);
14316            }
14317    
14318            /**
14319             * Returns an ordered range of all the journal articles.
14320             *
14321             * <p>
14322             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14323             * </p>
14324             *
14325             * @param start the lower bound of the range of journal articles
14326             * @param end the upper bound of the range of journal articles (not inclusive)
14327             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14328             * @return the ordered range of journal articles
14329             * @throws SystemException if a system exception occurred
14330             */
14331            public List<JournalArticle> findAll(int start, int end,
14332                    OrderByComparator orderByComparator) throws SystemException {
14333                    FinderPath finderPath = null;
14334                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
14335    
14336                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14337                                    (orderByComparator == null)) {
14338                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
14339                            finderArgs = FINDER_ARGS_EMPTY;
14340                    }
14341                    else {
14342                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
14343                            finderArgs = new Object[] { start, end, orderByComparator };
14344                    }
14345    
14346                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14347                                    finderArgs, this);
14348    
14349                    if (list == null) {
14350                            StringBundler query = null;
14351                            String sql = null;
14352    
14353                            if (orderByComparator != null) {
14354                                    query = new StringBundler(2 +
14355                                                    (orderByComparator.getOrderByFields().length * 3));
14356    
14357                                    query.append(_SQL_SELECT_JOURNALARTICLE);
14358    
14359                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14360                                            orderByComparator);
14361    
14362                                    sql = query.toString();
14363                            }
14364                            else {
14365                                    sql = _SQL_SELECT_JOURNALARTICLE.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
14366                            }
14367    
14368                            Session session = null;
14369    
14370                            try {
14371                                    session = openSession();
14372    
14373                                    Query q = session.createQuery(sql);
14374    
14375                                    if (orderByComparator == null) {
14376                                            list = (List<JournalArticle>)QueryUtil.list(q,
14377                                                            getDialect(), start, end, false);
14378    
14379                                            Collections.sort(list);
14380                                    }
14381                                    else {
14382                                            list = (List<JournalArticle>)QueryUtil.list(q,
14383                                                            getDialect(), start, end);
14384                                    }
14385                            }
14386                            catch (Exception e) {
14387                                    throw processException(e);
14388                            }
14389                            finally {
14390                                    if (list == null) {
14391                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
14392                                    }
14393                                    else {
14394                                            cacheResult(list);
14395    
14396                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
14397                                    }
14398    
14399                                    closeSession(session);
14400                            }
14401                    }
14402    
14403                    return list;
14404            }
14405    
14406            /**
14407             * Removes all the journal articles where uuid = &#63; from the database.
14408             *
14409             * @param uuid the uuid
14410             * @throws SystemException if a system exception occurred
14411             */
14412            public void removeByUuid(String uuid) throws SystemException {
14413                    for (JournalArticle journalArticle : findByUuid(uuid)) {
14414                            remove(journalArticle);
14415                    }
14416            }
14417    
14418            /**
14419             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
14420             *
14421             * @param uuid the uuid
14422             * @param groupId the group ID
14423             * @throws SystemException if a system exception occurred
14424             */
14425            public void removeByUUID_G(String uuid, long groupId)
14426                    throws NoSuchArticleException, SystemException {
14427                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
14428    
14429                    remove(journalArticle);
14430            }
14431    
14432            /**
14433             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
14434             *
14435             * @param resourcePrimKey the resource prim key
14436             * @throws SystemException if a system exception occurred
14437             */
14438            public void removeByResourcePrimKey(long resourcePrimKey)
14439                    throws SystemException {
14440                    for (JournalArticle journalArticle : findByResourcePrimKey(
14441                                    resourcePrimKey)) {
14442                            remove(journalArticle);
14443                    }
14444            }
14445    
14446            /**
14447             * Removes all the journal articles where groupId = &#63; from the database.
14448             *
14449             * @param groupId the group ID
14450             * @throws SystemException if a system exception occurred
14451             */
14452            public void removeByGroupId(long groupId) throws SystemException {
14453                    for (JournalArticle journalArticle : findByGroupId(groupId)) {
14454                            remove(journalArticle);
14455                    }
14456            }
14457    
14458            /**
14459             * Removes all the journal articles where companyId = &#63; from the database.
14460             *
14461             * @param companyId the company ID
14462             * @throws SystemException if a system exception occurred
14463             */
14464            public void removeByCompanyId(long companyId) throws SystemException {
14465                    for (JournalArticle journalArticle : findByCompanyId(companyId)) {
14466                            remove(journalArticle);
14467                    }
14468            }
14469    
14470            /**
14471             * Removes all the journal articles where smallImageId = &#63; from the database.
14472             *
14473             * @param smallImageId the small image ID
14474             * @throws SystemException if a system exception occurred
14475             */
14476            public void removeBySmallImageId(long smallImageId)
14477                    throws SystemException {
14478                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId)) {
14479                            remove(journalArticle);
14480                    }
14481            }
14482    
14483            /**
14484             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
14485             *
14486             * @param resourcePrimKey the resource prim key
14487             * @param status the status
14488             * @throws SystemException if a system exception occurred
14489             */
14490            public void removeByR_ST(long resourcePrimKey, int status)
14491                    throws SystemException {
14492                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey, status)) {
14493                            remove(journalArticle);
14494                    }
14495            }
14496    
14497            /**
14498             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
14499             *
14500             * @param groupId the group ID
14501             * @param articleId the article ID
14502             * @throws SystemException if a system exception occurred
14503             */
14504            public void removeByG_A(long groupId, String articleId)
14505                    throws SystemException {
14506                    for (JournalArticle journalArticle : findByG_A(groupId, articleId)) {
14507                            remove(journalArticle);
14508                    }
14509            }
14510    
14511            /**
14512             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
14513             *
14514             * @param groupId the group ID
14515             * @param urlTitle the url title
14516             * @throws SystemException if a system exception occurred
14517             */
14518            public void removeByG_UT(long groupId, String urlTitle)
14519                    throws SystemException {
14520                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle)) {
14521                            remove(journalArticle);
14522                    }
14523            }
14524    
14525            /**
14526             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
14527             *
14528             * @param groupId the group ID
14529             * @param structureId the structure ID
14530             * @throws SystemException if a system exception occurred
14531             */
14532            public void removeByG_S(long groupId, String structureId)
14533                    throws SystemException {
14534                    for (JournalArticle journalArticle : findByG_S(groupId, structureId)) {
14535                            remove(journalArticle);
14536                    }
14537            }
14538    
14539            /**
14540             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
14541             *
14542             * @param groupId the group ID
14543             * @param templateId the template ID
14544             * @throws SystemException if a system exception occurred
14545             */
14546            public void removeByG_T(long groupId, String templateId)
14547                    throws SystemException {
14548                    for (JournalArticle journalArticle : findByG_T(groupId, templateId)) {
14549                            remove(journalArticle);
14550                    }
14551            }
14552    
14553            /**
14554             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
14555             *
14556             * @param groupId the group ID
14557             * @param layoutUuid the layout uuid
14558             * @throws SystemException if a system exception occurred
14559             */
14560            public void removeByG_L(long groupId, String layoutUuid)
14561                    throws SystemException {
14562                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid)) {
14563                            remove(journalArticle);
14564                    }
14565            }
14566    
14567            /**
14568             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
14569             *
14570             * @param groupId the group ID
14571             * @param status the status
14572             * @throws SystemException if a system exception occurred
14573             */
14574            public void removeByG_ST(long groupId, int status)
14575                    throws SystemException {
14576                    for (JournalArticle journalArticle : findByG_ST(groupId, status)) {
14577                            remove(journalArticle);
14578                    }
14579            }
14580    
14581            /**
14582             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
14583             *
14584             * @param companyId the company ID
14585             * @param version the version
14586             * @throws SystemException if a system exception occurred
14587             */
14588            public void removeByC_V(long companyId, double version)
14589                    throws SystemException {
14590                    for (JournalArticle journalArticle : findByC_V(companyId, version)) {
14591                            remove(journalArticle);
14592                    }
14593            }
14594    
14595            /**
14596             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
14597             *
14598             * @param companyId the company ID
14599             * @param status the status
14600             * @throws SystemException if a system exception occurred
14601             */
14602            public void removeByC_ST(long companyId, int status)
14603                    throws SystemException {
14604                    for (JournalArticle journalArticle : findByC_ST(companyId, status)) {
14605                            remove(journalArticle);
14606                    }
14607            }
14608    
14609            /**
14610             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
14611             *
14612             * @param groupId the group ID
14613             * @param classNameId the class name ID
14614             * @param classPK the class p k
14615             * @throws SystemException if a system exception occurred
14616             */
14617            public void removeByG_C_C(long groupId, long classNameId, long classPK)
14618                    throws SystemException {
14619                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
14620                                    classPK)) {
14621                            remove(journalArticle);
14622                    }
14623            }
14624    
14625            /**
14626             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
14627             *
14628             * @param groupId the group ID
14629             * @param classNameId the class name ID
14630             * @param structureId the structure ID
14631             * @throws SystemException if a system exception occurred
14632             */
14633            public void removeByG_C_S(long groupId, long classNameId, String structureId)
14634                    throws NoSuchArticleException, SystemException {
14635                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
14636                                    structureId);
14637    
14638                    remove(journalArticle);
14639            }
14640    
14641            /**
14642             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
14643             *
14644             * @param groupId the group ID
14645             * @param classNameId the class name ID
14646             * @param templateId the template ID
14647             * @throws SystemException if a system exception occurred
14648             */
14649            public void removeByG_C_T(long groupId, long classNameId, String templateId)
14650                    throws SystemException {
14651                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
14652                                    templateId)) {
14653                            remove(journalArticle);
14654                    }
14655            }
14656    
14657            /**
14658             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
14659             *
14660             * @param groupId the group ID
14661             * @param classNameId the class name ID
14662             * @param layoutUuid the layout uuid
14663             * @throws SystemException if a system exception occurred
14664             */
14665            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
14666                    throws SystemException {
14667                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
14668                                    layoutUuid)) {
14669                            remove(journalArticle);
14670                    }
14671            }
14672    
14673            /**
14674             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
14675             *
14676             * @param groupId the group ID
14677             * @param articleId the article ID
14678             * @param version the version
14679             * @throws SystemException if a system exception occurred
14680             */
14681            public void removeByG_A_V(long groupId, String articleId, double version)
14682                    throws NoSuchArticleException, SystemException {
14683                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
14684    
14685                    remove(journalArticle);
14686            }
14687    
14688            /**
14689             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
14690             *
14691             * @param groupId the group ID
14692             * @param articleId the article ID
14693             * @param status the status
14694             * @throws SystemException if a system exception occurred
14695             */
14696            public void removeByG_A_ST(long groupId, String articleId, int status)
14697                    throws SystemException {
14698                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
14699                                    status)) {
14700                            remove(journalArticle);
14701                    }
14702            }
14703    
14704            /**
14705             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
14706             *
14707             * @param groupId the group ID
14708             * @param urlTitle the url title
14709             * @param status the status
14710             * @throws SystemException if a system exception occurred
14711             */
14712            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
14713                    throws SystemException {
14714                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
14715                                    status)) {
14716                            remove(journalArticle);
14717                    }
14718            }
14719    
14720            /**
14721             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
14722             *
14723             * @param companyId the company ID
14724             * @param version the version
14725             * @param status the status
14726             * @throws SystemException if a system exception occurred
14727             */
14728            public void removeByC_V_ST(long companyId, double version, int status)
14729                    throws SystemException {
14730                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
14731                                    status)) {
14732                            remove(journalArticle);
14733                    }
14734            }
14735    
14736            /**
14737             * Removes all the journal articles from the database.
14738             *
14739             * @throws SystemException if a system exception occurred
14740             */
14741            public void removeAll() throws SystemException {
14742                    for (JournalArticle journalArticle : findAll()) {
14743                            remove(journalArticle);
14744                    }
14745            }
14746    
14747            /**
14748             * Returns the number of journal articles where uuid = &#63;.
14749             *
14750             * @param uuid the uuid
14751             * @return the number of matching journal articles
14752             * @throws SystemException if a system exception occurred
14753             */
14754            public int countByUuid(String uuid) throws SystemException {
14755                    Object[] finderArgs = new Object[] { uuid };
14756    
14757                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
14758                                    finderArgs, this);
14759    
14760                    if (count == null) {
14761                            StringBundler query = new StringBundler(2);
14762    
14763                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14764    
14765                            if (uuid == null) {
14766                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
14767                            }
14768                            else {
14769                                    if (uuid.equals(StringPool.BLANK)) {
14770                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
14771                                    }
14772                                    else {
14773                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
14774                                    }
14775                            }
14776    
14777                            String sql = query.toString();
14778    
14779                            Session session = null;
14780    
14781                            try {
14782                                    session = openSession();
14783    
14784                                    Query q = session.createQuery(sql);
14785    
14786                                    QueryPos qPos = QueryPos.getInstance(q);
14787    
14788                                    if (uuid != null) {
14789                                            qPos.add(uuid);
14790                                    }
14791    
14792                                    count = (Long)q.uniqueResult();
14793                            }
14794                            catch (Exception e) {
14795                                    throw processException(e);
14796                            }
14797                            finally {
14798                                    if (count == null) {
14799                                            count = Long.valueOf(0);
14800                                    }
14801    
14802                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
14803                                            finderArgs, count);
14804    
14805                                    closeSession(session);
14806                            }
14807                    }
14808    
14809                    return count.intValue();
14810            }
14811    
14812            /**
14813             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
14814             *
14815             * @param uuid the uuid
14816             * @param groupId the group ID
14817             * @return the number of matching journal articles
14818             * @throws SystemException if a system exception occurred
14819             */
14820            public int countByUUID_G(String uuid, long groupId)
14821                    throws SystemException {
14822                    Object[] finderArgs = new Object[] { uuid, groupId };
14823    
14824                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
14825                                    finderArgs, this);
14826    
14827                    if (count == null) {
14828                            StringBundler query = new StringBundler(3);
14829    
14830                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14831    
14832                            if (uuid == null) {
14833                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
14834                            }
14835                            else {
14836                                    if (uuid.equals(StringPool.BLANK)) {
14837                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
14838                                    }
14839                                    else {
14840                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
14841                                    }
14842                            }
14843    
14844                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
14845    
14846                            String sql = query.toString();
14847    
14848                            Session session = null;
14849    
14850                            try {
14851                                    session = openSession();
14852    
14853                                    Query q = session.createQuery(sql);
14854    
14855                                    QueryPos qPos = QueryPos.getInstance(q);
14856    
14857                                    if (uuid != null) {
14858                                            qPos.add(uuid);
14859                                    }
14860    
14861                                    qPos.add(groupId);
14862    
14863                                    count = (Long)q.uniqueResult();
14864                            }
14865                            catch (Exception e) {
14866                                    throw processException(e);
14867                            }
14868                            finally {
14869                                    if (count == null) {
14870                                            count = Long.valueOf(0);
14871                                    }
14872    
14873                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
14874                                            finderArgs, count);
14875    
14876                                    closeSession(session);
14877                            }
14878                    }
14879    
14880                    return count.intValue();
14881            }
14882    
14883            /**
14884             * Returns the number of journal articles where resourcePrimKey = &#63;.
14885             *
14886             * @param resourcePrimKey the resource prim key
14887             * @return the number of matching journal articles
14888             * @throws SystemException if a system exception occurred
14889             */
14890            public int countByResourcePrimKey(long resourcePrimKey)
14891                    throws SystemException {
14892                    Object[] finderArgs = new Object[] { resourcePrimKey };
14893    
14894                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
14895                                    finderArgs, this);
14896    
14897                    if (count == null) {
14898                            StringBundler query = new StringBundler(2);
14899    
14900                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14901    
14902                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
14903    
14904                            String sql = query.toString();
14905    
14906                            Session session = null;
14907    
14908                            try {
14909                                    session = openSession();
14910    
14911                                    Query q = session.createQuery(sql);
14912    
14913                                    QueryPos qPos = QueryPos.getInstance(q);
14914    
14915                                    qPos.add(resourcePrimKey);
14916    
14917                                    count = (Long)q.uniqueResult();
14918                            }
14919                            catch (Exception e) {
14920                                    throw processException(e);
14921                            }
14922                            finally {
14923                                    if (count == null) {
14924                                            count = Long.valueOf(0);
14925                                    }
14926    
14927                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
14928                                            finderArgs, count);
14929    
14930                                    closeSession(session);
14931                            }
14932                    }
14933    
14934                    return count.intValue();
14935            }
14936    
14937            /**
14938             * Returns the number of journal articles where groupId = &#63;.
14939             *
14940             * @param groupId the group ID
14941             * @return the number of matching journal articles
14942             * @throws SystemException if a system exception occurred
14943             */
14944            public int countByGroupId(long groupId) throws SystemException {
14945                    Object[] finderArgs = new Object[] { groupId };
14946    
14947                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
14948                                    finderArgs, this);
14949    
14950                    if (count == null) {
14951                            StringBundler query = new StringBundler(2);
14952    
14953                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14954    
14955                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
14956    
14957                            String sql = query.toString();
14958    
14959                            Session session = null;
14960    
14961                            try {
14962                                    session = openSession();
14963    
14964                                    Query q = session.createQuery(sql);
14965    
14966                                    QueryPos qPos = QueryPos.getInstance(q);
14967    
14968                                    qPos.add(groupId);
14969    
14970                                    count = (Long)q.uniqueResult();
14971                            }
14972                            catch (Exception e) {
14973                                    throw processException(e);
14974                            }
14975                            finally {
14976                                    if (count == null) {
14977                                            count = Long.valueOf(0);
14978                                    }
14979    
14980                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
14981                                            finderArgs, count);
14982    
14983                                    closeSession(session);
14984                            }
14985                    }
14986    
14987                    return count.intValue();
14988            }
14989    
14990            /**
14991             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
14992             *
14993             * @param groupId the group ID
14994             * @return the number of matching journal articles that the user has permission to view
14995             * @throws SystemException if a system exception occurred
14996             */
14997            public int filterCountByGroupId(long groupId) throws SystemException {
14998                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14999                            return countByGroupId(groupId);
15000                    }
15001    
15002                    StringBundler query = new StringBundler(2);
15003    
15004                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15005    
15006                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
15007    
15008                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15009                                    JournalArticle.class.getName(),
15010                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15011    
15012                    Session session = null;
15013    
15014                    try {
15015                            session = openSession();
15016    
15017                            SQLQuery q = session.createSQLQuery(sql);
15018    
15019                            q.addScalar(COUNT_COLUMN_NAME,
15020                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15021    
15022                            QueryPos qPos = QueryPos.getInstance(q);
15023    
15024                            qPos.add(groupId);
15025    
15026                            Long count = (Long)q.uniqueResult();
15027    
15028                            return count.intValue();
15029                    }
15030                    catch (Exception e) {
15031                            throw processException(e);
15032                    }
15033                    finally {
15034                            closeSession(session);
15035                    }
15036            }
15037    
15038            /**
15039             * Returns the number of journal articles where companyId = &#63;.
15040             *
15041             * @param companyId the company ID
15042             * @return the number of matching journal articles
15043             * @throws SystemException if a system exception occurred
15044             */
15045            public int countByCompanyId(long companyId) throws SystemException {
15046                    Object[] finderArgs = new Object[] { companyId };
15047    
15048                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
15049                                    finderArgs, this);
15050    
15051                    if (count == null) {
15052                            StringBundler query = new StringBundler(2);
15053    
15054                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15055    
15056                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
15057    
15058                            String sql = query.toString();
15059    
15060                            Session session = null;
15061    
15062                            try {
15063                                    session = openSession();
15064    
15065                                    Query q = session.createQuery(sql);
15066    
15067                                    QueryPos qPos = QueryPos.getInstance(q);
15068    
15069                                    qPos.add(companyId);
15070    
15071                                    count = (Long)q.uniqueResult();
15072                            }
15073                            catch (Exception e) {
15074                                    throw processException(e);
15075                            }
15076                            finally {
15077                                    if (count == null) {
15078                                            count = Long.valueOf(0);
15079                                    }
15080    
15081                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
15082                                            finderArgs, count);
15083    
15084                                    closeSession(session);
15085                            }
15086                    }
15087    
15088                    return count.intValue();
15089            }
15090    
15091            /**
15092             * Returns the number of journal articles where smallImageId = &#63;.
15093             *
15094             * @param smallImageId the small image ID
15095             * @return the number of matching journal articles
15096             * @throws SystemException if a system exception occurred
15097             */
15098            public int countBySmallImageId(long smallImageId) throws SystemException {
15099                    Object[] finderArgs = new Object[] { smallImageId };
15100    
15101                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
15102                                    finderArgs, this);
15103    
15104                    if (count == null) {
15105                            StringBundler query = new StringBundler(2);
15106    
15107                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15108    
15109                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
15110    
15111                            String sql = query.toString();
15112    
15113                            Session session = null;
15114    
15115                            try {
15116                                    session = openSession();
15117    
15118                                    Query q = session.createQuery(sql);
15119    
15120                                    QueryPos qPos = QueryPos.getInstance(q);
15121    
15122                                    qPos.add(smallImageId);
15123    
15124                                    count = (Long)q.uniqueResult();
15125                            }
15126                            catch (Exception e) {
15127                                    throw processException(e);
15128                            }
15129                            finally {
15130                                    if (count == null) {
15131                                            count = Long.valueOf(0);
15132                                    }
15133    
15134                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
15135                                            finderArgs, count);
15136    
15137                                    closeSession(session);
15138                            }
15139                    }
15140    
15141                    return count.intValue();
15142            }
15143    
15144            /**
15145             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
15146             *
15147             * @param resourcePrimKey the resource prim key
15148             * @param status the status
15149             * @return the number of matching journal articles
15150             * @throws SystemException if a system exception occurred
15151             */
15152            public int countByR_ST(long resourcePrimKey, int status)
15153                    throws SystemException {
15154                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
15155    
15156                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_ST,
15157                                    finderArgs, this);
15158    
15159                    if (count == null) {
15160                            StringBundler query = new StringBundler(3);
15161    
15162                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15163    
15164                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
15165    
15166                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
15167    
15168                            String sql = query.toString();
15169    
15170                            Session session = null;
15171    
15172                            try {
15173                                    session = openSession();
15174    
15175                                    Query q = session.createQuery(sql);
15176    
15177                                    QueryPos qPos = QueryPos.getInstance(q);
15178    
15179                                    qPos.add(resourcePrimKey);
15180    
15181                                    qPos.add(status);
15182    
15183                                    count = (Long)q.uniqueResult();
15184                            }
15185                            catch (Exception e) {
15186                                    throw processException(e);
15187                            }
15188                            finally {
15189                                    if (count == null) {
15190                                            count = Long.valueOf(0);
15191                                    }
15192    
15193                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_ST,
15194                                            finderArgs, count);
15195    
15196                                    closeSession(session);
15197                            }
15198                    }
15199    
15200                    return count.intValue();
15201            }
15202    
15203            /**
15204             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
15205             *
15206             * @param groupId the group ID
15207             * @param articleId the article ID
15208             * @return the number of matching journal articles
15209             * @throws SystemException if a system exception occurred
15210             */
15211            public int countByG_A(long groupId, String articleId)
15212                    throws SystemException {
15213                    Object[] finderArgs = new Object[] { groupId, articleId };
15214    
15215                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
15216                                    finderArgs, this);
15217    
15218                    if (count == null) {
15219                            StringBundler query = new StringBundler(3);
15220    
15221                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15222    
15223                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
15224    
15225                            if (articleId == null) {
15226                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
15227                            }
15228                            else {
15229                                    if (articleId.equals(StringPool.BLANK)) {
15230                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
15231                                    }
15232                                    else {
15233                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
15234                                    }
15235                            }
15236    
15237                            String sql = query.toString();
15238    
15239                            Session session = null;
15240    
15241                            try {
15242                                    session = openSession();
15243    
15244                                    Query q = session.createQuery(sql);
15245    
15246                                    QueryPos qPos = QueryPos.getInstance(q);
15247    
15248                                    qPos.add(groupId);
15249    
15250                                    if (articleId != null) {
15251                                            qPos.add(articleId);
15252                                    }
15253    
15254                                    count = (Long)q.uniqueResult();
15255                            }
15256                            catch (Exception e) {
15257                                    throw processException(e);
15258                            }
15259                            finally {
15260                                    if (count == null) {
15261                                            count = Long.valueOf(0);
15262                                    }
15263    
15264                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
15265                                            count);
15266    
15267                                    closeSession(session);
15268                            }
15269                    }
15270    
15271                    return count.intValue();
15272            }
15273    
15274            /**
15275             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
15276             *
15277             * @param groupId the group ID
15278             * @param articleId the article ID
15279             * @return the number of matching journal articles that the user has permission to view
15280             * @throws SystemException if a system exception occurred
15281             */
15282            public int filterCountByG_A(long groupId, String articleId)
15283                    throws SystemException {
15284                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15285                            return countByG_A(groupId, articleId);
15286                    }
15287    
15288                    StringBundler query = new StringBundler(3);
15289    
15290                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15291    
15292                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
15293    
15294                    if (articleId == null) {
15295                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
15296                    }
15297                    else {
15298                            if (articleId.equals(StringPool.BLANK)) {
15299                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
15300                            }
15301                            else {
15302                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
15303                            }
15304                    }
15305    
15306                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15307                                    JournalArticle.class.getName(),
15308                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15309    
15310                    Session session = null;
15311    
15312                    try {
15313                            session = openSession();
15314    
15315                            SQLQuery q = session.createSQLQuery(sql);
15316    
15317                            q.addScalar(COUNT_COLUMN_NAME,
15318                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15319    
15320                            QueryPos qPos = QueryPos.getInstance(q);
15321    
15322                            qPos.add(groupId);
15323    
15324                            if (articleId != null) {
15325                                    qPos.add(articleId);
15326                            }
15327    
15328                            Long count = (Long)q.uniqueResult();
15329    
15330                            return count.intValue();
15331                    }
15332                    catch (Exception e) {
15333                            throw processException(e);
15334                    }
15335                    finally {
15336                            closeSession(session);
15337                    }
15338            }
15339    
15340            /**
15341             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
15342             *
15343             * @param groupId the group ID
15344             * @param urlTitle the url title
15345             * @return the number of matching journal articles
15346             * @throws SystemException if a system exception occurred
15347             */
15348            public int countByG_UT(long groupId, String urlTitle)
15349                    throws SystemException {
15350                    Object[] finderArgs = new Object[] { groupId, urlTitle };
15351    
15352                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT,
15353                                    finderArgs, this);
15354    
15355                    if (count == null) {
15356                            StringBundler query = new StringBundler(3);
15357    
15358                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15359    
15360                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
15361    
15362                            if (urlTitle == null) {
15363                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
15364                            }
15365                            else {
15366                                    if (urlTitle.equals(StringPool.BLANK)) {
15367                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
15368                                    }
15369                                    else {
15370                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
15371                                    }
15372                            }
15373    
15374                            String sql = query.toString();
15375    
15376                            Session session = null;
15377    
15378                            try {
15379                                    session = openSession();
15380    
15381                                    Query q = session.createQuery(sql);
15382    
15383                                    QueryPos qPos = QueryPos.getInstance(q);
15384    
15385                                    qPos.add(groupId);
15386    
15387                                    if (urlTitle != null) {
15388                                            qPos.add(urlTitle);
15389                                    }
15390    
15391                                    count = (Long)q.uniqueResult();
15392                            }
15393                            catch (Exception e) {
15394                                    throw processException(e);
15395                            }
15396                            finally {
15397                                    if (count == null) {
15398                                            count = Long.valueOf(0);
15399                                    }
15400    
15401                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT,
15402                                            finderArgs, count);
15403    
15404                                    closeSession(session);
15405                            }
15406                    }
15407    
15408                    return count.intValue();
15409            }
15410    
15411            /**
15412             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
15413             *
15414             * @param groupId the group ID
15415             * @param urlTitle the url title
15416             * @return the number of matching journal articles that the user has permission to view
15417             * @throws SystemException if a system exception occurred
15418             */
15419            public int filterCountByG_UT(long groupId, String urlTitle)
15420                    throws SystemException {
15421                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15422                            return countByG_UT(groupId, urlTitle);
15423                    }
15424    
15425                    StringBundler query = new StringBundler(3);
15426    
15427                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15428    
15429                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
15430    
15431                    if (urlTitle == null) {
15432                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
15433                    }
15434                    else {
15435                            if (urlTitle.equals(StringPool.BLANK)) {
15436                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
15437                            }
15438                            else {
15439                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
15440                            }
15441                    }
15442    
15443                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15444                                    JournalArticle.class.getName(),
15445                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15446    
15447                    Session session = null;
15448    
15449                    try {
15450                            session = openSession();
15451    
15452                            SQLQuery q = session.createSQLQuery(sql);
15453    
15454                            q.addScalar(COUNT_COLUMN_NAME,
15455                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15456    
15457                            QueryPos qPos = QueryPos.getInstance(q);
15458    
15459                            qPos.add(groupId);
15460    
15461                            if (urlTitle != null) {
15462                                    qPos.add(urlTitle);
15463                            }
15464    
15465                            Long count = (Long)q.uniqueResult();
15466    
15467                            return count.intValue();
15468                    }
15469                    catch (Exception e) {
15470                            throw processException(e);
15471                    }
15472                    finally {
15473                            closeSession(session);
15474                    }
15475            }
15476    
15477            /**
15478             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
15479             *
15480             * @param groupId the group ID
15481             * @param structureId the structure ID
15482             * @return the number of matching journal articles
15483             * @throws SystemException if a system exception occurred
15484             */
15485            public int countByG_S(long groupId, String structureId)
15486                    throws SystemException {
15487                    Object[] finderArgs = new Object[] { groupId, structureId };
15488    
15489                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
15490                                    finderArgs, this);
15491    
15492                    if (count == null) {
15493                            StringBundler query = new StringBundler(3);
15494    
15495                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15496    
15497                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
15498    
15499                            if (structureId == null) {
15500                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
15501                            }
15502                            else {
15503                                    if (structureId.equals(StringPool.BLANK)) {
15504                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
15505                                    }
15506                                    else {
15507                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
15508                                    }
15509                            }
15510    
15511                            String sql = query.toString();
15512    
15513                            Session session = null;
15514    
15515                            try {
15516                                    session = openSession();
15517    
15518                                    Query q = session.createQuery(sql);
15519    
15520                                    QueryPos qPos = QueryPos.getInstance(q);
15521    
15522                                    qPos.add(groupId);
15523    
15524                                    if (structureId != null) {
15525                                            qPos.add(structureId);
15526                                    }
15527    
15528                                    count = (Long)q.uniqueResult();
15529                            }
15530                            catch (Exception e) {
15531                                    throw processException(e);
15532                            }
15533                            finally {
15534                                    if (count == null) {
15535                                            count = Long.valueOf(0);
15536                                    }
15537    
15538                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
15539                                            count);
15540    
15541                                    closeSession(session);
15542                            }
15543                    }
15544    
15545                    return count.intValue();
15546            }
15547    
15548            /**
15549             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
15550             *
15551             * @param groupId the group ID
15552             * @param structureId the structure ID
15553             * @return the number of matching journal articles that the user has permission to view
15554             * @throws SystemException if a system exception occurred
15555             */
15556            public int filterCountByG_S(long groupId, String structureId)
15557                    throws SystemException {
15558                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15559                            return countByG_S(groupId, structureId);
15560                    }
15561    
15562                    StringBundler query = new StringBundler(3);
15563    
15564                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15565    
15566                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
15567    
15568                    if (structureId == null) {
15569                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
15570                    }
15571                    else {
15572                            if (structureId.equals(StringPool.BLANK)) {
15573                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
15574                            }
15575                            else {
15576                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
15577                            }
15578                    }
15579    
15580                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15581                                    JournalArticle.class.getName(),
15582                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15583    
15584                    Session session = null;
15585    
15586                    try {
15587                            session = openSession();
15588    
15589                            SQLQuery q = session.createSQLQuery(sql);
15590    
15591                            q.addScalar(COUNT_COLUMN_NAME,
15592                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15593    
15594                            QueryPos qPos = QueryPos.getInstance(q);
15595    
15596                            qPos.add(groupId);
15597    
15598                            if (structureId != null) {
15599                                    qPos.add(structureId);
15600                            }
15601    
15602                            Long count = (Long)q.uniqueResult();
15603    
15604                            return count.intValue();
15605                    }
15606                    catch (Exception e) {
15607                            throw processException(e);
15608                    }
15609                    finally {
15610                            closeSession(session);
15611                    }
15612            }
15613    
15614            /**
15615             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
15616             *
15617             * @param groupId the group ID
15618             * @param templateId the template ID
15619             * @return the number of matching journal articles
15620             * @throws SystemException if a system exception occurred
15621             */
15622            public int countByG_T(long groupId, String templateId)
15623                    throws SystemException {
15624                    Object[] finderArgs = new Object[] { groupId, templateId };
15625    
15626                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T,
15627                                    finderArgs, this);
15628    
15629                    if (count == null) {
15630                            StringBundler query = new StringBundler(3);
15631    
15632                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15633    
15634                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
15635    
15636                            if (templateId == null) {
15637                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
15638                            }
15639                            else {
15640                                    if (templateId.equals(StringPool.BLANK)) {
15641                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
15642                                    }
15643                                    else {
15644                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
15645                                    }
15646                            }
15647    
15648                            String sql = query.toString();
15649    
15650                            Session session = null;
15651    
15652                            try {
15653                                    session = openSession();
15654    
15655                                    Query q = session.createQuery(sql);
15656    
15657                                    QueryPos qPos = QueryPos.getInstance(q);
15658    
15659                                    qPos.add(groupId);
15660    
15661                                    if (templateId != null) {
15662                                            qPos.add(templateId);
15663                                    }
15664    
15665                                    count = (Long)q.uniqueResult();
15666                            }
15667                            catch (Exception e) {
15668                                    throw processException(e);
15669                            }
15670                            finally {
15671                                    if (count == null) {
15672                                            count = Long.valueOf(0);
15673                                    }
15674    
15675                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_T, finderArgs,
15676                                            count);
15677    
15678                                    closeSession(session);
15679                            }
15680                    }
15681    
15682                    return count.intValue();
15683            }
15684    
15685            /**
15686             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
15687             *
15688             * @param groupId the group ID
15689             * @param templateId the template ID
15690             * @return the number of matching journal articles that the user has permission to view
15691             * @throws SystemException if a system exception occurred
15692             */
15693            public int filterCountByG_T(long groupId, String templateId)
15694                    throws SystemException {
15695                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15696                            return countByG_T(groupId, templateId);
15697                    }
15698    
15699                    StringBundler query = new StringBundler(3);
15700    
15701                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15702    
15703                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
15704    
15705                    if (templateId == null) {
15706                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
15707                    }
15708                    else {
15709                            if (templateId.equals(StringPool.BLANK)) {
15710                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
15711                            }
15712                            else {
15713                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
15714                            }
15715                    }
15716    
15717                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15718                                    JournalArticle.class.getName(),
15719                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15720    
15721                    Session session = null;
15722    
15723                    try {
15724                            session = openSession();
15725    
15726                            SQLQuery q = session.createSQLQuery(sql);
15727    
15728                            q.addScalar(COUNT_COLUMN_NAME,
15729                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15730    
15731                            QueryPos qPos = QueryPos.getInstance(q);
15732    
15733                            qPos.add(groupId);
15734    
15735                            if (templateId != null) {
15736                                    qPos.add(templateId);
15737                            }
15738    
15739                            Long count = (Long)q.uniqueResult();
15740    
15741                            return count.intValue();
15742                    }
15743                    catch (Exception e) {
15744                            throw processException(e);
15745                    }
15746                    finally {
15747                            closeSession(session);
15748                    }
15749            }
15750    
15751            /**
15752             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
15753             *
15754             * @param groupId the group ID
15755             * @param layoutUuid the layout uuid
15756             * @return the number of matching journal articles
15757             * @throws SystemException if a system exception occurred
15758             */
15759            public int countByG_L(long groupId, String layoutUuid)
15760                    throws SystemException {
15761                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
15762    
15763                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_L,
15764                                    finderArgs, this);
15765    
15766                    if (count == null) {
15767                            StringBundler query = new StringBundler(3);
15768    
15769                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15770    
15771                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
15772    
15773                            if (layoutUuid == null) {
15774                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
15775                            }
15776                            else {
15777                                    if (layoutUuid.equals(StringPool.BLANK)) {
15778                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
15779                                    }
15780                                    else {
15781                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
15782                                    }
15783                            }
15784    
15785                            String sql = query.toString();
15786    
15787                            Session session = null;
15788    
15789                            try {
15790                                    session = openSession();
15791    
15792                                    Query q = session.createQuery(sql);
15793    
15794                                    QueryPos qPos = QueryPos.getInstance(q);
15795    
15796                                    qPos.add(groupId);
15797    
15798                                    if (layoutUuid != null) {
15799                                            qPos.add(layoutUuid);
15800                                    }
15801    
15802                                    count = (Long)q.uniqueResult();
15803                            }
15804                            catch (Exception e) {
15805                                    throw processException(e);
15806                            }
15807                            finally {
15808                                    if (count == null) {
15809                                            count = Long.valueOf(0);
15810                                    }
15811    
15812                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_L, finderArgs,
15813                                            count);
15814    
15815                                    closeSession(session);
15816                            }
15817                    }
15818    
15819                    return count.intValue();
15820            }
15821    
15822            /**
15823             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
15824             *
15825             * @param groupId the group ID
15826             * @param layoutUuid the layout uuid
15827             * @return the number of matching journal articles that the user has permission to view
15828             * @throws SystemException if a system exception occurred
15829             */
15830            public int filterCountByG_L(long groupId, String layoutUuid)
15831                    throws SystemException {
15832                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15833                            return countByG_L(groupId, layoutUuid);
15834                    }
15835    
15836                    StringBundler query = new StringBundler(3);
15837    
15838                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15839    
15840                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
15841    
15842                    if (layoutUuid == null) {
15843                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
15844                    }
15845                    else {
15846                            if (layoutUuid.equals(StringPool.BLANK)) {
15847                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
15848                            }
15849                            else {
15850                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
15851                            }
15852                    }
15853    
15854                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15855                                    JournalArticle.class.getName(),
15856                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15857    
15858                    Session session = null;
15859    
15860                    try {
15861                            session = openSession();
15862    
15863                            SQLQuery q = session.createSQLQuery(sql);
15864    
15865                            q.addScalar(COUNT_COLUMN_NAME,
15866                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15867    
15868                            QueryPos qPos = QueryPos.getInstance(q);
15869    
15870                            qPos.add(groupId);
15871    
15872                            if (layoutUuid != null) {
15873                                    qPos.add(layoutUuid);
15874                            }
15875    
15876                            Long count = (Long)q.uniqueResult();
15877    
15878                            return count.intValue();
15879                    }
15880                    catch (Exception e) {
15881                            throw processException(e);
15882                    }
15883                    finally {
15884                            closeSession(session);
15885                    }
15886            }
15887    
15888            /**
15889             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
15890             *
15891             * @param groupId the group ID
15892             * @param status the status
15893             * @return the number of matching journal articles
15894             * @throws SystemException if a system exception occurred
15895             */
15896            public int countByG_ST(long groupId, int status) throws SystemException {
15897                    Object[] finderArgs = new Object[] { groupId, status };
15898    
15899                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_ST,
15900                                    finderArgs, this);
15901    
15902                    if (count == null) {
15903                            StringBundler query = new StringBundler(3);
15904    
15905                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15906    
15907                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15908    
15909                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15910    
15911                            String sql = query.toString();
15912    
15913                            Session session = null;
15914    
15915                            try {
15916                                    session = openSession();
15917    
15918                                    Query q = session.createQuery(sql);
15919    
15920                                    QueryPos qPos = QueryPos.getInstance(q);
15921    
15922                                    qPos.add(groupId);
15923    
15924                                    qPos.add(status);
15925    
15926                                    count = (Long)q.uniqueResult();
15927                            }
15928                            catch (Exception e) {
15929                                    throw processException(e);
15930                            }
15931                            finally {
15932                                    if (count == null) {
15933                                            count = Long.valueOf(0);
15934                                    }
15935    
15936                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_ST,
15937                                            finderArgs, count);
15938    
15939                                    closeSession(session);
15940                            }
15941                    }
15942    
15943                    return count.intValue();
15944            }
15945    
15946            /**
15947             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
15948             *
15949             * @param groupId the group ID
15950             * @param status the status
15951             * @return the number of matching journal articles that the user has permission to view
15952             * @throws SystemException if a system exception occurred
15953             */
15954            public int filterCountByG_ST(long groupId, int status)
15955                    throws SystemException {
15956                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15957                            return countByG_ST(groupId, status);
15958                    }
15959    
15960                    StringBundler query = new StringBundler(3);
15961    
15962                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15963    
15964                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15965    
15966                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15967    
15968                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15969                                    JournalArticle.class.getName(),
15970                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15971    
15972                    Session session = null;
15973    
15974                    try {
15975                            session = openSession();
15976    
15977                            SQLQuery q = session.createSQLQuery(sql);
15978    
15979                            q.addScalar(COUNT_COLUMN_NAME,
15980                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15981    
15982                            QueryPos qPos = QueryPos.getInstance(q);
15983    
15984                            qPos.add(groupId);
15985    
15986                            qPos.add(status);
15987    
15988                            Long count = (Long)q.uniqueResult();
15989    
15990                            return count.intValue();
15991                    }
15992                    catch (Exception e) {
15993                            throw processException(e);
15994                    }
15995                    finally {
15996                            closeSession(session);
15997                    }
15998            }
15999    
16000            /**
16001             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
16002             *
16003             * @param companyId the company ID
16004             * @param version the version
16005             * @return the number of matching journal articles
16006             * @throws SystemException if a system exception occurred
16007             */
16008            public int countByC_V(long companyId, double version)
16009                    throws SystemException {
16010                    Object[] finderArgs = new Object[] { companyId, version };
16011    
16012                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V,
16013                                    finderArgs, this);
16014    
16015                    if (count == null) {
16016                            StringBundler query = new StringBundler(3);
16017    
16018                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16019    
16020                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
16021    
16022                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
16023    
16024                            String sql = query.toString();
16025    
16026                            Session session = null;
16027    
16028                            try {
16029                                    session = openSession();
16030    
16031                                    Query q = session.createQuery(sql);
16032    
16033                                    QueryPos qPos = QueryPos.getInstance(q);
16034    
16035                                    qPos.add(companyId);
16036    
16037                                    qPos.add(version);
16038    
16039                                    count = (Long)q.uniqueResult();
16040                            }
16041                            catch (Exception e) {
16042                                    throw processException(e);
16043                            }
16044                            finally {
16045                                    if (count == null) {
16046                                            count = Long.valueOf(0);
16047                                    }
16048    
16049                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V, finderArgs,
16050                                            count);
16051    
16052                                    closeSession(session);
16053                            }
16054                    }
16055    
16056                    return count.intValue();
16057            }
16058    
16059            /**
16060             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
16061             *
16062             * @param companyId the company ID
16063             * @param status the status
16064             * @return the number of matching journal articles
16065             * @throws SystemException if a system exception occurred
16066             */
16067            public int countByC_ST(long companyId, int status)
16068                    throws SystemException {
16069                    Object[] finderArgs = new Object[] { companyId, status };
16070    
16071                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_ST,
16072                                    finderArgs, this);
16073    
16074                    if (count == null) {
16075                            StringBundler query = new StringBundler(3);
16076    
16077                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16078    
16079                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
16080    
16081                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
16082    
16083                            String sql = query.toString();
16084    
16085                            Session session = null;
16086    
16087                            try {
16088                                    session = openSession();
16089    
16090                                    Query q = session.createQuery(sql);
16091    
16092                                    QueryPos qPos = QueryPos.getInstance(q);
16093    
16094                                    qPos.add(companyId);
16095    
16096                                    qPos.add(status);
16097    
16098                                    count = (Long)q.uniqueResult();
16099                            }
16100                            catch (Exception e) {
16101                                    throw processException(e);
16102                            }
16103                            finally {
16104                                    if (count == null) {
16105                                            count = Long.valueOf(0);
16106                                    }
16107    
16108                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_ST,
16109                                            finderArgs, count);
16110    
16111                                    closeSession(session);
16112                            }
16113                    }
16114    
16115                    return count.intValue();
16116            }
16117    
16118            /**
16119             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16120             *
16121             * @param groupId the group ID
16122             * @param classNameId the class name ID
16123             * @param classPK the class p k
16124             * @return the number of matching journal articles
16125             * @throws SystemException if a system exception occurred
16126             */
16127            public int countByG_C_C(long groupId, long classNameId, long classPK)
16128                    throws SystemException {
16129                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
16130    
16131                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C,
16132                                    finderArgs, this);
16133    
16134                    if (count == null) {
16135                            StringBundler query = new StringBundler(4);
16136    
16137                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16138    
16139                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
16140    
16141                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
16142    
16143                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
16144    
16145                            String sql = query.toString();
16146    
16147                            Session session = null;
16148    
16149                            try {
16150                                    session = openSession();
16151    
16152                                    Query q = session.createQuery(sql);
16153    
16154                                    QueryPos qPos = QueryPos.getInstance(q);
16155    
16156                                    qPos.add(groupId);
16157    
16158                                    qPos.add(classNameId);
16159    
16160                                    qPos.add(classPK);
16161    
16162                                    count = (Long)q.uniqueResult();
16163                            }
16164                            catch (Exception e) {
16165                                    throw processException(e);
16166                            }
16167                            finally {
16168                                    if (count == null) {
16169                                            count = Long.valueOf(0);
16170                                    }
16171    
16172                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C,
16173                                            finderArgs, count);
16174    
16175                                    closeSession(session);
16176                            }
16177                    }
16178    
16179                    return count.intValue();
16180            }
16181    
16182            /**
16183             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
16184             *
16185             * @param groupId the group ID
16186             * @param classNameId the class name ID
16187             * @param classPK the class p k
16188             * @return the number of matching journal articles that the user has permission to view
16189             * @throws SystemException if a system exception occurred
16190             */
16191            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
16192                    throws SystemException {
16193                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16194                            return countByG_C_C(groupId, classNameId, classPK);
16195                    }
16196    
16197                    StringBundler query = new StringBundler(4);
16198    
16199                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16200    
16201                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
16202    
16203                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
16204    
16205                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
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                            qPos.add(classPK);
16228    
16229                            Long count = (Long)q.uniqueResult();
16230    
16231                            return count.intValue();
16232                    }
16233                    catch (Exception e) {
16234                            throw processException(e);
16235                    }
16236                    finally {
16237                            closeSession(session);
16238                    }
16239            }
16240    
16241            /**
16242             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
16243             *
16244             * @param groupId the group ID
16245             * @param classNameId the class name ID
16246             * @param structureId the structure ID
16247             * @return the number of matching journal articles
16248             * @throws SystemException if a system exception occurred
16249             */
16250            public int countByG_C_S(long groupId, long classNameId, String structureId)
16251                    throws SystemException {
16252                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
16253    
16254                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
16255                                    finderArgs, this);
16256    
16257                    if (count == null) {
16258                            StringBundler query = new StringBundler(4);
16259    
16260                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16261    
16262                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
16263    
16264                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
16265    
16266                            if (structureId == null) {
16267                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
16268                            }
16269                            else {
16270                                    if (structureId.equals(StringPool.BLANK)) {
16271                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
16272                                    }
16273                                    else {
16274                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
16275                                    }
16276                            }
16277    
16278                            String sql = query.toString();
16279    
16280                            Session session = null;
16281    
16282                            try {
16283                                    session = openSession();
16284    
16285                                    Query q = session.createQuery(sql);
16286    
16287                                    QueryPos qPos = QueryPos.getInstance(q);
16288    
16289                                    qPos.add(groupId);
16290    
16291                                    qPos.add(classNameId);
16292    
16293                                    if (structureId != null) {
16294                                            qPos.add(structureId);
16295                                    }
16296    
16297                                    count = (Long)q.uniqueResult();
16298                            }
16299                            catch (Exception e) {
16300                                    throw processException(e);
16301                            }
16302                            finally {
16303                                    if (count == null) {
16304                                            count = Long.valueOf(0);
16305                                    }
16306    
16307                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
16308                                            finderArgs, count);
16309    
16310                                    closeSession(session);
16311                            }
16312                    }
16313    
16314                    return count.intValue();
16315            }
16316    
16317            /**
16318             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
16319             *
16320             * @param groupId the group ID
16321             * @param classNameId the class name ID
16322             * @param templateId the template ID
16323             * @return the number of matching journal articles
16324             * @throws SystemException if a system exception occurred
16325             */
16326            public int countByG_C_T(long groupId, long classNameId, String templateId)
16327                    throws SystemException {
16328                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
16329    
16330                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_T,
16331                                    finderArgs, this);
16332    
16333                    if (count == null) {
16334                            StringBundler query = new StringBundler(4);
16335    
16336                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16337    
16338                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
16339    
16340                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
16341    
16342                            if (templateId == null) {
16343                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
16344                            }
16345                            else {
16346                                    if (templateId.equals(StringPool.BLANK)) {
16347                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
16348                                    }
16349                                    else {
16350                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
16351                                    }
16352                            }
16353    
16354                            String sql = query.toString();
16355    
16356                            Session session = null;
16357    
16358                            try {
16359                                    session = openSession();
16360    
16361                                    Query q = session.createQuery(sql);
16362    
16363                                    QueryPos qPos = QueryPos.getInstance(q);
16364    
16365                                    qPos.add(groupId);
16366    
16367                                    qPos.add(classNameId);
16368    
16369                                    if (templateId != null) {
16370                                            qPos.add(templateId);
16371                                    }
16372    
16373                                    count = (Long)q.uniqueResult();
16374                            }
16375                            catch (Exception e) {
16376                                    throw processException(e);
16377                            }
16378                            finally {
16379                                    if (count == null) {
16380                                            count = Long.valueOf(0);
16381                                    }
16382    
16383                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_T,
16384                                            finderArgs, count);
16385    
16386                                    closeSession(session);
16387                            }
16388                    }
16389    
16390                    return count.intValue();
16391            }
16392    
16393            /**
16394             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
16395             *
16396             * @param groupId the group ID
16397             * @param classNameId the class name ID
16398             * @param templateId the template ID
16399             * @return the number of matching journal articles that the user has permission to view
16400             * @throws SystemException if a system exception occurred
16401             */
16402            public int filterCountByG_C_T(long groupId, long classNameId,
16403                    String templateId) throws SystemException {
16404                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16405                            return countByG_C_T(groupId, classNameId, templateId);
16406                    }
16407    
16408                    StringBundler query = new StringBundler(4);
16409    
16410                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16411    
16412                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
16413    
16414                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
16415    
16416                    if (templateId == null) {
16417                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
16418                    }
16419                    else {
16420                            if (templateId.equals(StringPool.BLANK)) {
16421                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
16422                            }
16423                            else {
16424                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
16425                            }
16426                    }
16427    
16428                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16429                                    JournalArticle.class.getName(),
16430                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16431    
16432                    Session session = null;
16433    
16434                    try {
16435                            session = openSession();
16436    
16437                            SQLQuery q = session.createSQLQuery(sql);
16438    
16439                            q.addScalar(COUNT_COLUMN_NAME,
16440                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16441    
16442                            QueryPos qPos = QueryPos.getInstance(q);
16443    
16444                            qPos.add(groupId);
16445    
16446                            qPos.add(classNameId);
16447    
16448                            if (templateId != null) {
16449                                    qPos.add(templateId);
16450                            }
16451    
16452                            Long count = (Long)q.uniqueResult();
16453    
16454                            return count.intValue();
16455                    }
16456                    catch (Exception e) {
16457                            throw processException(e);
16458                    }
16459                    finally {
16460                            closeSession(session);
16461                    }
16462            }
16463    
16464            /**
16465             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16466             *
16467             * @param groupId the group ID
16468             * @param classNameId the class name ID
16469             * @param layoutUuid the layout uuid
16470             * @return the number of matching journal articles
16471             * @throws SystemException if a system exception occurred
16472             */
16473            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
16474                    throws SystemException {
16475                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
16476    
16477                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_L,
16478                                    finderArgs, this);
16479    
16480                    if (count == null) {
16481                            StringBundler query = new StringBundler(4);
16482    
16483                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16484    
16485                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
16486    
16487                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
16488    
16489                            if (layoutUuid == null) {
16490                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
16491                            }
16492                            else {
16493                                    if (layoutUuid.equals(StringPool.BLANK)) {
16494                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
16495                                    }
16496                                    else {
16497                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
16498                                    }
16499                            }
16500    
16501                            String sql = query.toString();
16502    
16503                            Session session = null;
16504    
16505                            try {
16506                                    session = openSession();
16507    
16508                                    Query q = session.createQuery(sql);
16509    
16510                                    QueryPos qPos = QueryPos.getInstance(q);
16511    
16512                                    qPos.add(groupId);
16513    
16514                                    qPos.add(classNameId);
16515    
16516                                    if (layoutUuid != null) {
16517                                            qPos.add(layoutUuid);
16518                                    }
16519    
16520                                    count = (Long)q.uniqueResult();
16521                            }
16522                            catch (Exception e) {
16523                                    throw processException(e);
16524                            }
16525                            finally {
16526                                    if (count == null) {
16527                                            count = Long.valueOf(0);
16528                                    }
16529    
16530                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_L,
16531                                            finderArgs, count);
16532    
16533                                    closeSession(session);
16534                            }
16535                    }
16536    
16537                    return count.intValue();
16538            }
16539    
16540            /**
16541             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16542             *
16543             * @param groupId the group ID
16544             * @param classNameId the class name ID
16545             * @param layoutUuid the layout uuid
16546             * @return the number of matching journal articles that the user has permission to view
16547             * @throws SystemException if a system exception occurred
16548             */
16549            public int filterCountByG_C_L(long groupId, long classNameId,
16550                    String layoutUuid) throws SystemException {
16551                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16552                            return countByG_C_L(groupId, classNameId, layoutUuid);
16553                    }
16554    
16555                    StringBundler query = new StringBundler(4);
16556    
16557                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16558    
16559                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
16560    
16561                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
16562    
16563                    if (layoutUuid == null) {
16564                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
16565                    }
16566                    else {
16567                            if (layoutUuid.equals(StringPool.BLANK)) {
16568                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
16569                            }
16570                            else {
16571                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
16572                            }
16573                    }
16574    
16575                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16576                                    JournalArticle.class.getName(),
16577                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16578    
16579                    Session session = null;
16580    
16581                    try {
16582                            session = openSession();
16583    
16584                            SQLQuery q = session.createSQLQuery(sql);
16585    
16586                            q.addScalar(COUNT_COLUMN_NAME,
16587                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16588    
16589                            QueryPos qPos = QueryPos.getInstance(q);
16590    
16591                            qPos.add(groupId);
16592    
16593                            qPos.add(classNameId);
16594    
16595                            if (layoutUuid != null) {
16596                                    qPos.add(layoutUuid);
16597                            }
16598    
16599                            Long count = (Long)q.uniqueResult();
16600    
16601                            return count.intValue();
16602                    }
16603                    catch (Exception e) {
16604                            throw processException(e);
16605                    }
16606                    finally {
16607                            closeSession(session);
16608                    }
16609            }
16610    
16611            /**
16612             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
16613             *
16614             * @param groupId the group ID
16615             * @param articleId the article ID
16616             * @param version the version
16617             * @return the number of matching journal articles
16618             * @throws SystemException if a system exception occurred
16619             */
16620            public int countByG_A_V(long groupId, String articleId, double version)
16621                    throws SystemException {
16622                    Object[] finderArgs = new Object[] { groupId, articleId, version };
16623    
16624                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_V,
16625                                    finderArgs, this);
16626    
16627                    if (count == null) {
16628                            StringBundler query = new StringBundler(4);
16629    
16630                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16631    
16632                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
16633    
16634                            if (articleId == null) {
16635                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
16636                            }
16637                            else {
16638                                    if (articleId.equals(StringPool.BLANK)) {
16639                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
16640                                    }
16641                                    else {
16642                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
16643                                    }
16644                            }
16645    
16646                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
16647    
16648                            String sql = query.toString();
16649    
16650                            Session session = null;
16651    
16652                            try {
16653                                    session = openSession();
16654    
16655                                    Query q = session.createQuery(sql);
16656    
16657                                    QueryPos qPos = QueryPos.getInstance(q);
16658    
16659                                    qPos.add(groupId);
16660    
16661                                    if (articleId != null) {
16662                                            qPos.add(articleId);
16663                                    }
16664    
16665                                    qPos.add(version);
16666    
16667                                    count = (Long)q.uniqueResult();
16668                            }
16669                            catch (Exception e) {
16670                                    throw processException(e);
16671                            }
16672                            finally {
16673                                    if (count == null) {
16674                                            count = Long.valueOf(0);
16675                                    }
16676    
16677                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V,
16678                                            finderArgs, count);
16679    
16680                                    closeSession(session);
16681                            }
16682                    }
16683    
16684                    return count.intValue();
16685            }
16686    
16687            /**
16688             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
16689             *
16690             * @param groupId the group ID
16691             * @param articleId the article ID
16692             * @param status the status
16693             * @return the number of matching journal articles
16694             * @throws SystemException if a system exception occurred
16695             */
16696            public int countByG_A_ST(long groupId, String articleId, int status)
16697                    throws SystemException {
16698                    Object[] finderArgs = new Object[] { groupId, articleId, status };
16699    
16700                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_ST,
16701                                    finderArgs, this);
16702    
16703                    if (count == null) {
16704                            StringBundler query = new StringBundler(4);
16705    
16706                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16707    
16708                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
16709    
16710                            if (articleId == null) {
16711                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
16712                            }
16713                            else {
16714                                    if (articleId.equals(StringPool.BLANK)) {
16715                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
16716                                    }
16717                                    else {
16718                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
16719                                    }
16720                            }
16721    
16722                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
16723    
16724                            String sql = query.toString();
16725    
16726                            Session session = null;
16727    
16728                            try {
16729                                    session = openSession();
16730    
16731                                    Query q = session.createQuery(sql);
16732    
16733                                    QueryPos qPos = QueryPos.getInstance(q);
16734    
16735                                    qPos.add(groupId);
16736    
16737                                    if (articleId != null) {
16738                                            qPos.add(articleId);
16739                                    }
16740    
16741                                    qPos.add(status);
16742    
16743                                    count = (Long)q.uniqueResult();
16744                            }
16745                            catch (Exception e) {
16746                                    throw processException(e);
16747                            }
16748                            finally {
16749                                    if (count == null) {
16750                                            count = Long.valueOf(0);
16751                                    }
16752    
16753                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_ST,
16754                                            finderArgs, count);
16755    
16756                                    closeSession(session);
16757                            }
16758                    }
16759    
16760                    return count.intValue();
16761            }
16762    
16763            /**
16764             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = any &#63;.
16765             *
16766             * @param groupId the group ID
16767             * @param articleId the article ID
16768             * @param statuses the statuses
16769             * @return the number of matching journal articles
16770             * @throws SystemException if a system exception occurred
16771             */
16772            public int countByG_A_ST(long groupId, String articleId, int[] statuses)
16773                    throws SystemException {
16774                    Object[] finderArgs = new Object[] {
16775                                    groupId, articleId, StringUtil.merge(statuses)
16776                            };
16777    
16778                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_ST,
16779                                    finderArgs, this);
16780    
16781                    if (count == null) {
16782                            StringBundler query = new StringBundler();
16783    
16784                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16785    
16786                            boolean conjunctionable = false;
16787    
16788                            if (conjunctionable) {
16789                                    query.append(WHERE_AND);
16790                            }
16791    
16792                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
16793    
16794                            conjunctionable = true;
16795    
16796                            if (conjunctionable) {
16797                                    query.append(WHERE_AND);
16798                            }
16799    
16800                            if (articleId == null) {
16801                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
16802                            }
16803                            else {
16804                                    if (articleId.equals(StringPool.BLANK)) {
16805                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
16806                                    }
16807                                    else {
16808                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
16809                                    }
16810                            }
16811    
16812                            conjunctionable = true;
16813    
16814                            if ((statuses == null) || (statuses.length > 0)) {
16815                                    if (conjunctionable) {
16816                                            query.append(WHERE_AND);
16817                                    }
16818    
16819                                    query.append(StringPool.OPEN_PARENTHESIS);
16820    
16821                                    for (int i = 0; i < statuses.length; i++) {
16822                                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
16823    
16824                                            if ((i + 1) < statuses.length) {
16825                                                    query.append(WHERE_OR);
16826                                            }
16827                                    }
16828    
16829                                    query.append(StringPool.CLOSE_PARENTHESIS);
16830    
16831                                    conjunctionable = true;
16832                            }
16833    
16834                            String sql = query.toString();
16835    
16836                            Session session = null;
16837    
16838                            try {
16839                                    session = openSession();
16840    
16841                                    Query q = session.createQuery(sql);
16842    
16843                                    QueryPos qPos = QueryPos.getInstance(q);
16844    
16845                                    qPos.add(groupId);
16846    
16847                                    if (articleId != null) {
16848                                            qPos.add(articleId);
16849                                    }
16850    
16851                                    if (statuses != null) {
16852                                            qPos.add(statuses);
16853                                    }
16854    
16855                                    count = (Long)q.uniqueResult();
16856                            }
16857                            catch (Exception e) {
16858                                    throw processException(e);
16859                            }
16860                            finally {
16861                                    if (count == null) {
16862                                            count = Long.valueOf(0);
16863                                    }
16864    
16865                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_ST,
16866                                            finderArgs, count);
16867    
16868                                    closeSession(session);
16869                            }
16870                    }
16871    
16872                    return count.intValue();
16873            }
16874    
16875            /**
16876             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
16877             *
16878             * @param groupId the group ID
16879             * @param articleId the article ID
16880             * @param status the status
16881             * @return the number of matching journal articles that the user has permission to view
16882             * @throws SystemException if a system exception occurred
16883             */
16884            public int filterCountByG_A_ST(long groupId, String articleId, int status)
16885                    throws SystemException {
16886                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16887                            return countByG_A_ST(groupId, articleId, status);
16888                    }
16889    
16890                    StringBundler query = new StringBundler(4);
16891    
16892                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16893    
16894                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
16895    
16896                    if (articleId == null) {
16897                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
16898                    }
16899                    else {
16900                            if (articleId.equals(StringPool.BLANK)) {
16901                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
16902                            }
16903                            else {
16904                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
16905                            }
16906                    }
16907    
16908                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
16909    
16910                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16911                                    JournalArticle.class.getName(),
16912                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16913    
16914                    Session session = null;
16915    
16916                    try {
16917                            session = openSession();
16918    
16919                            SQLQuery q = session.createSQLQuery(sql);
16920    
16921                            q.addScalar(COUNT_COLUMN_NAME,
16922                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16923    
16924                            QueryPos qPos = QueryPos.getInstance(q);
16925    
16926                            qPos.add(groupId);
16927    
16928                            if (articleId != null) {
16929                                    qPos.add(articleId);
16930                            }
16931    
16932                            qPos.add(status);
16933    
16934                            Long count = (Long)q.uniqueResult();
16935    
16936                            return count.intValue();
16937                    }
16938                    catch (Exception e) {
16939                            throw processException(e);
16940                    }
16941                    finally {
16942                            closeSession(session);
16943                    }
16944            }
16945    
16946            /**
16947             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = any &#63;.
16948             *
16949             * @param groupId the group ID
16950             * @param articleId the article ID
16951             * @param statuses the statuses
16952             * @return the number of matching journal articles that the user has permission to view
16953             * @throws SystemException if a system exception occurred
16954             */
16955            public int filterCountByG_A_ST(long groupId, String articleId,
16956                    int[] statuses) throws SystemException {
16957                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16958                            return countByG_A_ST(groupId, articleId, statuses);
16959                    }
16960    
16961                    StringBundler query = new StringBundler();
16962    
16963                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16964    
16965                    boolean conjunctionable = false;
16966    
16967                    if (conjunctionable) {
16968                            query.append(WHERE_AND);
16969                    }
16970    
16971                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_5);
16972    
16973                    conjunctionable = true;
16974    
16975                    if (conjunctionable) {
16976                            query.append(WHERE_AND);
16977                    }
16978    
16979                    if (articleId == null) {
16980                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_4);
16981                    }
16982                    else {
16983                            if (articleId.equals(StringPool.BLANK)) {
16984                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_6);
16985                            }
16986                            else {
16987                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_5);
16988                            }
16989                    }
16990    
16991                    conjunctionable = true;
16992    
16993                    if ((statuses == null) || (statuses.length > 0)) {
16994                            if (conjunctionable) {
16995                                    query.append(WHERE_AND);
16996                            }
16997    
16998                            query.append(StringPool.OPEN_PARENTHESIS);
16999    
17000                            for (int i = 0; i < statuses.length; i++) {
17001                                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_5);
17002    
17003                                    if ((i + 1) < statuses.length) {
17004                                            query.append(WHERE_OR);
17005                                    }
17006                            }
17007    
17008                            query.append(StringPool.CLOSE_PARENTHESIS);
17009    
17010                            conjunctionable = true;
17011                    }
17012    
17013                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17014                                    JournalArticle.class.getName(),
17015                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17016    
17017                    Session session = null;
17018    
17019                    try {
17020                            session = openSession();
17021    
17022                            SQLQuery q = session.createSQLQuery(sql);
17023    
17024                            q.addScalar(COUNT_COLUMN_NAME,
17025                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17026    
17027                            QueryPos qPos = QueryPos.getInstance(q);
17028    
17029                            qPos.add(groupId);
17030    
17031                            if (articleId != null) {
17032                                    qPos.add(articleId);
17033                            }
17034    
17035                            if (statuses != null) {
17036                                    qPos.add(statuses);
17037                            }
17038    
17039                            Long count = (Long)q.uniqueResult();
17040    
17041                            return count.intValue();
17042                    }
17043                    catch (Exception e) {
17044                            throw processException(e);
17045                    }
17046                    finally {
17047                            closeSession(session);
17048                    }
17049            }
17050    
17051            /**
17052             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
17053             *
17054             * @param groupId the group ID
17055             * @param urlTitle the url title
17056             * @param status the status
17057             * @return the number of matching journal articles
17058             * @throws SystemException if a system exception occurred
17059             */
17060            public int countByG_UT_ST(long groupId, String urlTitle, int status)
17061                    throws SystemException {
17062                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
17063    
17064                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT_ST,
17065                                    finderArgs, this);
17066    
17067                    if (count == null) {
17068                            StringBundler query = new StringBundler(4);
17069    
17070                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17071    
17072                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
17073    
17074                            if (urlTitle == null) {
17075                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
17076                            }
17077                            else {
17078                                    if (urlTitle.equals(StringPool.BLANK)) {
17079                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
17080                                    }
17081                                    else {
17082                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
17083                                    }
17084                            }
17085    
17086                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
17087    
17088                            String sql = query.toString();
17089    
17090                            Session session = null;
17091    
17092                            try {
17093                                    session = openSession();
17094    
17095                                    Query q = session.createQuery(sql);
17096    
17097                                    QueryPos qPos = QueryPos.getInstance(q);
17098    
17099                                    qPos.add(groupId);
17100    
17101                                    if (urlTitle != null) {
17102                                            qPos.add(urlTitle);
17103                                    }
17104    
17105                                    qPos.add(status);
17106    
17107                                    count = (Long)q.uniqueResult();
17108                            }
17109                            catch (Exception e) {
17110                                    throw processException(e);
17111                            }
17112                            finally {
17113                                    if (count == null) {
17114                                            count = Long.valueOf(0);
17115                                    }
17116    
17117                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT_ST,
17118                                            finderArgs, count);
17119    
17120                                    closeSession(session);
17121                            }
17122                    }
17123    
17124                    return count.intValue();
17125            }
17126    
17127            /**
17128             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
17129             *
17130             * @param groupId the group ID
17131             * @param urlTitle the url title
17132             * @param status the status
17133             * @return the number of matching journal articles that the user has permission to view
17134             * @throws SystemException if a system exception occurred
17135             */
17136            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
17137                    throws SystemException {
17138                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17139                            return countByG_UT_ST(groupId, urlTitle, status);
17140                    }
17141    
17142                    StringBundler query = new StringBundler(4);
17143    
17144                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
17145    
17146                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
17147    
17148                    if (urlTitle == null) {
17149                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
17150                    }
17151                    else {
17152                            if (urlTitle.equals(StringPool.BLANK)) {
17153                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
17154                            }
17155                            else {
17156                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
17157                            }
17158                    }
17159    
17160                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
17161    
17162                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17163                                    JournalArticle.class.getName(),
17164                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17165    
17166                    Session session = null;
17167    
17168                    try {
17169                            session = openSession();
17170    
17171                            SQLQuery q = session.createSQLQuery(sql);
17172    
17173                            q.addScalar(COUNT_COLUMN_NAME,
17174                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17175    
17176                            QueryPos qPos = QueryPos.getInstance(q);
17177    
17178                            qPos.add(groupId);
17179    
17180                            if (urlTitle != null) {
17181                                    qPos.add(urlTitle);
17182                            }
17183    
17184                            qPos.add(status);
17185    
17186                            Long count = (Long)q.uniqueResult();
17187    
17188                            return count.intValue();
17189                    }
17190                    catch (Exception e) {
17191                            throw processException(e);
17192                    }
17193                    finally {
17194                            closeSession(session);
17195                    }
17196            }
17197    
17198            /**
17199             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
17200             *
17201             * @param companyId the company ID
17202             * @param version the version
17203             * @param status the status
17204             * @return the number of matching journal articles
17205             * @throws SystemException if a system exception occurred
17206             */
17207            public int countByC_V_ST(long companyId, double version, int status)
17208                    throws SystemException {
17209                    Object[] finderArgs = new Object[] { companyId, version, status };
17210    
17211                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V_ST,
17212                                    finderArgs, this);
17213    
17214                    if (count == null) {
17215                            StringBundler query = new StringBundler(4);
17216    
17217                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
17218    
17219                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
17220    
17221                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
17222    
17223                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
17224    
17225                            String sql = query.toString();
17226    
17227                            Session session = null;
17228    
17229                            try {
17230                                    session = openSession();
17231    
17232                                    Query q = session.createQuery(sql);
17233    
17234                                    QueryPos qPos = QueryPos.getInstance(q);
17235    
17236                                    qPos.add(companyId);
17237    
17238                                    qPos.add(version);
17239    
17240                                    qPos.add(status);
17241    
17242                                    count = (Long)q.uniqueResult();
17243                            }
17244                            catch (Exception e) {
17245                                    throw processException(e);
17246                            }
17247                            finally {
17248                                    if (count == null) {
17249                                            count = Long.valueOf(0);
17250                                    }
17251    
17252                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V_ST,
17253                                            finderArgs, count);
17254    
17255                                    closeSession(session);
17256                            }
17257                    }
17258    
17259                    return count.intValue();
17260            }
17261    
17262            /**
17263             * Returns the number of journal articles.
17264             *
17265             * @return the number of journal articles
17266             * @throws SystemException if a system exception occurred
17267             */
17268            public int countAll() throws SystemException {
17269                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
17270                                    FINDER_ARGS_EMPTY, this);
17271    
17272                    if (count == null) {
17273                            Session session = null;
17274    
17275                            try {
17276                                    session = openSession();
17277    
17278                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
17279    
17280                                    count = (Long)q.uniqueResult();
17281                            }
17282                            catch (Exception e) {
17283                                    throw processException(e);
17284                            }
17285                            finally {
17286                                    if (count == null) {
17287                                            count = Long.valueOf(0);
17288                                    }
17289    
17290                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
17291                                            FINDER_ARGS_EMPTY, count);
17292    
17293                                    closeSession(session);
17294                            }
17295                    }
17296    
17297                    return count.intValue();
17298            }
17299    
17300            /**
17301             * Initializes the journal article persistence.
17302             */
17303            public void afterPropertiesSet() {
17304                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
17305                                            com.liferay.portal.util.PropsUtil.get(
17306                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
17307    
17308                    if (listenerClassNames.length > 0) {
17309                            try {
17310                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
17311    
17312                                    for (String listenerClassName : listenerClassNames) {
17313                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
17314                                                            listenerClassName));
17315                                    }
17316    
17317                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
17318                            }
17319                            catch (Exception e) {
17320                                    _log.error(e);
17321                            }
17322                    }
17323            }
17324    
17325            public void destroy() {
17326                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
17327                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
17328                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17329            }
17330    
17331            @BeanReference(type = JournalArticlePersistence.class)
17332            protected JournalArticlePersistence journalArticlePersistence;
17333            @BeanReference(type = JournalArticleImagePersistence.class)
17334            protected JournalArticleImagePersistence journalArticleImagePersistence;
17335            @BeanReference(type = JournalArticleResourcePersistence.class)
17336            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
17337            @BeanReference(type = JournalContentSearchPersistence.class)
17338            protected JournalContentSearchPersistence journalContentSearchPersistence;
17339            @BeanReference(type = JournalFeedPersistence.class)
17340            protected JournalFeedPersistence journalFeedPersistence;
17341            @BeanReference(type = JournalStructurePersistence.class)
17342            protected JournalStructurePersistence journalStructurePersistence;
17343            @BeanReference(type = JournalTemplatePersistence.class)
17344            protected JournalTemplatePersistence journalTemplatePersistence;
17345            @BeanReference(type = CompanyPersistence.class)
17346            protected CompanyPersistence companyPersistence;
17347            @BeanReference(type = GroupPersistence.class)
17348            protected GroupPersistence groupPersistence;
17349            @BeanReference(type = ImagePersistence.class)
17350            protected ImagePersistence imagePersistence;
17351            @BeanReference(type = PortletPreferencesPersistence.class)
17352            protected PortletPreferencesPersistence portletPreferencesPersistence;
17353            @BeanReference(type = ResourcePersistence.class)
17354            protected ResourcePersistence resourcePersistence;
17355            @BeanReference(type = SubscriptionPersistence.class)
17356            protected SubscriptionPersistence subscriptionPersistence;
17357            @BeanReference(type = UserPersistence.class)
17358            protected UserPersistence userPersistence;
17359            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
17360            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
17361            @BeanReference(type = AssetCategoryPersistence.class)
17362            protected AssetCategoryPersistence assetCategoryPersistence;
17363            @BeanReference(type = AssetEntryPersistence.class)
17364            protected AssetEntryPersistence assetEntryPersistence;
17365            @BeanReference(type = AssetLinkPersistence.class)
17366            protected AssetLinkPersistence assetLinkPersistence;
17367            @BeanReference(type = AssetTagPersistence.class)
17368            protected AssetTagPersistence assetTagPersistence;
17369            @BeanReference(type = ExpandoValuePersistence.class)
17370            protected ExpandoValuePersistence expandoValuePersistence;
17371            @BeanReference(type = MBMessagePersistence.class)
17372            protected MBMessagePersistence mbMessagePersistence;
17373            @BeanReference(type = RatingsStatsPersistence.class)
17374            protected RatingsStatsPersistence ratingsStatsPersistence;
17375            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
17376            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
17377            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
17378            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
17379            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
17380            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
17381            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?)";
17382            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
17383            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
17384            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?) AND ";
17385            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
17386            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
17387                    "journalArticle.resourcePrimKey = ?";
17388            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
17389            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
17390            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
17391            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
17392            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
17393            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
17394            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
17395            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
17396            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?)";
17397            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
17398            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
17399            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
17400            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?)";
17401            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
17402            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
17403            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
17404            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
17405            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
17406            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
17407            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
17408            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
17409            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
17410            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
17411            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
17412            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
17413            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
17414            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
17415            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
17416            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
17417            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
17418            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
17419            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
17420            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
17421            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
17422            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
17423            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
17424            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
17425            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
17426            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
17427            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
17428            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
17429            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
17430            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
17431            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
17432            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
17433            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
17434            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
17435            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
17436            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
17437            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
17438            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
17439            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
17440            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
17441            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
17442            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
17443            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_5 = "(" +
17444                    _removeConjunction(_FINDER_COLUMN_G_A_ST_GROUPID_2) + ")";
17445            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
17446            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
17447            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
17448            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_4 = "(" +
17449                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_1) + ")";
17450            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_5 = "(" +
17451                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_2) + ")";
17452            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_6 = "(" +
17453                    _removeConjunction(_FINDER_COLUMN_G_A_ST_ARTICLEID_3) + ")";
17454            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
17455            private static final String _FINDER_COLUMN_G_A_ST_STATUS_5 = "(" +
17456                    _removeConjunction(_FINDER_COLUMN_G_A_ST_STATUS_2) + ")";
17457            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
17458            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
17459            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
17460            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?) AND ";
17461            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
17462            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
17463            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
17464            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
17465    
17466            private static String _removeConjunction(String sql) {
17467                    int pos = sql.indexOf(" AND ");
17468    
17469                    if (pos != -1) {
17470                            sql = sql.substring(0, pos);
17471                    }
17472    
17473                    return sql;
17474            }
17475    
17476            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.resourcePrimKey";
17477            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
17478            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
17479                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
17480            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
17481                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
17482            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
17483            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
17484            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
17485            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
17486            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
17487            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
17488            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
17489            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
17490            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
17491            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
17492                            @Override
17493                            public Object clone() {
17494                                    return this;
17495                            }
17496    
17497                            @Override
17498                            public CacheModel<JournalArticle> toCacheModel() {
17499                                    return _nullJournalArticleCacheModel;
17500                            }
17501                    };
17502    
17503            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
17504                            public JournalArticle toEntityModel() {
17505                                    return _nullJournalArticle;
17506                            }
17507                    };
17508    }